Function at 0x404120
Capabilities:
Get file size
Read file on windows
Write file on windows

Disassembly:
push ebp
mov ebp, esp
push 0xffffffffffffffff
push 0x42bb48
mov eax, dword fs:[0]
push eax
sub esp, 0x38
mov eax, dword [0x439190]
xor eax, ebp
mov dword [ebp - 0x10], eax
push ebx
push esi
push edi
push eax
lea eax, [ebp - 0xc]
mov dword fs:[0], eax
mov esi, ecx
cmp dword [esi + 0x10], 0
mov ebx, edx
je 0x4041dc
cmp dword [ebx + 0x10], 0
je 0x4041dc
cmp dword [esi + 0x14], 8
jb 0x404169
mov eax, dword [esi]
jmp 0x40416b
mov eax, esi
push 0
push 0
push 3
push 0
push 1
push SysReAllocString
push eax
call dword [sym.imp.KERNEL32.dll_CreateFileW]
mov edi, eax
mov dword [ebp - 0x30], edi
cmp edi, 0xffffffff
jne 0x4041aa
cmp dword [esi + 0x14], 8
jb 0x404193
mov esi, dword [esi]
call dword [sym.imp.KERNEL32.dll_GetLastError]
push eax
push esi
push str.SaveFileBufferAsFile_____CreateFile_lpSrcFilePath:___s___failed__error_code:__lu.
call fcn.004166a0
add esp, 0xc
jmp 0x4041dc
push 0
push edi
call dword [sym.imp.KERNEL32.dll_GetFileSize]
cmp eax, 0xffffffff
jne 0x4041fc
cmp dword [esi + 0x14], 8
jb 0x4041c0
mov esi, dword [esi]
call dword [sym.imp.KERNEL32.dll_GetLastError]
push eax
push esi
push str.SaveFileBufferAsFile_____GetFileSize_lpSrcFilePath:___s___failed__error_code:__lu.
call fcn.004166a0
add esp, 0xc
push edi
call dword [sym.imp.KERNEL32.dll_CloseHandle]
xor eax, eax
mov ecx, dword [ebp - 0xc]
mov dword fs:[0], ecx
pop ecx
pop edi
pop esi
pop ebx
mov ecx, dword [ebp - 0x10]
xor ecx, ebp
call fcn.004180c9
mov esp, ebp
pop ebp
ret 8
mov ecx, dword [ebp + 8]
mov edx, dword [ebp + 0xc]
lea esi, [ecx + edx]
cmp eax, esi
jae 0x40421b
push edx
push ecx
push eax
push str.SaveFileBufferAsFile_____Invalid_file_size__dwSrcFileSize:__lu__dwSrcFileOffset:__lu__dwDstFileSize:__lu.
call fcn.004166a0
add esp, 0x10
jmp 0x4041d5
push 0
push 0
push ecx
push edi
call dword [sym.imp.KERNEL32.dll_SetFilePointer]
mov esi, 8
cmp dword [ebx + 0x14], esi
jb 0x404235
mov ecx, dword [ebx]
jmp 0x404237
mov ecx, ebx
lea eax, [ebp - 0x2c]
push eax
call fcn.0040cfd0
add esp, 4
mov dword [ebp - 4], 0
mov eax, dword [ebp - 0x2c]
cmp dword [ebp - 0x18], esi
jae 0x404255
lea eax, [ebp - 0x2c]
push eax
call fcn.0040d0b0
add esp, 4
cmp dword [ebx + 0x14], esi
jb 0x404267
mov eax, dword [ebx]
jmp 0x404269
mov eax, ebx
push 0
push 0x80
push 2
push 0
push 1
push 0x40000000
push eax
call dword [sym.imp.KERNEL32.dll_CreateFileW]
mov dword [ebp - 0x44], eax
cmp eax, 0xffffffff
jne 0x4042d1
push edi
call dword [sym.imp.KERNEL32.dll_CloseHandle]
call dword [sym.imp.KERNEL32.dll_GetLastError]
cmp eax, 0x20
jne 0x4042ae
lea ecx, [ebp - 0x2c]
call fcn.00401470
mov eax, 1
jmp 0x4041de
cmp dword [ebx + 0x14], esi
jb 0x4042b5
mov ebx, dword [ebx]
push eax
push ebx
push str.SaveFileBufferAsFile_____CreateFile_lpDstFilePath:___s___failed__error_code:__lu.
call fcn.004166a0
add esp, 0xc
lea ecx, [ebp - 0x2c]
call fcn.00401470
jmp 0x4041dc
mov eax, dword [ebp + 0xc]
mov esi, 0x100000
cmp eax, esi
jae 0x4042df
mov esi, eax
push esi
call fcn.00417cfb
add esp, 4
cmp dword [ebp + 0xc], 0
mov ebx, eax
mov dword [ebp - 0x38], 1
mov dword [ebp - 0x40], 0
jbe 0x40439d
mov eax, dword [ebp + 0xc]
sub eax, dword [ebp - 0x40]
cmp esi, eax
jbe 0x40430e
mov esi, eax
push 0
lea ecx, [ebp - 0x34]
push ecx
push esi
push ebx
push edi
mov dword [ebp - 0x34], 0
call dword [sym.imp.KERNEL32.dll_ReadFile]
mov edi, eax
test edi, edi
je 0x404379
cmp dword [ebp - 0x34], esi
jne 0x404379
mov eax, dword [ebp - 0x44]
push 0
lea edx, [ebp - 0x3c]
push edx
push esi
push ebx
push eax
mov dword [ebp - 0x3c], 0
call dword [sym.imp.KERNEL32.dll_WriteFile]
mov edi, eax
test edi, edi
je 0x404365
cmp dword [ebp - 0x3c], esi
jne 0x404365
mov eax, dword [ebp - 0x40]
mov edi, dword [ebp - 0x30]
add eax, esi
mov dword [ebp - 0x40], eax
cmp eax, dword [ebp + 0xc]
jb 0x404302
jmp 0x40439d
call dword [sym.imp.KERNEL32.dll_GetLastError]
mov ecx, dword [ebp - 0x3c]
push eax
push ecx
push esi
push edi
push str.SaveFileBufferAsFile_____WriteFile___failed__bWriteResult:__d__dwBufferSize:__lu__dwBytesWritten:__lu__error_code:__lu.
jmp 0x40438b
call dword [sym.imp.KERNEL32.dll_GetLastError]
mov edx, dword [ebp - 0x34]
push eax
push edx
push esi
push edi
push str.SaveFileBufferAsFile_____ReadFile___failed__bReadResult:__d__dwBufferSize:__lu__dwBytesRead:__lu__error_code:__lu.
call fcn.004166a0
mov edi, dword [ebp - 0x30]
mov dword [ebp - 0x38], 0
add esp, 0x14
mov esi, dword [sym.imp.KERNEL32.dll_CloseHandle]
push edi
call esi
mov eax, dword [ebp - 0x44]
push eax
call esi
lea ecx, [ebp - 0x2c]
call fcn.00401470
mov eax, dword [ebp - 0x38]
jmp 0x4041de