Function at 0x401240
Capabilities:
Create new key via cryptacquirecontext
Generate random numbers via winapi

Disassembly:
push ebp
mov ebp, esp
sub esp, 0x14
mov eax, dword [0x41e028]
xor eax, ebp
mov dword [ebp - 4], eax
mov eax, dword [ebp + 0xc]
push ebx
push esi
xor ebx, ebx
test byte [0x420870], 1
push edi
mov edi, ecx
mov dword [ebp - 0x14], eax
jne 0x4012b2
or dword [0x420870], 1
push 0x420854
call dword [sym.imp.KERNEL32.dll_InitializeCriticalSection]
mov esi, dword [sym.imp.ADVAPI32.dll_CryptAcquireContextA]
push ebx
push 1
push ebx
push ebx
push 0x42086c
call esi
test eax, eax
jne 0x4012a5
push 8
push 1
push ebx
push ebx
push 0x42086c
call esi
test eax, eax
jne 0x4012a5
mov dword [0x42086c], ebx
push 0x418c20
call fcn.004096b5
add esp, 4
xor eax, eax
mov byte [ebp - 0xc], bl
mov dword [ebp - 0xb], eax
mov word [ebp - 7], ax
cmp dword [0x42086c], ebx
je 0x4012ef
push 0x420854
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
mov edx, dword [0x42086c]
lea ecx, [ebp - 0xc]
push ecx
push 7
push edx
call dword [sym.imp.ADVAPI32.dll_CryptGenRandom]
push 0x420854
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
mov dl, byte [ebp - 0xb]
and dl, 0x38
mov al, byte [ebp - 0xc]
mov byte [ebp - 0xd], dl
mov dl, byte [ebp - 9]
and dl, 0xc7
or dl, byte [ebp - 0xd]
mov bl, byte [ebp - 6]
mov cl, byte [ebp - 0xa]
mov byte [ebp - 9], dl
mov dl, byte [ebp - 8]
and dl, 0xc7
and al, 0x38
or dl, al
mov byte [ebp - 8], dl
mov dl, byte [ebp - 7]
and dl, 0xc7
or dl, byte [ebp - 0xd]
and cl, 0xc7
mov byte [ebp - 7], dl
or cl, al
movzx edx, dl
shr edx, 3
and edx, 7
and bl, 0xc7
or bl, al
movzx eax, bl
shr eax, 3
and eax, 7
add eax, edx
movzx edx, byte [ebp - 8]
shr edx, 3
and edx, 7
add eax, edx
movzx edx, byte [ebp - 0xb]
shr edx, 3
and edx, 7
add eax, edx
movzx edx, byte [ebp - 9]
shr edx, 3
and edx, 7
add eax, edx
movzx edx, byte [ebp - 0xc]
mov byte [ebp - 0xa], cl
movzx ecx, cl
shr ecx, 3
and ecx, 7
shr edx, 3
add eax, ecx
and edx, 7
lea esi, [eax + edx + 0x1f]
mov eax, dword [ebp - 0x14]
mov byte [ebp - 6], bl
xor ebx, ebx
mov dword [eax], esi
cmp esi, ebx
jg 0x4013a8
mov eax, dword [edi]
cmp eax, ebx
je 0x4013a1
push eax
call fcn.00409587
add esp, 4
mov dword [edi + 4], ebx
mov dword [edi], ebx
jmp 0x4013e5
cmp esi, dword [edi + 4]
jg 0x4013b4
mov ecx, dword [edi]
push esi
push ebx
push ecx
jmp 0x4013dd
mov eax, dword [edi]
cmp eax, ebx
je 0x4013c3
push eax
call fcn.00409587
add esp, 4
push esi
mov dword [edi + 4], ebx
mov dword [edi], ebx
call fcn.00409507
add esp, 4
mov dword [edi], eax
cmp eax, ebx
je 0x4013e5
push esi
push ebx
mov dword [edi + 4], esi
push eax
call fcn.0040e850
add esp, 0xc
mov edi, dword [edi]
mov dl, byte [ebp - 0xc]
mov byte [edi], dl
movzx esi, byte [ebp - 0xc]
shr esi, 3
and esi, 7
cmp dword [0x42086c], ebx
je 0x401426
push 0x420854
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
mov ecx, dword [0x42086c]
lea eax, [edi + 1]
push eax
push esi
push ecx
call dword [sym.imp.ADVAPI32.dll_CryptGenRandom]
push 0x420854
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
movzx esi, byte [ebp - 0xc]
mov edx, dword [ebp + 8]
mov eax, dword [edx]
shr esi, 3
and esi, 7
mov dword [esi + edi + 1], eax
mov cl, byte [ebp - 0xb]
mov byte [esi + edi + 5], cl
movzx ebx, byte [ebp - 0xb]
shr ebx, 3
add esi, 6
and ebx, 7
cmp dword [0x42086c], 0
je 0x40147d
push 0x420854
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
mov eax, dword [0x42086c]
lea edx, [esi + edi]
push edx
push ebx
push eax
call dword [sym.imp.ADVAPI32.dll_CryptGenRandom]
push 0x420854
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
movzx ecx, byte [ebp - 0xb]
mov edx, dword [ebp + 8]
mov eax, dword [edx + 4]
shr ecx, 3
and ecx, 7
add esi, ecx
mov dword [esi + edi], eax
mov cl, byte [ebp - 0xa]
mov byte [esi + edi + 4], cl
movzx ebx, byte [ebp - 0xa]
shr ebx, 3
add esi, 5
and ebx, 7
cmp dword [0x42086c], 0
je 0x4014d6
push 0x420854
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
mov eax, dword [0x42086c]
lea edx, [esi + edi]
push edx
push ebx
push eax
call dword [sym.imp.ADVAPI32.dll_CryptGenRandom]
push 0x420854
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
movzx ecx, byte [ebp - 0xa]
mov edx, dword [ebp + 8]
mov eax, dword [edx + 8]
shr ecx, 3
and ecx, 7
add esi, ecx
mov dword [esi + edi], eax
mov cl, byte [ebp - 9]
mov byte [esi + edi + 4], cl
movzx ebx, byte [ebp - 9]
shr ebx, 3
add esi, 5
and ebx, 7
cmp dword [0x42086c], 0
je 0x40152f
push 0x420854
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
mov eax, dword [0x42086c]
lea edx, [esi + edi]
push edx
push ebx
push eax
call dword [sym.imp.ADVAPI32.dll_CryptGenRandom]
push 0x420854
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
movzx ecx, byte [ebp - 9]
mov edx, dword [ebp + 8]
mov eax, dword [edx + 0xc]
shr ecx, 3
and ecx, 7
add esi, ecx
mov dword [esi + edi], eax
mov cl, byte [ebp - 8]
mov byte [esi + edi + 4], cl
movzx ebx, byte [ebp - 8]
shr ebx, 3
add esi, 5
and ebx, 7
cmp dword [0x42086c], 0
je 0x401588
push 0x420854
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
mov eax, dword [0x42086c]
lea edx, [esi + edi]
push edx
push ebx
push eax
call dword [sym.imp.ADVAPI32.dll_CryptGenRandom]
push 0x420854
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
movzx ecx, byte [ebp - 8]
mov edx, dword [ebp + 8]
mov eax, dword [edx + 0x10]
shr ecx, 3
and ecx, 7
add esi, ecx
mov dword [esi + edi], eax
mov cl, byte [ebp - 7]
mov byte [esi + edi + 4], cl
movzx ebx, byte [ebp - 7]
shr ebx, 3
add esi, 5
and ebx, 7
cmp dword [0x42086c], 0
je 0x4015e1
push 0x420854
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
mov eax, dword [0x42086c]
lea edx, [esi + edi]
push edx
push ebx
push eax
call dword [sym.imp.ADVAPI32.dll_CryptGenRandom]
push 0x420854
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
movzx ecx, byte [ebp - 7]
mov edx, dword [ebp + 8]
mov eax, dword [edx + 0x14]
shr ecx, 3
and ecx, 7
add esi, ecx
mov dword [esi + edi], eax
mov cl, byte [ebp - 6]
mov byte [esi + edi + 4], cl
movzx ebx, byte [ebp - 6]
shr ebx, 3
and ebx, 7
cmp dword [0x42086c], 0
je 0x401638
push 0x420854
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
mov eax, dword [0x42086c]
lea edx, [esi + edi + 5]
push edx
push ebx
push eax
call dword [sym.imp.ADVAPI32.dll_CryptGenRandom]
push 0x420854
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
mov ecx, dword [ebp - 4]
pop edi
pop esi
xor ecx, ebp
pop ebx
call fcn.0040942c
mov esp, ebp
pop ebp
ret