Taptiive / machineid-rs

Create a unique MachineID/HWID/UUID with customizable options, like .Net DeviceId
64 stars 26 forks source link

Thread panics on 32-bit windows #4

Closed raslund closed 1 year ago

raslund commented 1 year ago

I am trying to use this crate to integrate a hardware fingerprint into my application. The application is built for 32/64 bit windows and for 64 bit linux.

A couple of the hardware components return thread-panics when used in windows applications: SystemID returns HWIDError { message: "The system cannot find the file specified. (os error 2)", kind: "NotFound" }

The MacAddress returns the same error for both 32 and 64 bit windows. MacAddress returns HWIDError { message: "invalid type: Option value, expected a string", kind: "WMIError" }

I have included the code I used to identify these errors below:

use machineid_rs;

fn main() {

    use machineid_rs::{IdBuilder, Encryption, HWIDComponent};
    let mut builder = IdBuilder::new(Encryption::SHA1);
    // builder.add_component(HWIDComponent::SystemID).add_component(HWIDComponent::CPUID);
    // builder.add_component(HWIDComponent::SystemID);
    // builder.add_component(HWIDComponent::CPUCores);
    // builder.add_component(HWIDComponent::OSName);
    // builder.add_component(HWIDComponent::Username);
    // builder.add_component(HWIDComponent::MachineName);
    // builder.add_component(HWIDComponent::MacAddress);
    // builder.add_component(HWIDComponent::CPUID);
    builder.add_component(HWIDComponent::DriveSerial);

    let hwid = builder.build("mykey").unwrap();
    println!("{}",hwid);

Compile commands: 32-bit: cargo build --target i686-pc-windows-msvc 64-bit: cargo build --target x86_64-pc-windows-msvc

Taptiive commented 1 year ago

I think this has been fixed in the last version, thanks for the report!