News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Machine ID

Started by Nilrem, January 31, 2005, 01:41:46 PM

Previous topic - Next topic

Nilrem

How can I get the ID of a machine? I tried seraching APIs like GetSystemInfo but they don't seem to provide, unless I overlooked it by mistake.
Thankyou.

00100b

Are you looking for the computer name (ie: GetComputerName\GetComputerNameEx)?

Nilrem

Does that return a number or just the name of the computer (for example 'NilremComputer')?

00100b

Name.

What number are you looking for?

pbrennick

Nilrem,
If you were to run the following program:

Quoteipconfig /all >MachineID.txt

It will create a file called MachineID.txt with lots of neat stuff in it.  In there you will find a line called Physical Address, it contains the Machine ID.  On my machine, it shows:

QuotePhysical Address. . . . . . . . . : 08-00-46-59-27-41

So, 08-00-46-59-27-41 is my Machine ID.

Now, if you use CreateProcess to run the above command line, you can then open the file and read in the Macine ID, that does it.

Cheers,
Paul

Relvinian

Quote from: pbrennick on January 31, 2005, 06:34:32 PM
Nilrem,
If you were to run the following program:

Quoteipconfig /all >MachineID.txt

It will create a file called MachineID.txt with lots of neat stuff in it.  In there you will find a line called Physical Address, it contains the Machine ID.  On my machine, it shows:

QuotePhysical Address. . . . . . . . . : 08-00-46-59-27-41

So, 08-00-46-59-27-41 is my Machine ID.

Now, if you use CreateProcess to run the above command line, you can then open the file and read in the Macine ID, that does it.

Cheers,
Paul


Paul,
The machine ID you listed (Physical Address) is actually your MAC address of your network card.

Nilrem,
What machine ID are you trying to get?  There are a lot of different type of IDs.  CPU, Network, Hard Drive, etc.

Relvinian

Nilrem

#6
Sorry I got confused. Again. I need to retrieve the serial of the hard-disk, I'm guessing GetVolumeInfo or something along those lines?
I've looked up the API but I need to specify the path of the disk, but what if it isn't called C:\ what if it is something else like F:\ how would one determine the hardisk drive letter? I looked up GetDriveType but needs the root also.

pbrennick

#7
Relvinian,
Where I googled, it says it is also the Machine ID.  http://www.elysiuminc.com/login/misc/machineid.html is where I got the information.  All I did was copy what was posted minus the pictures.  :'(

Cheers,
Paul



Nilrem

I've figured this much out but it's not working, also when having one line code over more than one line how to do it?

    .data
   
    lpDrive DB "C:",0
   
   
    .data?
   
    nSize DD ?
    lpNumber DD ?
    lpMaximumComponentLength DD ?
    lpFileSystemFlags DD ?
    nFileSystemNameSize DD ?
    lpszVolumeName DD ?

ID PROC

LOCAL lpFileSystemNameBuffer:DWORD; Points to a buffer that receives the name of the file system (such as FAT or NTFS).
LOCAL lpBuffer:DWORD
LOCAL lpstring[128]:DWORD
LOCAL cchBufferLength:DWORD

;invoke FindFirstVolume,lpszVolumeName,cchBufferLength
invoke GetVolumeInformation,lpDrive,lpBuffer,nSize,lpNumber,lpMaximumComponentLength,lpFileSystemFlags,lpFileSystemNameBuffer,nFileSystemNameSize
invoke StdOut, [lpNumber]
mov lpstring, input ()

ID endp

Peterpan

Quote from: Nilrem on January 31, 2005, 10:02:40 PM
I've looked up the API but I need to specify the path of the disk, but what if it isn't called C:\ what if it is something else like F:\ how would one determine the hardisk drive letter? I looked up GetDriveType but needs the root also.

Take a look at GetLogicalDrives and/or GetLogicalDriveStrings. It will give you all the list of the drive letter that exist in your machine.

:U

Relvinian

Quote from: pbrennick on January 31, 2005, 10:33:47 PM
Relvinian,
Where I googled, it says it is also the Machine ID.  http://www.elysiuminc.com/login/misc/machineid.html is where I got the information.  All I did was copy what was posted minus the pictures.  :'(

Cheers,
Paul


Hehe. The only reason I mentioned that is because if you don't have a network card installed (which is still possible), doing IPCONFIG will produce nothing. Your machine is still valid and does have an ID still. Just no MAC information (or any TCP/IP information too -- unless you have a virtual TCP/IP driver for some other device).

Terminology is the biggest obstical in communications. ;-)  I'm not saying you are wrong in what you posted, just putting an extra clarification on what that was.

Relvinian

pbrennick

Relvinian,
Thank you for your words.  I notice that you usually are a lot of help to others and that is my goal, also.

BTW I used to be a CNA (Novell 4.1 cert.) and have seen all the MAC addresses I care to for one lifetime.   :dazzled:

Cheers,
Paul

Relvinian

Paul,

Hehe.  Yep, I bet you have seen a lot of addresses then eh?

I never did get into the certifcation thing (novell, microsoft, cisco, etc).  I would rather program then work on networks or be an admin type.

You answer a lot more post then ever will and because of that, you'll always help more.  I just chime in when and where I can.  Sometimes my information isn't the best, wrong or I don't clair myself enough.

Relvinian

MichaelW

Nilrem,

IIRC the volume serial number is assigned when the volume is formatted. I don't know how the number is derived, but considering that the volume serial number thing started back in the DOS days, I doubt that it has anything to do with the hardware. The hard drive will have a serial number assigned by the manufacturer, and it should be accessible in the data returned by the Identify Device command. See this thread:

http://www.masmforum.com/simple/index.php?topic=45.0

Windows 2000 (and probably later versions) uses the model number returned by Identify Device to identify the hard disk in Device Manager. But I couldn't find my hard disk serial number anywhere in the registry, probably indicating that it is not available. I think WinIo could be used to run an Identify Device command on the hard disk from within Windows. But to do it you would need to change several of the command/control block registers, and without some way to temporarily prevent Windows from accessing the drive, I think this would be more than a little risky. And assuming you could prevent Windows from accessing the drive while you are running the command, you still would need to be very careful to restore all of the registers you changed.
eschew obfuscation

P1

Nilrem,

This should get you past your coding issues for now.  After calling the code, lpnumber will have the 32 bit serial number.  What I tried to get, but could not, was how to format it for output.

lpDrive     DB "C:\",0

lpNumber DD ?
lpMaximumComponentLength DD ?
lpFileSystemFlags DD ?

invoke GetVolumeInformation,
       addr lpDrive,NULL,0,
       addr lpNumber,
       addr lpMaximumComponentLength,
       addr lpFileSystemFlags,NULL,0
Plus, if your are trying to serialize the system, try googling for solutions that you may code into MASM.  Be aware users change stuff in their systems and which break certain kinds of serials.

Regards,  P1  :8)