CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Other Programming > Assembly
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Assembly Questions and Answers for Assembly here!

    Reply
     
    Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 5.00 average. Display Modes
      #1    
    Old August 22nd, 2004, 07:31 AM
    ovidiucucu's Avatar
    ovidiucucu ovidiucucu is offline
    Moderator/Reviewer
    Power Poster
     
    Join Date: Feb 2003
    Location: Iasi - Romania
    Posts: 6,518
    ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)
    [RESOLVED] How to get Processor Serial Number

    Well, this question was posted tens times.
    I know that acual Intel/AMD CPUs does not support Processor Serial Number.
    Next function demonstrates this. Executing CPUID with EAX=1, and then test bit 18 of EDX (Processor Serial Number feature flag - is always '0').
    Code:
    bool CPU::IsCPUSerialSupported()
    {
       bool bSupported = false;
       DWORD cpufeat   = 0;
       _asm
       {
          xor    eax, eax
          inc    eax
          CPUID
          mov    cpufeat, edx
       }
       if(0x00040000 & cpufeat) // get bit 18 
       {
          bSupported = true;
       }
       return bSupported;
    }
    Sorry for mixing C++ with assembly code (I'm not an assemblyguru )
    In fact, MY QUESTION IS:
    Does enybody know why it is not supported?
    Is it not possible for the manufacturer to assure an unique one, or it's a privacy reason, or someting else?
    Also, does enybody know if this will be changed in the future?
    __________________
    Ovidiu Cucu
    Reply With Quote
      #2    
    Old August 22nd, 2004, 08:52 AM
    Bornish's Avatar
    Bornish Bornish is offline
    Senior Member
     
    Join Date: Aug 2004
    Location: Bucharest, Romania... sometimes
    Posts: 1,031
    Bornish is a splendid one to behold (750+)Bornish is a splendid one to behold (750+)Bornish is a splendid one to behold (750+)Bornish is a splendid one to behold (750+)Bornish is a splendid one to behold (750+)Bornish is a splendid one to behold (750+)Bornish is a splendid one to behold (750+)Bornish is a splendid one to behold (750+)
    no rules

    Hi Ovidiu!
    Interesting subject you're bringing. Don't know too much about so many processors types and manufacturers, so you've made me curious about it.
    It seems same as for graphics cards, or in fact, for most of the hardware, ... there're no rules constraining the manufacturers about certain things.
    Did search about more info and came across some nice links.
    Just in case it might bring you something useful:
    http://osdev.berlios.de/cpuid.html
    http://www.sandpile.org/ia32/cpuid.htm
    http://www.ka9q.net/code/cpuid/
    http://grafi.ii.pw.edu.pl/gbm/x86/cpuid.html
    http://www.paradicesoftware.com/specs/cpuid/

    Best part I've read on this subject was:
    Quote:
    Originally Posted by PARADICE Software
    Unfortunately, there is a small problem with just calling CPUID to find the CPU information, and that is: If the CPU you are running on does not support CPUID, it will crash (or, as the OS likes to call it, an "Invalid Instruction Exception"). There is a method of "checking" the CPU to see if it supports CPUID, but (of course) the check only works on 486+ class CPUs. Relax, though, because the process (and appropriate source code) to find out as much information as possible from any given CPU type is here, in flow-chart form (this assumes you are using at least a 386, which is a moot point as any compiler you'll find nowadays will require at least a 386 processor)
    Best of luck,
    __________________
    Bogdan Apostol
    ESRI Developer Network

    Compilers demystified - Function pointers in Visual Basic 6.0
    Enables the use of function pointers in VB6 and shows how to embed native code in a VB application.

    Customize your R2H
    The unofficial board dedicated to ASUS R2H UMPC owners.
    Reply With Quote
      #3    
    Old August 22nd, 2004, 09:48 AM
    ovidiucucu's Avatar
    ovidiucucu ovidiucucu is offline
    Moderator/Reviewer
    Power Poster
     
    Join Date: Feb 2003
    Location: Iasi - Romania
    Posts: 6,518
    ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)
    Thank you for the answer and for useful links.
    What is strange is that it seems the manufacturers "made place" for Processor Serial Number, (CPUID function 3 (EAX=3)), but did not implement it. Why?
    I attached a little test application in this long thread (cpuid.zip).
    Even the maximum CPUID function reported is 2 (and also PSN flag is '0'), it executes (just for testing) CPUID with EAX=3.
    Well, it not chrashes but the results are the same as for function 2.
    So, from Processor Serial Number point of view this is garbage
    __________________
    Ovidiu Cucu
    Reply With Quote
      #4    
    Old August 22nd, 2004, 04:21 PM
    indiocolifa's Avatar
    indiocolifa indiocolifa is offline
    Member +
     
    Join Date: Dec 2002
    Location: La Plata, Buenos Aires
    Posts: 604
    indiocolifa is on a distinguished road (30+)
    take in consideration that in most motherboards the processor serial number becomes disabled by default, so it's not worth programming anything with a feature that it's useless..
    __________________
    Visit my page: http://usuarios.lycos.es/hernandp and my blog... http://hernandp.blogspot.com
    Reply With Quote
      #5    
    Old August 24th, 2004, 09:30 AM
    marsh_pottaye marsh_pottaye is offline
    Member
     
    Join Date: Oct 2003
    Location: Romania
    Posts: 127
    marsh_pottaye will become famous soon enough (80+)
    Quote:
    Originally Posted by indiocolifa
    take in consideration that in most motherboards the processor serial number becomes disabled by default, so it's not worth programming anything with a feature that it's useless..
    You mean the motherboards disables the processor serial number, in a hardware way (e.g. by connect a pin to ground)?
    Not very clear, please explain more.
    __________________
    VOTE HERE!
    Reply With Quote
      #6    
    Old August 24th, 2004, 02:20 PM
    indiocolifa's Avatar
    indiocolifa indiocolifa is offline
    Member +
     
    Join Date: Dec 2002
    Location: La Plata, Buenos Aires
    Posts: 604
    indiocolifa is on a distinguished road (30+)
    Re: How to get Processor Serial Number

    I mean that the motherboard BIOS disables the processor serial number (this is configurable with the CMOS Setup) but suppose that you program an application that effectively uses that Serial Number. In fact, in most mobos the default setting is Processor SN : DISABLED.

    I do not recommend using this "feature" because : 1) from the end user perspective: many users won't want to touch any obscure CMOS setup 2) this SN feature can issue some privacy problems, and that's the reason why the PIII Serial Number exposition to the outside was so blamed in the past.
    __________________
    Visit my page: http://usuarios.lycos.es/hernandp and my blog... http://hernandp.blogspot.com
    Reply With Quote
      #7    
    Old August 25th, 2004, 03:24 AM
    ovidiucucu's Avatar
    ovidiucucu ovidiucucu is offline
    Moderator/Reviewer
    Power Poster
     
    Join Date: Feb 2003
    Location: Iasi - Romania
    Posts: 6,518
    ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)
    Re: How to get Processor Serial Number

    Quote:
    Originally Posted by indiocolifa
    I mean that the motherboard BIOS disables the processor serial number (this is configurable with the CMOS Setup) but suppose that you program an application that effectively uses that Serial Number. In fact, in most mobos the default setting is Processor SN : DISABLED.

    I do not recommend using this "feature" because : 1) from the end user perspective: many users won't want to touch any obscure CMOS setup 2) this SN feature can issue some privacy problems, and that's the reason why the PIII Serial Number exposition to the outside was so blamed in the past.
    Quite clear. Thanks for the aswer!
    This is a frequently posted problem in other forums, so I thought this is the best place where it can be clarified for everybody once and forever.
    __________________
    Ovidiu Cucu
    Reply With Quote
      #8    
    Old December 21st, 2004, 04:31 AM
    ovidiucucu's Avatar
    ovidiucucu ovidiucucu is offline
    Moderator/Reviewer
    Power Poster
     
    Join Date: Feb 2003
    Location: Iasi - Romania
    Posts: 6,518
    ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)
    Re: How to get Processor Serial Number

    I have found this interesting comment in another discussion forum:
    Quote:
    Originally Posted by Norm Dresner
    It was a feature that software sellers desperately wanted to enable
    locking a license to a single CPU -- but there was so much outcry from the
    software pirates who wanted to be able to steal that software that Intel
    caved in to "popular pressure" and made the feature disableable -- which
    means that it'll always be disabled. It's unfortunate that the market
    caters to thieves.
    That's it.
    __________________
    Ovidiu Cucu

    Last edited by ovidiucucu; December 21st, 2004 at 04:34 AM.
    Reply With Quote
      #9    
    Old December 26th, 2004, 12:46 PM
    NoHero's Avatar
    NoHero NoHero is offline
    Moderator
     
    Join Date: Mar 2004
    Location: (Upper-) Austria
    Posts: 2,899
    NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)
    Re: How to get Processor Serial Number

    Don't trust thirdparty information.
    Take a look at the Intel Developer Resource:

    ftp://download.intel.com/design/Xeon...s/24161827.pdf

    Quote:
    The Brand string is a new extension to the CPUID instruction implemented in some Intel IA-32
    processors, including the Pentium 4 processor. Using the brand string feature, future IA-32
    architecture based processors will return their ASCII brand identification string and maximum
    operating frequency via an extended CPUID instruction. Note that the frequency returned is the
    maximum operating frequency that the processor has been qualified for and not the current
    operating frequency of the processor.
    When CPUID is executed with EAX set to the values listed in Table 1, the processor will return
    an ASCII brand string in the general-purpose registers as detailed in Table 1.
    The brand/frequency string is defined to be 48 characters long, 47 bytes will contain characters
    and the 48th byte is defined to be NULL (0). A processor may return less than the 47 ASCII
    characters as long as the string is null terminated and the processor returns valid data when
    CPUID is executed with EAX = 80000002h, 80000003h and 80000004h.
    The cpuid3a.asm program shows how software forms the brand string (see Example 1). To
    determine if the brand string is supported on a processor, software must follow the step below:
    1. Execute the CPUID instruction with EAX=80000000h
    2. If ((returned value in EAX) > 80000000h) then the processor supports the extended CPUID
    functions and EAX contains the largest extended function supported.
    3. The processor brand string feature is supported if EAX >= 80000004h
    __________________
    I am not offering technical guidiance via email or IM
    Come on share your photo with us! CG members photo album!
    Use the Code Tags!
    Reply With Quote
      #10    
    Old July 10th, 2005, 10:36 AM
    ovidiucucu's Avatar
    ovidiucucu ovidiucucu is offline
    Moderator/Reviewer
    Power Poster
     
    Join Date: Feb 2003
    Location: Iasi - Romania
    Posts: 6,518
    ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)ovidiucucu has a reputation beyond repute (3000+)
    Resolved Re: [RESOLVED] How to get Processor Serial Number

    Resolved.
    __________________
    Ovidiu Cucu
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Other Programming > Assembly


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    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


    All times are GMT -5. The time now is 03:04 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009