Function at 0x40d5f6
Capabilities:
Resolve function by parsing pe exports

Disassembly:
sub esp, 0x58
mov eax, dword [0x476b8c]
push ebx
push ebp
push esi
xor esi, esi
mov dword [esp + 0x14], esi
mov ebx, esi
mov dword [0x476b94], esi
push edi
test eax, eax
je 0x40d62e
cmp dword [esp + 0x7c], ebx
jne 0x40d62e
push eax
push esi
push dword [0x476928]
call dword [sym.imp.KERNEL32.dll_HeapFree]
mov dword [0x476b8c], esi
mov eax, dword [0x476b90]
test eax, eax
je 0x40d64b
push eax
push esi
push dword [0x476928]
call dword [sym.imp.KERNEL32.dll_HeapFree]
mov dword [0x476b90], esi
and dword [esp + 0x80], 1
mov ebp, 0x104
je 0x40d67f
push 0xfa000
push 8
push dword [0x476928]
mov dword [esp + 0x1c], 0x7d000
call dword [sym.imp.KERNEL32.dll_HeapAlloc]
mov edi, eax
mov dword [0x476b8c], edi
jmp 0x40d69e
push 0x208
push 8
push dword [0x476928]
mov dword [esp + 0x1c], ebp
call dword [sym.imp.KERNEL32.dll_HeapAlloc]
mov edi, eax
mov dword [0x476b90], edi
test edi, edi
je 0x40d867
mov eax, dword [esp + 0x74]
test eax, eax
jne 0x40d6b7
mov eax, 0x45806c
mov dword [esp + 0x74], eax
push eax
call sub.MSVCRT.dll_wcslen
pop ecx
lea eax, [eax*2 + 6]
push eax
push 8
push dword [0x476928]
call dword [sym.imp.KERNEL32.dll_HeapAlloc]
mov dword [esp + 0x14], eax
test eax, eax
je 0x40d867
push dword [esp + 0x74]
push eax
call sub.MSVCRT.dll_wcscpy
mov eax, dword [esp + 0x1c]
pop ecx
pop ecx
mov ecx, eax
cmp word [eax], si
je 0x40d70a
cmp word [ecx], 0x7c
jne 0x40d702
xor eax, eax
mov word [ecx], ax
add ecx, 2
cmp word [ecx], si
jne 0x40d6f7
cmp dword [esp + 0x70], ebx
je 0x40d7b6
push dword [esp + 0x70]
call sub.MSVCRT.dll_wcslen
pop ecx
lea eax, [eax*2 + 4]
push eax
push 8
push dword [0x476928]
call dword [sym.imp.KERNEL32.dll_HeapAlloc]
push dword [esp + 0x70]
mov ebx, eax
push ebx
call sub.MSVCRT.dll_wcscpy
push ebx
call sub.MSVCRT.dll_wcslen
add esp, 0xc
lea ecx, [ebx + eax*2]
push 0x5c
pop eax
jmp 0x40d758
cmp ecx, ebx
jbe 0x40d786
sub ecx, 2
cmp word [ecx], ax
jne 0x40d751
cmp ecx, ebx
jbe 0x40d786
xor eax, eax
mov word [ecx], ax
mov eax, dword [esp + 0x10]
dec eax
push eax
lea eax, [ecx + 2]
push eax
push edi
call sub.MSVCRT.dll_wcsncpy
mov eax, dword [esp + 0x1c]
add esp, 0xc
xor ecx, ecx
mov word [edi + eax*2 - 2], cx
jmp 0x40d7a9
mov eax, dword [esp + 0x10]
dec eax
push eax
push dword [esp + 0x74]
push edi
call sub.MSVCRT.dll_wcsncpy
mov eax, dword [esp + 0x1c]
xor ecx, ecx
add esp, 0xc
mov word [edi + eax*2 - 2], cx
xor eax, eax
mov word [ebx], ax
push edi
call fcn.004187bf
test eax, eax
jne 0x40d7b6
mov word [edi], ax
push 0x4c
lea eax, [esp + 0x20]
push esi
push eax
call sub.MSVCRT.dll_memset
add esp, 0xc
mov dword [esp + 0x1c], 0x4c
call fcn.0040de1b
mov dword [esp + 0x20], eax
mov eax, dword [esp + 0x10]
mov dword [esp + 0x3c], eax
mov eax, dword [esp + 0x14]
mov dword [esp + 0x28], eax
mov eax, dword [esp + 0x78]
inc eax
mov dword [esp + 0x38], edi
mov dword [esp + 0x34], eax
mov eax, dword [esp + 0x6c]
mov dword [esp + 0x48], ebx
mov dword [esp + 0x4c], eax
mov dword [esp + 0x50], 0x8080c
cmp dword [esp + 0x80], esi
je 0x40d819
mov dword [esp + 0x50], 0x80a0c
push 1
call fcn.0040ded2
cmp dword [esp + 0x7c], 1
lea eax, [esp + 0x1c]
push eax
jne 0x40d834
call dword [sym.imp.COMDLG32.DLL_GetSaveFileNameW]
jmp 0x40d83a
call dword [sym.imp.COMDLG32.DLL_GetOpenFileNameW]
push esi
mov dword [esp + 0x1c], eax
call fcn.0040ded2
push dword [esp + 0x14]
push esi
push dword [0x476928]
call dword [sym.imp.KERNEL32.dll_HeapFree]
test ebx, ebx
je 0x40d867
push ebx
push esi
push dword [0x476928]
call dword [sym.imp.KERNEL32.dll_HeapFree]
push dword [esp + 0x84]
push ebp
call fcn.0041f770
mov ebx, eax
xor eax, eax
mov word [ebx], ax
cmp dword [esp + 0x18], eax
je 0x40d938
mov ecx, dword [esp + 0x34]
mov dword [0x476b94], ecx
push edi
cmp dword [esp + 0x84], eax
je 0x40d927
call sub.MSVCRT.dll_wcslen
inc eax
pop ecx
mov dword [0x476b88], eax
push edi
cmp word [edi + eax*2], si
jne 0x40d8c3
push ebx
call sub.MSVCRT.dll_wcscpy
xor eax, eax
mov dword [0x476b88], esi
mov word [edi], ax
jmp 0x40d92d
mov esi, 0x476b98
push esi
call sub.MSVCRT.dll_wcscpy
push esi
call sub.MSVCRT.dll_wcslen
add esp, 0xc
lea eax, [eax*2 + 0x476b98]
push 0x5c
pop ecx
cmp word [eax - 2], cx
je 0x40d8f0
mov word [eax], cx
xor ecx, ecx
mov word [eax + 2], cx
push esi
push ebx
call sub.MSVCRT.dll_wcscpy
mov eax, dword [0x476b88]
lea eax, [edi + eax*2]
push eax
push ebx
call sub.MSVCRT.dll_wcscat
mov eax, dword [0x476b88]
lea eax, [edi + eax*2]
push eax
call sub.MSVCRT.dll_wcslen
mov ecx, dword [0x476b88]
add esp, 0x14
inc ecx
add eax, ecx
mov dword [0x476b88], eax
jmp 0x40d92f
push ebx
call sub.MSVCRT.dll_wcscpy
pop ecx
pop ecx
push ebx
call sub.MSVCRT.dll_wcslen
pop ecx
mov esi, eax
sub ebp, esi
push ebp
call fcn.0041f850
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x58
ret