Solved

Get processor ID or Motherboard ID

Posted on 2003-11-20
22
63,797 Views
Last Modified: 2011-08-18
How can I get one of them?

Motaz
0
Comment
Question by:Motaz
  • 8
  • 7
  • 3
  • +3
22 Comments
 
LVL 8

Expert Comment

by:gmayo
Comment Utility
http://www.torry.net/cpu.htm has what you want, most with source.

Geoff M.
0
 
LVL 5

Expert Comment

by:snehanshu
Comment Utility
From:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_11054364.html

HTH,
...Shu

Comment from Olympus
Date: 08/21/2000 06:05AM IST
 Author Comment  

im sure theres an assembly function that returns something you can convert to the specific processor type string..


 
Comment from ckaneta
Date: 08/21/2000 08:20AM IST
 Comment  

well, that code I mentioned uses an awful lot of assembly
here it is
------------------------------------
/////////////////////////////////////////////////////////////////////////////
// (c) NPS, 1997                  - Idea, realisation, adoptation IsCPUID_Available) //
//                        kvk@estpak.ee                                    //
// (c) Alex Abreu, 1997 - IsCPUID_Available source and idea                //
//                        simonet@bhnet.com.br                             //
/////////////////////////////////////////////////////////////////////////////

interface

uses
  Windows,
  Messages,
  SysUtils,
  Classes,
  Graphics,
  Controls,
  Forms,
  Dialogs,
  ExtCtrls,
  StdCtrls,
  Buttons;

type
  TDemoForm = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    GetButton: TBitBtn;
    CloseButton: TBitBtn;
    Bevel1: TBevel;
    Label5: TLabel;
    FLabel: TLabel;
    MLabel: TLabel;
    PLabel: TLabel;
    SLabel: TLabel;
    PValue: TLabel;
    FValue: TLabel;
    MValue: TLabel;
    SValue: TLabel;
    procedure GetButtonClick(Sender: TObject);
  end;

var
  DemoForm: TDemoForm;

implementation

{$R *.DFM}

const
     ID_BIT     =     $200000;               // EFLAGS ID bit
type
     TCPUID     = array[1..4] of Longint;
     TVendor     = array [0..11] of char;

function IsCPUID_Available : Boolean; register;
asm
     PUSHFD                                   {direct access to flags no possible, only via stack}
  POP     EAX                         {flags to EAX}
  MOV     EDX,EAX               {save current flags}
  XOR     EAX,ID_BIT     {not ID bit}
  PUSH    EAX                         {onto stack}
  POPFD                                        {from stack to flags, with not ID bit}
  PUSHFD                                   {back to stack}
  POP     EAX                         {get back to EAX}
  XOR     EAX,EDX               {check if ID bit affected}
  JZ      @exit                    {no, CPUID not availavle}
  MOV     AL,True               {Result=True}
@exit:
end;

function GetCPUID : TCPUID; assembler; register;
asm
  PUSH    EBX         {Save affected register}
  PUSH    EDI
  MOV     EDI,EAX     {@Resukt}
  MOV     EAX,1
  DW      $A20F       {CPUID Command}
  STOSD                         {CPUID[1]}
  MOV     EAX,EBX
  STOSD               {CPUID[2]}
  MOV     EAX,ECX
  STOSD               {CPUID[3]}
  MOV     EAX,EDX
  STOSD               {CPUID[4]}
  POP     EDI                         {Restore registers}
  POP     EBX
end;

function GetCPUVendor : TVendor; assembler; register;
asm
  PUSH    EBX                         {Save affected register}
  PUSH    EDI
  MOV     EDI,EAX               {@Result (TVendor)}
  MOV     EAX,0
  DW      $A20F                    {CPUID Command}
  MOV     EAX,EBX
  XCHG          EBX,ECX     {save ECX result}
  MOV               ECX,4
@1:
  STOSB
  SHR     EAX,8
  LOOP    @1
  MOV     EAX,EDX
  MOV               ECX,4
@2:
  STOSB
  SHR     EAX,8
  LOOP    @2
  MOV     EAX,EBX
  MOV               ECX,4
