Announcement

Collapse
No announcement yet.

CPUID in NSIS?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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?

  • #2
    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

    Comment


    • #3
      parasoul
      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"

      Comment


      • #4
        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

        Comment


        • #5
          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()?

          Comment


          • #6
            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

            Comment


            • #7
              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

              Comment

              Working...
              X