Function at 0x402040
Capabilities:
Allocate or change rwx memory
Check if file exists
Execute shellcode via indirect call
Get file attributes

Disassembly:
push ebp
mov ebp, esp
sub esp, 0x330
mov eax, dword [0x6b7040]
xor eax, ebp
mov dword [ebp - 4], eax
mov al, byte [ebp + 0x10]
push esi
mov esi, dword [ebp + 8]
push edi
mov edi, dword [ebp + 0xc]
mov byte [ebp - 0x321], al
mov byte [ebp - 0x330], al
mov eax, dword [ebp + 0x14]
mov dword [ebp - 0x32c], eax
test edi, edi
jne 0x40208a
lea eax, [edi + 1]
pop edi
pop esi
mov ecx, dword [ebp - 4]
xor ecx, ebp
call fcn.00403dbb
mov esp, ebp
pop ebp
ret
test esi, esi
je 0x4022dd
push 0x104
lea eax, [ebp - 0x108]
push 0
push eax
call sub.VCRUNTIME140.dll_memset
add esp, 0xc
cmp byte [esi + 1], 0x3a
je 0x4020c9
push 0
lea eax, [ebp - 0x108]
push eax
push 0x104
push esi
call dword [sym.imp.KERNEL32.dll_GetFullPathNameA]
lea esi, [ebp - 0x108]
push esi
call dword [sym.imp.KERNEL32.dll_GetFileAttributesA]
cmp eax, 0xffffffff
je 0x4022dd
push 0x218
lea eax, [ebp - 0x320]
push 0
push eax
call sub.VCRUNTIME140.dll_memset
lea eax, [ebp - 0x310]
add esp, 0xc
mov dword [ebp - 0x314], eax
mov eax, 0x208
mov word [ebp - 0x316], ax
xor eax, eax
cmp byte [esi], al
je 0x402117
nop dword [eax]
inc eax
cmp byte [esi + eax], 0
jne 0x402110
push eax
mov dword [ebp - 0x328], eax
inc eax
push esi
push eax
lea eax, [ebp - 0x310]
push eax
lea eax, [ebp - 0x328]
push eax
call dword [sym.imp.api_ms_win_crt_convert_l1_1_0.dll_mbstowcs_s]
mov eax, dword [ebp - 0x328]
add esp, 0x14
lea eax, [eax*2 - 2]
push str.ntdll.dll
mov word [ebp - 0x318], ax
call dword [sym.imp.KERNEL32.dll_GetModuleHandleA]
test eax, eax
jne 0x40217b
call dword [sym.imp.KERNEL32.dll_GetLastError]
pop edi
mov dword [0x6b7290], eax
mov eax, 8
pop esi
mov ecx, dword [ebp - 4]
xor ecx, ebp
call fcn.00403dbb
mov esp, ebp
pop ebp
ret
push str.LdrLoadDll
push eax
call dword [sym.imp.KERNEL32.dll_GetProcAddress]
test eax, eax
jne 0x4021ab
call dword [sym.imp.KERNEL32.dll_GetLastError]
pop edi
mov dword [0x6b7290], eax
mov eax, 9
pop esi
mov ecx, dword [ebp - 4]
xor ecx, ebp
call fcn.00403dbb
mov esp, ebp
pop ebp
ret
push 0x40
push 0x3000
push 0x418
push 0
push edi
mov dword [ebp - 0x320], eax
call dword [sym.imp.KERNEL32.dll_VirtualAllocEx]
mov esi, eax
test esi, esi
jne 0x4021ec
call dword [sym.imp.KERNEL32.dll_GetLastError]
pop edi
mov dword [0x6b7290], eax
mov eax, 0x80000002
pop esi
mov ecx, dword [ebp - 4]
xor ecx, ebp
call fcn.00403dbb
mov esp, ebp
pop ebp
ret
push ebx
mov ebx, dword [sym.imp.KERNEL32.dll_WriteProcessMemory]
lea eax, [ebp - 0x320]
push 0
push 0x218
push eax
push esi
push edi
call ebx
test eax, eax
je 0x402223
push 0
push pe_nt_image_headers32
push 0x402010
lea eax, [esi + 0x218]
push eax
push edi
call ebx
test eax, eax
jne 0x402253
call dword [sym.imp.KERNEL32.dll_GetLastError]
push 0
push 0x8000
push esi
push edi
mov dword [0x6b7290], eax
call dword [sym.imp.KERNEL32.dll_VirtualFreeEx]
pop ebx
pop edi
mov eax, 0x80000003
pop esi
mov ecx, dword [ebp - 4]
xor ecx, ebp
call fcn.00403dbb
mov esp, ebp
pop ebp
ret
mov eax, dword [ebp - 0x32c]
push 0
and al, 1
movzx eax, al
push eax
push dword [ebp - 0x330]
lea eax, [esi + 0x218]
push esi
push eax
push edi
call fcn.00402950
mov ebx, eax
add esp, 0x18
test ebx, ebx
jne 0x4022a2
push 0x8000
push eax
push esi
push edi
call dword [sym.imp.KERNEL32.dll_VirtualFreeEx]
pop ebx
pop edi
mov eax, 0x80000001
pop esi
mov ecx, dword [ebp - 4]
xor ecx, ebp
call fcn.00403dbb
mov esp, ebp
pop ebp
ret
cmp byte [ebp - 0x321], 0
jne 0x4022bb
push 0xffffffffffffffff
push ebx
call dword [sym.imp.KERNEL32.dll_WaitForSingleObject]
push ebx
call dword [sym.imp.KERNEL32.dll_CloseHandle]
push 0x8000
push 0
push esi
push edi
call dword [sym.imp.KERNEL32.dll_VirtualFreeEx]
pop ebx
pop edi
xor eax, eax
pop esi
mov ecx, dword [ebp - 4]
xor ecx, ebp
call fcn.00403dbb
mov esp, ebp
pop ebp
ret
mov ecx, dword [ebp - 4]
mov eax, 2
pop edi
xor ecx, ebp
pop esi
call fcn.00403dbb
mov esp, ebp
pop ebp
ret