Function at 0x408782
Capabilities:
Check if file exists
Delete file
Get file attributes
Read file on windows
Write file on windows

Disassembly:
push ebp
mov ebp, esp
sub esp, 0x28c
and dword [ebp - 0x20], 0
push ebx
push esi
mov esi, eax
mov eax, dword [esi + 0x24]
mov ecx, eax
and ecx, 0xf
push edi
push dword [ebp + 0xc]
sub eax, ecx
mov dword [ebp - 0x10], eax
call fcn.00408601
pop ecx
push eax
mov dword [ebp - 0x30], eax
call fcn.004090c6
mov ebx, dword [esi + 0x20]
lea edi, [ebx + 0x20]
pop ecx
lea ecx, [eax + eax + 2]
mov eax, edi
sub eax, ebx
add eax, ecx
mov dword [ebp - 0x34], ecx
mov dword [ebp - 0x2c], edi
test al, 0xf
je 0x4087e3
mov eax, ebx
mov edx, edi
sub edx, eax
add edx, ecx
and edx, 0xf
sub edi, edx
sub edi, eax
lea eax, [edi + ecx + 0x10]
jmp 0x4087e9
mov eax, edi
sub eax, ebx
add eax, ecx
push dword [ebp + 0xc]
mov edi, ebx
mov dword [ebp - 0x24], eax
add edi, eax
call dword [sym.imp.KERNEL32.DLL_GetFileAttributesW]
or dword [ebp - 4], 0xffffffff
mov dword [ebp - 0x1c], eax
mov eax, edi
sub eax, dword [esi + 0x20]
add eax, 0xb2
cmp dword [ebp - 0x10], eax
jb 0x408ae9
push dword [ebp + 0x10]
call dword [sym.imp.KERNEL32.DLL_GetFileAttributesW]
cmp eax, 0xffffffff
jne 0x408ae9
xor eax, eax
push eax
push eax
push 3
push eax
push eax
push 0xc0000000
push dword [ebp + 0xc]
call dword [sym.imp.KERNEL32.DLL_CreateFileW]
mov dword [ebp - 8], eax
cmp eax, 0xffffffff
je 0x408ae9
and dword [ebp - 0x14], 0
and dword [ebp - 0x18], 0
push 2
lea ecx, [ebp - 0x18]
push ecx
push dword [ebp - 0x14]
push dword [ebp - 0x18]
push eax
call dword [sym.imp.KERNEL32.DLL_SetFilePointerEx]
test eax, eax
je 0x408ab9
mov eax, dword [ebp - 0x18]
or eax, dword [ebp - 0x14]
je 0x408ab9
xor eax, eax
push eax
mov dword [ebp - 0x18], eax
mov dword [ebp - 0x14], eax
lea eax, [ebp - 0x18]
push eax
push dword [ebp - 0x14]
push dword [ebp - 0x18]
push dword [ebp - 8]
call dword [sym.imp.KERNEL32.DLL_SetFilePointerEx]
test eax, eax
je 0x408ab9
push 0
push dword [ebp - 0x1c]
push 1
push 0
push 1
push 0x40000000
push dword [ebp + 0x10]
call dword [sym.imp.KERNEL32.DLL_CreateFileW]
mov dword [ebp - 4], eax
cmp eax, 0xffffffff
je 0x408ab9
mov eax, dword [esi]
push dword [ebp + 8]
push eax
lea eax, [ebp - 0x288]
push eax
call fcn.0040669b
add esp, 0xc
test eax, eax
jne 0x408ab9
jmp 0x408957
mov ecx, dword [ebp - 0xc]
cmp ecx, dword [ebp - 0x10]
jae 0x40890d
push 0x10
mov edx, ecx
pop eax
and edx, 0xf
sub eax, edx
push eax
mov dword [ebp - 0x1c], eax
mov eax, dword [esi + 0x20]
add eax, ecx
push 0
push eax
call fcn.00408fa9
mov ecx, dword [ebp - 0xc]
add esp, 0xc
add ecx, dword [ebp - 0x1c]
mov dword [ebp - 0xc], ecx
mov eax, dword [esi + 0x20]
push eax
push eax
lea eax, [ebp - 0x288]
push eax
call fcn.00406432
add esp, 0xc
test eax, eax
je 0x408aa3
push 0
lea eax, [ebp - 0x28]
push eax
push dword [ebp - 0xc]
push dword [esi + 0x20]
push dword [ebp - 4]
call dword [sym.imp.KERNEL32.DLL_WriteFile]
test eax, eax
je 0x408aa3
mov eax, dword [ebp - 0xc]
cmp dword [ebp - 0x28], eax
jne 0x408aa3
cmp eax, dword [ebp - 0x10]
jb 0x408979
push 0
lea eax, [ebp - 0xc]
push eax
push dword [ebp - 0x10]
push dword [esi + 0x20]
push dword [ebp - 8]
call dword [sym.imp.KERNEL32.DLL_ReadFile]
test eax, eax
jne 0x4088de
jmp 0x408aa3
push dword [ebp - 0x34]
and dword [ebx], 0
push dword [ebp - 0x30]
mov dword [ebx + 4], 2
push dword [ebp - 0x2c]
mov dword [ebx + 8], 0xf0a75e12
mov dword [ebx + 0x18], 0x20
call fcn.00408fd7
add esp, 0xc
push 0x14
lea eax, [esi + 4]
push eax
push edi
call fcn.00408fd7
add esp, 0xc
push 0x10
push dword [ebp + 8]
lea eax, [edi + 0x14]
push eax
call fcn.00408fd7
mov eax, dword [esi]
add esp, 0xc
add eax, 0x20
push 0x80
push eax
lea eax, [edi + 0x28]
push eax
call fcn.00408fd7
add esp, 0xc
push 6
lea eax, [esi + 0x18]
push eax
lea eax, [edi + 0xac]
push eax
call fcn.00408fd7
mov eax, dword [ebp - 0x1c]
mov ebx, dword [ebp - 0x24]
mov dword [edi + 0x24], eax
add esp, 0xc
push dword [ebp + 8]
lea eax, [ebx + 0xb2]
mov dword [edi + 0xa8], eax
mov eax, dword [esi]
push eax
lea eax, [ebp - 0x160]
push eax
call fcn.0040669b
add esp, 0xc
test eax, eax
jne 0x408aa3
mov eax, dword [esi + 0x20]
push eax
push eax
lea eax, [ebp - 0x160]
push eax
mov ecx, ebx
call fcn.00406432
add esp, 0xc
test eax, eax
je 0x408aa3
push 0x128
lea eax, [ebp - 0x160]
push 0
push eax
call fcn.00408fa9
add esp, 0xc
push 0
lea eax, [ebp - 0x28]
push eax
push dword [edi + 0xa8]
push dword [esi + 0x20]
push dword [ebp - 4]
call dword [sym.imp.KERNEL32.DLL_WriteFile]
test eax, eax
je 0x408aa3
mov eax, dword [ebp - 0x28]
cmp eax, dword [edi + 0xa8]
jne 0x408aa3
test byte [ebp + 0x14], 4
je 0x408a86
push dword [ebp - 8]
call fcn.004086b7
pop ecx
test byte [ebp + 0x14], 2
je 0x408a9c
push dword [ebp - 8]
mov esi, dword [sym.imp.KERNEL32.DLL_FlushFileBuffers]
call esi
push dword [ebp - 4]
call esi
mov dword [ebp - 0x20], 1
push 0x128
lea eax, [ebp - 0x288]
push 0
push eax
call fcn.00408fa9
add esp, 0xc
push dword [ebp - 8]
mov esi, dword [sym.imp.KERNEL32.DLL_CloseHandle]
call esi
cmp dword [ebp - 4], 0xffffffff
je 0x408acf
push dword [ebp - 4]
call esi
cmp dword [ebp - 0x20], 0
je 0x408ada
push dword [ebp + 0xc]
jmp 0x408ae3
cmp dword [ebp - 4], 0xffffffff
je 0x408ae9
push dword [ebp + 0x10]
call dword [sym.imp.KERNEL32.DLL_DeleteFileW]
mov eax, dword [ebp - 0x20]
pop edi
pop esi
pop ebx
leave
ret