@3:
  STOSB
  SHR     EAX,8
  LOOP    @3
  POP     EDI                         {Restore registers}
  POP     EBX
end;

procedure TDemoForm.GetButtonClick(Sender: TObject);
var
  CPUID : TCPUID;
  I     : Integer;
  S               : TVendor;
begin
     for I := Low(CPUID) to High(CPUID)  do CPUID[I] := -1;
  if IsCPUID_Available then begin
       CPUID     := GetCPUID;
       Label1.Caption := 'CPUID[1] = ' + IntToHex(CPUID[1],8);
       Label2.Caption := 'CPUID[2] = ' + IntToHex(CPUID[2],8);
       Label3.Caption := 'CPUID[3] = ' + IntToHex(CPUID[3],8);
       Label4.Caption := 'CPUID[4] = ' + IntToHex(CPUID[4],8);
       PValue.Caption := IntToStr(CPUID[1] shr 12 and 3);
       FValue.Caption := IntToStr(CPUID[1] shr 8 and $f);
       MValue.Caption := IntToStr(CPUID[1] shr 4 and $f);
       SValue.Caption := IntToStr(CPUID[1] and $f);
       S := GetCPUVendor;
       Label5.Caption := 'Vendor: ' + S; end
  else begin
       Label5.Caption := 'CPUID not available';
  end;
end;

end.
 
0
 
LVL 7

Author Comment

by:Motaz
Comment Utility
It seems that I miss-ask the question:

It should be:

How can I get CPU Serial number, or motherboard serial number

I need an idetification of a computer

Motaz
0
 
LVL 5

Expert Comment

by:snehanshu
Comment Utility
Motaz,
  Has your premium service expired?
:-P
  Most of the threads suggest it is not a very good idea to use these any way!
...Snehanshu

Unique indentifiers like MAC address, CPU serial number
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20671536.html

Accepted Answer from geobul
Date: 07/08/2003 03:59PM IST
 Accepted Answer  

Hi,

MAC Address example (works on Win2000 and XP for sure):

uses NB30;

function GetAdapterInfo(Lana: Char): String;
var
 Adapter: TAdapterStatus;
 NCB: TNCB;
begin
 FillChar(NCB, SizeOf(NCB), 0);
 NCB.ncb_command := Char(NCBRESET);
 NCB.ncb_lana_num := Lana;
 if Netbios(@NCB) <> Char(NRC_GOODRET) then
 begin
   Result := 'mac not found';
   Exit;
 end;

 FillChar(NCB, SizeOf(NCB), 0);
 NCB.ncb_command := Char(NCBASTAT);
 NCB.ncb_lana_num := Lana;
 NCB.ncb_callname := '*';

 FillChar(Adapter, SizeOf(Adapter), 0);
 NCB.ncb_buffer := @Adapter;
 NCB.ncb_length := SizeOf(Adapter);
 if Netbios(@NCB) <> Char(NRC_GOODRET) then
 begin
   Result := 'mac not found';
   Exit;
 end;
 Result :=
   IntToHex(Byte(Adapter.adapter_address[0]), 2) + '-' +
   IntToHex(Byte(Adapter.adapter_address[1]), 2) + '-' +
   IntToHex(Byte(Adapter.adapter_address[2]), 2) + '-' +
   IntToHex(Byte(Adapter.adapter_address[3]), 2) + '-' +
   IntToHex(Byte(Adapter.adapter_address[4]), 2) + '-' +
   IntToHex(Byte(Adapter.adapter_address[5]), 2);
end;

function GetMACAddress: string;
var
 AdapterList: TLanaEnum;
 NCB: TNCB;
begin
 FillChar(NCB, SizeOf(NCB), 0);
 NCB.ncb_command := Char(NCBENUM);
 NCB.ncb_buffer := @AdapterList;
 NCB.ncb_length := SizeOf(AdapterList);
 Netbios(@NCB);
 if Byte(AdapterList.length) > 0 then
   Result := GetAdapterInfo(AdapterList.lana[0])
 else
   Result := 'mac not found';
end;

