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

Disassembly:
push ebp
push edi
push esi
push ebx
xor ebx, ebx
sub esp, 0xac
mov edx, dword [esp + 0xc0]
mov dword [esp], edx
call sub.msvcrt.dll__fileno
lea edx, [esp + 0x30]
mov dword [esp + 4], edx
mov dword [esp], eax
call dword [sym.imp.msvcrt.dll__fstat64]
test eax, eax
jne 0x402674
mov ebx, dword [esp + 0x58]
mov eax, dword [esp + 0xc4]
mov dword [esp + 4], 0x4137a8
mov dword [esp], eax
call sub.msvcrt.dll_fopen
test eax, eax
mov edi, eax
je 0x402a7c
mov dword [esp + 0xc], eax
mov dword [esp + 8], 1
mov dword [esp + 4], 4
mov dword [esp], 0x4137b1
call sub.msvcrt.dll_fwrite
cmp eax, 1
jne 0x402a02
movzx eax, bl
mov dword [esp + 4], edi
mov dword [esp], eax
call sub.msvcrt.dll_fputc
cmp eax, 0xffffffff
je 0x402a02
movzx eax, bh
mov dword [esp + 4], edi
mov dword [esp], eax
call sub.msvcrt.dll_fputc
cmp eax, 0xffffffff
je 0x402a02
mov eax, ebx
shr eax, 0x10
and eax, 0xff
mov dword [esp + 4], edi
mov dword [esp], eax
call sub.msvcrt.dll_fputc
cmp eax, 0xffffffff
je 0x402a02
shr ebx, 0x18
mov dword [esp + 4], edi
mov dword [esp], ebx
call sub.msvcrt.dll_fputc
cmp eax, 0xffffffff
je 0x402a02
mov dword [esp + 0xc], edi
mov dword [esp + 8], 1
mov dword [esp + 4], 2
mov dword [esp], 0x4137bc
call sub.msvcrt.dll_fwrite
cmp eax, 1
jne 0x402a02
mov edx, dword [esp + 0xc8]
mov dword [esp], edx
call sub.msvcrt.dll_malloc
mov edx, dword [esp + 0xc8]
add edx, 0x1f4
mov dword [esp + 0x2c], edx
mov dword [esp], edx
mov esi, eax
call sub.msvcrt.dll_malloc
mov dword [esp + 8], 0
mov dword [esp + 4], 0
mov dword [esp], 0
mov dword [esp + 0x24], eax
call fcn.00408070
mov dword [esp + 0x88], 0
mov dword [esp + 0x8c], 0
mov dword [esp + 0x90], 0
mov dword [esp + 0x70], 0
mov dword [esp + 0x7c], 0
mov dword [esp + 0x20], eax
lea eax, [esp + 0x68]
mov dword [esp + 0x1c], 0x38
mov dword [esp + 0x18], 0x4137bf
mov dword [esp + 0x14], 0
mov dword [esp + 0x10], 8
mov dword [esp + 0xc], 0xfffffff1
mov dword [esp + 8], 8
mov dword [esp + 4], 9
mov dword [esp], eax
call fcn.0040abd0
mov dword [esp + 0x28], edi
mov edi, dword [esp + 0xc8]
mov edx, dword [esp + 0xc0]
mov dword [esp + 8], edi
mov dword [esp + 4], 1
mov dword [esp], esi
mov dword [esp + 0xc], edx
call sub.msvcrt.dll_fread
test eax, eax
mov ebx, eax
js 0x402a58
mov dword [esp + 8], eax
mov eax, dword [esp + 0x20]
mov dword [esp + 4], esi
mov dword [esp], eax
call fcn.00408070
cmp ebx, 1
mov edx, dword [esp + 0x2c]
mov dword [esp + 0x68], esi
mov dword [esp + 0x6c], ebx
mov dword [esp + 0x78], edx
mov dword [esp + 0x20], eax
mov eax, dword [esp + 0x24]
mov dword [esp + 0x74], eax
sbb eax, eax
and eax, 3
add eax, 1
mov dword [esp + 4], eax
lea eax, [esp + 0x68]
mov dword [esp], eax
call fcn.0040a5f0
cmp eax, 1
ja 0x402a20
mov eax, dword [esp + 0x28]
mov ebp, dword [esp + 0x74]
sub ebp, dword [esp + 0x24]
mov dword [esp + 4], 1
mov dword [esp + 0xc], eax
mov eax, dword [esp + 0x24]
mov dword [esp + 8], ebp
mov dword [esp], eax
call sub.msvcrt.dll_fwrite
cmp eax, ebp
je 0x402a50
mov edi, dword [esp + 0x28]
mov dword [esp], str.write
call sub.msvcrt.dll_perror
mov ebx, 0xffffffff
movzx eax, byte [esp + 0x20]
mov dword [esp + 4], edi
mov dword [esp], eax
call sub.msvcrt.dll_fputc
cmp eax, 0xffffffff
je 0x402a02
mov edx, dword [esp + 0x20]
mov dword [esp + 4], edi
movzx eax, dh
mov dword [esp], eax
call sub.msvcrt.dll_fputc
cmp eax, 0xffffffff
je 0x402a02
mov eax, dword [esp + 0x20]
mov dword [esp + 4], edi
shr eax, 0x10
and eax, 0xff
mov dword [esp], eax
call sub.msvcrt.dll_fputc
cmp eax, 0xffffffff
je 0x402a02
mov eax, dword [esp + 0x20]
mov dword [esp + 4], edi
shr eax, 0x18
mov dword [esp], eax
call sub.msvcrt.dll_fputc
cmp eax, 0xffffffff
je 0x402a02
mov ebp, dword [esp + 0x70]
mov dword [esp + 4], edi
mov eax, ebp
and eax, 0xff
mov dword [esp], eax
call sub.msvcrt.dll_fputc
cmp eax, 0xffffffff
je 0x402a02
mov edx, ebp
movzx eax, dh
mov dword [esp + 4], edi
mov dword [esp], eax
call sub.msvcrt.dll_fputc
cmp eax, 0xffffffff
je 0x402a02
mov eax, ebp
shr eax, 0x10
and eax, 0xff
mov dword [esp + 4], edi
mov dword [esp], eax
call sub.msvcrt.dll_fputc
cmp eax, 0xffffffff
je 0x402a02
shr ebp, 0x18
mov dword [esp + 4], edi
mov dword [esp], ebp
call sub.msvcrt.dll_fputc
cmp eax, 0xffffffff
je 0x402a02
mov dword [esp], edi
call sub.msvcrt.dll_fflush
mov eax, dword [esp + 0x24]
mov dword [esp], eax
call sub.msvcrt.dll_free
mov dword [esp], esi
call sub.msvcrt.dll_free
mov edx, dword [esp + 0xc0]
mov dword [esp], edx
call sub.msvcrt.dll_fclose
test eax, eax
jne 0x402a65
test ebx, ebx
jne 0x402a65
mov dword [esp], edi
call sub.msvcrt.dll_rewind
add esp, 0xac
mov eax, edi
pop ebx
pop esi
pop edi
pop ebp
ret
mov dword [esp], str.write
xor edi, edi
call sub.msvcrt.dll_perror
add esp, 0xac
mov eax, edi
pop ebx
pop esi
pop edi
pop ebp
ret
mov dword [esp + 0xc], eax
mov eax, dword [esp + 0x80]
mov edi, dword [esp + 0x28]
mov dword [esp + 4], str.zlib_error:__s___d__n
mov dword [esp + 8], eax
mov eax, dword [sym.imp.msvcrt.dll__iob]
add eax, 0x40
mov dword [esp], eax
call sub.msvcrt.dll_fprintf
jmp 0x4028d9
test ebx, ebx
jne 0x40281c
mov edi, dword [esp + 0x28]
lea esi, [esi]
jmp 0x4028de
mov dword [esp], edi
xor edi, edi
call sub.msvcrt.dll_fclose
add esp, 0xac
mov eax, edi
pop ebx
pop esi
pop edi
pop ebp
ret
mov dword [esp], str.open
call sub.msvcrt.dll_perror
jmp 0x402a10