Function at 0x402120
Capabilities:
Get common file path
Read file on windows
Set current directory
Write file on windows

Disassembly:
push ebp
mov ebp, esp
and esp, 0xfffffff8
mov eax, 0x411c
call fcn.00408640
mov eax, dword [0x412158]
push ebx
mov dword [esp + 0x411c], eax
push esi
push edi
mov byte [esp + 0x120], 0
xor eax, eax
mov ecx, 0xfff
lea edi, [esp + 0x121]
rep stosd dword es:[edi], eax
stosw word es:[edi], ax
mov dword [esp + 0x10], 0xc350
stosb byte es:[edi], al
call fcn.004015f0
call fcn.00401f20
test eax, eax
jne 0x40217a
push 0xe306
call fcn.00402080
push 0x412ff8
push 0x104
call dword [sym.imp.KERNEL32.dll_GetCurrentDirectoryA]
push 0x412ce0
call dword [sym.imp.KERNEL32.dll_SetCurrentDirectoryA]
push 0x104
lea eax, [esp + 0x1c]
push eax
push 0
call dword [sym.imp.KERNEL32.dll_GetModuleFileNameA]
push 0
push 0
push 3
push 0
push 1
push 0x80000000
lea ecx, [esp + 0x30]
push ecx
call dword [sym.imp.KERNEL32.dll_CreateFileA]
mov esi, eax
cmp esi, 0xffffffff
jne 0x4021d2
push 0xe302
call fcn.00402080
mov edi, dword [sym.imp.KERNEL32.dll_SetFilePointer]
push 0
push 0
push 0xc350
push esi
call edi
push 0
lea edx, [esp + 0x10]
push edx
push 0x4000
lea eax, [esp + 0x12c]
push eax
push esi
call dword [sym.imp.KERNEL32.dll_ReadFile]
test eax, eax
je 0x402274
mov ebx, dword [esp + 0xc]
cmp ebx, 0xe
jb 0x40237d
lea ecx, [esp + 0x120]
push ebx
push ecx
call fcn.00401570
add esp, 8
test eax, eax
push 1
push 0
jge 0x402285
push 0xfffffffffffffff2
push esi
call edi
mov eax, dword [esp + 0xc]
cmp eax, 0x4000
mov edx, dword [esp + 0x10]
lea ecx, [edx + eax - 0xe]
mov dword [esp + 0x10], ecx
jb 0x40237d
cmp ecx, 0x30d40
ja 0x40237d
push 0
lea eax, [esp + 0x10]
push eax
push 0x4000
lea ecx, [esp + 0x12c]
push ecx
push esi
call dword [sym.imp.KERNEL32.dll_ReadFile]
test eax, eax
jne 0x402203
push esi
call dword [sym.imp.KERNEL32.dll_CloseHandle]
push 0xe302
call fcn.00402080
sub eax, ebx
push eax
push esi
call edi
push 1
push 0
push 0xe
push esi
call edi
push 0
lea edx, [esp + 0x10]
push edx
push 0x104
push 0x412ef0
push esi
call dword [sym.imp.KERNEL32.dll_ReadFile]
mov ecx, dword [esp + 0xc]
push 1
push 0
mov eax, 0x3f2
sub eax, ecx
push eax
push esi
call edi
push 0x412de8
push 0
push 0x40f328
push 0x412ce0
call dword [sym.imp.KERNEL32.dll_GetTempFileNameA]
push 0
push 0
push 2
push 0
push 3
push 0x40000000
push 0x412de8
call dword [sym.imp.KERNEL32.dll_CreateFileA]
mov edi, eax
cmp edi, 0xffffffff
jne 0x402308
push esi
call dword [sym.imp.KERNEL32.dll_CloseHandle]
push 0xe304
call fcn.00402080
push 4
push 0x1000
push 0xffff
push 0
call dword [sym.imp.KERNEL32.dll_VirtualAlloc]
mov ebx, eax
mov edi, edi
push 0
lea ecx, [esp + 0x10]
push ecx
push 0xffff
push ebx
push esi
call dword [sym.imp.KERNEL32.dll_ReadFile]
mov eax, dword [esp + 0xc]
push 0
lea edx, [esp + 0x18]
push edx
push eax
push ebx
push edi
call dword [sym.imp.KERNEL32.dll_WriteFile]
mov eax, dword [esp + 0xc]
test eax, eax
jne 0x402320
push esi
mov esi, dword [sym.imp.KERNEL32.dll_CloseHandle]
call esi
push edi
call esi
push 0x8000
push 0
push ebx
call dword [sym.imp.KERNEL32.dll_VirtualFree]
mov ecx, dword [esp + 0x4124]
call fcn.004076bf
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret
push esi
call dword [sym.imp.KERNEL32.dll_CloseHandle]
push 0xe303
call fcn.00402080
int3