Function at 0x402959
Capabilities:
Read file on windows
Write file on windows

Disassembly:
push ebp
mov ebp, esp
push 0xffffffffffffffff
push 0x405c1b
mov eax, dword fs:[0]
push eax
mov eax, 0x40224
call fcn.00404730
mov eax, dword [section..data]
xor eax, ebp
mov dword [ebp - 0x14], eax
push ebx
push esi
push eax
lea eax, [ebp - 0xc]
mov dword fs:[0], eax
mov eax, dword [ebp + 8]
mov dword [ebp - 0x40228], eax
xor ebx, ebx
push ebx
lea eax, [ebp - 0x4022c]
push eax
mov esi, 0x200
push esi
lea eax, [ebp - 0x40214]
push eax
push dword [edi]
mov byte [ebp - 0x40215], 1
call dword [sym.imp.KERNEL32.dll_ReadFile]
cmp eax, ebx
je 0x402a78
cmp dword [ebp - 0x4022c], esi
jne 0x402a78
push 4
lea eax, [ebp - 0x40113]
push 0x406380
push eax
call sub.msvcrt.dll_memcmp
add esp, 0xc
test eax, eax
jne 0x4029f7
mov eax, dword [ebp - 0x40228]
mov byte [eax], 1
mov al, 1
jmp 0x402a7a
push 5
lea eax, [ebp - 0x40113]
push 0x406378
push eax
call sub.msvcrt.dll_memcmp
add esp, 0xc
test eax, eax
jne 0x402a78
mov eax, dword [edi + 4]
sub eax, 0x10
call fcn.00402286
add eax, 0x10
mov dword [ebp - 0x4021c], eax
mov eax, 0x4063dc
lea ecx, [ebp - 0x4021c]
mov dword [ebp - 4], ebx
call fcn.00402bbb
lea eax, [ebp - 0x40214]
lea ecx, [ebp - 0x4021c]
call fcn.00402bbb
mov esi, dword [ebp - 0x4021c]
push ebx
push pe_nt_image_headers32
push 2
push ebx
push ebx
push 0x40000000
push esi
call dword [sym.imp.KERNEL32.dll_CreateFileA]
cmp eax, 0xffffffff
mov dword [ebp - 0x40228], eax
jne 0x402a95
lea eax, [esi - 0x10]
call fcn.004010b2
xor al, al
mov ecx, dword [ebp - 0xc]
mov dword fs:[0], ecx
pop ecx
pop esi
pop ebx
mov ecx, dword [ebp - 0x14]
xor ecx, ebp
call fcn.00404720
leave
ret 4
push 8
lea eax, [ebp - 0x40198]
push ebx
push eax
call sub.msvcrt.dll_strtol
add esp, 0xc
push 1
push ebx
push ebx
push dword [edi]
mov esi, eax
mov dword [ebp - 0x40220], esi
call dword [sym.imp.KERNEL32.dll_SetFilePointer]
add eax, dword [ebp - 0x40220]
neg esi
and esi, 0x1ff
add esi, eax
cmp dword [ebp - 0x40220], ebx
mov dword [ebp - 0x40230], esi
jbe 0x402b50
mov ecx, dword [ebp - 0x40220]
mov eax, 0x40000
cmp ecx, eax
mov dword [ebp - 0x40224], eax
jae 0x402af4
mov dword [ebp - 0x40224], ecx
push ebx
lea eax, [ebp - 0x4022c]
push eax
push dword [ebp - 0x40224]
lea eax, [ebp - 0x40014]
push eax
push dword [edi]
call dword [sym.imp.KERNEL32.dll_ReadFile]
test eax, eax
je 0x402b4a
push ebx
lea eax, [ebp - 0x4022c]
push eax
push dword [ebp - 0x40224]
lea eax, [ebp - 0x40014]
push eax
push dword [ebp - 0x40228]
call dword [sym.imp.KERNEL32.dll_WriteFile]
test eax, eax
je 0x402b4a
mov eax, dword [ebp - 0x40224]
sub dword [ebp - 0x40220], eax
jne 0x402ad9
jmp 0x402b50
mov byte [ebp - 0x40215], bl
push dword [ebp - 0x40228]
call dword [sym.imp.KERNEL32.dll_CloseHandle]
cmp byte [ebp - 0x40215], bl
je 0x402b92
cmp byte [edi + 8], bl
je 0x402b7e
lea eax, [ebp - 0x4021c]
push eax
lea esi, [edi + 0xc]
call fcn.00401f35
mov esi, dword [ebp - 0x40230]
mov eax, dword [edi + 0x18]
cmp eax, ebx
je 0x402b92
push dword [ebp - 0x4021c]
push dword [edi + 0x1c]
call eax
pop ecx
pop ecx
cmp esi, 0xffffffff
je 0x402ba2
push ebx
push ebx
push esi
push dword [edi]
call dword [sym.imp.KERNEL32.dll_SetFilePointer]
mov eax, dword [ebp - 0x4021c]
add eax, 0xfffffff0
call fcn.004010b2
mov al, byte [ebp - 0x40215]
jmp 0x402a7a