Function at 0x402850
Capabilities:
Query environment variable
Set current directory
Set environment variable

Disassembly:
sub esp, 0x138
mov eax, dword [0x4153c0]
push ebx
push ebp
push esi
push edi
push 0x401040
mov dword [esp + 0x148], eax
call fcn.0040d42d
push 0x401050
call dword [sym.imp.MSVCR71.dll__set_security_error_handler]
push 0x401030
call dword [sym.imp.MSVCR71.dll_void____cdecl___void____cdecl_set_terminate_void____cdecl___void__]
push 0x401030
call dword [sym.imp.MSVCR71.dll_void____cdecl___void____cdecl_set_unexpected_void____cdecl___void__]
add esp, 0x10
push entry0
call dword [sym.imp.KERNEL32.dll_SetUnhandledExceptionFilter]
call fcn.00402750
push 0x104
lea eax, [esp + 0x44]
push eax
push 0
call dword [sym.imp.KERNEL32.dll_GetModuleFileNameA]
lea ecx, [esp + 0x40]
push ecx
lea ecx, [esp + 0x18]
call fcn.004024c0
push 0x4105e8
push 0x4105e8
lea ecx, [esp + 0x1c]
call fcn.00402050
mov ecx, eax
call fcn.00401e90
mov edx, dword [esp + 0x14]
push 0x5c
push edx
call dword [sym.imp.MSVCR71.dll__mbsrchr]
mov edx, dword [esp + 0x1c]
add esp, 8
test eax, eax
je 0x402928
sub eax, edx
js 0x402928
cmp eax, 0xffffffff
jne 0x402919
test edx, edx
jne 0x402907
xor eax, eax
jmp 0x402919
mov eax, edx
lea esi, [eax + 1]
lea esp, [esp]
mov cl, byte [eax]
inc eax
test cl, cl
jne 0x402910
sub eax, esi
mov dword [edx - 0xc], eax
mov ecx, dword [esp + 0x14]
mov byte [eax + ecx], 0
mov edx, dword [esp + 0x14]
push edx
call dword [sym.imp.KERNEL32.dll_SetCurrentDirectoryA]
lea ecx, [esp + 0x10]
call fcn.00401af0
mov ebx, dword [sym.imp.KERNEL32.dll_GetEnvironmentVariableA]
push 0
push 0
push str.PATH
call ebx
mov esi, dword [esp + 0x10]
mov edi, eax
mov eax, dword [esi - 4]
mov edx, 1
sub edx, eax
mov eax, dword [esi - 8]
sub eax, edi
or edx, eax
jge 0x402970
push edi
lea ecx, [esp + 0x14]
call fcn.00401a50
mov esi, dword [esp + 0x10]
push edi
push esi
push str.PATH
call ebx
test esi, esi
jne 0x402981
xor eax, eax
jmp 0x40298f
mov eax, esi
lea edx, [eax + 1]
mov cl, byte [eax]
inc eax
test cl, cl
jne 0x402986
sub eax, edx
push 1
mov dword [esi - 0xc], eax
push 0x4105dc
lea ecx, [esp + 0x18]
mov byte [eax + esi], 0
call fcn.00401d30
lea ecx, [esp + 0x18]
push ecx
call fcn.00401db0
mov eax, dword [eax]
mov edx, dword [eax - 0xc]
add esp, 4
push edx
push eax
lea ecx, [esp + 0x18]
call fcn.00401d30
lea ecx, [esp + 0x18]
call fcn.00401b10
push 4
push str._bin
lea ecx, [esp + 0x18]
call fcn.00401d30
mov eax, dword [esp + 0x10]
push eax
push str.PATH
call dword [sym.imp.KERNEL32.dll_SetEnvironmentVariableA]
mov ecx, dword [0x41530c]
push 1
push str.Sys_PreStartup
call dword [ecx + 0xc]
mov edx, dword [0x41530c]
push 1
push str.Sys_Startup
mov esi, eax
call dword [edx + 0xc]
mov edi, eax
mov eax, dword [0x41530c]
push 0
push str.Sys_Shutdown
call dword [eax + 0xc]
mov ecx, dword [0x41530c]
push 0
push str.Sys_UnloadModules
mov ebp, eax
call dword [ecx + 0xc]
add esp, 0x20
mov dword [esp + 0x18], eax
call fcn.00408440
test eax, eax
je 0x402b2a
call fcn.00405b40
test eax, eax
je 0x402b2a
push str.._plugins_dh.dll
lea ecx, [esp + 0x20]
call fcn.00401850
mov edx, dword [0x41530c]
push 0
push str.._plugins_dh.dll
push str.Sys_LoadModule
call dword [edx + 8]
add esp, 0xc
call fcn.00405ff0
test eax, eax
je 0x402b21
mov eax, dword [0x41530c]
push 0
push 0
push esi
call dword [eax + 0x1c]
add esp, 0xc
test eax, eax
je 0x402aa2
cmp eax, 1
jne 0x402b21
mov ecx, dword [0x41530c]
push 0
push 0
push edi
call dword [ecx + 0x1c]
add esp, 0xc
test eax, eax
je 0x402abc
cmp eax, 1
jne 0x402b21
mov esi, dword [sym.imp.USER32.dll_GetMessageA]
push 0
push 0
push 0
lea edx, [esp + 0x30]
push edx
call esi
test eax, eax
je 0x402aff
mov edi, dword [sym.imp.USER32.dll_TranslateMessage]
mov ebx, dword [sym.imp.USER32.dll_DispatchMessageA]
nop
lea eax, [esp + 0x24]
push eax
call edi
lea ecx, [esp + 0x24]
push ecx
call ebx
push 0
push 0
push 0
lea edx, [esp + 0x30]
push edx
call esi
test eax, eax
jne 0x402ae0
mov eax, dword [0x41530c]
push 0
push 0
push ebp
call dword [eax + 0x1c]
mov ecx, dword [esp + 0x24]
mov edx, dword [0x41530c]
push 0
push 0
push ecx
call dword [edx + 0x1c]
add esp, 0x18
lea ecx, [esp + 0x1c]
call fcn.00401880
lea ecx, [esp + 0x10]
call fcn.00401b10
lea ecx, [esp + 0x14]
call fcn.00401b10
mov ecx, dword [esp + 0x144]
pop edi
pop esi
pop ebp
xor eax, eax
pop ebx
call fcn.0040d4b1
add esp, 0x138
ret 0x10