Solved

Getting BIOS-serial ?

Posted on 1998-06-03
6
561 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
ID: 1350036
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
ID: 1350037
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
ID: 1350038
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 6

Expert Comment

by:Holger101497
ID: 1350039
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
ID: 1350040
Thank you Edo !
/Erik N
0
 
LVL 6

Expert Comment

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

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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 my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

770 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