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

Disassembly:
push ebp
mov ebp, esp
and esp, 0xfffffff8
mov eax, 0x131c
call fcn.00414fb0
mov eax, dword [0x4251a4]
push ebx
xor eax, ebp
push esi
push edi
mov edi, dword [ebp + 0x14]
test edi, edi
mov dword [esp + 0x1324], eax
mov eax, dword [ebp + 0xc]
mov esi, ecx
mov dword [esp + 0x14], eax
je 0x40509f
cmp dword [0x425040], 0xffffffff
jne 0x40509f
push edi
call fcn.004020c0
test eax, eax
je 0x40509f
push 0
push 0
push 4
push 0
push 3
push 0x40000000
push edi
call dword [sym.imp.KERNEL32.dll_CreateFileW]
mov dword [0x425040], eax
cmp dword [esi + 0xe8], 0xffffffff
jne 0x4051f8
lea ebx, [esi + 0xf8]
push ebx
call dword [sym.imp.KERNEL32.dll_GetFileAttributesA]
cmp eax, 0xffffffff
je 0x4050c2
test al, 0x10
jne 0x40510c
push ebx
mov ecx, esi
call fcn.00401fe0
test eax, eax
jne 0x40510c
push ebx
push 0x104
call dword [sym.imp.KERNEL32.dll_GetTempPathA]
test eax, eax
je 0x40545e
push str.TSLOG
push ebx
push str._s_S_
push 0x104
push ebx
call dword [sym.imp.MSVCR71.dll__snprintf]
add esp, 0x14
push ebx
mov ecx, esi
call fcn.00401fe0
test eax, eax
je 0x40545e
xor eax, eax
mov word [esp + 0x18], 0
mov ecx, 0x81
lea edi, [esp + 0x1a]
rep stosd dword es:[edi], eax
stosw word es:[edi], ax
mov eax, dword [esi + 0xec]
push 0
lea ecx, [esp + 0x1c]
inc eax
push ecx
push eax
mov ecx, esi
mov dword [esi + 0xec], eax
call fcn.00404120
mov edx, dword [esi + 0x23c]
push 0
push 0
push 2
push 0
inc edx
push 3
mov dword [esi + 0x23c], edx
push 0x40000000
lea edx, [esp + 0x30]
push edx
call dword [sym.imp.KERNEL32.dll_CreateFileW]
cmp eax, 0xffffffff
mov dword [esi + 0xe8], eax
jne 0x4051f8
call dword [sym.imp.KERNEL32.dll_GetLastError]
cmp eax, 0x70
je 0x4052f5
cmp eax, 5
jne 0x40545e
push ebx
push 0x104
call dword [sym.imp.KERNEL32.dll_GetTempPathA]
test eax, eax
je 0x40545e
push str.TSLOG
push ebx
push str._sTSLOG_S_
push 0x104
push ebx
call dword [sym.imp.MSVCR71.dll__snprintf]
mov ecx, dword [esi + 0xec]
add esp, 0x14
push 0
lea eax, [esp + 0x1c]
push eax
push ecx
mov ecx, esi
call fcn.00404120
push 0
push 0
push 2
push 0
push 3
push 0x40000000
lea edx, [esp + 0x30]
push edx
call dword [sym.imp.KERNEL32.dll_CreateFileW]
cmp eax, 0xffffffff
mov dword [esi + 0xe8], eax
je 0x40545e
mov ebx, dword [sym.imp.KERNEL32.dll_WideCharToMultiByte]
mov byte [esp + 0x220], 0
xor eax, eax
push 0
mov ecx, 0x43f
lea edi, [esp + 0x225]
rep stosd dword es:[edi], eax
push 0
push 0
stosw word es:[edi], ax
push 0
push 0xffffffffffffffff
stosb byte es:[edi], al
mov edi, dword [esp + 0x28]
push edi
push 0
push 0x3a8
mov dword [esp + 0x30], 0
call ebx
test eax, eax
jle 0x40545e
cmp eax, 0x10ff
jg 0x40545e
push 0
push 0
push eax
lea eax, [esp + 0x22c]
push eax
push 0xffffffffffffffff
push edi
push 0
push 0x3a8
call ebx
mov edi, eax
test edi, edi
jbe 0x40545e
dec edi
cmp edi, 0x1000
jbe 0x40527d
mov edi, 0x1000
mov eax, dword [0x425040]
cmp eax, 0xffffffff
mov ebx, dword [sym.imp.KERNEL32.dll_WriteFile]
je 0x4052c9
push 2
push 0
push 0
push eax
call dword [sym.imp.KERNEL32.dll_SetFilePointer]
mov eax, dword [0x425040]
push 0
lea ecx, [esp + 0x14]
push ecx
push edi
lea edx, [esp + 0x22c]
push edx
push eax
call ebx
mov ecx, dword [0x425040]
push ecx
call dword [sym.imp.KERNEL32.dll_CloseHandle]
mov dword [0x425040], 0xffffffff
mov ecx, dword [esi + 0xe8]
push 0
lea edx, [esp + 0x14]
push edx
push edi
lea eax, [esp + 0x22c]
push eax
push ecx
call ebx
test eax, eax
jne 0x40532d
call dword [sym.imp.KERNEL32.dll_GetLastError]
cmp eax, 0x70
jne 0x40545e
push str.C:TSLOG_CONFIGTSLOG.ini
push 0x418f6c
push str.FileLog
push str.Output
mov dword [esi + 0x2c], 0
call dword [sym.imp.KERNEL32.dll_WritePrivateProfileStringW]
pop edi
pop esi
pop ebx
mov ecx, dword [esp + 0x1318]
xor ecx, ebp
call fcn.00414f09
mov esp, ebp
pop ebp
ret 0x10
mov eax, dword [esi + 0x23c]
mov ecx, dword [0x4251cc]
cmp ecx, eax
jae 0x40534b
mov ecx, esi
mov dword [0x4251cc], eax
call fcn.00403f80
jmp 0x405352
jbe 0x405352
mov dword [0x4251cc], eax
cmp dword [ebp + 8], 6
je 0x40536a
mov eax, dword [esi + 0xf4]
mov edx, dword [esp + 0x10]
add eax, edx
mov dword [esi + 0xf4], eax
mov eax, dword [esi + 0xdc]
mov ecx, dword [esi + 0xf4]
shl eax, 0xa
cmp ecx, eax
jb 0x40545e
mov ecx, dword [esi + 0xe8]
xor ebx, ebx
push ecx
mov dword [esi + 0xf4], ebx
call dword [sym.imp.KERNEL32.dll_FlushFileBuffers]
mov edx, dword [esi + 0xe8]
push edx
call dword [sym.imp.KERNEL32.dll_CloseHandle]
xor eax, eax
mov ecx, 0x82
lea edi, [esp + 0x18]
rep stosd dword es:[edi], eax
mov eax, dword [esi + 0xec]
mov ecx, dword [esi + 0xe0]
cmp eax, ecx
jl 0x4053dc
push ebx
sub eax, ecx
lea edx, [esp + 0x1c]
push edx
inc eax
push eax
mov ecx, esi
call fcn.00404120
lea eax, [esp + 0x18]
push eax
call dword [sym.imp.KERNEL32.dll_DeleteFileW]
mov edx, dword [esi + 0xec]
xor eax, eax
mov ecx, 0x82
lea edi, [esp + 0x18]
rep stosd dword es:[edi], eax
lea ecx, [esp + 0x18]
push ecx
push ebx
push edx
mov ecx, esi
call fcn.00404120
mov ecx, dword [esi + 0xec]
inc ecx
mov eax, ecx
cmp eax, 0x3e7
mov dword [esi + 0xec], ecx
jl 0x405419
mov dword [esi + 0xec], ebx
mov eax, dword [esi + 0x23c]
push ebx
push ebx
push 2
push ebx
inc eax
push 3
mov dword [esi + 0x23c], eax
push 0x40000000
lea eax, [esp + 0x30]
push eax
call dword [sym.imp.KERNEL32.dll_CreateFileW]
mov ecx, dword [esi + 0x23c]
mov dword [esi + 0xe8], eax
mov dword [0x4251cc], ecx
cmp dword [esi + 0xe8], ebx
je 0x40545e
mov ecx, esi
call fcn.00403f80
mov ecx, dword [esp + 0x1324]
pop edi
pop esi
xor ecx, ebp
pop ebx
call fcn.00414f09
mov esp, ebp
pop ebp
ret 0x10