Function at 0x4058fb
Capabilities:
Enumerate pe sections
Parse pe header
Write file on windows

Disassembly:
push ebp
mov ebp, esp
push ebx
push edi
push esi
and esp, 0xfffffff0
sub esp, 0x30
mov esi, esp
cmp byte [0x40c078], 0
jne 0x405a42
mov byte [0x40c078], 1
mov edx, dword [0x408004]
movzx ecx, word [edx]
xor eax, eax
cmp ecx, 0x5a4d
jne 0x40595a
mov ecx, dword [edx + 0x3c]
cmp dword [edx + ecx], 0x4550
jne 0x40595a
movzx edx, word [edx + ecx + 0x18]
cmp edx, 0x10b
mov edx, dword [0x408004]
jne 0x40595a
movzx eax, word [edx + ecx + 6]
shl eax, 2
lea eax, [eax + eax*4]
add eax, 3
and eax, 0xfffffffc
call fcn.004014ee
mov eax, esp
and eax, 0xfffffff0
mov esp, eax
mov dword [0x40c4f8], eax
mov dword [0x40c4ac], 0
mov ebx, 0x40a8d8
mov eax, 0x40a8d8
sub eax, ebx
cmp eax, 7
jle 0x405a42
cmp eax, 0xc
jl 0x4059bb
cmp dword [0x40a8d8], 0
jne 0x4059ca
cmp dword [0x40a8dc], 0
jne 0x4059ca
cmp dword [0x40a8e0], 0
mov eax, 0x40a8d8
mov ebx, 0x40a8e4
cmovne ebx, eax
cmp dword [ebx], 0
jne 0x4059ca
cmp dword [ebx + 4], 0
je 0x405a4a
cmp ebx, 0x40a8d8
jae 0x4059ff
lea edi, [esi + 0x14]
mov eax, dword [ebx]
mov ecx, dword [ebx + 4]
add eax, dword [ecx + edx]
add ecx, edx
mov dword [esi + 0x14], eax
mov edx, edi
push 4
call 0x405b61
mov edx, dword [0x408004]
add esp, 4
add ebx, 8
cmp ebx, 0x40a8d8
jb 0x4059d5
mov eax, dword [0x40c4ac]
test eax, eax
jle 0x405a42
xor edi, edi
mov ebx, 8
mov ecx, dword [0x40c4f8]
mov edx, dword [ecx + ebx - 8]
test edx, edx
je 0x405a3a
lea eax, [esi + 0x1c]
push eax
push edx
push dword [ecx + ebx]
push dword [ecx + ebx - 4]
call dword [sym.imp.KERNEL32.dll_VirtualProtect]
mov ecx, dword [0x40c4f8]
mov eax, dword [0x40c4ac]
inc edi
add ebx, 0x14
cmp edi, eax
jl 0x405a15
lea esp, [ebp - 0xc]
pop esi
pop edi
pop ebx
pop ebp
ret
mov eax, dword [ebx + 8]
cmp eax, 1
jne 0x405b56
add ebx, 0xc
cmp ebx, 0x40a8d8
jae 0x4059ff
mov eax, dword [ebx + 4]
add eax, edx
mov edi, dword [ebx]
mov ecx, dword [ebx + 8]
mov edx, dword [edi + edx]
mov dword [esi + 0xc], edx
cmp cl, 0x20
mov dword [esi + 0x10], ecx
movzx edx, cl
mov dword [esi + 8], eax
je 0x405aaf
cmp edx, 0x10
je 0x405a9c
cmp edx, 8
jne 0x405b4b
mov ecx, edi
movzx eax, byte [eax]
lea edi, [eax - 0x100]
test al, al
jmp 0x405aaa
mov ecx, edi
movzx eax, word [eax]
lea edi, [eax - 0x10000]
test ax, ax
cmovns edi, eax
jmp 0x405ab3
mov ecx, edi
mov edi, dword [eax]
add ecx, dword [0x408004]
sub edi, ecx
add edi, dword [esi + 0xc]
mov dword [esi + 0x18], edi
cmp edx, 0x1f
ja 0x405aeb
xor eax, eax
dec eax
mov ecx, edx
shl eax, cl
test dl, 0x20
mov ecx, 0
cmovne eax, ecx
not eax
cmp edi, eax
jg 0x405b39
mov ecx, edx
dec cl
xor eax, eax
dec eax
shl eax, cl
cmp edi, eax
jl 0x405b39
mov eax, dword [esi + 0x10]
cmp al, 8
mov edi, 1
je 0x405b10
movzx eax, al
cmp eax, 0x20
je 0x405b0b
cmp eax, 0x10
jne 0x405b1f
mov edi, 2
jmp 0x405b10
mov edi, 4
mov ecx, dword [esi + 8]
lea edx, [esi + 0x18]
push edi
call 0x405b61
add esp, 4
add ebx, 0xc
cmp ebx, 0x40a8d8
mov edx, dword [0x408004]
jb 0x405a61
jmp 0x4059ff
push edi
push dword [esi + 0xc]
push dword [esi + 8]
push edx
push str._d_bit_pseudo_relocation_at__p_out_of_range__targeting__p__yielding_the_value__p._n
call 0x405cd3
push edx
push str.__Unknown_pseudo_relocation_bit_size__d._n
call 0x405cd3
push eax
push str.__Unknown_pseudo_relocation_protocol_version__d._n
call 0x405cd3
push ebp
push ebx
push edi
push esi
sub esp, 0x20
mov ebp, edx
mov esi, ecx
mov eax, dword [0x40c4ac]
test eax, eax
jle 0x405b9f
mov ecx, dword [0x40c4f8]
add ecx, 0x10
mov edx, eax
mov edi, dword [ecx - 4]
cmp edi, esi
ja 0x405b94
mov ebx, dword [ecx]
add edi, dword [ebx + 8]
cmp edi, esi
ja 0x405c99
add ecx, 0x14
dec edx
jne 0x405b80
mov dword [esp], ebp
jmp 0x405ba4
mov dword [esp], ebp
xor eax, eax
mov ebx, dword [0x408004]
movzx ecx, word [ebx]
cmp ecx, 0x5a4d
jne 0x405bfd
mov ecx, dword [ebx + 0x3c]
cmp dword [ebx + ecx], 0x4550
jne 0x405bfd
add ebx, ecx
movzx ecx, word [ebx + 0x18]
cmp ecx, 0x10b
jne 0x405bfd
movzx ecx, word [ebx + 6]
test ecx, ecx
je 0x405bfd
mov edx, esi
sub edx, dword [0x408004]
movzx edi, word [ebx + 0x14]
lea ebp, [ebx + edi + 0x18]
mov edi, dword [ebp + 0xc]
cmp edi, edx
ja 0x405bf7
mov ebx, dword [ebp + 8]
add ebx, edi
cmp ebx, edx
ja 0x405c08
add ebp, 0x28
dec ecx
jne 0x405be7
push esi
push str.Address__p_has_no_image_section
call 0x405cd3
mov ecx, dword [0x40c4f8]
lea ebx, [eax + eax*4]
mov dword [ecx + ebx*4 + 0x10], ebp
mov dword [ecx + ebx*4], 0
add edi, dword [0x408004]
mov dword [ecx + ebx*4 + 0xc], edi
lea eax, [esp + 4]
push 0x1c
push eax
push edi
call dword [sym.imp.KERNEL32.dll_VirtualQuery]
test eax, eax
je 0x405cac
mov eax, dword [esp + 0x18]
cmp eax, 7
jle 0x405c57
cmp eax, 8
mov ebp, dword [esp]
je 0x405c93
cmp eax, 0x40
je 0x405c93
cmp eax, 0x80
je 0x405c93
jmp 0x405c69
mov ecx, 4
cmp eax, 2
mov ebp, dword [esp]
je 0x405c6e
cmp eax, 4
je 0x405c93
mov ecx, 0x40
mov eax, dword [esp + 4]
mov edx, dword [0x40c4f8]
lea edx, [edx + ebx*4]
mov dword [edx + 4], eax
mov edi, dword [esp + 0x10]
mov dword [edx + 8], edi
push edx
push ecx
push edi
push eax
call dword [sym.imp.KERNEL32.dll_VirtualProtect]
test eax, eax
je 0x405cc2
inc dword [0x40c4ac]
push dword [esp + 0x34]
push ebp
push esi
call fcn.0040354f
add esp, 0x2c
pop esi
pop edi
pop ebx
pop ebp
ret
mov eax, dword [0x40c4f8]
push dword [eax + ebx*4 + 0xc]
push dword [ebp + 8]
push str.__VirtualQuery_failed_for__d_bytes_at_address__p
call 0x405cd3
call dword [sym.imp.KERNEL32.dll_GetLastError]
push eax
push str.__VirtualProtect_failed_with_code_0x_x
call 0x405cd3
push edi
push esi
push eax
mov esi, dword [esp + 0x10]
lea eax, [esp + 0x14]
mov dword [esp], eax
mov edi, 2
push edi
call sub.api_ms_win_crt_stdio_l1_1_0.dll___acrt_iob_func
add esp, 4
push eax
push 1
push 0x1b
push str.Mingw_w64_runtime_failure:_n
call sub.api_ms_win_crt_stdio_l1_1_0.dll_fwrite
add esp, 0x10
push edi
call sub.api_ms_win_crt_stdio_l1_1_0.dll___acrt_iob_func
add esp, 4
mov ecx, eax
mov edx, esi
push dword [esp]
call fcn.00405f6e
add esp, 4
call sub.api_ms_win_crt_runtime_l1_1_0.dll_abort
push ebx
mov eax, dword [esp + 8]
mov eax, dword [eax]
mov eax, dword [eax]
lea ecx, [eax + 0x3fffff73]
cmp ecx, 9
ja case.default.0x405d34
mov bl, 1
jmp dword [ecx*4 + 0x40a8a0]
xor ebx, ebx
push 0
push 8
call sub.api_ms_win_crt_runtime_l1_1_0.dll_signal
add esp, 8
test eax, eax
je case.0x405d34.1073741678
cmp eax, 1
jne 0x405d92
push 1
push 8
call sub.api_ms_win_crt_runtime_l1_1_0.dll_signal
add esp, 8
xor eax, eax
dec eax
test bl, bl
jne 0x405dd7
fninit
jmp 0x405dd7
cmp eax, 0xc000001d
je case.0x405d34.1073741674
cmp eax, 0xc0000005
jne case.0x405d34.1073741678
push 0
push 0xb
call sub.api_ms_win_crt_runtime_l1_1_0.dll_signal
add esp, 8
test eax, eax
je case.0x405d34.1073741678
cmp eax, 1
jne 0x405dcd
push 1
push 0xb
jmp 0x405daf
push 8
jmp 0x405dcf
push 0
push 4
call sub.api_ms_win_crt_runtime_l1_1_0.dll_signal
add esp, 8
test eax, eax
je case.0x405d34.1073741678
cmp eax, 1
jne 0x405dc9
push 1
push 4
call sub.api_ms_win_crt_runtime_l1_1_0.dll_signal
add esp, 8
jmp 0x405dd4
mov eax, dword [0x40c040]
test eax, eax
je 0x405dc5
pop ebx
jmp eax
xor eax, eax
jmp 0x405dd7
push 4
jmp 0x405dcf
push 0xb
call eax
add esp, 4
xor eax, eax
dec eax
pop ebx
ret 4