Jump to content
Sign in to follow this  
msd

Hardware ID

Recommended Posts

Hello, 

 

I'm working now on Latest RAD Studio and I version incompatibility of my source which is generating some unique HardwareID

 

function InternalGetHardwareID(Hdd: AnsiChar): AnsiString;
var
  pdw: pDWord;
  mc, fl: dword;
  ID_1: AnsiString;
  ID_1L: dword;
  ID_2: Cardinal;
  ID_3: Cardinal;
  ID_5: AnsiString;
  CPUID: TCPUID;
  I: Integer;
  AddOn: Longword;
  TempStr: AnsiString;
  TempByte: Byte;
  Index: Integer;
  FUniqueID: AnsiString;
begin
  Result := '';
  FUniqueID := '{61AF17B9-4EDB-4849-93CD-113C14E139F7}';
  try
    New(pdw);
    GetVolumeInformation(PChar(Hdd + ':'), nil, 0, pdw, mc, fl, nil, 0);
    ID_1L := pdw^;
    ID_1 := IntToHex(pdw^, 8);
    Dispose(pdw);
  except
    exit;
  end;
  for I := Low(CPUID) to High(CPUID) do
    CPUID[I] := -1;
  if IsCPUIDAvailable then
  begin
    CPUID := GetCPUID;
    ID_2 := CPUID[1] + CPUID[2] + CPUID[3] + CPUID[4];  // First chance exception at $7631ED42. Exception class EIntOverflow with message 'Integer overflow'
    ID_3 := (CPUID[1] shr 12 and 3) * (CPUID[1] shr 8 and $F) *
      (CPUID[1] shr 4 and $F) * (CPUID[1] and $F);
    ID_5 := GetCPUVendor;
{$WARNINGS OFF}
    AddOn := Longword(ID_1L + ID_2 * ID_3);
    for I := 1 to Length(ID_5) do
      AddOn := (AddOn xor Ord(ID_5[I]));
    TempStr := IntToHex(AddOn, 8);
    Index := 1;
    for I := 1 to Length(TempStr) do
    begin
{$R-}
      TempByte := ((Ord(TempStr[I]) xor (AddOn div I)) + Ord(ID_1[I])) div 5;
{$R+}
{$WARNINGS ON}
      if poUniqueHardwareID in Options then // This is error line
      begin
        TempByte := Ord(FUniqueID[Index]) xor TempByte;
        Inc(Index);
        if Index > Length(FUniqueID) then
          Index := 1;
      end;
      Result := Result + IntToHex(TempByte, 2);
    end;
    if Length(Result) > 16 then
      Result := Copy(Result, 1, 16);
    if Length(Result) < 16 then
      for I := Length(Result) + 1 to 16 do
        Result := '0' + Result;
  end
  else
  begin
    if Assigned(FOnUnknownHardware) then FOnUnknownHardware(Self);  // This is error line
  end;
end;

 

 

Share this post


Link to post
50 minutes ago, msd said:

// This is error line

I don't see how that would have ever compiled in that form. Since it's a standalone function, there's no "Self" for it to refer to. Perhaps InternalGetHardwareID was once a method of an object?

  • Like 2

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×