Function at 0x401040
Capabilities:
Allocate or change rwx memory
Create thread
Execute shellcode via indirect call
Inject thread
Spawn thread to rwx shellcode

Disassembly:
push ebp
mov ebp, esp
sub esp, 8
mov eax, dword [section..data]
xor eax, ebp
mov dword [ebp - 4], eax
push ebx
push edi
push ecx
push 0
push 0x1fffff
mov ebx, edx
call dword [sym.imp.KERNEL32.dll_OpenProcess]
mov edi, eax
test edi, edi
jne 0x40107b
lea eax, [edi + 1]
pop edi
pop ebx
mov ecx, dword [ebp - 4]
xor ecx, ebp
call fcn.00401340
mov esp, ebp
pop ebp
ret
push esi
push 0x40
push 0x3000
push 0x104
push 0
push edi
call dword [sym.imp.KERNEL32.dll_VirtualAllocEx]
mov esi, eax
test esi, esi
jne 0x4010c6
call dword [sym.imp.KERNEL32.dll_GetLastError]
push eax
push str.Error_on_VirtualAllocEx:__u_n
call fcn.00401010
add esp, 8
push edi
call dword [sym.imp.KERNEL32.dll_CloseHandle]
lea eax, [esi + 1]
pop esi
pop edi
pop ebx
mov ecx, dword [ebp - 4]
xor ecx, ebp
call fcn.00401340
mov esp, ebp
pop ebp
ret
mov ecx, ebx
lea edx, [ecx + 1]
nop dword [eax + eax]
mov al, byte [ecx]
inc ecx
test al, al
jne 0x4010d0
sub ecx, edx
push 0
lea eax, [ecx + 1]
push eax
push ebx
push esi
push edi
call dword [sym.imp.KERNEL32.dll_WriteProcessMemory]
test eax, eax
jne 0x40111d
call dword [sym.imp.KERNEL32.dll_GetLastError]
push eax
push str.Error_on_WriteProcessMemory:__u_n
call fcn.00401010
add esp, 8
push edi
call dword [sym.imp.KERNEL32.dll_CloseHandle]
pop esi
pop edi
mov eax, 1
pop ebx
mov ecx, dword [ebp - 4]
xor ecx, ebp
call fcn.00401340
mov esp, ebp
pop ebp
ret
push 0
push 0
push esi
push dword [sym.imp.KERNEL32.dll_LoadLibraryA]
push 0
push 0
push edi
call dword [sym.imp.KERNEL32.dll_CreateRemoteThread]
mov ebx, eax
test ebx, ebx
jne 0x40118f
mov ebx, dword [sym.imp.KERNEL32.dll_GetLastError]
call ebx
push eax
push str.Error_on_CreateRemoteThread:__u_n
call fcn.00401010
add esp, 8
push 0x8000
push 0
push esi
push edi
call dword [sym.imp.KERNEL32.dll_VirtualFreeEx]
test eax, eax
jne 0x401172
call ebx
push eax
push str.Error_on_VirtualFreeEx:__u_n
call fcn.00401010
add esp, 8
push edi
call dword [sym.imp.KERNEL32.dll_CloseHandle]
pop esi
pop edi
mov eax, 1
pop ebx
mov ecx, dword [ebp - 4]
xor ecx, ebp
call fcn.00401340
mov esp, ebp
pop ebp
ret
push 0xffffffffffffffff
push ebx
call dword [sym.imp.KERNEL32.dll_WaitForSingleObject]
cmp eax, 0xffffffff
jne 0x4011ab
call dword [sym.imp.KERNEL32.dll_GetLastError]
push eax
push str.Error_on_WaitForSingleObject:__u_n
jmp 0x4011d5
lea eax, [ebp - 8]
push eax
push ebx
call dword [sym.imp.KERNEL32.dll_GetExitCodeThread]
test eax, eax
jne 0x4011c8
call dword [sym.imp.KERNEL32.dll_GetLastError]
push eax
push str.Error_on_GetExitCodeThread:__u_n
jmp 0x4011d5
cmp dword [ebp - 8], 0
jne 0x401226
push 0
push str.Error_in_the_execution_of_LoadLibraryA_in_the_target_process:__u_n
call fcn.00401010
add esp, 8
push 0x8000
push 0
push esi
push edi
call dword [sym.imp.KERNEL32.dll_VirtualFreeEx]
test eax, eax
jne 0x401204
call dword [sym.imp.KERNEL32.dll_GetLastError]
push eax
push str.Error_on_VirtualFreeEx:__u_n
call fcn.00401010
add esp, 8
mov esi, dword [sym.imp.KERNEL32.dll_CloseHandle]
push ebx
call esi
push edi
call esi
pop esi
pop edi
mov eax, 1
pop ebx
mov ecx, dword [ebp - 4]
xor ecx, ebp
call fcn.00401340
mov esp, ebp
pop ebp
ret
push 0x8000
push 0
push esi
push edi
call dword [sym.imp.KERNEL32.dll_VirtualFreeEx]
test eax, eax
jne 0x40124d
call dword [sym.imp.KERNEL32.dll_GetLastError]
push eax
push str.Error_on_VirtualFreeEx:__u_n
call fcn.00401010
add esp, 8
mov esi, dword [sym.imp.KERNEL32.dll_CloseHandle]
push ebx
call esi
push edi
call esi
mov ecx, dword [ebp - 4]
xor eax, eax
pop esi
pop edi
xor ecx, ebp
pop ebx
call fcn.00401340
mov esp, ebp
pop ebp
ret