コード例 #1
0
        public void ToString_FormatterIsNull_ThrowsInvalidOperationException()
        {
            var builder = new DeviceIdBuilder();

            builder.Formatter = null;

            Action act = () => builder.ToString();

            act.ShouldThrow <InvalidOperationException>().WithMessage("The Formatter property must not be null in order for ToString to be called.");
        }
コード例 #2
0
ファイル: Methods.cs プロジェクト: SkyN9ne/OpenBullet2
        public static string GetHWID(BotData data)
        {
            var builder = new DeviceIdBuilder()
                          .AddUserName()
                          .AddMachineName()
                          .AddOSVersion()
                          .AddMacAddress()
                          .AddSystemDriveSerialNumber()
                          .AddOSInstallationID();

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                builder
                .AddProcessorId()
                .AddMotherboardSerialNumber()
                .AddSystemUUID();
            }

            var hwid = builder.ToString();

            data.Logger.LogHeader();
            data.Logger.Log($"Got HWID {hwid}", LogColors.DeepChampagne);
            return(hwid);
        }
コード例 #3
0
        public SRClient GetClientDevice()
        {
            DeviceIdBuilder cDeviceId = new DeviceIdBuilder();

            cDeviceId.AddProcessorId();
            cDeviceId.AddMachineName();
            cDeviceId.AddOSVersion();
            cDeviceId.AddSystemUUID();
            cDeviceId.AddUserName();

            // DeviceIdComponent dc = new DeviceIdComponent("test", );
            var wmi = new ManagementObjectSearcher("select * from Win32_OperatingSystem")
                      .Get()
                      .Cast <ManagementObject>()
                      .First();
            var cpu = new ManagementObjectSearcher("select * from Win32_Processor")
                      .Get()
                      .Cast <ManagementObject>()
                      .First();

            var cMachineName    = Environment.MachineName;
            var cExePath        = Environment.CommandLine;
            var cOSVersion      = Environment.OSVersion;
            var cProcessorID    = new WmiDeviceIdComponent("ProcessorId", "Win32_Processor", "ProcessorId").GetValue();
            var cProcessorCount = System.Environment.ProcessorCount;
            var cUUID           = new WmiDeviceIdComponent("SystemUUID", "Win32_ComputerSystemProduct", "UUID").GetValue();
            var cNetwork        = new NetworkAdapterDeviceIdComponent(false, false).GetValue();

            var c = new SRClient();

            c.MachineName = cMachineName;
            c.DeviceID    = cDeviceId.ToString();
            c.FirstRun    = DateTime.Now;
            c.LastActive  = DateTime.Now;
            c.ExePath     = cExePath;
            c.UUID        = cUUID;

            var cOS = new ClientOS();

            cOS.Name            = ((string)wmi["Caption"]).Trim();;
            cOS.Build           = ((string)wmi["BuildNumber"]).StrToInt();
            cOS.Version         = (string)wmi["Version"];
            cOS.SerialNumber    = (string)wmi["SerialNumber"];
            cOS.Architecture    = (string)wmi["OSArchitecture"];
            cOS.MaxProcessCount = (uint)wmi["MaxNumberOfProcesses"];
            cOS.MaxProcessRAM   = (ulong)wmi["MaxProcessMemorySize"];
            c.OS = new List <ClientOS>()
            {
                cOS
            };

            var cCPU = new ClientCPU();

            cCPU.ID          = (string)cpu["ProcessorId"];
            cCPU.Name        = (string)cpu["Name"];
            cCPU.Description = (string)cpu["Caption"];
            // cCPU.Socket = (string)cpu["SocketDesignation"];
            // cCPU.AddressWidth = (ushort)cpu["AddressWidth"];
            // cCPU.DataWidth = (ushort)cpu["DataWidth"];
            // cCPU.Architecture = (ushort)cpu["Architecture"];
            // cCPU.SpeedMHz = (uint)cpu["MaxClockSpeed"];
            // cCPU.BusSpeedMHz = (uint)cpu["ExtClock"];
            // cCPU.L2Cache = (uint)cpu["L2CacheSize"] * (ulong)1024;
            // cCPU.L3Cache = (uint)cpu["L3CacheSize"] * (ulong)1024;
            // cCPU.Cores = (uint)cpu["NumberOfCores"];
            // cCPU.Threads = (uint)cpu["NumberOfLogicalProcessors"];
            c.CPU = new List <ClientCPU>()
            {
                cCPU
            };

            // var js = JsonConvert.SerializeObject(c);
            // Debug.WriteLine(js);
            return(c);
        }