Function at 0x10032060
Capabilities:
Encrypt data using rc4 ksa

Disassembly:
sub esp, 0x10
push ebx
push ebp
mov ebp, dword [esp + 0x20]
mov bx, dx
mov dword [esp + 0xc], ecx
push esi
push edi
test ebp, ebp
je 0x100320b6
mov esi, dword [ebp]
mov ecx, 0x10
mov eax, ecx
lea edx, [esi + 0x130]
and edx, 0xf
sub eax, edx
neg edx
sbb edx, edx
and edx, eax
cmp word [edx + esi + 0x146], cx
jae 0x100320b6
lea eax, [esi + 0x130]
and eax, 0xf
lea edi, [esi + 0x160]
sub ecx, eax
neg eax
sbb eax, eax
and eax, ecx
add edi, eax
jmp 0x100320b8
xor edi, edi
movzx eax, bx
cmp eax, 1
jbe 0x10032209
cmp eax, 3
jne 0x100322c5
lea eax, [esp + 0x18]
push eax
lea eax, [esp + 0x14]
push eax
lea eax, [esp + 0x24]
push eax
push 0x140
push dword [esp + 0x24]
call fcn.1017e7e0
mov cl, byte [esp + 0x38]
mov eax, 1
mov ebx, dword [esp + 0x2c]
mov esi, dword [esp + 0x24]
mov ebp, dword [esp + 0x30]
mov edx, ebp
shl eax, cl
push ebx
push esi
mov ecx, eax
mov dword [esp + 0x44], eax
call fcn.10031d40
add esp, 0x1c
cmp ax, 0x10
jne 0x100321b6
mov eax, dword [esp + 0x28]
add eax, 0xffffffff
mov dword [esp + 0x28], eax
js 0x100322c5
lea edi, [edi + eax*4]
sub ebp, esi
lea ecx, [esi + eax*2]
inc edi
sub ebx, esi
mov esi, ecx
nop dword [eax + eax]
movzx eax, word [esi + ebp]
lea esi, [esi - 2]
imul ecx, eax, 0xff
lea edi, [edi - 4]
mov eax, 0x80008001
imul ecx
add edx, ecx
sar edx, 0xf
mov eax, edx
shr eax, 0x1f
add eax, edx
mov byte [edi + 5], al
movzx eax, word [esi + 2]
imul ecx, eax, 0xff
mov eax, 0x80008001
imul ecx
add edx, ecx
sar edx, 0xf
mov eax, edx
shr eax, 0x1f
add eax, edx
mov byte [edi + 4], al
movzx eax, word [ebx + esi + 2]
imul ecx, eax, 0xff
mov eax, 0x80008001
imul ecx
add edx, ecx
sar edx, 0xf
mov eax, edx
shr eax, 0x1f
add eax, edx
sub dword [esp + 0x28], 1
mov byte [edi + 3], al
jns 0x10032140
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x10
ret
mov esi, dword [esp + 0x28]
sub esi, 1
js 0x100322c5
mov eax, dword [esp + 0x10]
lea edx, [esi*4 + 1]
add edx, edi
sub ebp, eax
sub ebx, eax
lea ecx, [eax + esi*2]
nop word [eax + eax]
sub esi, 1
movzx eax, byte [ecx + ebp]
mov byte [edx + 1], al
lea ecx, [ecx - 2]
movzx eax, byte [ecx + 2]
lea edx, [edx - 4]
mov byte [edx + 4], al
movzx eax, byte [ecx + ebx + 2]
mov byte [edx + 3], al
jns 0x100321e0
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x10
ret
mov eax, dword [esp + 0x24]
cmp ax, 1
jne 0x1003224b
test bx, bx
jne 0x10032230
mov word [edi + 4], bx
mov byte [edi + 6], bl
mov word [edi], 0xffff
mov byte [edi + 2], 0xff
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x10
ret
mov word [edi], 0
mov byte [edi + 2], 0
mov word [edi + 4], 0xffff
mov byte [edi + 6], 0xff
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x10
ret
cmp ax, 4
je 0x10032257
cmp ax, 8
jne 0x100322c5
push ebp
call sym.FreeImage.dll__FreeImage_GetColorsUsed_4
mov esi, eax
cmp bx, 1
jne 0x1003229b
test esi, esi
jle 0x100322c5
mov eax, 0xff
lea ecx, [esi - 1]
cdq
xor ebx, ebx
idiv ecx
lea ecx, [edi + 2]
nop dword [eax]
mov byte [ecx - 2], bl
lea ecx, [ecx + 4]
mov byte [ecx - 5], bl
mov byte [ecx - 4], bl
add ebx, eax
sub esi, 1
jne 0x10032280
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x10
ret
test esi, esi
jle 0x100322c5
mov eax, 0xffffff01
lea ecx, [esi - 1]
cdq
idiv ecx
lea edx, [edi + 2]
mov ecx, 0xff
mov byte [edx - 2], cl
lea edx, [edx + 4]
mov byte [edx - 5], cl
mov byte [edx - 4], cl
add ecx, eax
sub esi, 1
jne 0x100322b2
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x10
ret