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

Disassembly:
push ebp
mov ebp, esp
sub esp, 0x818
push ebx
push edi
xor edi, edi
cmp dword [ebp + 0x18], edi
je 0x4019b7
movzx eax, word [ebp + 0x1c]
push edi
push eax
push 0x8001
push dword [ebp + 0x18]
call dword [sym.imp.USER32.dll_PostMessageW]
push edi
push edi
push 2
push edi
push 1
push 0x40000000
push dword [ebp + 0x14]
call dword [sym.imp.KERNEL32.DLL_CreateFileW]
cmp eax, 0xffffffff
mov dword [esi + 4], eax
jne 0x4019eb
push dword [ebp + 0x14]
push 0x70
push dword [esi + 8]
call fcn.0040210d
add esp, 0xc
xor eax, eax
jmp 0x401bcc
push edi
push edi
push dword [ebp + 8]
push dword [esi]
call dword [sym.imp.KERNEL32.DLL_SetFilePointer]
cmp dword [ebp + 0x1c], 2
jne 0x401a2d
push edi
lea eax, [ebp - 0xc]
push eax
push 3
push 0x4091e8
push dword [esi + 4]
call dword [sym.imp.KERNEL32.DLL_WriteFile]
test eax, eax
je 0x401a1d
cmp dword [ebp - 0xc], 3
je 0x401a2d
push dword [esi + 4]
call dword [sym.imp.KERNEL32.DLL_CloseHandle]
push dword [ebp + 0x14]
push 0x71
jmp 0x4019d9
cmp dword [ebp + 0x10], edi
mov dword [ebp - 8], edi
mov dword [ebp - 4], edi
jl 0x401b1b
jg 0x401a47
cmp dword [ebp + 0xc], edi
jbe 0x401b1b
push edi
lea eax, [ebp - 0x14]
push eax
push 0x800
lea eax, [ebp - 0x818]
push eax
push dword [esi]
call dword [sym.imp.KERNEL32.DLL_ReadFile]
test eax, eax
je 0x401b1b
mov edx, dword [ebp - 0x14]
cmp edx, edi
je 0x401b1b
mov ecx, dword [ebp + 0xc]
sub ecx, dword [ebp - 8]
mov eax, dword [ebp + 0x10]
sbb eax, dword [ebp - 4]
cmp eax, edi
jg 0x401a92
jl 0x401a89
cmp ecx, edx
jae 0x401a92
mov edx, dword [ebp + 0xc]
sub edx, dword [ebp - 8]
mov dword [ebp - 0x14], edx
cmp edx, edi
je 0x401ab7
push edi
lea eax, [ebp - 0xc]
push eax
push edx
lea eax, [ebp - 0x818]
push eax
push dword [esi + 4]
call dword [sym.imp.KERNEL32.DLL_WriteFile]
test eax, eax
je 0x401a1d
mov edx, dword [ebp - 0x14]
mov eax, dword [ebp - 0xc]
cmp eax, edx
jne 0x401a1d
add dword [ebp - 8], eax
adc dword [ebp - 4], edi
cmp dword [ebp + 0x18], edi
je 0x401b01
push edi
push 0x64
push dword [ebp - 4]
push dword [ebp - 8]
call fcn.00408ca0
push dword [ebp + 0x10]
push dword [ebp + 0xc]
push edx
push eax
call fcn.00408bf0
push eax
movzx eax, word [ebp + 0x1c]
or eax, 0x10000
push eax
push 0x8001
push dword [ebp + 0x18]
call dword [sym.imp.USER32.dll_PostMessageW]
mov eax, dword [ebp - 4]
cmp eax, dword [ebp + 0x10]
jl 0x401a47
jg 0x401b1b
mov eax, dword [ebp + 0xc]
cmp dword [ebp - 8], eax
jb 0x401a47
cmp dword [ebp + 0x1c], 1
jne 0x401b85
mov eax, dword [esi + 0x14]
cmp eax, dword [esi + 0x18]
jbe 0x401b85
push 0x800
lea eax, [ebp - 0x818]
push edi
push eax
call sub.MSVCRT.dll_memset
mov ebx, dword [esi + 0x14]
add esp, 0xc
sub ebx, dword [esi + 0x18]
je 0x401b85
mov eax, 0x800
cmp ebx, eax
mov dword [ebp - 0x10], eax
ja 0x401b55
mov dword [ebp - 0x10], ebx
push edi
lea eax, [ebp - 0xc]
push eax
push dword [ebp - 0x10]
lea eax, [ebp - 0x818]
push eax
push dword [esi + 4]
call dword [sym.imp.KERNEL32.DLL_WriteFile]
test eax, eax
je 0x401a1d
mov eax, dword [ebp - 0x10]
cmp dword [ebp - 0xc], eax
jne 0x401a1d
sub ebx, eax
jne 0x401b46
push dword [esi + 4]
call dword [sym.imp.KERNEL32.DLL_CloseHandle]
or dword [esi + 4], 0xffffffff
cmp dword [ebp + 0x18], edi
je 0x401bb1
movzx eax, word [ebp + 0x1c]
push 0x64
or eax, 0x20000
push eax
push 0x8001
push dword [ebp + 0x18]
call dword [sym.imp.USER32.dll_PostMessageW]
mov eax, dword [ebp + 0xc]
cmp dword [ebp - 8], eax
jne 0x4019e4
mov eax, dword [ebp + 0x10]
cmp dword [ebp - 4], eax
jne 0x4019e4
xor eax, eax
inc eax
pop edi
pop ebx
leave
ret