Function at 0x40d730
Capabilities:
Check if file exists
Get file size
Read file on windows
Write file on windows

Disassembly:
sub esp, 0x28
push ebx
push edi
push 0x4daa30
xor ebx, ebx
push 2
mov edi, ecx
mov dword [esp + 0x14], 0xffffffff
mov dword [esp + 0x10], ebx
call fcn.00483f74
add esp, 8
mov dword [esp + 0x10], eax
cmp eax, ebx
je 0x40dada
mov eax, dword [edi + 0x20]
push ebp
mov ebp, dword [sym.imp.KERNEL32.dll_CreateFileW]
push esi
push ebx
push 0x20
push 3
push ebx
push 1
push SysReAllocString
push eax
call ebp
mov esi, eax
cmp esi, 0xffffffff
je 0x40da9e
mov ecx, dword [esp + 0x18]
push 0
lea eax, [esp + 0x24]
push eax
push 2
push ecx
push esi
mov ebx, 1
mov dword [esp + 0x28], 0
call dword [sym.imp.KERNEL32.dll_ReadFile]
test eax, eax
je 0x40d7ca
cmp dword [esp + 0x20], 2
jne 0x40d7ca
mov ax, word [0x4d42e0]
mov ecx, dword [esp + 0x18]
cmp byte [ecx], al
jne 0x40d7c6
cmp byte [ecx + 1], ah
je 0x40d7d4
xor ebx, ebx
jmp 0x40d7d4
call dword [sym.imp.KERNEL32.dll_GetLastError]
mov dword [esp + 0x10], eax
push esi
call dword [sym.imp.KERNEL32.dll_CloseHandle]
test ebx, ebx
jne 0x40dab6
mov eax, dword [edi + 0x20]
push ebx
push 0x20
push 3
push ebx
push 1
push 0xc0000000
push eax
mov dword [esp + 0x30], 0xffffffff
call ebp
mov esi, eax
cmp esi, 0xffffffff
je 0x40da70
lea edx, [esp + 0x30]
push edx
push esi
call dword [sym.imp.KERNEL32.dll_GetFileSizeEx]
test eax, eax
je 0x40da3b
cmp dword [esp + 0x34], 1
jg 0x40da3b
mov edi, dword [esp + 0x30]
jl 0x40d836
test edi, edi
jae 0x40da3b
lea eax, [edi + 1]
push 0x4daa30
push eax
call fcn.00483f74
mov ebx, eax
add esp, 8
test ebx, ebx
je 0x40da08
push 0
lea ecx, [esp + 0x28]
push ecx
push edi
push ebx
push esi
call dword [sym.imp.KERNEL32.dll_ReadFile]
test eax, eax
je 0x40d9ca
cmp dword [esp + 0x24], edi
jne 0x40d9ca
push ebx
lea ecx, [esp + 0x20]
mov byte [ebx + edi], 0
call fcn.0040d650
push 0
push 0
push 0
push esi
call dword [sym.imp.KERNEL32.dll_SetFilePointer]
mov edi, dword [sym.imp.KERNEL32.dll_GetLastError]
cmp eax, 0xffffffff
jne 0x40d8a3
call edi
test eax, eax
jne 0x40d987
push esi
call dword [sym.imp.KERNEL32.dll_SetEndOfFile]
test eax, eax
je 0x40d987
mov ebp, dword [sym.imp.KERNEL32.dll_WriteFile]
push 0
lea edx, [esp + 0x2c]
push edx
push 2
push 0x4d42e0
push esi
mov dword [esp + 0x28], 1
call ebp
test eax, eax
je 0x40d940
cmp dword [esp + 0x28], 2
jne 0x40d940
mov eax, dword [esp + 0x1c]
mov edi, dword [eax - 0xc]
push 0
lea ecx, [esp + 0x30]
push ecx
add edi, edi
push edi
push eax
push esi
call ebp
test eax, eax
je 0x40d940
cmp edi, dword [esp + 0x2c]
jne 0x40d940
lea ecx, [esp + 0x1c]
mov dword [esp + 0x14], 1
call fcn.0041f860
push ebx
call fcn.0046082f
add esp, 4
push esi
call dword [sym.imp.KERNEL32.dll_CloseHandle]
mov edx, dword [esp + 0x18]
push edx
call fcn.0046082f
mov eax, dword [esp + 0x14]
add esp, 4
pop esi
pop ebp
push eax
call dword [sym.imp.KERNEL32.dll_SetLastError]
mov eax, dword [esp + 0xc]
pop edi
pop ebx
add esp, 0x28
ret
call dword [sym.imp.KERNEL32.dll_GetLastError]
lea ecx, [esp + 0x1c]
mov dword [esp + 0x10], eax
call fcn.0041f860
push ebx
call fcn.0046082f
add esp, 4
push esi
call dword [sym.imp.KERNEL32.dll_CloseHandle]
mov edx, dword [esp + 0x18]
push edx
call fcn.0046082f
mov eax, dword [esp + 0x14]
add esp, 4
pop esi
pop ebp
push eax
call dword [sym.imp.KERNEL32.dll_SetLastError]
mov eax, dword [esp + 0xc]
pop edi
pop ebx
add esp, 0x28
ret
call edi
lea ecx, [esp + 0x1c]
mov dword [esp + 0x10], eax
call fcn.0041f860
push ebx
call fcn.0046082f
add esp, 4
push esi
call dword [sym.imp.KERNEL32.dll_CloseHandle]
mov edx, dword [esp + 0x18]
push edx
call fcn.0046082f
mov eax, dword [esp + 0x14]
add esp, 4
pop esi
pop ebp
push eax
call dword [sym.imp.KERNEL32.dll_SetLastError]
mov eax, dword [esp + 0xc]
pop edi
pop ebx
add esp, 0x28
ret
call dword [sym.imp.KERNEL32.dll_GetLastError]
push ebx
mov dword [esp + 0x14], eax
call fcn.0046082f
add esp, 4
push esi
call dword [sym.imp.KERNEL32.dll_CloseHandle]
mov edx, dword [esp + 0x18]
push edx
call fcn.0046082f
mov eax, dword [esp + 0x14]
add esp, 4
pop esi
pop ebp
push eax
call dword [sym.imp.KERNEL32.dll_SetLastError]
mov eax, dword [esp + 0xc]
pop edi
pop ebx
add esp, 0x28
ret
push esi
mov dword [esp + 0x14], 8
call dword [sym.imp.KERNEL32.dll_CloseHandle]
mov edx, dword [esp + 0x18]
push edx
call fcn.0046082f
mov eax, dword [esp + 0x14]
add esp, 4
pop esi
pop ebp
push eax
call dword [sym.imp.KERNEL32.dll_SetLastError]
mov eax, dword [esp + 0xc]
pop edi
pop ebx
add esp, 0x28
ret
call dword [sym.imp.KERNEL32.dll_GetLastError]
push esi
mov dword [esp + 0x14], eax
call dword [sym.imp.KERNEL32.dll_CloseHandle]
mov edx, dword [esp + 0x18]
push edx
call fcn.0046082f
mov eax, dword [esp + 0x14]
add esp, 4
pop esi
pop ebp
push eax
call dword [sym.imp.KERNEL32.dll_SetLastError]
mov eax, dword [esp + 0xc]
pop edi
pop ebx
add esp, 0x28
ret
call dword [sym.imp.KERNEL32.dll_GetLastError]
mov edx, dword [esp + 0x18]
push edx
mov dword [esp + 0x14], eax
call fcn.0046082f
mov eax, dword [esp + 0x14]
add esp, 4
pop esi
pop ebp
push eax
call dword [sym.imp.KERNEL32.dll_SetLastError]
mov eax, dword [esp + 0xc]
pop edi
pop ebx
add esp, 0x28
ret
call dword [sym.imp.KERNEL32.dll_GetLastError]
mov dword [esp + 0x10], eax
cmp eax, 2
je 0x40dab2
cmp eax, 3
jne 0x40dab6
mov dword [esp + 0x14], ebx
mov edx, dword [esp + 0x18]
push edx
call fcn.0046082f
mov eax, dword [esp + 0x14]
add esp, 4
pop esi
pop ebp
push eax
call dword [sym.imp.KERNEL32.dll_SetLastError]
mov eax, dword [esp + 0xc]
pop edi
pop ebx
add esp, 0x28
ret
mov dword [esp + 8], 8
mov eax, dword [esp + 8]
push eax
call dword [sym.imp.KERNEL32.dll_SetLastError]
mov eax, dword [esp + 0xc]
pop edi
pop ebx
add esp, 0x28
ret