Solved

serial number in BIOS?

Posted on 1997-04-03
3
777 Views
Last Modified: 2008-02-26
We are looking for way to identify PC hardware programatically.  We considered using the ethernet address coded into the card, but we sometimes change out network cards.  DOS environment variables are not secure enough.

My boss says that the newer BIOS chips have a serial number in them that is unique.   I am looking for a way to retrieve the serial number that is flexible enough to handle different BIOS suppliers (AMI, Phoenix) and will handle new BIOS revisions.  If there is indeed a serial number coded into the BIOS, I'm sure it moves around every time the code is assembled.
0
Comment
Question by:jnearing
3 Comments
 
LVL 2

Accepted Solution

by:
javiertb earned 100 total points
Comment Utility
It's not safe getting the BIOS serial number. It's better to obtain the hard disk serial number of a DOS drive

Here you have the code:

*/
 #include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h>
 #include <dos.h>

struct info {
    int  info;             //  DW 0         Info Level
    long serial_num;       //  DD ?         Volume Serial Number
    char label[11];        //  DB 11 Dup(?) Volume Label
    char file_sys[8];      //  DB  8 Dup(?) File System Name
};

int main(int argc, char* argv[])
{
   union {
      unsigned long sn;
      unsigned int words[2];
   } sn;

   struct SREGS sregs;
   union  REGS  regs;
   struct info  buff;

   int  drive = 0, error;

   if(argc == 2)
      drive = tolower( argv[1][0] ) - 'a' + 1;

   regs.x.dx = FP_OFF(&buff);
   sregs.ds  = FP_SEG(&buff);
   regs.h.bl = drive;          // BL contains the drive. 0=current, 1=A,
etc.
   regs.x.ax = 0x6900;

   error = intdosx( &regs, &regs, &sregs );
   if( regs.x.cflag )
      {
      fprintf(stderr, "DOS Error: Disk Drive type %d\n", error);
      return 1;
      }

   sn.sn = buff.serial_num;
   printf("Disk serial number: %04X-%04X\n", sn.words[1], sn.words[0]);

   return 0;
}

// get volume label name

#include <stdio.h>
#include <dir.h>
#include <dos.h>

main()
{
   ffblk ffblk;  //DOS file control block structure used to get label name
   findfirst ("c:\\*.*", &ffblk, FA_LABEL);
   printf("\n%s\n", ffblk.ff_name);
   return 0;
}

Hope this help
0
 
LVL 3

Expert Comment

by:pc012197
Comment Utility
If you  use HD serial numbers you'll get into trouble when you upgrade to a bigger disk...
Whatever hardware info you use, you'll always get into trouble when you upgrade part of your system.

0
 

Expert Comment

by:alexander031597
Comment Utility
You can get ID of CPU. This is only additional information, but
it's good enough with information about BIOS. If you need it,
send me E-mail and I explain it in details.
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

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

762 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

7 Experts available now in Live!

Get 1:1 Help Now