Old 13th January 2017, 01:13   #1
parasoul
Senior Member
 
Join Date: Aug 2007
Posts: 117
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?
parasoul is offline   Reply With Quote
Old 13th January 2017, 05:33   #2
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 916
You can try calling __cpuid() with the system plugin, if that doesn't work then writing a plugin that calls it will work.

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 13th January 2017, 06:40   #3
stass
Senior Member
 
Join Date: Nov 2012
Posts: 166
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"

stass is offline   Reply With Quote
Old 13th January 2017, 13:13   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,442
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...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 13th January 2017, 19:14   #5
parasoul
Senior Member
 
Join Date: Aug 2007
Posts: 117
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()?
parasoul is offline   Reply With Quote
Old 13th January 2017, 19:48   #6
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,442
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.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 14th January 2017, 12:07   #7
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,442
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 

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
cpuid, system plug-in

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump