public static byte[]? GetMachineID() { if (generateTask is null) { DebugLog.WriteLine(nameof(HardwareUtils), "GetMachineID() called before Init()"); return(null); } bool didComplete = generateTask.Wait(TimeSpan.FromSeconds(30)); if (!didComplete) { DebugLog.WriteLine(nameof(HardwareUtils), "Unable to generate machine_id in a timely fashion, logons may fail"); return(null); } MachineID machineId = generateTask.Result; using (MemoryStream ms = new MemoryStream()) { machineId.WriteToStream(ms); return(ms.ToArray()); } }
public static byte[]? GetMachineID(IMachineInfoProvider machineInfoProvider) { if (!generationTable.TryGetValue(machineInfoProvider, out var generateTask)) { DebugLog.WriteLine(nameof(HardwareUtils), "GetMachineID() called before Init()"); return(null); } DebugLog.Assert(generateTask != null, nameof(HardwareUtils), "GetMachineID() found null task - should be impossible."); try { bool didComplete = generateTask.Wait(TimeSpan.FromSeconds(30)); if (!didComplete) { DebugLog.WriteLine(nameof(HardwareUtils), "Unable to generate machine_id in a timely fashion, logons may fail"); return(null); } } catch (AggregateException ex) when(ex.InnerException != null && generateTask.IsFaulted) { // Rethrow the original exception rather than a wrapped AggregateException. ExceptionDispatchInfo.Capture(ex.InnerException).Throw(); } MachineID machineId = generateTask.Result; using MemoryStream ms = new MemoryStream(); machineId.WriteToStream(ms); return(ms.ToArray()); }
public static byte[] GetMachineID(string userId) { var machineId = new MachineID(); machineId.SetBB3(GetHexString(Encoding.UTF8.GetBytes(userId + "Machine"))); machineId.SetFF2(GetHexString(Encoding.UTF8.GetBytes(userId + "Mac"))); machineId.Set3B3(GetHexString(Encoding.UTF8.GetBytes(userId + "Disk"))); using (MemoryStream ms = new MemoryStream()) { machineId.WriteToStream(ms); return(ms.ToArray()); } }
public static byte[] GenerateMachineID() { // the aug 25th 2015 CM update made well-formed machine MessageObjects required for logon // this was flipped off shortly after the update rolled out, likely due to linux steamclients running on distros without a way to build a machineid // so while a valid MO isn't currently (as of aug 25th) required, they could be in the future and we'll abide by The Valve Law now var machineId = new MachineID(); using (var ms = new MemoryStream()) { // TODO: each field should ideally be a different set of identifying information, but we'll just temporarily use machineguids for all three machineId.BB3 = GetMachineGuid(); machineId.FF2 = GetMachineGuid(); machineId.ThreeB3 = GetMachineGuid(); machineId.WriteToStream(ms); return(ms.ToArray()); } }
public static byte[] GenerateMachineID() { // the aug 25th 2015 CM update made well-formed machine MessageObjects required for logon // this was flipped off shortly after the update rolled out, likely due to linux steamclients running on distros without a way to build a machineid // so while a valid MO isn't currently (as of aug 25th) required, they could be in the future and we'll abide by The Valve Law now var machineId = new MachineID(); using (var ms = new MemoryStream()) { MachineInfoProvider provider = MachineInfoProvider.GetProvider(); machineId.SetBB3(GetHexString(provider.GetMachineGuid())); machineId.SetFF2(GetHexString(provider.GetMacAddress())); machineId.Set3B3(GetHexString(provider.GetDiskId())); // 333 is some sort of user supplied data and is currently unused machineId.WriteToStream(ms); return(ms.ToArray()); } }
public static string GenerateRandomMachineID() { var machineId = new MachineID(); MachineInfoProvider provider = new RandomInfoProvider(); machineId.SetBB3(GetHexString(provider.GetMachineGuid())); machineId.SetFF2(GetHexString(provider.GetMacAddress())); machineId.Set3B3(GetHexString(provider.GetDiskId())); // 333 is some sort of user supplied data and is currently unused byte[] buffer; using (MemoryStream ms = new MemoryStream()) { machineId.WriteToStream(ms); buffer = ms.ToArray(); } return(Convert.ToBase64String(buffer)); }