Solved

Getting BIOS-serial ?

Posted on 1998-06-03
6
555 Views
Last Modified: 2011-03-07
Is it possible to get the computers BIOS-serialnumber by using Delphi ? How do I do it?

I run Delphi Developer 2.0...

Thanx!
/ Erik N
0
Comment
Question by:Erik N
  • 3
  • 2
6 Comments
 
LVL 1

Accepted Solution

by:
Edo082297 earned 200 total points
Comment Utility
Here, try this:

unit GetBIOS;
interface

uses WINPROCS;

function GetBiosSerial: LongInt;

implementation

function allocRealModePointer(var P: pointer; Size: longInt): boolean; forward;
function freeRealModePointer(var p: pointer): boolean; forward;

function GetBiosSerial: LongInt;
{ code Test: The Rom-Bios' date is allways at $ffff:0005 (real-mode)}
var
  l: ^LongInt;
begin
  l := Ptr($FFFF, $0005); {FFFF5 -> data da Rom-Bios}
  if AllocRealModePointer(Pointer(l), 8) then {8 chars to RomBios' date}
  begin { Use p to read ROM Bios' date here}
    GetBiosSerial := l^;
    FreeRealModePointer(Pointer(l)); {dispose l}
  end;
end;

function allocRealModePointer(var P: pointer; Size: longInt): boolean;
var
  Selector, base : word;
  LinearBase : longint;
begin
  result := false;
  LinearBase := MakeLong(0,hiword(longint(p)) shr 12) + hiword(longint(P)) shl 4 +           loword(longint(P)); {converts 20-bit address into a 32-bit one} {i.e. $ffff:0006 into $000ffff6}        Selector := AllocSelector(DSeg); {Copies DSeg Selector properties }
  base := SetSelectorBase(Selector, LinearBase);
  SetSelectorLimit(Selector, Size);
  if (Selector <> 0) and (base<>0) then
  begin
    P := Ptr(Selector, 0);
    result := true;
  end;
end;

function freeRealModePointer(var p: pointer): boolean;
var
  fr : Word;
begin
  fr := FreeSelector(hiword(longint(p))); {seletor is at hiword(p)}
  if (fr=0) then
  begin {ok}
    p := nil;
    result := true;
  end
  else
  begin {fail}
    result := false;
  end;
end;

{Author: Jose Bastos Neto}

HTH

Edo
0
 
LVL 6

Expert Comment

by:Holger101497
Comment Utility
Really cool! I haven't tried it yet, but this looks like something I was looking for as well...

Specifically, I was looking for a "unique System ID" that I can use to copy-protect my programs that are distributed to a very limited number of people (<20).

How likely is it to have two computers with the same BIOS serial no? Is this just a version number that will be the same in systems with the same motherboard/BIOS? Or is it almost unique?

Which other information from the computer could I use to get a unique ID? BIOS sounds good because it's rarely replaced... in times of huge harddisks that are replaced or repartitioned every once in a while, that's not a good indicator...

btw: Does anybody know how to get the serial-number of hard disks? I had some code to do it in DOS, but it doesn't work in windows (was some inline assembler! (read the boot sector))

Thanks!

P.S.: Erik, I would appreciate it if you waited a day or so with accepting the answer so I'll have time to read any additional comments... Thx!
0
 
LVL 1

Expert Comment

by:Edo082297
Comment Utility
Hi Holger,
  I STAND TO BE CORRECTED:
  The BIOS serial is supposed to be unique. This, in conjunction with a username, gives you a very good chance of having a unique identifier for a given system. Hard disks may be replaced, but unless the motherboard is replaced, the same BIOS serial will remain (this information is stored in EEPROM in the cpu itself). People always want to do stuff like this. The problem is that when the user changes systems (and they will!), they will call you and whine. Users don't like this.
  MY RAMBLINGS:
  Someone needs to write a program that would use a call back modem (or some other such guaranteed identification process) to distribute a key to unlock a given software product. The user would be registered, and your software would automatically dial in, pass in a password of sorts, and get the new key, allowing the program to continue  functioning properly.
  If someone tried to fool the system, then all would go ok for a couple of days, before your program would format their hard drive (event: OnPiratedCopyFound) :)

Edo
0
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.

 
LVL 6

Expert Comment

by:Holger101497
Comment Utility
HELP!
I tried ypur code, but it won't work in 32-bit Delphi (i.e. Win 95/NT, which by now probably is much more common than Win3.1 *g*)
I feel a bit insecure messing with code I don't really understand. Well, I understand what it does, but I don't know if it still does the same thing if i change it...

The problems are at least these:
1) l := Ptr($FFFF, $0005); => Segment/Offset pairs not supported.
I forgot how to convert manually... wasn't it 16 bytes to a segment? So would it have to be I:=Ptr($FFFF5)?

2) AllocSelector: The AllocSelector function is not implemented in the Win32 API. Win32-based applications should use the VirtualLock and VirtualUnlock functions.
Well, the help says that VirtualLock makes sure the page is not paged out... How can the BIOS be paged out to the swap-file? It also says that this function doesn't do anything in Win 95

3) SetSelectorBase: Not known at all...

Of course I'm not normally allowed to read address 000FFFF5 and trying to do so causes an access violation.

I'd appreciate any help, because this is important! Thanks!!
0
 

Author Comment

by:Erik N
Comment Utility
Thank you Edo !
/Erik N
0
 
LVL 6

Expert Comment

by:Holger101497
Comment Utility
Any way to do it in Windows 95 with Delphi 3.0?
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

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

11 Experts available now in Live!

Get 1:1 Help Now