Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   CPUID in NSIS? (http://forums.winamp.com/showthread.php?t=399436)

parasoul 13th January 2017 01:13

CPUID in NSIS?
 
Is there a way to get the CPUID information from the assembly instruction in NSIS? Would this need to be done via plugin?

JasonFriday13 13th January 2017 05:33

You can try calling __cpuid() with the system plugin, if that doesn't work then writing a plugin that calls it will work.

stass 13th January 2017 06:40

parasoul
Quote:

get the CPUID information
code:

nsexec::exectostack "wmic /NAMESPACE:\\root\CIMV2 path Win32_Processor get ProcessorId"
pop $0
pop $1
;detailprint "$0 $1"
detailprint "$1"


Anders 13th January 2017 13:13

The only way to call CPUID directly with the system plug-in is to VirtualAlloc some memory and fill it with the machine instructions before calling it but that is probably overkill. Windows has some CPU information functions you might be able to use if you just tell us why you need to call CPUID...

parasoul 13th January 2017 19:14

I need to call CPUID because I need to see if the hyperthreading and some other features are supported on the user's computer, so I can decide what version of software to run.

__cpuid() i don't believe is an exported function, but an intrinsic function from the compiler, so I don't think that will work

Do you know of any exported winapi functions that would perform the same action as __cpuid()?

Anders 13th January 2017 19:48

Do you actually care about hyperthreading or just single threaded vs multithreaded? Some older CPUs are hyper threaded but single core and the new low-end Intel chips are multi-core but not hyper threaded. GetLogicalProcessorInformation can detect HT on Vista+ but GetActiveProcessorCount or GetProcessAffinityMask might be better if you need to know how many threads to use.

You might be able to call IsProcessorFeaturePresent to detect other features.

Anders 14th January 2017 12:07

If you absolutely want to call CPUID yourself:
PHP Code:

Section
#UINT32 WINAPI CPUID(UINT32*pEAX, UINT32*pEBX, UINT32*pECX, UINT32*pEDX)
!ifdef NSIS_IX86
System
::Call 'KERNEL32::VirtualAlloc(p0, i50, i0x3000, i0x40)p.r0'
System::Call '*$0(i0x448b5355,i0x008b0c24,i0x14244c8b,i0xa20f098b,i0x0c246c8b,i0x8b004589,i0x8910246c,i0x6c8b005d,i0x4d891424,i0x246c8b00,i0x00558918,i0x10c25d5b,&i1 00)'
!else
!
error "NSIS3+ & i386 target"
!endif


System::Call '::$0(*i 0 r1, *i.r2, *i 0 r3, *i.r4)' Call CPUID with EAX=0ECX=0

System
::Call '*(i$2,i$4,i$3,i0)p.r9'
System::Call '*$9(&m12.r5)'
System::Free $9
MessageBox MB_OK 
"Leaf 0:$\n  EAX=$1$\n  VendorID=$5"
SectionEnd 



All times are GMT. The time now is 17:19.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.