How to Get the MachineID in Win32 Assembly?

I found something written in VC++ and I'm not very understand it. Could anybody explain or "translate" it?


=====================================================
extern "C" _declspec(dllexport) DWORD GetMachineID(void);


int main(int argc, char* argv[])
{
DWORD CID = GetMachineID();
char buffer[255];
bool keyok=false;
sprintf(buffer,"%x",CID);

RSALOCK_BEGIN;     
    keyok =! keyok;
MessageBox(NULL,"********","********",MB_OK);   

RSALOCK_END;   
if (keyok=false) {
  MessageBox(NULL,"*********","Hint:",MB_OK);   
          MessageBox(NULL,buffer,"Ur ComputerID is:",MB_OK);   
    }

return 0;
}

DWORD __declspec(dllexport)GetMachineID()
{
  DWORD VolumeSerialNumber;
      GetVolumeInformation("c:\\",NULL,12,&VolumeSerialNumber,NULL,NULL,NULL,10);
      return VolumeSerialNumber;
}
===========================================================

PS: In the beginning,it include "windows.h" and "stdlib.h" which I do not found in MASM

Posted on 2005-11-14 00:26:28 by Eric4ever
This looks like some sample code from some protection SDK - noting the RSALOCK_* macros.

What you want is the GetMachineID() function - which simply reads the drive serial number off drive C. Not very secure, probably requires administrator privileges, and will fail on "nonstandard" setups (be sure to query SystemDrive instead of blindly using C: ).

Other than that, the GetVolumeInformation call is really a no-brainer to port to MASM or whatever assembler of your choice :)
Posted on 2005-11-14 00:50:09 by f0dder