Function at 0x406790
Capabilities:
Resolve function by parsing pe exports
Write file on windows

Disassembly:
push ebp
mov ebp, esp
and esp, 0xfffffff8
push 0xffffffffffffffff
push 0x4f2dc9
mov eax, dword fs:[0]
push eax
sub esp, 0x78
mov eax, dword [0x52f4a8]
xor eax, esp
mov dword [esp + 0x70], eax
push ebx
push esi
push edi
mov eax, dword [0x52f4a8]
xor eax, esp
push eax
lea eax, [esp + 0x88]
mov dword fs:[0], eax
mov esi, dword [ebp + 8]
xor edi, edi
mov eax, 0xffff
mov ebx, ecx
mov dword [esp + 0x20], edi
cmp ax, si
jne 0x4067e6
xor eax, eax
jmp 0x406a9e
mov eax, dword [ebx + 0x24]
cmp dword [eax], edi
je 0x406812
mov ecx, dword [eax]
mov eax, dword [ebx + 0x34]
mov edx, dword [eax]
lea edx, [ecx + edx*2]
cmp ecx, edx
jae 0x406812
dec dword [eax]
mov ebx, dword [ebx + 0x24]
mov eax, dword [ebx]
lea ecx, [eax + 2]
mov dword [ebx], ecx
mov word [eax], si
mov ax, si
jmp 0x406a9e
mov eax, dword [ebx + 0x4c]
cmp eax, edi
je 0x406a99
cmp dword [ebx + 0x3c], edi
jne 0x406844
push eax
push esi
call fcn.004797d0
mov edx, 0xffff
add esp, 8
cmp ax, dx
movzx eax, si
jne 0x406a9e
mov eax, edx
jmp 0x406a9e
movzx eax, si
push edi
lea ecx, [esp + 0x64]
push ecx
mov ecx, 8
mov dword [esp + 0x24], eax
call fcn.004077a0
lea esi, [esp + 0x30]
lea ecx, [esp + 0x60]
mov dword [esp + 0x90], edi
call fcn.004079d0
mov edi, eax
lea esi, [esp + 0x3c]
lea ecx, [esp + 0x60]
mov byte [esp + 0x90], 1
call fcn.004079d0
mov dword [esp + 0x18], eax
mov esi, edi
mov byte [esp + 0x90], 2
call fcn.00408ed0
mov edx, dword [esp + 0x78]
mov esi, dword [esp + 0x18]
mov edi, eax
mov dword [esp + 0x24], edx
call fcn.00408ed0
mov ecx, dword [ebx + 0x3c]
mov edx, dword [ecx]
mov edx, dword [edx + 0x14]
lea esi, [esp + 0x28]
push esi
mov esi, dword [esp + 0x28]
add esi, edi
push esi
push eax
lea eax, [esp + 0x38]
push eax
lea eax, [esp + 0x2e]
push eax
lea eax, [esp + 0x30]
push eax
lea eax, [ebx + 0x44]
push eax
call edx
lea edi, [esp + 0x3c]
mov esi, eax
mov byte [esp + 0x90], 1
call fcn.004026a0
lea edi, [esp + 0x30]
mov byte [esp + 0x90], 0
call fcn.004026a0
test esi, esi
jl 0x406a85
cmp esi, 1
jg 0x406ac1
lea esi, [esp + 0x48]
lea ecx, [esp + 0x60]
call fcn.004079d0
mov esi, eax
mov byte [esp + 0x90], 3
call fcn.00408ed0
mov esi, dword [esp + 0x28]
sub esi, eax
lea edi, [esp + 0x48]
mov dword [esp + 0x18], esi
mov byte [esp + 0x90], 0
call fcn.004026a0
test esi, esi
jbe 0x406984
lea esi, [esp + 0x54]
lea ecx, [esp + 0x60]
call fcn.004079d0
mov byte [esp + 0x90], 4
or dword [esp + 0x20], 1
mov esi, eax
call fcn.00408ed0
mov ecx, dword [ebx + 0x4c]
mov esi, dword [esp + 0x18]
push ecx
push esi
push 1
push eax
call fcn.0047ddf0
add esp, 0x10
mov byte [esp + 0x17], 1
cmp esi, eax
jne 0x406989
mov byte [esp + 0x17], 0
mov dword [esp + 0x90], 0
test byte [esp + 0x20], 1
je 0x4069a9
and dword [esp + 0x20], 0xfffffffe
lea edi, [esp + 0x54]
call fcn.004026a0
cmp byte [esp + 0x17], 0
jne 0x406a85
lea edx, [esp + 0x1c]
mov byte [ebx + 0x42], 1
cmp dword [esp + 0x2c], edx
jne 0x406af8
test esi, esi
ja 0x4069e5
cmp dword [esp + 0x78], 0x20
jae 0x406a85
push 0
mov eax, 8
lea edi, [esp + 0x64]
call fcn.00407930
lea esi, [esp + 0x30]
lea ecx, [esp + 0x60]
call fcn.004079d0
mov edi, eax
lea esi, [esp + 0x3c]
lea ecx, [esp + 0x60]
mov byte [esp + 0x90], 1
call fcn.004079d0
mov dword [esp + 0x18], eax
mov esi, edi
mov byte [esp + 0x90], 2
call fcn.00408ed0
mov esi, dword [esp + 0x18]
mov edi, eax
mov eax, dword [esp + 0x78]
mov dword [esp + 0x24], eax
call fcn.00408ed0
mov ecx, dword [ebx + 0x3c]
mov edx, dword [ecx]
mov edx, dword [edx + 0x14]
lea esi, [esp + 0x28]
push esi
mov esi, dword [esp + 0x28]
add esi, edi
push esi
push eax
lea eax, [esp + 0x38]
push eax
lea eax, [esp + 0x2e]
push eax
lea eax, [esp + 0x30]
push eax
lea eax, [ebx + 0x44]
push eax
call edx
lea edi, [esp + 0x3c]
mov esi, eax
mov byte [esp + 0x90], 1
call fcn.004026a0
lea edi, [esp + 0x30]
mov byte [esp + 0x90], 0
call fcn.004026a0
test esi, esi
jge 0x406902
lea ecx, [esp + 0x60]
mov dword [esp + 0x90], 0xffffffff
call fcn.00401740
mov eax, 0xffff
mov ecx, dword [esp + 0x88]
mov dword fs:[0], ecx
pop ecx
pop edi
pop esi
pop ebx
mov ecx, dword [esp + 0x70]
xor ecx, esp
call fcn.00476680
mov esp, ebp
pop ebp
ret 4
cmp esi, 3
jne 0x406a85
mov eax, dword [ebx + 0x4c]
mov ecx, dword [esp + 0x1c]
call fcn.00404040
movzx esi, word [ebp + 8]
test al, al
jne 0x406adf
mov esi, 0xffff
lea ecx, [esp + 0x60]
mov dword [esp + 0x90], 0xffffffff
call fcn.00401740
mov ax, si
jmp 0x406a9e
lea ecx, [esp + 0x60]
mov dword [esp + 0x90], 0xffffffff
call fcn.00401740
mov ax, word [ebp + 8]
jmp 0x406a9e