// usage
procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage(GetMACAddress);
end;

Regards, Geo  
0
 
LVL 8

Expert Comment

by:gmayo
Comment Utility
Well, just glancing at the page I suggested (http://www.torry.net/cpu.htm), at least 1 of the components DOES give you the serial number:

"By  AA. CPUID asm instruction wrapper component, reveals CPU's Serial Number, Cache Descriptor and available features (FPU, VME, DE, PSE, TSC, MSR, PAE, MCE, CX8, APIC, SEP, MTRR, PGE, MCA, CMOV, PAT, PSE-36, PSN/PPN, CLFlush, DTES, ACPI, MMX, FXSR, ISSE/XMM, ISSE2, SSNOOP, ACC, JMPE), retrieves Windows Global Info (Hardware Profile, System, OS Version and Memory Status). Calls CPUID for virtually any specified level and get all of the results.
You may even see it's capabilities in design mode, just right-click and pick one of 4 samples on the menu items. "

Geoff M.
0
 
LVL 5

Accepted Solution

by:
snehanshu earned 200 total points
Comment Utility
And,
  Why not use Hard disk serial number? I used that for my software at my previous job.
GetVolumeInformation
...Shu

The code from EXEX:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_10181822.html

Accepted Answer from simonet
Date: 07/13/1999 07:24AM IST
 Accepted Answer  

CPUs have no serial numbers. Only very few P-III were released with this feature, and Intel didn't make the code public available.

For HD's you can use this routine:

function GetVolSN(Volumn:String):string;
var
   sVolName, sFName: Array[0..20] of Char;
   dwVolSN, dwMaxFNameLen, dwFlag: DWORD;
begin
  result:='';
  if GetVolumeInformation(PChar(Volumn), sVolName, 20,
@dwVolSN,dwMaxFNameLen, dwFlag, sFName, 20) then
    result := IntToHex(dwVolSN, 8);
end;


Usage: GetVolSN('C:');

YOurs,

Alex
0
 
LVL 7

Author Comment

by:Motaz
Comment Utility
I cann't user Harddisk serial number, because it can be replaced with another one (actually that should be the last solution if I fail to get another ID)

MAC!!
isn't for network cards
I want to deploy my applications in computers that has not network card nor modem

Motaz
0
 
LVL 8

Expert Comment

by:gmayo
Comment Utility
So... have you looked at this page yet? The page that has exactly what you are looking for?

Geoff M.
0
 
LVL 5

Expert Comment

by:snehanshu
Comment Utility
Motaz
  #1) I don't understand how does one determine whether there is more probability that a user would replace his hard disk and not the motherboard: Somebody could just as well upgrade the motherboard :-) And I have observed that in commercial organizations, people most probably get new systems: very few upgrades, so nither CPU nor harddisk works.
  #2) Not all CPUs have a serial number (only P3 onwards) and it seems serial numbers of BIOS are not unique.

Any way, check this:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_10327192.html

Cheers!
...Snehanshu
0
 
LVL 7

Author Comment

by:Motaz
Comment Utility
I want to give my customers a cd, containing a valid version only can run on thier computer by using unique serial number, and most of them solve thier windows problems by formatting thier hard disk, so that they need another copy of the application,

I cann't determine wither they replace the hard disk with another one (and run this application in another computer), and gave me a new hard disk, or they are really format it

anyway, as I was said, it is the last solution (althought it is my first thinking on protecting my application)
Motaz

0
 
LVL 5

Expert Comment

by:snehanshu
Comment Utility
Well,
  The choice is yours: either use CPU/Bios serial numbers which you are not guaranteed to find on all systems (My P3 doesn't have a serial no.) or use HDD serial number: I think all hard disks have a unique s/no.
  For CPU, you could use the links gmayo suggested. Or use simonet's BIOS serial number, again not guaranteed to be unique. Or use HDD serial no.
  Cheers!
...Shu
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 5

Expert Comment

by:snehanshu
Comment Utility
Motaz,
  Thank you for the points!
>>I cann't determine wither they replace the hard disk with another one (and run this application in another computer), and gave me a new hard disk, or they are really format it
  Well, you could copy the serial number to a floppy and take it with you for your reference so that next time you are required to install the S/W, you could cross-check. perhaps you could use a combination of HDD S/No and BIOS Serial Number.
  Just a suggestion. (We also had all these issues discussed when we finalized on HDD serial number security!)
:-)
...Snehanshu
0
 
LVL 2

Expert Comment

by:odissey1
Comment Utility
Hi All,

I've used SW protection before. That was a specific one which comes with a hardware (so the price was in 4-digit range anyway). The final solution was to use USB dong with SN burned (Alladin or Rainbow - I do not remember which company it was), with price per key ~$15. But SW protection brought us nothing but a headacke. This is not technical issue but a human perception. People just do not like it. So think twice. Thinking back I would rather loose 1/2 sales.

Regards,
odissey1  

 
0
 
LVL 7

Author Comment

by:Motaz
Comment Utility
BIOS serial number!
how can I get that, because I found that I can not rely only on HD serial number

0
 
LVL 5

Expert Comment

by:snehanshu
Comment Utility
From:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_10327192.html
:-)
HTH,
...Snehanshu

