Function at 0x406580
Capabilities:
Read file on windows

Disassembly:
push ebp
mov ebp, esp
sub esp, 0x14
push ebx
push esi
push edi
mov edi, ecx
mov dword [ebp - 4], 0
cmp dword [edi + 0x140], 0xffffffff
jne 0x4065a7
mov eax, 6
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret
push dword [edi + 0x154]
lea ebx, [edi + 0x144]
call dword [sym.imp.KERNEL32.dll_ResetEvent]
push ebx
lea eax, [ebp - 4]
mov dword [ebx + 8], 0
push eax
push 0x20
push edi
mov dword [ebx + 0xc], 0
push dword [edi + 0x140]
call dword [sym.imp.KERNEL32.dll_ReadFile]
test eax, eax
jne 0x4065eb
mov eax, 0x1e
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret
mov edx, dword [edi + 0x1c]
mov eax, dword [edi + 0x10]
add edx, 0x20
mov ecx, dword [edi + 0x18]
shl eax, 0xa
add ecx, edx
cdq
mov esi, eax
mov dword [ebp - 8], ecx
mov eax, edx
mov dword [ebp - 0x14], esi
push eax
push esi
push 0
push ecx
mov dword [ebp - 0xc], eax
call fcn.0041d800
mov ecx, eax
or ecx, edx
je 0x40662c
sub esi, eax
mov eax, dword [ebp - 0xc]
sbb eax, edx
add esi, dword [ebp - 8]
adc eax, 0
mov dword [ebp - 8], eax
jmp 0x406636
mov esi, dword [ebp - 8]
mov dword [ebp - 8], 0
push dword [ebx + 0x10]
call dword [sym.imp.KERNEL32.dll_ResetEvent]
mov eax, dword [ebp - 8]
mov dword [ebx + 0xc], eax
lea eax, [ebp - 4]
push ebx
push eax
push 0x18
lea eax, [edi + 0x20]
mov dword [ebx + 8], esi
push eax
push dword [edi + 0x140]
call dword [sym.imp.KERNEL32.dll_ReadFile]
test eax, eax
jne 0x406670
call dword [sym.imp.KERNEL32.dll_GetLastError]
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret
mov eax, dword [edi + 0x30]
xor ecx, ecx
push dword [ebp - 0xc]
add eax, esi
mov esi, dword [ebp - 0x14]
push esi
adc ecx, dword [ebp - 8]
add eax, 0x18
mov dword [ebp - 8], eax
adc ecx, 0
push ecx
push eax
mov dword [ebp - 0x10], ecx
call fcn.0041d800
mov ecx, eax
or ecx, edx
je 0x4066ac
sub esi, eax
mov eax, dword [ebp - 0xc]
sbb eax, edx
add esi, dword [ebp - 8]
adc eax, dword [ebp - 0x10]
mov dword [ebp - 8], eax
jmp 0x4066b5
mov esi, dword [ebp - 8]
mov ecx, dword [ebp - 0x10]
mov dword [ebp - 8], ecx
push dword [ebx + 0x10]
call dword [sym.imp.KERNEL32.dll_ResetEvent]
mov eax, dword [ebp - 8]
mov dword [ebx + 0xc], eax
lea eax, [ebp - 4]
push ebx
push eax
push pe_nt_image_headers32
lea eax, [edi + 0x38]
mov dword [ebx + 8], esi
push eax
push dword [edi + 0x140]
call dword [sym.imp.KERNEL32.dll_ReadFile]
test eax, eax
je 0x406663
mov eax, dword [ebp - 8]
add esi, 0xf8
adc eax, 0
push eax
push esi
push 0
push 0x10
call fcn.00406030
mov dword [ebp - 0x10], eax
mov eax, dword [edi + 0x114]
mov dword [ebp - 8], edx
cmp eax, 0xf4240
jae 0x406816
cmp dword [edi + 0x10c], 0xf4240
jae 0x406816
cmp dword [edi + 0x108], 0x10000000
jae 0x406816
push eax
call fcn.0040b54a
add esp, 4
mov esi, eax
mov dword [edi + 0x130], esi
push dword [edi + 0x10c]
call fcn.0040b54a
add esp, 4
mov dword [edi + 0x134], eax
test esi, esi
je 0x40681f
test eax, eax
je 0x40681f
cmp dword [edi + 0x114], 0
mov esi, dword [ebp - 0x10]
jbe 0x4067b8
push dword [ebp - 8]
push esi
push ebx
call fcn.00406000
push ebx
lea eax, [ebp - 4]
push eax
push dword [edi + 0x114]
push dword [edi + 0x130]
push dword [edi + 0x140]
call dword [sym.imp.KERNEL32.dll_ReadFile]
test eax, eax
je 0x406663
add esi, dword [edi + 0x114]
mov eax, dword [ebp - 8]
adc eax, 0
mov dword [ebp - 8], eax
jmp 0x4067bb
mov eax, dword [ebp - 8]
cmp dword [edi + 0x10c], 0
jbe 0x4067fd
push eax
push esi
push ebx
call fcn.00406000
push ebx
lea eax, [ebp - 4]
push eax
push dword [edi + 0x10c]
push dword [edi + 0x134]
push dword [edi + 0x140]
call dword [sym.imp.KERNEL32.dll_ReadFile]
test eax, eax
je 0x406663
add esi, dword [edi + 0x10c]
mov eax, dword [ebp - 8]
adc eax, 0
push eax
push esi
push dword [ebp - 0xc]
push dword [ebp - 0x14]
call fcn.00406030
mov dword [edi + 0x138], eax
mov dword [edi + 0x13c], edx
xor eax, eax
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret
push str.Failed_to_allocated_memory_for_headers_n
call fcn.0040b76b
add esp, 4
mov eax, 0xe
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret