Function at 0x512820
Capabilities:
Encrypt data using rc4 ksa
Resolve function by parsing pe exports

Disassembly:
sub esp, 0x50
mov eax, dword [0x7be9b8]
xor eax, esp
mov dword [esp + 0x4c], eax
push ebx
mov ebx, dword [esp + 0x58]
push ebp
push esi
push edi
mov eax, dword [ebx + 0x40]
xor edi, edi
mov dword [esp + 0x24], ebx
mov ebp, 3
mov dword [esp + 0x1c], edi
mov dword [esp + 0x10], edi
movzx ecx, word [eax + 0x16]
movzx eax, word [eax + 0x78]
add ecx, 8
mov dword [esp + 0x28], eax
mov eax, dword [esp + 0x68]
mov esi, eax
and esi, 6
mov dword [esp + 0x40], ecx
mov dword [esp + 0x44], edi
mov dword [esp + 0x18], esi
jne 0x51288b
test al, 8
jne 0x51288b
pop edi
pop esi
pop ebp
xor eax, eax
pop ebx
mov ecx, dword [esp + 0x4c]
xor ecx, esp
call fcn.004daa4c
add esp, 0x50
ret
mov eax, dword [ebx + 0x3c]
test eax, eax
je 0x5128a4
mov eax, dword [eax + 0x3c]
test eax, eax
je 0x5128a4
push 0
push eax
call fcn.00512230
add esp, 8
mov ecx, dword [ebx + 0xc]
cmp ecx, ebp
jle 0x5128c2
mov edx, dword [ebx + 0x10]
cmp edx, 1
jle 0x5128c2
lea eax, [edx + 1]
cmp eax, ecx
jl 0x5128bf
lea edx, [ecx - 3]
jmp 0x5128c4
dec edx
jmp 0x5128c4
xor edx, edx
sub ecx, edx
mov dword [esp + 0x34], edx
cmp ecx, ebp
mov eax, 8
cmovge eax, edi
cmovl ebp, ecx
mov dword [esp + 0x2c], eax
test esi, esi
jne 0x5128e8
cmp ebp, 2
jl 0x5131f5
mov dword [esp + 0x14], edi
test ebp, ebp
jle 0x512a4f
mov eax, edx
mov esi, edx
not eax
mov dword [esp + 0x20], eax
nop
test esi, esi
js 0x512909
cmp esi, dword [ebx + 0xc]
jl 0x51291f
push 0
push 0
push str.hb_cdxPageGetKeyPage:_wrong_iKey_index.
push 0x23f1
call fcn.00448c10
add esp, 0x10
test byte [ebx + 0x20], 2
je 0x51293b
push 0
push 0
push str.hb_cdxPageGetKeyPage:_page_is_a_leaf.
push 0x23f1
call fcn.00448c10
add esp, 0x10
mov edx, dword [ebx + 0x40]
lea eax, [esi + 1]
movzx ecx, word [edx + 0x16]
add ecx, 8
imul ecx, eax
mov eax, dword [ecx + ebx + 0x54]
mov ecx, dword [ebx + 0x3c]
bswap eax
test ecx, ecx
je 0x512965
cmp dword [ecx], eax
jne 0x512965
mov dword [ebx + 0x3c], 0
jmp 0x512972
push eax
push ebx
push edx
call fcn.005147d0
add esp, 0xc
mov ecx, eax
mov edx, dword [esp + 0x14]
lea edi, [esp + 0x48]
lea eax, [edx*4]
add edi, eax
mov dword [esp + 0x3c], eax
mov dword [esp + 0x30], edi
mov edi, dword [esp + 0x1c]
mov dword [esp + eax + 0x48], ecx
test edx, edx
jle 0x512a0e
mov eax, dword [esp + eax + 0x44]
mov eax, dword [eax + 8]
mov dword [esp + 0x38], eax
cmp dword [ecx], eax
jne 0x5129c0
mov eax, dword [ecx + 4]
lea ebx, [edx*4]
mov edi, dword [esp + ebx + 0x44]
mov ebx, dword [esp + 0x24]
cmp eax, dword [edi]
mov edi, dword [esp + 0x1c]
je 0x512a0e
push dword [ecx + 4]
mov eax, dword [esp + 0x24]
push edx
push dword [ecx]
add eax, esi
push edx
mov edx, dword [esp + 0x4c]
push dword [esp + 0x48]
push eax
mov ecx, dword [esp + edx + 0x5c]
push dword [ecx]
push eax
push str._r_nchilds__d___Page_lx__childs__d___Right_lx__childs__d___Page_lx__childs__d___Left_lx
call fcn.00419640
push 1
call fcn.004e03e0
push eax
call fcn.004ec5db
push 0
push 0
push str.hb_cdxPageKeyIntBalance:_index_corrupted.
push 0x23f1
call fcn.00448c10
mov edx, dword [esp + 0x50]
add esp, 0x3c
mov eax, dword [esp + 0x30]
mov eax, dword [eax]
mov ecx, dword [eax + 0xc]
add edi, ecx
cmp ecx, dword [esp + 0x10]
mov eax, ecx
mov dword [esp + 0x1c], edi
cmovle eax, dword [esp + 0x10]
cmp ecx, dword [esp + 0x28]
mov dword [esp + 0x10], eax
cmovge ecx, dword [esp + 0x28]
inc edx
inc esi
mov dword [esp + 0x28], ecx
mov dword [esp + 0x14], edx
cmp edx, ebp
jl 0x512900
mov dword [esp + 0x10], eax
mov dword [esp + 0x28], ecx
mov eax, dword [ebx + 0x40]
movzx ecx, word [eax + 0x78]
lea eax, [edi - 1]
add eax, ecx
mov dword [esp + 0x38], ecx
cdq
idiv ecx
mov ecx, dword [esp + 0x48]
mov esi, eax
mov dword [esp + 0x14], ecx
mov dword [esp + 0x20], esi
cmp esi, 1
jne 0x512aa8
cmp ebp, 1
jle 0x512aa8
cmp dword [ecx + 4], 0xffffffff
mov edx, dword [esp + 0x38]
je 0x512aac
mov eax, dword [esp + ebp*4 + 0x44]
cmp dword [eax + 8], 0xffffffff
je 0x512aac
cmp edi, 6
jl 0x512aac
lea eax, [edx + edx*2]
sar eax, 1
cmp edi, eax
mov eax, 2
cmovg esi, eax
mov dword [esp + 0x20], esi
jmp 0x512aac
mov edx, dword [esp + 0x38]
mov eax, edx
shr eax, 1
sub dword [esp + 0x10], eax
mov eax, dword [esp + 0x10]
sub eax, dword [esp + 0x28]
inc eax
mov dword [esp + 0x28], eax
mov eax, ebp
mov ebx, dword [esp + 0x28]
sub eax, esi
cmp ebx, eax
cmovle ebx, eax
mov eax, dword [esp + 0x2c]
mov dword [esp + 0x28], ebx
mov ebx, dword [esp + 0x24]
mov dword [esp + 0x10], eax
test edi, edi
jle 0x512c50
cmp dword [esp + 0x28], 2
jge 0x512afc
cmp dword [esp + 0x18], 0
mov dword [esp + 0x10], eax
je 0x512c57
cmp ebp, 1
jne 0x512b5d
cmp edi, edx
jle 0x512b5d
mov eax, dword [ecx + 8]
cmp eax, 0xffffffff
je 0x512b5d
push eax
push ebx
push dword [ebx + 0x40]
call fcn.005147d0
mov dword [esp + 0x58], eax
mov ebp, 2
add esp, 0xc
add edi, dword [eax + 0xc]
mov eax, dword [ebx + 0x40]
mov dword [esp + 0x1c], edi
movzx ecx, word [eax + 0x78]
lea eax, [ecx - 1]
add eax, edi
cdq
idiv ecx
mov edx, dword [esp + 0x2c]
mov esi, eax
or edx, 1
mov eax, dword [esp + 0x34]
add eax, ebp
mov dword [esp + 0x20], esi
cmp eax, dword [ebx + 0xc]
cmovle edx, dword [esp + 0x2c]
mov dword [esp + 0x10], edx
jmp 0x512c4c
mov eax, edi
mov ecx, 2
cdq
idiv esi
cmp eax, ecx
cmovg ecx, eax
lea eax, [edi - 1]
add eax, esi
cdq
idiv esi
lea edx, [ebp - 1]
cmp eax, ecx
mov dword [esp + 0x30], edx
cmovle eax, ecx
cmp edx, 1
jle 0x512bd1
mov ebx, edx
mov edx, dword [esp + ebx*4 + 0x48]
mov edx, dword [edx + 0xc]
cmp edx, ecx
jl 0x512bc9
cmp edx, eax
jg 0x512bc9
push 0
push dword [esp + ebx*4 + 0x4c]
sub edi, edx
call fcn.00512230
mov eax, edi
add esp, 8
cdq
dec ebp
idiv esi
mov ecx, 2
cmp eax, ecx
cmovg ecx, eax
lea eax, [edi - 1]
add eax, esi
dec ebx
cdq
idiv esi
cmp eax, ecx
cmovle eax, ecx
cmp ebx, 1
jg 0x512b87
mov ebx, dword [esp + 0x24]
mov dword [esp + 0x1c], edi
mov edx, dword [esp + 0x2c]
mov dword [esp + 0x10], edx
cmp ebp, 2
jle 0x512c4c
mov ebx, dword [esp + 0x14]
mov dword [esp + 0x10], edx
mov edx, dword [ebx + 0xc]
cmp edx, ecx
jl 0x512c44
cmp edx, eax
jg 0x512c44
sub edi, edx
push 0
push ebx
mov dword [esp + 0x24], edi
call fcn.00512230
inc dword [esp + 0x3c]
dec ebp
add esp, 8
test ebp, ebp
jle 0x512c23
mov ecx, ebp
lea esi, [esp + 0x4c]
lea edi, [esp + 0x48]
rep movsd dword es:[edi], dword [esi]
mov ebx, dword [esp + 0x48]
mov esi, dword [esp + 0x20]
mov edi, dword [esp + 0x1c]
mov eax, edi
mov ecx, 2
cdq
idiv esi
cmp eax, ecx
cmovg ecx, eax
lea eax, [edi - 1]
add eax, esi
cdq
idiv esi
cmp eax, ecx
cmovle eax, ecx
cmp ebp, 2
jg 0x512be6
mov dword [esp + 0x14], ebx
mov ebx, dword [esp + 0x24]
mov eax, dword [esp + 0x10]
cmp dword [esp + 0x18], 0
jne 0x512c9a
cmp ebp, 2
jl 0x512c63
cmp dword [esp + 0x28], 2
jge 0x512c9a
xor esi, esi
test ebp, ebp
jle 0x5131f5
nop dword [eax]
push 0
push dword [esp + esi*4 + 0x4c]
call fcn.00512230
inc esi
add esp, 8
cmp esi, ebp
jl 0x512c70
mov eax, dword [esp + 0x10]
pop edi
pop esi
pop ebp
pop ebx
mov ecx, dword [esp + 0x4c]
xor ecx, esp
call fcn.004daa4c
add esp, 0x50
ret
test edi, edi
jle 0x512cfb
mov eax, edi
imul eax, dword [esp + 0x40]
push eax
call fcn.00470460
add esp, 4
mov dword [esp + 0x44], eax
xor edi, edi
mov dword [esp + 0x30], eax
test ebp, ebp
jle 0x512cf7
mov esi, dword [esp + 0x40]
mov ebx, eax
mov ecx, dword [esp + edi*4 + 0x48]
mov eax, dword [ecx + 0xc]
test eax, eax
jle 0x512cea
imul eax, esi
push eax
lea eax, [ecx + 0x58]
push eax
push ebx
call fcn.004dbc20
mov eax, dword [esp + edi*4 + 0x54]
add esp, 0xc
mov eax, dword [eax + 0xc]
imul eax, esi
add ebx, eax
inc edi
cmp edi, ebp
jl 0x512cc2
mov ebx, dword [esp + 0x24]
mov esi, dword [esp + 0x20]
mov edi, dword [esp + 0x1c]
cmp esi, ebp
jle 0x512f02
cmp ebp, 2
jge 0x512d0e
mov dword [esp + 0x20], ebp
jmp 0x512d1d
lea eax, [ebp - 1]
mov dword [esp + 0x20], eax
mov eax, dword [esp + eax*4 + 0x48]
mov dword [esp + ebp*4 + 0x48], eax
mov esi, dword [ebx + 0x40]
mov eax, dword [esi + 0x7c]
movzx ecx, word [eax + 0x2e]
movzx eax, word [esi + 0x16]
add ecx, 0x54
add eax, ecx
push eax
push 0
push eax
call fcn.00470460
add esp, 4
push eax
call fcn.004dc1a0
push 0
mov dword [esp + 0x28], eax
mov byte [eax + 0x20], 0xff
mov dword [eax + 8], 0xffffffff
mov dword [eax + 4], 0xffffffff
mov dword [eax + 0x40], esi
push dword [esi + 0x7c]
call fcn.00510950
mov ecx, dword [esp + 0x2c]
add esp, 0x14
mov dword [ecx], eax
mov dword [ecx + 0x24], 1
mov dword [ecx + 0x44], 0
mov eax, dword [esi + 0xa4]
mov dword [ecx + 0x48], eax
mov dword [esi + 0xa4], ecx
mov esi, ecx
mov eax, dword [esi + 0x48]
test eax, eax
je 0x512d97
mov dword [eax + 0x44], esi
mov eax, dword [esp + 0x20]
lea ecx, [esp + 0x48]
lea ecx, [ecx + eax*4]
mov dword [esi + 0x38], ebx
mov dword [esi + 0x10], 0xffffffff
mov dword [esp + 0x2c], ecx
mov dword [ecx], esi
mov ecx, dword [esp + ebp*4 + 0x48]
mov word [esi + 0x20], 0x100
mov dword [esi + 0xc], 0
mov dword [esi + 0x24], 1
mov ecx, dword [ecx]
mov dword [esp + 0x24], ecx
mov ecx, dword [esp + 0x34]
add ecx, eax
mov eax, dword [ebx + 0x40]
mov dword [esp + 0x18], ecx
movzx eax, word [eax + 0x16]
mov dword [esp + 0x14], eax
add eax, 8
mov dword [esp + 0x3c], eax
imul eax, ecx
test byte [ebx + 0x20], 2
mov dword [esp + 0x30], eax
je 0x512e13
push 0
push 0
push str.hb_cdxPageIntSetKey:_page_is_a_leaf_
push 0x23f1
call fcn.00448c10
mov ecx, dword [esp + 0x28]
add esp, 0x10
test ecx, ecx
js 0x512e1f
mov eax, dword [ebx + 0xc]
inc eax
cmp ecx, eax
jl 0x512e39
push 0
push 0
push str.hb_cdxPageIntSetKey:_wrong_iKey_index.
push 0x23f1
call fcn.00448c10
mov ecx, dword [esp + 0x28]
add esp, 0x10
mov edx, dword [esp + 0x30]
mov eax, dword [ebx + 0xc]
add edx, 0x58
add edx, ebx
mov dword [esp + 0x18], edx
cmp ecx, eax
jge 0x512e6f
sub eax, ecx
imul eax, dword [esp + 0x3c]
push eax
mov eax, dword [esp + 0x18]
add eax, 8
push edx
add eax, edx
push eax
call fcn.004dbc20
mov eax, dword [ebx + 0xc]
add esp, 0xc
mov edx, dword [esp + 0x18]
push dword [esp + 0x14]
inc eax
mov dword [ebx + 0xc], eax
mov eax, dword [ebx + 0x40]
movzx eax, byte [eax + 0x1a]
push eax
push edx
call fcn.004dc1a0
mov eax, dword [esp + 0x24]
add esp, 0xc
mov ecx, dword [esp + 0x14]
mov edx, dword [esp + 0x24]
bswap edx
mov dword [ecx + eax + 4], edx
mov ecx, dword [esp + 0x2c]
mov dword [ebx + 0x24], 1
mov ecx, dword [ecx - 4]
mov eax, dword [ecx]
mov dword [esi + 4], eax
mov eax, dword [ecx + 8]
mov dword [esi + 8], eax
mov eax, dword [esi]
mov dword [ecx + 8], eax
mov eax, dword [esp + 0x20]
cmp eax, ebp
jge 0x512ecf
mov ecx, dword [esp + eax*4 + 0x4c]
inc ebp
mov eax, dword [esi]
mov dword [ecx + 4], eax
jmp 0x513020
cmp dword [esi + 8], 0xffffffff
je 0x512efc
mov eax, dword [esp + ebp*4 + 0x48]
push dword [eax + 8]
push ebx
push dword [ebx + 0x40]
call fcn.005147d0
mov ecx, dword [esi]
push 0
push eax
mov dword [eax + 4], ecx
mov dword [eax + 0x24], 1
call fcn.00512230
add esp, 0x14
inc ebp
jmp 0x513020
jge 0x513025
cmp esi, 1
jle 0x512f30
mov edx, dword [esp + ebp*4 + 0x44]
mov ecx, dword [esp + esi*4 + 0x40]
mov eax, dword [edx]
mov dword [ecx + 8], eax
mov eax, dword [ecx]
mov dword [edx + 4], eax
mov eax, dword [esp + esi*4 + 0x44]
mov dword [esp + ebp*4 + 0x44], eax
mov dword [esp + esi*4 + 0x44], edx
jmp 0x512fcc
mov ecx, dword [esp + 0x14]
test esi, esi
jle 0x512f53
cmp dword [ecx + 4], 0xffffffff
jne 0x512f53
mov eax, dword [esp + ebp*4 + 0x44]
mov dword [esp + ebp*4 + 0x44], ecx
mov dword [esp + 0x48], eax
mov dword [eax + 4], 0xffffffff
jmp 0x512fcc
mov eax, dword [esp + ebp*4 + 0x44]
mov edx, dword [eax + 8]
mov dword [esp + 0x18], edx
test esi, esi
jle 0x512f71
mov eax, dword [esp + esi*4 + 0x44]
mov ecx, dword [eax]
mov dword [esp + 0x14], ecx
mov dword [eax + 8], edx
jmp 0x512fa4
mov ecx, dword [ecx + 4]
mov dword [esp + 0x14], ecx
cmp ecx, 0xffffffff
je 0x512fa4
push ecx
push ebx
push dword [ebx + 0x40]
call fcn.005147d0
mov ecx, dword [esp + 0x24]
push 0
push eax
mov dword [eax + 8], ecx
mov dword [eax + 0x24], 1
call fcn.00512230
mov edx, dword [esp + 0x2c]
add esp, 0x14
cmp edx, 0xffffffff
je 0x512fcc
push edx
push ebx
push dword [ebx + 0x40]
call fcn.005147d0
mov ecx, dword [esp + 0x20]
push 0
push eax
mov dword [eax + 4], ecx
mov dword [eax + 0x24], 1
call fcn.00512230
add esp, 0x14
dec ebp
cmp ebp, esi
jl 0x51301e
mov edi, dword [esp + 0x34]
lea eax, [edi + ebp]
push eax
push ebx
call fcn.00512650
mov eax, dword [esp + ebp*4 + 0x50]
push 0
push eax
mov dword [eax + 0x38], 0
mov dword [eax + 0x24], 0
mov byte [eax + 0x20], 0xff
mov dword [eax + 4], 0xffffffff
mov dword [eax + 8], 0xffffffff
mov dword [eax + 0xc], 0
call fcn.00512230
dec ebp
add esp, 0x10
cmp ebp, esi
jge 0x512fd5
mov edi, dword [esp + 0x1c]
mov ebp, esi
or dword [esp + 0x10], 8
test edi, edi
jle 0x5131d8
mov eax, dword [ebx + 0x40]
cmp word [eax + 0x78], 2
jne 0x51304e
cmp ebp, 2
jle 0x51304e
lea eax, [ebp*2 - 1]
cmp edi, eax
jne 0x51304e
mov eax, 1
jmp 0x513050
xor eax, eax
mov ecx, dword [esp + 0x44]
xor edi, edi
mov dword [esp + 0x2c], eax
mov dword [esp + 0x24], ecx
test ebp, ebp
jle 0x5131cc
test eax, eax
je 0x513077
cmp edi, 1
jne 0x513077
mov esi, edi
mov dword [esp + 0x18], esi
jmp 0x51308d
mov eax, dword [esp + 0x1c]
mov ecx, ebp
sub eax, edi
sub ecx, edi
dec eax
add eax, ebp
cdq
idiv ecx
mov esi, eax
mov dword [esp + 0x18], eax
mov ecx, dword [ebx + 0x40]
movzx ecx, word [ecx + 0x78]
cmp esi, ecx
jle 0x5130ae
push 0
push 0
push str.hb_cdxPageKeyIntBalance:_iNodeKeys_calculated_wrong_
push 0x23f1
call fcn.00448c10
add esp, 0x10
imul esi, dword [esp + 0x40]
mov eax, dword [esp + edi*4 + 0x48]
add eax, 0x58
push esi
push dword [esp + 0x28]
push eax
call fcn.004dbc20
mov ecx, dword [esp + edi*4 + 0x54]
add esp, 0xc
mov eax, dword [esp + 0x18]
mov edx, dword [esp + 0x34]
add dword [esp + 0x24], esi
add edx, edi
sub dword [esp + 0x1c], eax
mov dword [ecx + 0xc], eax
mov dword [ecx + 0x24], 1
mov dword [esp + 0x30], edx
cmp edx, dword [ebx + 0xc]
jge 0x5131b4
mov eax, dword [esp + 0x24]
mov esi, dword [eax - 8]
mov eax, dword [ecx]
mov dword [esp + 0x18], eax
mov eax, dword [esp + 0x24]
sub eax, dword [esp + 0x40]
mov dword [esp + 0x3c], eax
mov eax, dword [ebx + 0x40]
bswap esi
movzx eax, word [eax + 0x16]
mov dword [esp + 0x14], eax
add eax, 8
imul eax, edx
test byte [ebx + 0x20], 2
mov dword [esp + 0x20], eax
je 0x513145
push 0
push 0
push str.hb_cdxPageIntSetKey:_page_is_a_leaf_
push 0x23f1
call fcn.00448c10
mov edx, dword [esp + 0x40]
add esp, 0x10
mov eax, dword [ebx + 0xc]
test edx, edx
js 0x513150
cmp edx, eax
jl 0x513166
push 0
push 0
push str.hb_cdxPageIntSetKey:_wrong_iKey_index.
push 0x23f1
call fcn.00448c10
add esp, 0x10
mov eax, dword [esp + 0x3c]
test eax, eax
je 0x513185
push dword [esp + 0x14]
push eax
mov eax, dword [esp + 0x28]
add eax, 0x58
add eax, ebx
push eax
call fcn.004dbc20
add esp, 0xc
mov ecx, dword [esp + 0x14]
test esi, esi
je 0x513199
mov eax, dword [esp + 0x20]
add eax, ecx
bswap esi
mov dword [eax + ebx + 0x58], esi
mov eax, dword [esp + 0x20]
mov edx, dword [esp + 0x18]
add eax, ecx
mov ecx, dword [esp + edi*4 + 0x48]
bswap edx
mov dword [eax + ebx + 0x5c], edx
mov dword [ebx + 0x24], 1
push 0
push ecx
call fcn.00512230
mov eax, dword [esp + 0x34]
inc edi
add esp, 8
cmp edi, ebp
jl 0x513066
push dword [esp + 0x44]
call fcn.00470430
add esp, 4
mov eax, dword [ebx + 0x40]
mov dword [ebx + 0x24], 1
movzx ecx, word [eax + 0x78]
mov eax, dword [esp + 0x10]
or eax, 2
cmp dword [ebx + 0xc], ecx
cmovle eax, dword [esp + 0x10]
mov ecx, dword [esp + 0x5c]
pop edi
pop esi
pop ebp
pop ebx
xor ecx, esp
call fcn.004daa4c
add esp, 0x50
ret