Accepted Answer from simonet
Date: 05/25/2000 10:54AM IST
 Accepted Answer  

>is really this number UNIQUE to each PC?

No. The BIOS serial number identifies the motherboard: manufacturer, model, bios, Bios date, etc.

>How can I get the BIOS Serial No. of the machine running my Delphi 5.0 programs?

I've written a component, TASCpuInfo, that does that. It's freeware and can be downloaded from:

http://www.bhnet.com.br/~simonet/omnitools.htm

It also gives you other very useful information on the CPU and BIOS.

Yours,

Alex
0
 
LVL 7

Author Comment

by:Motaz
Comment Utility
Thanks Alex, but I'll use the combination of CPUID and HD Serial number

Motaz
0
 
LVL 5

Expert Comment

by:snehanshu
Comment Utility
It was me, snehanshu, pasting a previously provided solution from Alex.
You could use his tools to get the BIOS serial number.
:-)
Cheers
...Snehanshu
0
 
LVL 7

Author Comment

by:Motaz
Comment Utility
Yeah, I know Alex, I mean I'll use your first answer about CPUID, because I don't like to use third-party components, because of portability.

Motaz
0
 
LVL 1

Expert Comment

by:olas
Comment Utility
Hi!
I would think fingerprint.......combining bios id/version features, hd serial, maybe some timing info and then produce a fingerprint that allows for some deviation. If no timings are involved you can probably rely on that two computers wont get EXACTLY the same fingerprint.

Fingerprints(read checksums) can be combined with other bits of info to identify
a system with (i am guessing) more than 90% probability. That would be ok would it not?

Would be fairly simple to gather components that does the job.

//Olas
 
0
 

Expert Comment

by:oyg
Comment Utility
Hi Motaz, And Hi To All,

For software  protection I face the same problem, but I want to mention some points:

1- The Hard Disk Serial no that you all talk about it , it is not a Serial No. , but it is a Volume Serial No That becomes when you make a format to the Hard Disk. So it must be Unique, but it is not. because by some software you can copy this volume serial no and also you can change it, because it is a Logical Serial No, Not Physical.

2- So The Physical Hard Disk Serial No. it is  a number that fixed on external Hard Disk cover and It is very Difficult to depend on that because the component that I test is worked only with Win98, And Also The BIOS Component only worked with Win2000 / XP, So we don't have a component that worked with Poth Operating System.

3- So What I do with my software I make the protection with Hard Disk Volume Serial Number and I store it Encrypted in the Database.

that is the last solution that I find it for four years of searching.

Best Regards To all

Osama
0
 

Expert Comment

by:oyg
Comment Utility
Hi Again,

I Also make the hard disk two partitions and make the protection for hard disk C and D, so If he format the C the protection still on D.

Best Regards,

Osama
0
 
LVL 7

Author Comment

by:Motaz
Comment Utility
That's good idea, I may apply it in my future software in sha allah
Motaz
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now