Function at 0x408585
Capabilities:
Check if file exists
Get common file path
Get file attributes

Disassembly:
push 0x44
mov eax, 0x43d74a
call fcn.0043c0ef
mov dword [ebp - 0x50], edx
mov ebx, ecx
mov dword [ebp - 0x44], ebx
xor eax, eax
mov dword [ebp - 0x44], ebx
mov dword [ebp - 0x4c], eax
mov dword [ebp - 4], eax
lea ecx, [ebp - 0x28]
mov edi, pe_nt_image_headers32
mov dword [ebp - 0x28], eax
push edi
mov dword [ebp - 0x18], eax
mov dword [ebp - 0x14], 7
mov word [ebp - 0x28], ax
call fcn.0040bbfa
mov esi, eax
lea eax, [esi + 1]
push eax
call fcn.0040af80
mov edx, eax
mov dword [ebp - 0x18], edi
lea ecx, [edi - 0x80]
mov dword [ebp - 0x14], esi
xor eax, eax
mov edi, edx
rep stosd dword es:[edi], eax
push 8
mov word [edx + 0x200], ax
lea eax, [ebp - 0x28]
pop edi
mov dword [ebp - 0x28], edx
mov dword [ebp - 0x4c], edi
cmp dword [ebp - 0x14], edi
jb 0x4085f9
mov eax, edx
push eax
push dword [ebp - 0x18]
call dword [sym.imp.KERNEL32.dll_GetCurrentDirectoryW]
cmp eax, dword [ebp - 0x18]
jb 0x40862b
jne 0x40860c
add eax, eax
push ecx
push eax
lea ecx, [ebp - 0x28]
call fcn.004097b0
lea eax, [ebp - 0x28]
cmp dword [ebp - 0x14], edi
jb 0x408621
mov eax, dword [ebp - 0x28]
push eax
push dword [ebp - 0x18]
call dword [sym.imp.KERNEL32.dll_GetCurrentDirectoryW]
push ecx
push eax
lea ecx, [ebp - 0x28]
call fcn.004097b0
xor eax, eax
lea ecx, [ebp - 0x40]
inc eax
mov dword [ebp - 4], eax
mov edx, dword [sym.imp.KERNEL32.dll_GetSystemDirectoryW]
mov dword [ebp - 0x44], eax
call fcn.0040b409
lea ecx, [ebp - 0x40]
mov dword [ebp - 0x48], 0x14
cmp dword [ebp - 0x2c], edi
jb 0x40865e
mov ecx, dword [ebp - 0x40]
lea eax, [ebp - 0x28]
cmp dword [ebp - 0x14], edi
jb 0x408669
mov eax, dword [ebp - 0x28]
push ecx
push eax
call fcn.0042642a
pop ecx
pop ecx
lea ecx, [ebp - 0x40]
mov esi, eax
call fcn.00404757
test esi, esi
je 0x40876d
call fcn.004083b8
test al, al
je 0x4086c5
mov edx, dword [sym.imp.KERNEL32.dll_GetSystemWow64DirectoryW]
lea ecx, [ebp - 0x40]
call fcn.0040b409
lea ecx, [ebp - 0x40]
mov dword [ebp - 0x48], 0x36
cmp dword [ebp - 0x2c], edi
jb 0x4086ad
mov ecx, dword [ebp - 0x40]
lea eax, [ebp - 0x28]
cmp dword [ebp - 0x14], edi
jb 0x4086b8
mov eax, dword [ebp - 0x28]
push ecx
push eax
call fcn.0042642a
pop ecx
pop ecx
test eax, eax
je 0x4086c9
mov byte [ebp - 0x44], 0
test byte [ebp - 0x48], 2
je 0x4086d7
lea ecx, [ebp - 0x40]
call fcn.00404757
cmp byte [ebp - 0x44], 0
jne 0x40876d
mov ecx, dword [ebp - 0x18]
cmp ecx, dword [ebp - 0x14]
jae 0x40870a
lea eax, [ecx + 1]
mov dword [ebp - 0x18], eax
lea eax, [ebp - 0x28]
cmp dword [ebp - 0x14], edi
jb 0x4086fa
mov eax, dword [ebp - 0x28]
push 0x5c
pop edx
mov word [eax + ecx*2], dx
xor edx, edx
mov word [eax + ecx*2 + 2], dx
jmp 0x40871c
push 0x5c
mov byte [ebp - 0x44], 0
push dword [ebp - 0x44]
push ecx
lea ecx, [ebp - 0x28]
call fcn.0040b6b9
mov eax, dword [ebp - 0x50]
mov ecx, dword [eax + 0x10]
cmp dword [eax + 0x14], edi
jb 0x408729
mov eax, dword [eax]
push ecx
push eax
lea ecx, [ebp - 0x28]
call fcn.0040af21
lea eax, [ebp - 0x28]
cmp dword [ebp - 0x14], edi
jb 0x40873e
mov eax, dword [ebp - 0x28]
push eax
call dword [sym.imp.KERNEL32.dll_GetFileAttributesW]
cmp eax, 0xffffffff
je 0x40876d
test al, 0x10
jne 0x40876d
lea ecx, [ebp - 0x28]
call fcn.004081b9
lea eax, [ebp - 0x28]
mov ecx, ebx
push eax
call fcn.0040435b
cmp dword [ebp - 0x14], edi
jb 0x408796
push dword [ebp - 0x28]
push 0
jmp 0x408789
xor ecx, ecx
xor eax, eax
mov dword [ebx], ecx
mov dword [ebx + 0x10], ecx
mov dword [ebx + 0x14], 7
mov word [ebx], ax
cmp dword [ebp - 0x14], edi
jb 0x408796
push dword [ebp - 0x28]
push ecx
call dword [sym.imp.KERNEL32.dll_GetProcessHeap]
push eax
call dword [sym.imp.KERNEL32.dll_HeapFree]
mov eax, ebx
call fcn.0043c09e
ret