Function at 0x404040
Capabilities:
Encrypt data using aes via winapi
Get file size
Write file on windows

Disassembly:
push ebp
mov ebp, esp
sub esp, 0x48
push ebx
push esi
mov esi, ecx
push edi
mov dword [ebp - 0xc], esi
call fcn.00403bf0
test al, al
je 0x4040f5
lea eax, [ebp - 0x34]
push eax
mov eax, dword [ebp + 8]
push dword [eax]
call dword [sym.imp.KERNEL32.dll_GetFileSizeEx]
test eax, eax
je 0x4040f5
mov edi, dword [ebp - 0x34]
mov ebx, dword [ebp - 0x30]
mov eax, edi
or eax, ebx
je 0x4040f5
cmp byte [ebp + 0x10], 0
je 0x404117
mov eax, dword [esi + 0xc]
lea ecx, [esi + 0xc]
mov dword [ebp - 8], ecx
sub eax, 0
je 0x4040a7
dec eax
jne 0x4040f5
mov dword [ebp - 0x14], 0xa400
mov eax, 0x1000000
jmp 0x4040b0
mov dword [ebp - 0x14], 0x6610
xor eax, eax
mov dword [ebp - 0x10], eax
call fcn.00404620
test al, al
je 0x4040f5
mov ecx, dword [esi + 0x14]
lea eax, [esi + 0x14]
mov dword [ebp - 0x20], eax
test ecx, ecx
je 0x4040d3
push ecx
call dword [sym.imp.ADVAPI32.dll_CryptDestroyKey]
mov eax, dword [ebp - 0x20]
push eax
mov eax, dword [ebp - 0x10]
or eax, 1
push eax
push dword [ebp - 0x14]
push dword [esi + 0x10]
call dword [sym.imp.ADVAPI32.dll_CryptGenKey]
test eax, eax
jne 0x404100
mov eax, dword [ebp - 8]
mov dword [eax + 8], 0
xor al, al
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret 0xc
push dword [ebp + 0xc]
mov ecx, esi
call fcn.00403d70
test al, al
jne 0x404165
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret 0xc
mov eax, dword [esi + 0x2c]
test ebx, ebx
ja 0x404124
jb 0x4040f5
cmp edi, eax
jb 0x4040f5
mov ecx, dword [esi + 0x30]
sub edi, eax
push 1
sbb ebx, 0
add ecx, 0x14
add eax, 0xffffffec
push eax
push ecx
push eax
mov dword [ebp - 0x20], ecx
push ecx
mov ecx, esi
call fcn.00404a50
mov edx, eax
cmp edx, 0xc
jbe 0x4040f5
mov ecx, dword [ebp - 0x20]
cmp dword [ecx + 8], 0x20
jne 0x4040f5
lea eax, [esi + 0xc]
push edx
push ecx
mov ecx, eax
mov dword [ebp - 8], eax
call fcn.004046c0
test al, al
je 0x4040f5
mov eax, dword [esi + 0x28]
xorps xmm0, xmm0
movq qword [ebp - 0x43], xmm0
mov dword [ebp - 0x44], eax
lea eax, [esi + 0xc]
mov ecx, eax
mov dword [ebp - 0x3b], 0
mov word [ebp - 0x37], 0
mov byte [ebp - 0x35], 0
call fcn.004048a0
cmp ax, 0x10
jne 0x4040f5
push 0
lea eax, [ebp - 0x44]
push eax
push 1
push dword [esi + 0x14]
call dword [sym.imp.ADVAPI32.dll_CryptSetKeyParam]
test eax, eax
je 0x4040f5
mov ecx, dword [esi + 0x34]
xor edx, edx
cmp byte [ebp + 0x10], dl
mov eax, dword [ecx]
push 0
mov eax, dword [eax]
sete dl
push 0
push ebx
push edi
mov dword [ebp - 0x18], edi
mov dword [ebp - 0x14], ebx
push edx
mov dword [ebp - 0x28], edx
call eax
test al, al
je 0x4040f5
test ebx, ebx
jne 0x4041e8
test edi, edi
je 0x4042d1
test ebx, ebx
jb 0x404202
ja 0x4041f4
cmp edi, 0x4000
jbe 0x404202
mov eax, 0x4000
mov dword [ebp - 0x20], 0
jmp 0x404207
mov eax, edi
mov dword [ebp - 0x20], ebx
mov ecx, dword [ebp + 8]
push eax
push dword [esi + 0x30]
call fcn.00405250
mov dword [ebp - 0x20], eax
test eax, eax
jle 0x4040f5
sub edi, eax
sbb ebx, 0
mov ecx, edi
or ecx, ebx
mov byte [ebp - 0x10], 1
je 0x404231
mov byte [ebp - 0x10], 0
mov edx, dword [ebp - 0x18]
mov eax, dword [ebp - 0x14]
mov ecx, dword [esi + 0x34]
sub edx, edi
mov esi, dword [ecx]
sbb eax, ebx
push eax
mov eax, dword [esi]
push edx
push dword [ebp - 0x14]
push dword [ebp - 0x18]
push dword [ebp - 0x28]
call eax
test al, al
je 0x4040f5
cmp byte [ebp + 0x10], 0
mov eax, dword [ebp - 0xc]
push dword [ebp - 0x10]
mov ecx, dword [ebp - 8]
mov eax, dword [eax + 0x30]
je 0x40427a
push 0x4010
push eax
push dword [ebp - 0x20]
push eax
call fcn.004048f0
jmp 0x404289
push 0x4000
push eax
push dword [ebp - 0x20]
push eax
call fcn.00404a50
mov esi, eax
cmp esi, 0xffffffff
je 0x4040f5
test esi, esi
je 0x4042c1
push 0
lea eax, [ebp - 0x30]
push eax
mov eax, dword [ebp - 0xc]
push esi
push dword [eax + 0x30]
mov eax, dword [ebp + 0xc]
push dword [eax]
call dword [sym.imp.KERNEL32.dll_WriteFile]
test eax, eax
je 0x4040f5
cmp dword [ebp - 0x30], esi
jne 0x4040f5
test ebx, ebx
jne 0x4042c9
test edi, edi
je 0x4042d1
mov esi, dword [ebp - 0xc]
jmp 0x4041e6
pop edi
pop esi
mov al, 1
pop ebx
mov esp, ebp
pop ebp
ret 0xc