Function at 0x401666
Capabilities:
Check if file exists
Get common file path
Get file attributes
Query environment variable

Disassembly:
push ecx
push ebx
xor ebx, ebx
push esi
push ebx
call dword [sym.imp.KERNEL32.dll_GetModuleHandleA]
mov dword [0x408be8], eax
call fcn.00402ac0
mov byte [0x408c15], al
mov eax, dword [0x408c04]
push 0x7530
push eax
push ebx
call dword [sym.imp.KERNEL32.dll_GetModuleFileNameA]
mov ecx, dword [0x408c04]
lea edx, [esp + 8]
push edx
mov byte [ecx + 0x7530], bl
mov eax, dword [0x408bf4]
mov ecx, dword [0x408c04]
push eax
push 0x7530
push ecx
call dword [sym.imp.KERNEL32.dll_GetFullPathNameA]
mov esi, eax
mov eax, dword [esp + 8]
cmp eax, ebx
je 0x4016e1
push 0x401624
push eax
call dword [sym.imp.KERNEL32.dll_lstrcmpiA]
test eax, eax
jne 0x4016dd
mov byte [0x408c17], 1
mov eax, dword [esp + 8]
mov ecx, dword [0x408bf4]
cmp esi, ebx
je 0x4016ff
cmp esi, 0x7530
jae 0x4016ff
cmp eax, ebx
je 0x4016ff
cmp eax, ecx
je 0x4016ff
mov byte [eax], bl
jmp 0x401701
mov byte [ecx], bl
mov edx, dword [0x408bf4]
push edx
call fcn.0040150f
cmp byte [0x408c17], bl
je 0x401767
push edi
mov edi, dword [0x408bf4]
or ecx, 0xffffffff
xor eax, eax
repne scasb al, byte es:[edi]
not ecx
sub edi, ecx
push 0x401630
mov eax, ecx
mov esi, edi
mov edi, dword [0x408c04]
shr ecx, 2
rep movsd dword es:[edi], dword [esi]
mov ecx, eax
and ecx, 3
rep movsb byte es:[edi], byte [esi]
mov ecx, dword [0x408c04]
push ecx
call fcn.00401000
mov edx, dword [0x408c04]
push edx
call dword [sym.imp.KERNEL32.dll_GetFileAttributesA]
cmp eax, 0xffffffff
pop edi
jne 0x401767
mov byte [0x408c17], bl
mov eax, dword [0x408bec]
push 0x7530
push eax
call dword [sym.imp.KERNEL32.dll_GetWindowsDirectoryA]
mov esi, eax
cmp esi, ebx
je 0x401786
cmp esi, 0x752a
jb 0x40178d
push 2
call fcn.004013af
mov ecx, dword [0x408bec]
mov byte [ecx + esi], bl
mov edx, dword [0x408bec]
push edx
call fcn.0040153f
mov eax, dword [0x408bec]
push eax
call fcn.0040150f
mov ecx, dword [0x408bf0]
mov esi, dword [sym.imp.KERNEL32.dll_GetEnvironmentVariableA]
push 0x7530
push ecx
push 0x40163c
call esi
cmp eax, ebx
je 0x4017d1
cmp eax, 0x7530
jb 0x4017e4
mov edx, dword [0x408bf0]
push 0x7530
push edx
push 0x401640
call esi
cmp eax, ebx
je 0x4017ef
cmp eax, 0x7530
jb 0x401801
mov eax, dword [0x408bf0]
push 0x7530
push eax
push 0x401648
call esi
mov esi, dword [sym.imp.KERNEL32.dll_lstrcpyA]
cmp eax, ebx
je 0x401812
cmp eax, 0x7530
jb 0x401832
mov ecx, dword [0x408bec]
mov edx, dword [0x408bf0]
push ecx
push edx
call esi
mov eax, dword [0x408bf0]
push 0x401650
push eax
call fcn.00401000
mov ecx, dword [0x408bf0]
push ecx
call fcn.0040153f
mov edx, dword [0x408bf0]
push edx
call dword [sym.imp.KERNEL32.dll_lstrlenA]
cmp eax, ebx
je 0x401856
cmp eax, 0xee
jbe 0x40185d
push 3
call fcn.004013af
mov eax, dword [0x408bf0]
push eax
call fcn.0040150f
mov ecx, dword [0x408bf0]
push 0x401658
push ecx
call fcn.00401000
cmp byte [0x408c17], bl
je 0x4018ab
mov byte [0x408be4], bl
mov byte [0x408be5], bl
mov ecx, dword [0x408bf4]
mov edx, dword [0x408bf8]
push ecx
push edx
mov dword [0x407004], 3
call esi
pop esi
pop ebx
pop ecx
ret
cmp byte [0x408be4], bl
je 0x40188d
cmp byte [0x408c15], bl
jne 0x4018ca
mov byte [0x408c16], 1
mov byte [0x408be4], bl
jmp 0x40188d
mov edx, dword [0x408bf0]
mov eax, dword [0x408bf8]
push edx
push eax
call esi
pop esi
pop ebx
pop ecx
ret