Function at 0x404040
Capabilities:
Check if file exists
Get common file path
Get file attributes
Read file on windows
Write file on windows

Disassembly:
sub esp, 0x398
push ebx
push ebp
mov ebp, dword [esp + 0x3a4]
xor ebx, ebx
push esi
cmp ebp, ebx
push edi
je 0x40431c
mov ecx, 8
xor eax, eax
lea edi, [esp + 0x2c]
mov dword [esp + 0x28], ebx
rep stosd dword es:[edi], eax
mov ecx, 0x40
lea edi, [esp + 0x9d]
mov byte [esp + 0x9c], bl
mov byte [esp + 0x1a0], bl
rep stosd dword es:[edi], eax
stosw word es:[edi], ax
stosb byte es:[edi], al
mov ecx, 0x40
xor eax, eax
lea edi, [esp + 0x1a1]
mov dword [esp + 0x10], 0xffffffff
rep stosd dword es:[edi], eax
stosw word es:[edi], ax
stosb byte es:[edi], al
lea eax, [esp + 0x9c]
push eax
push 0x104
call dword [sym.imp.KERNEL32.dll_GetTempPathA]
mov edi, str.kz.21ec2020_3aea_1069_a2dd_08002b30309d_batexp.ini
or ecx, 0xffffffff
xor eax, eax
lea edx, [esp + 0x9c]
repne scasb al, byte es:[edi]
not ecx
sub edi, ecx
push ebp
mov esi, edi
mov edi, edx
mov edx, ecx
or ecx, 0xffffffff
repne scasb al, byte es:[edi]
mov ecx, edx
dec edi
shr ecx, 2
rep movsd dword es:[edi], dword [esi]
mov ecx, edx
and ecx, 3
rep movsb byte es:[edi], byte [esi]
call dword [sym.imp.KERNEL32.dll_GetFileAttributesA]
mov ebp, eax
cmp ebp, 0xffffffff
jne 0x4040fd
mov ebp, 0x80
mov eax, dword [esp + 0x3ac]
push ebx
push ebp
push 3
push ebx
push 1
push 0x80000000
push eax
call dword [sym.imp.KERNEL32.dll_CreateFileA]
mov esi, eax
cmp esi, 0xffffffff
je 0x40431c
xor ecx, ecx
xor eax, eax
mov dword [esp + 0x1c], ecx
lea edi, [esp + 0x54]
mov dword [esp + 0x20], ecx
mov dword [esp + 0x4c], ebx
mov dword [esp + 0x24], ecx
mov ecx, 0x12
mov dword [esp + 0x50], ebx
lea edx, [esp + 0x14]
rep stosd dword es:[edi], eax
mov edi, dword [sym.imp.KERNEL32.dll_ReadFile]
push ebx
push edx
lea eax, [esp + 0x20]
push 0x10
push eax
push esi
mov dword [esp + 0x28], ebx
mov dword [esp + 0x2c], ebx
call edi
lea ecx, [esp + 0x14]
push ebx
push ecx
lea edx, [esp + 0x54]
push 0x50
push edx
push esi
call edi
push esi
call dword [sym.imp.KERNEL32.dll_CloseHandle]
cmp dword [esp + 0x18], 0x93f8dcac
jne 0x40431c
cmp dword [esp + 0x1c], 0xbcfec3dc
jne 0x40431c
mov eax, dword [esp + 0x90]
lea ecx, [esp + 0x1a0]
push eax
push 0x409188
push ecx
call dword [sym.imp.MSVCRT.dll_sprintf]
lea edx, [esp + 0x34]
lea eax, [esp + 0xa8]
push edx
push eax
call fcn.00404ed0
add esp, 0x14
test eax, eax
je 0x40431c
mov ecx, 0x40
xor eax, eax
lea edi, [esp + 0x2a5]
mov byte [esp + 0x2a4], bl
rep stosd dword es:[edi], eax
stosw word es:[edi], ax
lea ecx, [esp + 0x28]
push ecx
push str.File_Open_Count
stosb byte es:[edi], al
call fcn.00405220
mov edi, eax
add esp, 8
cmp edi, ebx
je 0x40429b
lea edx, [esp + 0x2a4]
push 0x104
push edx
push edi
call fcn.004052c0
add esp, 0xc
test eax, eax
je 0x404292
lea esi, [esp + 0x1a0]
lea eax, [esp + 0x2a4]
mov dl, byte [eax]
mov cl, dl
cmp dl, byte [esi]
jne 0x404250
cmp cl, bl
je 0x40424c
mov dl, byte [eax + 1]
mov cl, dl
cmp dl, byte [esi + 1]
jne 0x404250
add eax, 2
add esi, 2
cmp cl, bl
jne 0x40422c
xor eax, eax
jmp 0x404255
sbb eax, eax
sbb eax, 0xffffffff
cmp eax, ebx
jne 0x404278
lea eax, [esp + 0x28]
lea ecx, [esp + 0x1a0]
push eax
push ebx
push ecx
push str.File_Open_Count
call fcn.00404b30
add esp, 0x10
mov dword [esp + 0x10], eax
lea edx, [esp + 0x2a4]
push 0x104
push edx
push edi
call fcn.004052c0
add esp, 0xc
test eax, eax
jne 0x40421e
push edi
call fcn.00405350
add esp, 4
lea eax, [esp + 0x28]
push eax
call fcn.004051f0
mov edi, dword [esp + 0x14]
mov eax, dword [esp + 0x64]
add esp, 4
cmp eax, edi
jbe 0x40430a
mov ecx, dword [esp + 0x3ac]
push ebx
push ebp
push 3
push ebx
push 1
push 0x40000000
push ecx
call dword [sym.imp.KERNEL32.dll_CreateFileA]
mov esi, eax
cmp esi, 0xffffffff
je 0x40431c
lea edx, [esp + 0x10]
push ebx
push edx
lea eax, [esp + 0x20]
push 0x10
mov dword [esp + 0x6c], edi
mov edi, dword [sym.imp.KERNEL32.dll_WriteFile]
push eax
push esi
mov dword [esp + 0x24], ebx
call edi
lea ecx, [esp + 0x10]
push ebx
push ecx
lea edx, [esp + 0x54]
push 0x50
push edx
push esi
call edi
push esi
call dword [sym.imp.KERNEL32.dll_CloseHandle]
pop edi
pop esi
pop ebp
mov eax, 1
pop ebx
add esp, 0x398
ret 4
pop edi
pop esi
pop ebp
xor eax, eax
pop ebx
add esp, 0x398
ret 4