Function at 0x406642
Capabilities:
Write file on windows

Disassembly:
sub esp, 0xc
push ebx
push esi
push edi
mov edi, dword [esp + 0x1c]
xor ebx, ebx
mov esi, ebx
mov dword [esp + 0xc], 1
cmp dword [edi], ebx
je 0x406670
cmp dword [edi + 8], ebx
je 0x4066a0
cmp dword [edi + 0xc], ebx
je 0x406670
push dword [edi]
call dword [sym.imp.KERNEL32.dll_CloseHandle]
mov dword [edi], ebx
cmp dword [edi + 8], ebx
je 0x4066a0
cmp dword [edi], ebx
jne 0x4066a8
cmp dword [edi + 4], ebx
je 0x4066a0
push ebx
push pe_nt_image_headers32
push 2
push ebx
push 1
push 0xc0000000
push dword [edi + 4]
call dword [sym.imp.KERNEL32.dll_CreateFileW]
mov dword [edi], eax
cmp eax, 0xffffffff
jne 0x4066a0
mov dword [edi], ebx
cmp dword [edi], ebx
je 0x406896
cmp dword [edi + 8], ebx
je 0x406896
test byte [edi + 0x2c], 1
mov dword [esp + 0x1c], 0x415024
jne 0x4066c7
mov dword [esp + 0x1c], 0x415028
cmp dword [edi + 0x18], 0xfde9
jne 0x4066d3
push 5
pop ebx
push ebp
mov ebp, dword [edi + 0x1c]
jmp 0x40672a
cmp dword [ebp + 8], 1
push dword [ebp + 0xc]
jne 0x4066ff
call sub.MSVCRT.dll_strlen
add ebx, 4
add ebx, eax
test byte [edi + 0x2c], 2
pop ecx
je 0x406727
push 0x41502c
call sub.MSVCRT.dll_strlen
jmp 0x406724
cmp dword [ebp + 8], 2
jne 0x40670f
call sub.MSVCRT.dll_strlen
add ebx, 4
jmp 0x406724
call sub.MSVCRT.dll_strlen
push dword [ebp + 8]
mov esi, eax
call sub.MSVCRT.dll_strlen
add eax, ebx
lea ebx, [esi + 5]
pop ecx
pop ecx
add ebx, eax
mov ebp, dword [ebp]
test ebp, ebp
jne 0x4066d9
test ebx, ebx
jne 0x40674a
push ebp
push ebp
push ebp
push dword [edi]
call dword [sym.imp.KERNEL32.dll_SetFilePointer]
push dword [edi]
call dword [sym.imp.KERNEL32.dll_SetEndOfFile]
jmp 0x40688c
lea eax, [ebx + 1]
push eax
push ebp
push dword [0x4194c4]
call dword [sym.imp.KERNEL32.dll_HeapAlloc]
mov ebx, eax
mov dword [esp + 0x14], ebx
test ebx, ebx
je 0x40688c
cmp dword [edi + 0x18], 0xfde9
mov esi, ebx
jne 0x406796
push 0x415018
push ebx
call sub.MSVCRT.dll_strcpy
push 0x41502c
push ebx
call sub.MSVCRT.dll_strcat
push ebx
call sub.MSVCRT.dll_strlen
add esp, 0x14
lea esi, [ebx + eax]
mov ebp, dword [edi + 0x1c]
test ebp, ebp
je 0x406857
mov ebx, dword [esp + 0x20]
cmp dword [ebp + 8], 1
jne 0x4067f7
test byte [edi + 0x2c], 2
je 0x4067ce
cmp dword [esp + 0x10], 0
jne 0x4067ce
push 0x41502c
push esi
call sub.MSVCRT.dll_strcpy
push esi
call sub.MSVCRT.dll_strlen
add esp, 0xc
add esi, eax
push 0x415030
push esi
call sub.MSVCRT.dll_strcpy
push dword [ebp + 0xc]
push esi
call sub.MSVCRT.dll_strcat
push 0x415034
push esi
call sub.MSVCRT.dll_strcat
add esp, 0x18
and dword [esp + 0x10], 0
jmp 0x406832
cmp dword [ebp + 8], 2
jne 0x406816
push 0x415038
push esi
call sub.MSVCRT.dll_strcpy
push dword [ebp + 0xc]
push esi
call sub.MSVCRT.dll_strcat
add esp, 0x10
jmp 0x406832
push dword [ebp + 8]
push esi
call sub.MSVCRT.dll_strcpy
push ebx
push esi
call sub.MSVCRT.dll_strcat
push dword [ebp + 0xc]
push esi
call sub.MSVCRT.dll_strcat
add esp, 0x18
push 0x41502c
push esi
call sub.MSVCRT.dll_strcat
push esi
call sub.MSVCRT.dll_strlen
mov ebp, dword [ebp]
add esp, 0xc
add esi, eax
test ebp, ebp
jne 0x4067a5
mov ebx, dword [esp + 0x14]
xor ebp, ebp
push ebp
push ebp
push ebp
push dword [edi]
call dword [sym.imp.KERNEL32.dll_SetFilePointer]
push ebp
lea eax, [esp + 0x1c]
sub esi, ebx
push eax
push esi
push ebx
push dword [edi]
call dword [sym.imp.KERNEL32.dll_WriteFile]
push dword [edi]
call dword [sym.imp.KERNEL32.dll_SetEndOfFile]
push ebx
push ebp
push dword [0x4194c4]
call dword [sym.imp.KERNEL32.dll_HeapFree]
xor esi, esi
mov dword [edi + 8], ebp
mov dword [edi + 0xc], ebp
inc esi
pop ebp
pop edi
mov eax, esi
pop esi
pop ebx
add esp, 0xc
ret 4