A .NET application that generates unique hardware-based identifiers for Windows systems using WMI (Windows Management Instrumentation) queries to gather system information.
.NET, Windows API, Hardware ID, WMI, System Information, Unique Identifier, Security
This project provides a robust hardware ID generation service that combines multiple system components to create a unique identifier for a Windows machine. The service collects information from various hardware components including CPU, BIOS, base board, disk drives, and TPM (if available) to generate a unique, persistent identifier.
- Multiple Hardware Components: Gathers information from CPU, BIOS, Base Board, Disk Drives, and TPM
- Configurable: Customizable hash algorithms and component selection
- Robust Error Handling: Includes retry mechanisms and fallback strategies
- WMI Query Support: Uses Windows Management Instrumentation for system information
- Validation: Built-in hardware ID validation functionality
- .NET 10.0 or later
- Windows operating system
- Administrative privileges may be required for some WMI queries
-
Clone the repository:
git clone https://github.com/yourusername/windows-api.git
-
Navigate to the project directory:
cd windows-api -
Restore dependencies:
dotnet restore
The hardware ID generation can be configured through the HardwareIdConfiguration class:
HashAlgorithm: Hash algorithm to use (SHA256, SHA512, SHA1) - defaults to SHA256IncludeCpuInfo: Include CPU information in the ID - defaults to trueIncludeBiosInfo: Include BIOS information in the ID - defaults to trueIncludeBaseBoardInfo: Include base board information in the ID - defaults to trueIncludeDiskInfo: Include disk information in the ID - defaults to trueIncludeTpmInfo: Include TPM information in the ID - defaults to trueWmiTimeoutMs: Timeout for WMI queries in milliseconds - defaults to 5000msMaxRetries: Maximum number of retries for failed WMI queries - defaults to 3
The application can be run directly to generate a hardware ID:
dotnet runThis will output the generated hardware ID along with information about which components were used in its creation.
System.Management: For WMI queriesMicrosoft.Extensions.DependencyInjection: For dependency injectionMicrosoft.Extensions.Logging: For loggingMicrosoft.Extensions.Logging.Console: For console loggingSystem.ComponentModel.Annotations: For data annotations
The service provides the following methods:
GenerateHardwareIdAsync(): Generates a unique hardware identifier based on multiple system componentsValidateHardwareId(string hardwareId): Validates if a hardware ID is properly formatted
The generated hardware ID is created using cryptographic hash functions to ensure uniqueness and prevent reverse engineering of the original hardware information.