Function at 0x509240
Capabilities:
Access peb ldr_data
Get ntdll base address

Disassembly:
push ebp
mov ebp, esp
push ecx
mov ecx, 0x11
push 0
push 0
dec ecx
jne 0x509249
xchg dword [ebp - 4], ecx
push ebx
push esi
push edi
mov edi, ecx
mov dword [ebp - 0x40], edx
mov dword [ebp - 0x3c], eax
lea esi, [ebp - 0x80]
xor eax, eax
push ebp
push 0x509658
push dword fs:[eax]
mov dword fs:[eax], esp
mov eax, dword [ebp + 0x14]
test byte [eax + 0x18], 1
setne bl
test bl, bl
je 0x509378
mov eax, dword [ebp - 0x3c]
call fcn.0040775c
test eax, eax
jle 0x5092bf
mov eax, dword [ebp - 0x3c]
call fcn.0040775c
mov edx, eax
add edx, edx
lea eax, [ebp - 0x20]
xor ecx, ecx
call fcn.00406f78
mov eax, dword [ebp - 0x20]
call fcn.00406ae8
push eax
lea eax, [ebp - 0x20]
call fcn.00406f0c
mov edx, eax
mov eax, dword [ebp - 0x3c]
pop ecx
call fcn.00404480
mov eax, dword [ebp - 0x40]
call fcn.0040775c
test eax, eax
jle 0x5092fd
mov eax, dword [ebp - 0x40]
call fcn.0040775c
mov edx, eax
add edx, edx
lea eax, [ebp - 0x30]
xor ecx, ecx
call fcn.00406f78
mov eax, dword [ebp - 0x30]
call fcn.00406ae8
push eax
lea eax, [ebp - 0x30]
call fcn.00406f0c
mov edx, eax
mov eax, dword [ebp - 0x40]
pop ecx
call fcn.00404480
mov eax, edi
call fcn.0040775c
test eax, eax
jle 0x509338
mov eax, edi
call fcn.0040775c
mov edx, eax
add edx, edx
lea eax, [ebp - 0x34]
xor ecx, ecx
call fcn.00406f78
mov eax, dword [ebp - 0x34]
call fcn.00406ae8
push eax
lea eax, [ebp - 0x34]
call fcn.00406f0c
mov edx, eax
mov eax, edi
pop ecx
call fcn.00404480
mov eax, dword [ebp + 0x18]
call fcn.0040775c
test eax, eax
jle 0x5093bd
mov eax, dword [ebp + 0x18]
call fcn.0040775c
mov edx, eax
add edx, edx
lea eax, [ebp - 0x18]
xor ecx, ecx
call fcn.00406f78
mov eax, dword [ebp - 0x18]
call fcn.00406ae8
push eax
lea eax, [ebp - 0x18]
call fcn.00406f0c
mov edx, eax
mov eax, dword [ebp + 0x18]
pop ecx
call fcn.00404480
jmp 0x5093bd
lea eax, [ebp - 0x20]
mov edx, dword [ebp - 0x3c]
mov ecx, 0
call fcn.00407630
lea eax, [ebp - 0x30]
mov edx, dword [ebp - 0x40]
mov ecx, 0
call fcn.00407630
lea eax, [ebp - 0x34]
push eax
xor ecx, ecx
mov edx, 1
mov eax, edi
call fcn.004fe6b0
lea eax, [ebp - 0x18]
push eax
xor ecx, ecx
mov edx, 1
mov eax, dword [ebp + 0x18]
call fcn.004fe6b0
lea edx, [ebp - 0x38]
mov eax, edi
call fcn.00412e94
mov eax, dword [ebp - 0x38]
call fcn.0040775c
mov edx, eax
add edx, edx
lea eax, [ebp - 0x1c]
xor ecx, ecx
call fcn.00406f78
mov eax, dword [ebp - 0x1c]
call fcn.00406ae8
push eax
lea eax, [ebp - 0x1c]
call fcn.00406f0c
mov edx, eax
mov eax, dword [ebp - 0x38]
pop ecx
call fcn.00404480
mov eax, esi
xor ecx, ecx
mov edx, 0x40
call fcn.00404cac
mov edx, esi
mov eax, 0x509668
mov ecx, 8
call fcn.00404480
mov dword [esi + 8], 3
mov eax, dword [ebp - 0x20]
call fcn.00406ae8
mov edi, eax
mov word [esi + 0x1c], di
mov word [esi + 0x1e], di
mov dword [esi + 0x20], 0x40
mov eax, dword [ebp - 0x34]
call fcn.00406ae8
mov edi, eax
mov word [esi + 0x24], di
mov word [esi + 0x26], di
movzx eax, word [esi + 0x1c]
add eax, dword [esi + 0x20]
mov dword [esi + 0x28], eax
mov eax, dword [ebp - 0x30]
call fcn.00406ae8
mov edi, eax
mov word [esi + 0x2c], di
mov word [esi + 0x2e], di
movzx eax, word [esi + 0x24]
add eax, dword [esi + 0x28]
mov dword [esi + 0x30], eax
test bl, bl
je 0x50947d
mov dword [esi + 0x3c], 1
jmp 0x509484
mov dword [esi + 0x3c], 2
mov eax, dword [esi + 0x3c]
or eax, 4
or eax, 0x200
or eax, 0x8000
mov dword [esi + 0x3c], eax
cmp dword [ebp + 0xc], 0
jne 0x5094da
lea eax, [ebp - 0x84]
mov edx, dword [ebp + 0x18]
mov ecx, 0
call fcn.00407630
mov eax, dword [ebp - 0x84]
lea ecx, [ebp - 0x28]
mov edx, dword [ebp + 0x14]
add edx, 0x10
call fcn.0050850c
lea ecx, [ebp - 0x2c]
mov edx, dword [ebp + 0x14]
add edx, 0x10
mov eax, dword [ebp - 0x18]
call fcn.005086dc
jmp 0x509576
mov eax, dword [ebp + 0xc]
dec eax
sub eax, 2
jae 0x50955d
mov eax, dword [ebp + 0x14]
test byte [eax + 0x1a], 8
je 0x509510
or dword [esi + 0x3c], 0x80000
push ebp
lea eax, [ebp - 0x2c]
call fcn.00406724
push eax
lea eax, [ebp - 0x28]
call fcn.00406724
xor ecx, ecx
pop edx
call fcn.00508c94
pop ecx
jmp 0x509576
lea ecx, [ebp - 0x2c]
mov edx, dword [ebp + 0x14]
add edx, 0x10
mov eax, dword [ebp - 0x18]
call fcn.005086dc
cmp dword [ebp + 0xc], 2
jne 0x509534
lea eax, [ebp - 0x28]
mov edx, dword [ebp - 0x2c]
call fcn.004067d4
jmp 0x509576
lea eax, [ebp - 0x88]
mov edx, dword [ebp + 0x18]
mov ecx, 0
call fcn.00407630
mov eax, dword [ebp - 0x88]
lea ecx, [ebp - 0x28]
mov edx, dword [ebp + 0x14]
add edx, 0x10
call fcn.0050850c
jmp 0x509576
push ebp
lea eax, [ebp - 0x2c]
call fcn.00406724
push eax
lea eax, [ebp - 0x28]
call fcn.00406724
pop edx
call fcn.00508fc8
pop ecx
mov eax, dword [ebp - 0x28]
call fcn.00406ae8
mov ebx, eax
mov word [esi + 0xc], bx
mov word [esi + 0xe], bx
movzx eax, word [esi + 0x2c]
add eax, dword [esi + 0x30]
mov dword [esi + 0x10], eax
mov eax, dword [ebp - 0x2c]
call fcn.00406ae8
mov ebx, eax
mov word [esi + 0x14], bx
mov word [esi + 0x16], bx
movzx eax, word [esi + 0xc]
add eax, dword [esi + 0x10]
mov dword [esi + 0x18], eax
mov word [esi + 0x34], 0
mov word [esi + 0x36], 0
movzx eax, word [esi + 0x14]
add eax, dword [esi + 0x18]
mov dword [esi + 0x38], eax
lea eax, [ebp - 0x24]
xor ecx, ecx
mov edx, 0x40
call fcn.00406f78
mov edx, dword [ebp - 0x24]
mov eax, esi
mov ecx, 0x40
call fcn.00404480
push dword [ebp - 0x24]
push dword [ebp - 0x20]
push dword [ebp - 0x34]
push dword [ebp - 0x30]
push dword [ebp - 0x28]
push dword [ebp - 0x2c]
lea eax, [ebp - 0x24]
mov edx, 6
call fcn.00406cd4
lea edx, [ebp - 0x8c]
mov eax, dword [ebp - 0x24]
call fcn.00506140
mov edx, dword [ebp - 0x8c]
mov eax, dword [ebp + 8]
call fcn.00407608
xor eax, eax
pop edx
pop ecx
pop ecx
mov dword fs:[eax], edx
push 0x50965f
lea eax, [ebp - 0x8c]
mov edx, 3
call fcn.00406748
lea eax, [ebp - 0x38]
call fcn.004073dc
lea eax, [ebp - 0x34]
mov edx, 8
call fcn.00406748
lea eax, [ebp - 4]
call fcn.00406724
ret