Function at 0x4067e4
Capabilities:
Access pe header
Allocate or change rwx memory
Allocate user process rwx memory
Attach user process memory

Disassembly:
push ebp
mov ebp, esp
sub esp, 0x34
mov edx, dword [0x41cff0]
push ebx
mov ebx, dword [0x41cff8]
add ebx, 0xfff
mov eax, 0xfffff000
add edx, 0xfff
xor ecx, ecx
and ebx, eax
and edx, eax
add ebx, edx
mov dword [ebp - 8], ecx
mov byte [ebp - 1], cl
mov dword [ebp - 0x10], ecx
je 0x406823
cmp dword [0x41cff4], ecx
jne 0x406828
mov ebx, 0x1000
cmp dword [ebp + 0x14], ecx
je 0x406be6
mov eax, dword [ebp + 0x18]
cmp eax, ecx
je 0x406be6
push esi
push edi
mov edi, dword [eax]
lea esi, [edi + 0xe7c]
cmp byte [esi], cl
je 0x406852
cmp dword [edi + 0xe68], ecx
jne 0x40685a
call dword [sym.imp.ntoskrnl.exe_KeGetCurrentThread]
xor ecx, ecx
cmp byte [esi], 0
je 0x40687a
cmp dword [edi + 0xe68], ecx
je 0x40687a
lea eax, [ebp - 0x34]
push eax
push dword [edi + 0x10]
call dword [sym.imp.ntoskrnl.exe_KeStackAttachProcess]
mov byte [ebp - 1], 1
xor ecx, ecx
mov eax, dword [ebp + 0x14]
mov eax, dword [eax]
push 0x40
lea eax, [eax + ebx + 0x1000]
push 0x3000
mov dword [ebp - 0x10], eax
lea eax, [ebp - 0x10]
push eax
push ecx
lea eax, [ebp - 8]
push eax
push 0xffffffffffffffff
call dword [sym.imp.ntoskrnl.exe_ZwAllocateVirtualMemory]
mov ecx, dword [edi + 0xe6c]
test ecx, ecx
mov dword [ebp - 0x14], ecx
je 0x406be4
test eax, eax
jl 0x406be4
mov eax, dword [0x41cff0]
test eax, eax
jbe 0x4068df
mov ecx, dword [0x41cfec]
test ecx, ecx
je 0x4068df
push eax
push ecx
push dword [ebp - 8]
call sub.ntoskrnl.exe_memcpy
mov eax, dword [0x41cff0]
add esp, 0xc
mov edx, dword [0x41cff8]
test edx, edx
jbe 0x40690b
mov ecx, dword [0x41cff4]
test ecx, ecx
je 0x40690b
add eax, 0xfff
push edx
and eax, 0xfffff000
add eax, dword [ebp - 8]
push ecx
push eax
call sub.ntoskrnl.exe_memcpy
add esp, 0xc
and dword [ebp + 0x14], 0
lea esi, [edi + 0xdb8]
xor eax, eax
cmp dword [esi - 4], eax
jbe 0x406964
mov ecx, dword [esi]
add ecx, 0xfff
push 0x40
and ecx, 0xfffff000
push 0x3000
mov dword [ebp - 0x1c], ecx
lea ecx, [ebp - 0x1c]
push ecx
push eax
mov dword [ebp - 0xc], eax
lea eax, [ebp - 0xc]
push eax
push 0xffffffffffffffff
call dword [sym.imp.ntoskrnl.exe_ZwAllocateVirtualMemory]
test eax, eax
jl 0x406a16
push dword [esi]
mov eax, dword [ebp - 0xc]
push dword [esi - 4]
mov dword [esi - 8], eax
push eax
call sub.ntoskrnl.exe_memcpy
add esp, 0xc
inc dword [ebp + 0x14]
add esi, 0x38
cmp dword [ebp + 0x14], 3
jl 0x406915
mov eax, dword [ebp - 8]
add eax, ebx
mov dword [edi + 0xe70], eax
mov eax, dword [ebp - 8]
lea esi, [ebx + eax]
lea ecx, [edi + 0xdb0]
lea eax, [esi + 0x1c]
mov dword [ebp + 0x14], 3
cmp dword [ecx], 0
jbe 0x4069d6
mov edx, dword [ebp - 8]
mov dword [eax - 4], edx
mov edx, dword [0x41cff0]
mov dword [eax], edx
mov edx, dword [0x41cff0]
add edx, 0xfff
and edx, 0xfffff000
add edx, dword [ebp - 8]
mov dword [eax + 4], edx
mov edx, dword [0x41cff8]
mov dword [eax + 8], edx
mov edx, dword [ecx]
mov dword [eax + 0xc], edx
mov edx, dword [ecx + 8]
mov dword [eax + 0x10], edx
inc dword [edi + 0xe74]
add ecx, 0x38
add eax, 0x30
dec dword [ebp + 0x14]
jne 0x406991
and dword [ebp + 0x18], 0
push 4
mov eax, 0x3000
push eax
mov dword [ebp - 0x18], eax
lea eax, [ebp - 0x18]
push eax
push 0
lea eax, [ebp + 0x18]
push eax
push 0xffffffffffffffff
call dword [sym.imp.ntoskrnl.exe_ZwAllocateVirtualMemory]
xor ecx, ecx
cmp eax, ecx
jge 0x406a29
mov dword [esi + 4], ecx
mov dword [esi + 0xc], ecx
mov dword [esi + 0x14], ecx
jmp 0x406be4
mov eax, dword [ebp + 0x14]
imul eax, eax, 0x38
and dword [eax + edi + 0xdb0], 0
jmp 0x406be4
push dword [ebp - 0x18]
push ecx
push dword [ebp + 0x18]
call sub.ntoskrnl.exe_memset
mov ecx, dword [0x41ddf4]
add esp, 0xc
test ecx, ecx
jbe 0x406a73
mov eax, dword [0x41ddf0]
test eax, eax
je 0x406a73
push ecx
push eax
push dword [ebp + 0x18]
call sub.ntoskrnl.exe_memcpy
mov eax, dword [0x41ddf4]
mov dword [esi + 4], eax
mov eax, dword [ebp + 0x18]
mov dword [esi], eax
mov eax, dword [0x41ddf4]
mov dword [esi + 0x34], eax
mov eax, dword [ebp + 0x18]
add esp, 0xc
mov dword [esi + 0x30], eax
mov ecx, dword [0x41ddfc]
test ecx, ecx
jbe 0x406abf
mov eax, dword [0x41ddf8]
test eax, eax
je 0x406abf
push ecx
push eax
mov eax, dword [ebp + 0x18]
add eax, 0x1000
push eax
call sub.ntoskrnl.exe_memcpy
mov eax, dword [0x41ddfc]
mov dword [esi + 0xc], eax
mov eax, dword [ebp + 0x18]
add eax, 0x1000
mov dword [esi + 8], eax
mov eax, dword [0x41ddfc]
mov dword [esi + 0x3c], eax
mov eax, dword [ebp + 0x18]
add esp, 0xc
add eax, 0x1000
mov dword [esi + 0x38], eax
mov ecx, dword [0x41de04]
test ecx, ecx
jbe 0x406b0b
mov eax, dword [0x41de00]
test eax, eax
je 0x406b0b
push ecx
push eax
mov eax, dword [ebp + 0x18]
add eax, 0x2000
push eax
call sub.ntoskrnl.exe_memcpy
mov eax, dword [0x41de04]
mov dword [esi + 0x14], eax
mov eax, dword [ebp + 0x18]
add eax, 0x2000
mov dword [esi + 0x10], eax
mov eax, dword [0x41de04]
mov dword [esi + 0x44], eax
mov eax, dword [ebp + 0x18]
add esp, 0xc
add eax, 0x2000
mov dword [esi + 0x40], eax
push dword [ebp - 0x14]
call sub.ntoskrnl.exe_RtlImageNtHeader
mov esi, eax
test esi, esi
je 0x406be4
mov eax, dword [ebp - 8]
lea eax, [eax + ebx + 0x1000]
mov dword [ebp - 8], eax
mov dword [edi + 0xe5c], eax
mov eax, dword [ebp - 8]
mov dword [edi + 0xe58], eax
mov ecx, dword [ebp - 0x10]
sub ecx, ebx
sub ecx, 0x1000
push ecx
push 0
push eax
mov dword [ebp - 0xc], eax
call sub.ntoskrnl.exe_memset
movzx eax, word [esi + 6]
mov dword [ebp + 0x14], eax
movzx eax, word [esi + 0x14]
lea ebx, [eax + esi + 0x18]
push dword [ebx + 0xc]
push dword [ebp - 0x14]
push dword [ebp - 0xc]
call sub.ntoskrnl.exe_memcpy
add esp, 0x18
cmp word [ebp + 0x14], 0
je 0x406ba3
add ebx, 0x14
mov eax, dword [ebx]
add eax, dword [ebp - 0x14]
push dword [ebx - 4]
add dword [ebp + 0x14], 0xffff
push eax
mov eax, dword [ebx - 8]
add eax, dword [ebp - 0xc]
push eax
call sub.ntoskrnl.exe_memcpy
add esp, 0xc
add ebx, 0x28
cmp word [ebp + 0x14], 0
jne 0x406b7a
push 2
push 1
push 0
push 0
push dword [edi + 0xe5c]
call fcn.00403b66
mov esi, dword [esi + 0x80]
add esi, dword [ebp - 0xc]
je 0x406be4
push edi
push esi
push dword [ebp - 0xc]
push 0
call fcn.00405a07
cmp byte [ebp - 1], 0
mov byte [edi + 0xe7d], 1
je 0x406be4
lea eax, [ebp - 0x34]
push eax
call dword [sym.imp.ntoskrnl.exe_KeUnstackDetachProcess]
pop edi
pop esi
pop ebx
leave
ret 0x14