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

Disassembly:
push ebp
mov ebp, esp
sub esp, 0x14
push ebx
push edi
push 0
mov ebx, eax
mov edi, ecx
call dword [sym.imp.KERNEL32.dll_SetLastError]
test edi, edi
je 0x40d400
cmp dword [ebp + 8], 0
je 0x40d400
push esi
push 0
push 0
push 3
push 0
push 1
push SysReAllocString
push edi
call dword [sym.imp.KERNEL32.dll_CreateFileW]
mov esi, eax
mov dword [ebp - 0x14], esi
cmp esi, 0xffffffff
jne 0x40d2a5
call dword [sym.imp.KERNEL32.dll_GetLastError]
push eax
push edi
push str.SaveFileBufferToFile_____1_CreateFile_lpSrcFilePath:___s___failed__error_code:__lu.
call fcn.004166a0
add esp, 0xc
pop esi
pop edi
xor eax, eax
pop ebx
mov esp, ebp
pop ebp
ret
push 0
push esi
call dword [sym.imp.KERNEL32.dll_GetFileSize]
cmp eax, 0xffffffff
jne 0x40d2d8
call dword [sym.imp.KERNEL32.dll_GetLastError]
push eax
push edi
push str.SaveFileBufferToFile____2__GetFileSize_lpSrcFilePath:___s___failed__error_code:__lu.
call fcn.004166a0
add esp, 0xc
push esi
call dword [sym.imp.KERNEL32.dll_CloseHandle]
pop esi
pop edi
xor eax, eax
pop ebx
mov esp, ebp
pop ebp
ret
mov edi, dword [ebp + 0xc]
lea ecx, [ebx + edi]
cmp eax, ecx
jae 0x40d302
push edi
push ebx
push eax
push str.SaveFileBufferToFile_____Invalid_file_size__dwSrcFileSize:__lu__dwSrcFileOffset:__lu__dwDstFileSize:__lu.
call fcn.004166a0
add esp, 0x10
push esi
call dword [sym.imp.KERNEL32.dll_CloseHandle]
pop esi
pop edi
xor eax, eax
pop ebx
mov esp, ebp
pop ebp
ret
push 0
push 0
push ebx
push esi
call dword [sym.imp.KERNEL32.dll_SetFilePointer]
mov esi, 0x100000
cmp edi, esi
jae 0x40d319
mov esi, edi
push esi
call fcn.00417cfb
add esp, 4
mov ebx, eax
mov dword [ebp - 0x10], 1
mov dword [ebp - 4], 0
test edi, edi
je 0x40d3ec
jmp 0x40d343
mov edi, dword [ebp + 0xc]
mov eax, edi
sub eax, dword [ebp - 4]
cmp esi, eax
jbe 0x40d34e
mov esi, eax
mov eax, dword [ebp - 0x14]
push 0
lea edx, [ebp - 0xc]
push edx
push esi
push ebx
push eax
mov dword [ebp - 0xc], 0
call dword [sym.imp.KERNEL32.dll_ReadFile]
mov edi, eax
test edi, edi
je 0x40d3cb
cmp dword [ebp - 0xc], esi
jne 0x40d3cb
mov edx, dword [ebp + 8]
push 0
lea ecx, [ebp - 8]
push ecx
push esi
push ebx
push edx
mov dword [ebp - 8], 0
call dword [sym.imp.KERNEL32.dll_WriteFile]
mov edi, eax
test edi, edi
je 0x40d3b7
cmp dword [ebp - 8], esi
jne 0x40d3b7
mov eax, dword [ebp - 4]
add eax, esi
mov dword [ebp - 4], eax
cmp eax, dword [ebp + 0xc]
jb 0x40d340
mov edx, dword [ebp - 0x14]
push edx
call dword [sym.imp.KERNEL32.dll_CloseHandle]
mov eax, dword [ebp - 0x10]
pop esi
pop edi
pop ebx
mov esp, ebp
pop ebp
ret
call dword [sym.imp.KERNEL32.dll_GetLastError]
push eax
mov eax, dword [ebp - 8]
push eax
push esi
push edi
push str.SaveFileBufferToFile_____WriteFile___failed__bWriteResult:__d__dwBufferSize:__lu__dwBytesWritten:__lu__error_code:__lu.
jmp 0x40d3dd
call dword [sym.imp.KERNEL32.dll_GetLastError]
mov ecx, dword [ebp - 0xc]
push eax
push ecx
push esi
push edi
push str.SaveFileBufferToFile_____ReadFile___failed__bReadResult:__d__dwBufferSize:__lu__dwBytesRead:__lu__error_code:__lu.
call fcn.004166a0
mov dword [ebp - 0x10], 0
add esp, 0x14
mov edx, dword [ebp - 0x14]
push edx
call dword [sym.imp.KERNEL32.dll_CloseHandle]
mov eax, dword [ebp - 0x10]
pop esi
pop edi
pop ebx
mov esp, ebp
pop ebp
ret
pop edi
xor eax, eax
pop ebx
mov esp, ebp
pop ebp
ret