Function at 0x405940
Capabilities:
Resolve function by parsing pe exports

Disassembly:
sub esp, 0x5c
push ebx
mov ebx, dword [esp + 0x64]
push ebp
push esi
push edi
xor edi, edi
mov ebp, ecx
cmp ebx, edi
mov dword [esp + 0x24], ebp
je 0x405cea
cmp dword [ebp], edi
je 0x405cea
mov eax, dword [esp + 0x74]
mov esi, dword [sym.imp.USER32.dll_CopyRect]
lea ecx, [esp + 0x5c]
push eax
push ecx
call esi
mov eax, dword [ebp]
lea ecx, [esp + 0x20]
push ecx
push eax
mov edx, dword [eax]
call dword [edx + 0x18]
mov eax, dword [ebp]
lea ecx, [esp + 0x1c]
push ecx
push eax
mov edx, dword [eax]
call dword [edx + 0x1c]
mov eax, dword [esp + 0x1c]
mov edx, dword [esp + 0x20]
mov dword [esp + 0x48], eax
mov eax, dword [esp + 0x78]
cmp eax, edi
mov dword [esp + 0x3c], edi
mov dword [esp + 0x40], edi
mov dword [esp + 0x44], edx
je 0x405a30
lea ecx, [esp + 0x3c]
push eax
push ecx
call esi
mov edx, dword [ebx + 4]
mov esi, dword [sym.imp.GDI32.dll_GetDeviceCaps]
push 0x58
push edx
call esi
mov edi, dword [sym.imp.KERNEL32.dll_MulDiv]
push eax
mov eax, dword [esp + 0x4c]
push 0x9ec
push eax
call edi
mov ecx, dword [ebx + 4]
push 0x58
push ecx
mov dword [esp + 0x50], eax
call esi
mov edx, dword [esp + 0x3c]
push eax
push 0x9ec
push edx
call edi
mov dword [esp + 0x3c], eax
mov eax, dword [ebx + 4]
push 0x58
push eax
call esi
mov ecx, dword [esp + 0x44]
push eax
push 0x9ec
push ecx
call edi
mov edx, dword [ebx + 4]
push 0x58
push edx
mov dword [esp + 0x4c], eax
call esi
push eax
mov eax, dword [esp + 0x44]
push 0x9ec
push eax
call edi
mov esi, dword [sym.imp.USER32.dll_CopyRect]
mov dword [esp + 0x40], eax
mov ecx, dword [esp + 0x74]
lea edx, [esp + 0x4c]
push ecx
push edx
call esi
lea eax, [esp + 0x34]
push 0
push eax
mov ecx, ebp
call fcn.00405880
mov ecx, dword [eax]
mov dword [esp + 0x2c], ecx
fild dword [esp + 0x2c]
mov edx, dword [eax + 4]
mov dword [esp + 0x30], edx
fstp qword [esp + 0x34]
fild dword [esp + 0x30]
fstp qword [esp + 0x2c]
fld qword [esp + 0x34]
fcomp qword [0x40b040]
fnstsw ax
test ah, 0x40
jne 0x405cea
fld qword [esp + 0x2c]
fcomp qword [0x40b040]
fnstsw ax
test ah, 0x40
jne 0x405cea
mov ecx, dword [esp + 0x1c]
mov ebp, dword [esp + 0x4c]
mov ebx, dword [esp + 0x50]
mov eax, dword [esp + 0x54]
mov edi, dword [esp + 0x58]
mov dword [esp + 0x28], ecx
neg ecx
mov dword [esp + 0x10], ecx
mov ecx, dword [esp + 0x7c]
mov edx, 1
sub eax, ebp
sub edi, ebx
mov dword [esp + 0x14], edx
test ecx, ecx
mov dword [esp + 0x18], edx
mov esi, ebp
mov dword [esp + 0x74], eax
mov dword [esp + 0x78], edi
jne 0x405b37
cdq
sub eax, edx
sar eax, 1
mov dword [esp + 0x7c], eax
fild dword [esp + 0x7c]
fcomp qword [esp + 0x34]
fild dword [esp + 0x74]
fnstsw ax
test ah, 0x41
je 0x405af4
fstp qword [esp + 0x34]
jmp 0x405b02
fdiv qword [esp + 0x34]
call sub.MSVCRT.dll__ftol
inc eax
mov dword [esp + 0x14], eax
mov eax, edi
cdq
sub eax, edx
sar eax, 1
mov dword [esp + 0x74], eax
fild dword [esp + 0x74]
fcomp qword [esp + 0x2c]
fild dword [esp + 0x78]
fnstsw ax
test ah, 0x41
jne 0x405c2b
fdiv qword [esp + 0x2c]
call sub.MSVCRT.dll__ftol
inc eax
mov dword [esp + 0x18], eax
jmp 0x405c2f
cmp ecx, edx
je 0x405c1f
cmp ecx, 0x64
je 0x405c1f
cmp ecx, 2
jne 0x405b82
fild dword [esp + 0x74]
fsub qword [esp + 0x34]
call sub.MSVCRT.dll__ftol
fild dword [esp + 0x78]
cdq
fsub qword [esp + 0x2c]
sub eax, edx
mov esi, eax
sar esi, 1
add esi, ebp
call sub.MSVCRT.dll__ftol
cdq
sub eax, edx
mov ebx, eax
mov eax, dword [esp + 0x50]
sar ebx, 1
add ebx, eax
jmp 0x405c2f
jle 0x405bc9
cmp ecx, 0x64
jge 0x405bcc
imul eax, ecx
imul edi, ecx
mov edx, eax
mov eax, 0x51eb851f
imul edx
sar edx, 5
mov eax, edx
shr eax, 0x1f
add edx, eax
mov eax, 0x51eb851f
mov dword [esp + 0x74], edx
imul edi
fild dword [esp + 0x74]
fstp qword [esp + 0x34]
sar edx, 5
mov ecx, edx
shr ecx, 0x1f
add edx, ecx
mov dword [esp + 0x74], edx
fild dword [esp + 0x74]
jmp 0x405c2b
cmp ecx, 0x64
jle 0x405c2f
mov eax, 0x51eb851f
imul ecx
sar edx, 5
mov eax, edx
shr eax, 0x1f
add edx, eax
mov eax, ecx
mov edi, edx
mov ecx, 0x64
cdq
idiv ecx
mov ecx, 0xa
mov dword [esp + 0x74], edi
fild dword [esp + 0x74]
fmul qword [esp + 0x2c]
mov eax, edx
cdq
idiv ecx
mov eax, edi
imul eax, dword [esp + 0x10]
mov ecx, edx
cdq
idiv ecx
mov dword [esp + 0x78], ecx
fidiv dword [esp + 0x78]
mov dword [esp + 0x10], eax
fstp qword [esp + 0x2c]
jmp 0x405c2f
fild dword [esp + 0x74]
fstp qword [esp + 0x34]
fild dword [esp + 0x78]
fstp qword [esp + 0x2c]
mov eax, dword [esp + 0x18]
mov dword [esp + 0x7c], esi
test eax, eax
mov dword [esp + 0x78], 0
jle 0x405cd6
mov eax, dword [esp + 0x14]
mov dword [esp + 0x74], 0
test eax, eax
jle 0x405cb2
fld qword [esp + 0x2c]
call sub.MSVCRT.dll__ftol
fld qword [esp + 0x34]
mov ebp, eax
call sub.MSVCRT.dll__ftol
mov edi, eax
mov edx, dword [esp + 0x24]
push 0
mov eax, dword [edx]
mov edx, dword [esp + 0x14]
push edx
mov edx, dword [esp + 0x28]
push edx
mov edx, dword [esp + 0x34]
mov ecx, dword [eax]
push edx
mov edx, dword [esp + 0x80]
push 0
push ebp
push edi
mov edx, dword [edx + 4]
push ebx
push esi
push edx
push eax
call dword [ecx + 0x20]
test eax, eax
jl 0x405ce5
mov eax, dword [esp + 0x74]
mov ecx, dword [esp + 0x14]
add esi, edi
inc eax
cmp eax, ecx
mov dword [esp + 0x74], eax
jl 0x405c6d
fld qword [esp + 0x2c]
mov esi, dword [esp + 0x7c]
call sub.MSVCRT.dll__ftol
mov ecx, dword [esp + 0x18]
add ebx, eax
mov eax, dword [esp + 0x78]
inc eax
cmp eax, ecx
mov dword [esp + 0x78], eax
jl 0x405c47
pop edi
pop esi
pop ebp
mov eax, 1
pop ebx
add esp, 0x5c
ret 0x10
call sub.MFC42.DLL_AfxThrowMemoryException
pop edi
pop esi
pop ebp
xor eax, eax
pop ebx
add esp, 0x5c
ret 0x10