SystemIdentification.GetSystemIdForPublisher returning same Hardware ID for all projects

80 views Asked by At

Based on MS documentation SystemIdentification.GetSystemIdForPublisher should return the same Id for the same machine as long as the publisher is the same.

Documentation: The identifier returned by this method is specific to the app publisher on the current device.

The ID has the following characteristics:

Unique for each system On any particular system, all apps by the same publisher will get the same value for this ID (for all users). Conversely, apps by different publishers on the same system will obtain different IDs. Can be created offline Persists across restarts, reinstalls and upgrades of Windows, including clean installs (please see below for exceptions) Persists across most hardware modifications Available in OneCore

I have created different solutions and application using .NET 8 and I tried different approaches yet the ID still the same.

1- Spesify Company attribute in csproj file.

2- Signning exe file with two diffrent code signing certificate.

3- create assembly.cs file and Spesify Company attribute in it.

Code sample

 SystemIdentificationInfo systemIdentificationInfo = SystemIdentification.GetSystemIdForPublisher();
 WSIBuffer hardwareId = systemIdentificationInfo.Id;
 byte[] hash = SHA256.HashData(hardwareId.ToArray());
 string hexString = BitConverter.ToString(hash).Replace("-", "").ToUpper();

I have tested it with different consoles and WPF applications.

Is there another way to specify publisher ID in .NET 8 apps?

I should mention that I need to use it with the WPF application

1

There are 1 answers

0
Abanoub Zak On BEST ANSWER

I have found my answer and I will leave it here for future comers who might come across the same problem.

First of all, I was trying to find a way to get HWID specific for each machine.

I came across ASHWID which can be acquired using GetPackageSpecificToken, however, when I tried to use it threw an error, after some research and tests I found that it's used for UWP, but even if you used Microsoft.Toolkit.Uwp NuGet, it would still throw an error, till I found that it meant for applications that are part application package.

Later I found SystemIdentificationInfo which did work for me, however, the ID was always the same even after I tried all the solutions mentioned in my question above.

Until I came across this note which I was missing.

Note

The system identification string is created using the calling app's Publisher ID and an identifier derived from the system's firmware/hardware. The system identification string will be identical for all unpackaged (Win32) apps and all packaged apps with no publisher ID.

The final conclusion after some tests is that even though it was working on regular unpackaged (Win32) apps, your publisher information comes from the application package, therefore your app will still be considered publisher-less when you use that method without packing your app in the application package.

For me, packing my app did work using Windows Application Packaging Project.

Another solution is that you can have your own logic to obfuscate the outcome to have your own unique HWID for your own app.