├── Framework Hub.Desktop
├── avalonia-logo.ico
├── Program.cs
├── app.manifest
└── Framework Hub.Desktop.csproj
├── Framework Hub
├── Assets
│ ├── avalonia-logo.ico
│ ├── Framework-Computer.png
│ ├── framework-laptop-13.png
│ ├── framework-laptop-13-2.png
│ └── Framework-Computer.svg
├── ViewModels
│ ├── ViewModelBase.cs
│ └── MainViewModel.cs
├── FodyWeavers.xml
├── App.axaml
├── Scripts
│ ├── Misc
│ │ └── Garbage.cs
│ ├── Windows
│ │ ├── Misc
│ │ │ ├── WinPowerMode.cs
│ │ │ └── GetSystemInfo.cs
│ │ ├── WindowsCpuInfo.cs
│ │ ├── Fan Control
│ │ │ ├── Fan Control.cs
│ │ │ ├── WinRingEC_Management.cs
│ │ │ └── OpenLibSys_Fan.cs
│ │ └── RyzenAdj
│ │ │ └── Backend.cs
│ ├── Linux
│ │ ├── LinuxCpuInfo.cs
│ │ └── RyzenAdj
│ │ │ └── Backend.cs
│ └── Apply Settings.cs
├── Framework Hub.csproj
├── Services
│ ├── AppSettings.cs
│ └── PowerModeSettings.cs
├── Views
│ ├── MainView.axaml.cs
│ ├── MainWindow.axaml.cs
│ ├── MainWindow.axaml
│ └── MainView.axaml
└── App.axaml.cs
├── README.md
├── Directory.Build.props
├── Framework Hub.sln
├── .gitattributes
├── .gitignore
└── LICENSE.txt
/Framework Hub.Desktop/avalonia-logo.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesCJ60/Framework-Hub/HEAD/Framework Hub.Desktop/avalonia-logo.ico
--------------------------------------------------------------------------------
/Framework Hub/Assets/avalonia-logo.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesCJ60/Framework-Hub/HEAD/Framework Hub/Assets/avalonia-logo.ico
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Framework Hub
2 | 
3 |
--------------------------------------------------------------------------------
/Framework Hub/Assets/Framework-Computer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesCJ60/Framework-Hub/HEAD/Framework Hub/Assets/Framework-Computer.png
--------------------------------------------------------------------------------
/Framework Hub/Assets/framework-laptop-13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesCJ60/Framework-Hub/HEAD/Framework Hub/Assets/framework-laptop-13.png
--------------------------------------------------------------------------------
/Framework Hub/Assets/framework-laptop-13-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JamesCJ60/Framework-Hub/HEAD/Framework Hub/Assets/framework-laptop-13-2.png
--------------------------------------------------------------------------------
/Framework Hub/ViewModels/ViewModelBase.cs:
--------------------------------------------------------------------------------
1 | using ReactiveUI;
2 |
3 | namespace Framework_Hub.ViewModels;
4 |
5 | public class ViewModelBase : ReactiveObject
6 | {
7 | }
8 |
--------------------------------------------------------------------------------
/Framework Hub/FodyWeavers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | enable
4 | 11.0.2
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Framework Hub/App.axaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Framework Hub.Desktop/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Avalonia;
4 | using Avalonia.ReactiveUI;
5 |
6 | namespace Framework_Hub.Desktop;
7 |
8 | class Program
9 | {
10 | // Initialization code. Don't use any Avalonia, third-party APIs or any
11 | // SynchronizationContext-reliant code before AppMain is called: things aren't initialized
12 | // yet and stuff might break.
13 | [STAThread]
14 | public static void Main(string[] args) => BuildAvaloniaApp()
15 | .StartWithClassicDesktopLifetime(args);
16 |
17 | // Avalonia configuration, don't remove; also used by visual designer.
18 | public static AppBuilder BuildAvaloniaApp()
19 | => AppBuilder.Configure()
20 | .UsePlatformDetect()
21 | .WithInterFont()
22 | .LogToTrace()
23 | .UseReactiveUI();
24 | }
25 |
--------------------------------------------------------------------------------
/Framework Hub/Scripts/Misc/Garbage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.Runtime.InteropServices;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace Framework_Hub.Scripts.Misc
10 | {
11 | internal class Garbage
12 | {
13 | [DllImport("psapi.dll")]
14 | static extern int EmptyWorkingSet(IntPtr hwProc);
15 | public static async Task Garbage_Collect()
16 | {
17 | try
18 | {
19 | await Task.Run(() =>
20 | {
21 | EmptyWorkingSet(Process.GetCurrentProcess().Handle);
22 |
23 | long usedMemory = GC.GetTotalMemory(true);
24 | });
25 | }
26 | catch
27 | {
28 |
29 | }
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Framework Hub.Desktop/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Framework Hub/Scripts/Windows/Misc/WinPowerMode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Framework_Hub.Scripts.Windows.Misc
9 | {
10 | internal class WinPowerMode
11 | {
12 | [DllImport("powrprof.dll", EntryPoint = "PowerSetActiveOverlayScheme")]
13 | public static extern uint PowerSetActiveOverlayScheme(Guid OverlaySchemeGuid);
14 |
15 | static string highPerformancePowerScheme = "DED574B5-45A0-4F42-8737-46345C09C238";
16 | static string balancedPowerScheme = "00000000-0000-0000-0000-000000000000";
17 | static string powerSaverPowerScheme = "961CC777-2547-4F9D-8174-7D86181b8A7A";
18 |
19 | public static void SetWinPowerMode(int mode)
20 | {
21 | if(mode == 0) PowerSetActiveOverlayScheme(new Guid(powerSaverPowerScheme.ToLower()));
22 | else if (mode == 1) PowerSetActiveOverlayScheme(new Guid(balancedPowerScheme.ToLower()));
23 | else if (mode == 2) PowerSetActiveOverlayScheme(new Guid(highPerformancePowerScheme.ToLower()));
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Framework Hub.Desktop/Framework Hub.Desktop.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | WinExe
4 |
6 | net8.0
7 | enable
8 | true
9 | app.manifest
10 | AnyCPU;x64
11 | True
12 | Framework Hub
13 | Framework Hub
14 | x64
15 | Framework
16 | avalonia-logo.ico
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/Framework Hub/Scripts/Windows/WindowsCpuInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | public class WindowsCpuInfo
4 | {
5 | public static string VendorId { get; private set; }
6 | public static int CpuFamily { get; private set; }
7 | public static int Model { get; private set; }
8 | public static string ModelName { get; private set; }
9 | public static int Stepping { get; private set; }
10 | public static double MHz { get; private set; }
11 | public static string CacheSize { get; private set; }
12 |
13 | public static void GetValues()
14 | {
15 | System.Management.ManagementObjectSearcher searcher = new System.Management.ManagementObjectSearcher("SELECT * FROM Win32_Processor");
16 | foreach (System.Management.ManagementObject obj in searcher.Get())
17 | {
18 | VendorId = obj["Manufacturer"]?.ToString();
19 | CpuFamily = int.Parse(obj["Family"]?.ToString() ?? "0");
20 | ModelName = obj["Name"]?.ToString();
21 | Stepping = int.Parse(obj["Stepping"]?.ToString() ?? "0");
22 | MHz = double.Parse(obj["MaxClockSpeed"]?.ToString() ?? "0") / 1000.0; // Convert to GHz
23 | CacheSize = obj["L2CacheSize"]?.ToString();
24 | break; // Assuming there's only one CPU
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Framework Hub/Framework Hub.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0
4 | enable
5 | latest
6 | True
7 | x64
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/Framework Hub/Scripts/Windows/Fan Control/Fan Control.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using static System.Runtime.InteropServices.JavaScript.JSType;
7 |
8 | namespace Framework_Hub.Scripts.Windows.Fan_Control
9 | {
10 | internal class Fan_Control
11 | {
12 | /*
13 | WARNING: THIS IS JUST PLACEHOLDER TEST CODE FOR FAN CONTROL VIA EC.
14 | USE AT YOUR OWN RISK!!!
15 | */
16 |
17 | public static int MaxFanSpeed = 100;
18 | public static int MinFanSpeed = 0;
19 | public static int MinFanSpeedPercentage = 0;
20 |
21 | public static double FanSpeed = 0;
22 |
23 | public static ushort FanToggleAddress = 0x52;
24 | public static ushort FanChangeAddress = 0x24;
25 | public static ushort RegAddress = 0x0802;
26 |
27 | public static bool fanControlEnabled = false;
28 |
29 | public static void UpdateAddresses(ushort reg_data)
30 | {
31 | WinRingEC_Management.reg_addr = RegAddress;
32 | WinRingEC_Management.reg_data = reg_data;
33 | }
34 |
35 | public static void setFanSpeed(int speedPercentage)
36 | {
37 | if (speedPercentage < MinFanSpeedPercentage && speedPercentage > 0)
38 | {
39 | speedPercentage = MinFanSpeedPercentage;
40 | }
41 | string hexString = speedPercentage.ToString("X");
42 | byte setValue = (byte)Convert.ToByte(hexString, 16);
43 |
44 | UpdateAddresses(0x0804);
45 | WinRingEC_Management.ECRamWrite(FanChangeAddress, setValue);
46 | UpdateAddresses(0x0806);
47 | WinRingEC_Management.ECRamWrite(FanChangeAddress, setValue);
48 | FanSpeed = speedPercentage;
49 | }
50 |
51 | public static void disableFanControl()
52 | {
53 | UpdateAddresses(0x0804);
54 | WinRingEC_Management.ECRamWrite(FanToggleAddress, 0x0);
55 | UpdateAddresses(0x0806);
56 | WinRingEC_Management.ECRamWrite(FanToggleAddress, 0x0);
57 | fanControlEnabled = false;
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/Framework Hub/Scripts/Linux/LinuxCpuInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Text.RegularExpressions;
4 |
5 | public class LinuxCpuInfo
6 | {
7 | public static string VendorId { get; private set; }
8 | public static int CpuFamily { get; private set; }
9 | public static int Model { get; private set; }
10 | public static string ModelName { get; private set; }
11 | public static int Stepping { get; private set; }
12 | public static double MHz { get; private set; }
13 | public static string CacheSize { get; private set; }
14 |
15 | public static void GetValues()
16 | {
17 | string[] cpuInfoLines = File.ReadAllLines(@"/proc/cpuinfo");
18 |
19 | CpuInfoMatch[] cpuInfoMatches =
20 | {
21 | new CpuInfoMatch(@"^vendor_id\s+:\s+(.+)", value => VendorId = value),
22 | new CpuInfoMatch(@"^cpu family\s+:\s+(.+)", value => CpuFamily = int.Parse(value)),
23 | new CpuInfoMatch(@"^model\s+:\s+(.+)", value => Model = int.Parse(value)),
24 | new CpuInfoMatch(@"^model name\s+:\s+(.+)", value => ModelName = value),
25 | new CpuInfoMatch(@"^stepping\s+:\s+(.+)", value => Stepping = int.Parse(value)),
26 | new CpuInfoMatch(@"^cpu MHz\s+:\s+(.+)", value => MHz = double.Parse(value)),
27 | new CpuInfoMatch(@"^cache size\s+:\s+(.+)", value => CacheSize = value)
28 | };
29 |
30 | foreach (string cpuInfoLine in cpuInfoLines)
31 | {
32 | foreach (CpuInfoMatch cpuInfoMatch in cpuInfoMatches)
33 | {
34 | Match match = cpuInfoMatch.regex.Match(cpuInfoLine);
35 | if (match.Success)
36 | {
37 | string value = match.Groups[1].Value.Trim();
38 | cpuInfoMatch.updateValue(value);
39 | }
40 | }
41 | }
42 | }
43 |
44 | public class CpuInfoMatch
45 | {
46 | public Regex regex;
47 | public Action updateValue;
48 |
49 | public CpuInfoMatch(string pattern, Action update)
50 | {
51 | this.regex = new Regex(pattern, RegexOptions.Compiled);
52 | this.updateValue = update;
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/Framework Hub.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.8.34525.116
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Framework Hub", "Framework Hub\Framework Hub.csproj", "{E3D8AA76-6F8A-416F-A289-1A12A563733D}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Framework Hub.Desktop", "Framework Hub.Desktop\Framework Hub.Desktop.csproj", "{4F04F5D5-94C0-4B03-913D-B2E430FA6AAC}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Debug|x64 = Debug|x64
14 | Release|Any CPU = Release|Any CPU
15 | Release|x64 = Release|x64
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {E3D8AA76-6F8A-416F-A289-1A12A563733D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {E3D8AA76-6F8A-416F-A289-1A12A563733D}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {E3D8AA76-6F8A-416F-A289-1A12A563733D}.Debug|x64.ActiveCfg = Debug|Any CPU
21 | {E3D8AA76-6F8A-416F-A289-1A12A563733D}.Debug|x64.Build.0 = Debug|Any CPU
22 | {E3D8AA76-6F8A-416F-A289-1A12A563733D}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {E3D8AA76-6F8A-416F-A289-1A12A563733D}.Release|Any CPU.Build.0 = Release|Any CPU
24 | {E3D8AA76-6F8A-416F-A289-1A12A563733D}.Release|x64.ActiveCfg = Release|Any CPU
25 | {E3D8AA76-6F8A-416F-A289-1A12A563733D}.Release|x64.Build.0 = Release|Any CPU
26 | {4F04F5D5-94C0-4B03-913D-B2E430FA6AAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {4F04F5D5-94C0-4B03-913D-B2E430FA6AAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {4F04F5D5-94C0-4B03-913D-B2E430FA6AAC}.Debug|x64.ActiveCfg = Debug|x64
29 | {4F04F5D5-94C0-4B03-913D-B2E430FA6AAC}.Debug|x64.Build.0 = Debug|x64
30 | {4F04F5D5-94C0-4B03-913D-B2E430FA6AAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
31 | {4F04F5D5-94C0-4B03-913D-B2E430FA6AAC}.Release|Any CPU.Build.0 = Release|Any CPU
32 | {4F04F5D5-94C0-4B03-913D-B2E430FA6AAC}.Release|x64.ActiveCfg = Release|x64
33 | {4F04F5D5-94C0-4B03-913D-B2E430FA6AAC}.Release|x64.Build.0 = Release|x64
34 | EndGlobalSection
35 | GlobalSection(SolutionProperties) = preSolution
36 | HideSolutionNode = FALSE
37 | EndGlobalSection
38 | GlobalSection(ExtensibilityGlobals) = postSolution
39 | SolutionGuid = {AE90540F-12BF-42AC-8BD9-88B52B5D080B}
40 | EndGlobalSection
41 | EndGlobal
42 |
--------------------------------------------------------------------------------
/Framework Hub/Services/AppSettings.cs:
--------------------------------------------------------------------------------
1 | using Framework_Hub.Scripts;
2 | using Newtonsoft.Json;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace Framework_Hub.Services
11 | {
12 | internal class AppSettings
13 | {
14 | public class Settings
15 | {
16 | public int lastPowerMode { get; set; } = 2;
17 |
18 | }
19 |
20 | internal class AppSettingsManager
21 | {
22 | private Dictionary _settings;
23 |
24 | private readonly string _configDirectory;
25 |
26 | // set up manager instance
27 | public AppSettingsManager(string configDirectory)
28 | {
29 | _configDirectory = configDirectory;
30 | _settings = new Dictionary();
31 | LoadPresets();
32 | }
33 |
34 | // Get data from preset
35 | public Settings GetPreset()
36 | {
37 | if (_settings.ContainsKey("Main Settings"))
38 | {
39 | return _settings["Main Settings"];
40 | }
41 | else
42 | {
43 | return null;
44 | }
45 | }
46 |
47 | // Load all presents into string dictionary
48 | private void LoadPresets()
49 | {
50 | if (File.Exists(_configDirectory))
51 | {
52 | string json = File.ReadAllText(_configDirectory);
53 | _settings = JsonConvert.DeserializeObject>(json);
54 | }
55 | else
56 | {
57 | _settings = new Dictionary();
58 | }
59 | }
60 |
61 | // Save preset to json file
62 | public void SaveSettings(Settings _newSettings)
63 | {
64 | _settings["Main Settings"] = _newSettings;
65 | SaveAppSettings();
66 | }
67 |
68 | // Save json file changes
69 | private void SaveAppSettings()
70 | {
71 | string json = JsonConvert.SerializeObject(_settings, Newtonsoft.Json.Formatting.Indented);
72 | File.WriteAllText(_configDirectory, json);
73 | }
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/Framework Hub/Views/MainView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.Controls;
3 | using Framework_Hub.Scripts.Windows.Misc;
4 | using Framework_Hub.ViewModels;
5 | using System;
6 | using System.Drawing;
7 | using System.IO;
8 | using System.Management;
9 | using System.Threading.Tasks;
10 | using static Framework_Hub.Views.MainWindow;
11 |
12 | namespace Framework_Hub.Views;
13 |
14 | public partial class MainView : UserControl
15 | {
16 | public MainView()
17 | {
18 | InitializeComponent();
19 | DataContext = new MainViewModel();
20 |
21 | // Setup GUI
22 | SetUpGUI();
23 | }
24 |
25 | private void SetUpGUI()
26 | {
27 | // Create variable containing viewmodel for GUI
28 | var mainViewModel = new MainViewModel();
29 |
30 | // Setup power mode selection menu
31 | lbPresets.Items.Add(new SideMenu { Icon = "\ue8be", Sub = "Silent", Margin = new Thickness(0, -8, 0, -8) });
32 | lbPresets.Items.Add(new SideMenu { Icon = "\uec49", Sub = "Balanced", Margin = new Thickness(0, -8, 0, -8) });
33 | lbPresets.Items.Add(new SideMenu { Icon = "\uec4a", Sub = "Performance", Margin = new Thickness(0, -8, 0, -8) });
34 |
35 | // Display laptop name
36 | tbxLaptopName.Text = $"{GetSystemInfo.Manufacturer} {GetSystemInfo.Product}";
37 |
38 | // Display CPU/APU name
39 | tbxCpuName.Text = $"- {GetSystemInfo.GetCPUName()}";
40 |
41 | // Determine how many GPUs are present, their order and display their names
42 | if(GetSystemInfo.GetGPUName(1) != null && GetSystemInfo.GetCPUName().Contains(GetSystemInfo.GetGPUName(1).Replace("AMD", null).Replace("(TM)", null))) tbxGpuName.Text = $"- {GetSystemInfo.GetGPUName(1)} + {GetSystemInfo.GetGPUName(0)}";
43 | else if (GetSystemInfo.GetGPUName(1) != null) tbxGpuName.Text = $"- {GetSystemInfo.GetGPUName(0)} + {GetSystemInfo.GetGPUName(1)}";
44 | else tbxGpuName.Text = $"- {GetSystemInfo.GetGPUName(0)}";
45 |
46 | // Display RAM spec of laptop
47 | GetSystemInfo.GetRAMInfo(tbxRamSpecs);
48 |
49 | // Detect if Ryzen 9/Ryzen AI 9 is present
50 | if (!GetSystemInfo.GetCPUName().Contains("Ryzen 9") && !GetSystemInfo.GetCPUName().Contains("Ryzen AI 9"))
51 | {
52 | // Hide options if no Ryzen 9/Ryzen AI 9 is detected
53 | expCO.IsVisible = false;
54 | expPBO.IsVisible = false;
55 | }
56 |
57 | // Update to correct values on load
58 | sdPL1.Value = mainViewModel.PL1;
59 | sdPL2.Value = mainViewModel.PL2;
60 | lbPresets.SelectedIndex = mainViewModel.PowerIndex;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Framework Hub/App.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.Controls.ApplicationLifetimes;
3 | using Avalonia.Markup.Xaml;
4 |
5 | using Framework_Hub.ViewModels;
6 | using Framework_Hub.Views;
7 | using System.Runtime.InteropServices;
8 | using System;
9 | using System.Security.Principal;
10 | using System.Diagnostics;
11 | using System.Threading.Tasks;
12 | using Framework_Hub.Scripts.Misc;
13 |
14 | namespace Framework_Hub;
15 |
16 | public partial class App : Application
17 | {
18 | public override void Initialize()
19 | {
20 | AvaloniaXamlLoader.Load(this);
21 | }
22 |
23 | public override void OnFrameworkInitializationCompleted()
24 | {
25 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
26 | {
27 | if (IsAdmin() == false) RestartAsAdmin();
28 | else
29 | {
30 | WindowsCpuInfo.GetValues();
31 | SetUpGUI();
32 | }
33 | }
34 | else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
35 | {
36 | LinuxCpuInfo.GetValues();
37 | SetUpGUI();
38 | }
39 | else
40 | {
41 | Console.WriteLine("Operating system not recognised.");
42 | Environment.Exit(0);
43 | }
44 | }
45 |
46 | void SetUpGUI()
47 | {
48 | if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
49 | {
50 | desktop.MainWindow = new MainWindow
51 | {
52 | DataContext = new MainViewModel()
53 | };
54 | }
55 | else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform)
56 | {
57 | singleViewPlatform.MainView = new MainView
58 | {
59 | DataContext = new MainViewModel()
60 | };
61 | }
62 |
63 | base.OnFrameworkInitializationCompleted();
64 | }
65 |
66 | static bool IsAdmin()
67 | {
68 | WindowsIdentity identity = WindowsIdentity.GetCurrent();
69 | WindowsPrincipal principal = new WindowsPrincipal(identity);
70 | return principal.IsInRole(WindowsBuiltInRole.Administrator);
71 | }
72 |
73 | static void RestartAsAdmin()
74 | {
75 | // Restart and run as admin
76 | var exeName = Process.GetCurrentProcess().MainModule.FileName;
77 | ProcessStartInfo startInfo = new ProcessStartInfo(exeName);
78 | startInfo.Verb = "runas";
79 | startInfo.UseShellExecute = true;
80 | startInfo.Arguments = "restart";
81 | Process.Start(startInfo);
82 | Environment.Exit(0);
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/Framework Hub/Views/MainWindow.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.Controls;
3 | using Avalonia.Input;
4 | using Avalonia.Interactivity;
5 | using Avalonia.Threading;
6 | using Framework_Hub.Scripts.Misc;
7 | using System;
8 | using System.Timers;
9 |
10 | namespace Framework_Hub.Views;
11 |
12 | public partial class MainWindow : Window
13 | {
14 | public class SideMenu
15 | {
16 | public string Icon { get; set; }
17 | public string Sub { get; set; }
18 | public Thickness Margin { get; set; }
19 | }
20 |
21 | private UserControl currentPage;
22 |
23 | public MainWindow()
24 | {
25 | InitializeComponent();
26 |
27 | lbSide.Items.Add(new SideMenu { Icon = "\ue80f", Sub = "Home", Margin = new Thickness(0,-8,0,-8) });
28 | //lbSide.Items.Add(new SideMenu { Icon = "\uea80", Sub = "KBD LED", Margin = new Thickness(0,-8,0,-8) });
29 | //lbSide.Items.Add(new SideMenu { Icon = "\ue8ab", Sub = "Auto", Margin = new Thickness(0,-8,0,-8) });
30 | //lbSide.Items.Add(new SideMenu { Icon = "\ue713", Sub = "Settings", Margin = new Thickness(0, -8, 0, -8) });
31 | lbSide.SelectedIndex = 0;
32 |
33 | this.MinWidth = 1120;
34 | this.MinHeight = 550;
35 |
36 | currentPage = new MainView();
37 | contentArea.Content = currentPage;
38 |
39 | Garbage.Garbage_Collect();
40 | }
41 |
42 |
43 | private bool _mouseDownForWindowMoving = false;
44 | private PointerPoint _originalPoint;
45 |
46 | private void InputElement_OnPointerMoved(object? sender, PointerEventArgs e)
47 | {
48 | if (!_mouseDownForWindowMoving) return;
49 |
50 | PointerPoint currentPoint = e.GetCurrentPoint(this);
51 | Position = new PixelPoint(Position.X + (int)(currentPoint.Position.X - _originalPoint.Position.X),
52 | Position.Y + (int)(currentPoint.Position.Y - _originalPoint.Position.Y));
53 | }
54 |
55 | private void InputElement_OnPointerPressed(object? sender, PointerPressedEventArgs e)
56 | {
57 | if (WindowState == WindowState.Maximized || WindowState == WindowState.FullScreen) return;
58 |
59 | _mouseDownForWindowMoving = true;
60 | _originalPoint = e.GetCurrentPoint(this);
61 | }
62 |
63 | private void InputElement_OnPointerReleased(object? sender, PointerReleasedEventArgs e)
64 | {
65 | _mouseDownForWindowMoving = false;
66 | }
67 |
68 | public void btnClose_OnClick(object? sender, RoutedEventArgs args)
69 | {
70 | Environment.Exit(0);
71 | }
72 |
73 | public void btnMax_OnClick(object? sender, RoutedEventArgs args)
74 | {
75 | if(this.WindowState == WindowState.Maximized) this.WindowState = WindowState.Normal;
76 | else this.WindowState = WindowState.Maximized;
77 | }
78 |
79 | public void btnMini_OnClick(object? sender, RoutedEventArgs args)
80 | {
81 | if (this.WindowState != WindowState.Minimized) this.WindowState = WindowState.Minimized;
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/Framework Hub/Scripts/Apply Settings.cs:
--------------------------------------------------------------------------------
1 | using Framework_Hub.Scripts.Linux.RyzenAdj;
2 | using Framework_Hub.Scripts.Windows.RyzenAdj;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Runtime.InteropServices;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace Framework_Hub.Scripts
11 | {
12 | internal class Apply_Settings
13 | {
14 | public static void ApplyTDP(int PL1, int PL2)
15 | {
16 | //Determine OS
17 | //Windows
18 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
19 | {
20 | //Determine CPU vendor
21 | if (WindowsCpuInfo.ModelName.ToLower().Contains("ryzen"))
22 | {
23 | //Apply slow limit
24 | RyzenAdj_Backend_Windows.set_slow_limit(RyzenAdj_Backend_Windows.ry, (uint)(PL1 * 1000));
25 | //Apply fast limit
26 | RyzenAdj_Backend_Windows.set_fast_limit(RyzenAdj_Backend_Windows.ry, (uint)(PL2 * 1000));
27 | }
28 | }
29 | //Linux
30 | else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
31 | {
32 | //Determine CPU vendor
33 | if (LinuxCpuInfo.ModelName.ToLower().Contains("ryzen"))
34 | {
35 | //Apply slow limit
36 | RyzenAdj_Backend_Linux.set_slow_limit(RyzenAdj_Backend_Linux.ry, (uint)(PL1 * 1000));
37 | //Apply fast limit
38 | RyzenAdj_Backend_Linux.set_fast_limit(RyzenAdj_Backend_Linux.ry, (uint)(PL2 * 1000));
39 | }
40 | }
41 | }
42 |
43 | public static void ApplyCO(int cpuAllCO, int gfxCO)
44 | {
45 | //Determine OS
46 | //Windows
47 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
48 | {
49 | //Determine CPU vendor
50 | if (WindowsCpuInfo.ModelName.ToLower().Contains("ryzen"))
51 | {
52 | //Apply all core CO offset
53 | RyzenAdj_Backend_Windows.set_coall(RyzenAdj_Backend_Windows.ry, Convert.ToUInt32(0x100000 - (uint)(-1 * cpuAllCO)));
54 | //Apply iGPU CO offset
55 | RyzenAdj_Backend_Windows.set_cogfx(RyzenAdj_Backend_Windows.ry, Convert.ToUInt32(0x100000 - (uint)(-1 * gfxCO)));
56 | }
57 | }
58 | //Linux
59 | else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
60 | {
61 | //Determine CPU vendor
62 | if (LinuxCpuInfo.ModelName.ToLower().Contains("ryzen"))
63 | {
64 | //Apply all core CO offset
65 | RyzenAdj_Backend_Linux.set_coall(RyzenAdj_Backend_Linux.ry, Convert.ToUInt32(0x100000 - (uint)(-1 * cpuAllCO)));
66 | //Apply iGPU CO offset
67 | RyzenAdj_Backend_Linux.set_cogfx(RyzenAdj_Backend_Linux.ry, Convert.ToUInt32(0x100000 - (uint)(-1 * gfxCO)));
68 | }
69 | }
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/Framework Hub/Services/PowerModeSettings.cs:
--------------------------------------------------------------------------------
1 | using Framework_Hub.Scripts.Windows.Misc;
2 | using Newtonsoft.Json;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace Framework_Hub.Services
11 | {
12 | internal class PowerModeSettings
13 | {
14 | public class PowerModePresets
15 | {
16 | public int _powerIndex { get; set; } = 2;
17 |
18 | public int _pl1 { get; set; } = 999;
19 | public int _pl2 { get; set; } = 999;
20 |
21 | public int _pl1Max { get; set; } = 999;
22 | public int _pl2Max { get; set; } = 999;
23 | public int _pl1Min { get; set; } = 999;
24 | public int _pl2Min { get; set; } = 999;
25 |
26 | public int _temp { get; set; } = 100;
27 |
28 | public int _allCO { get; set; } = 0;
29 | public int _gfxCO { get; set; } = 0;
30 |
31 | public int _pboOffset { get; set; } = 1;
32 |
33 | public int _winPower { get; set; } = 2;
34 |
35 | }
36 |
37 | internal class PowerModeSettingsManager
38 | {
39 | private Dictionary _settings;
40 |
41 | private readonly string _configDirectory;
42 | string _device = GetSystemInfo.Product;
43 | bool hasDGPUModule = GetSystemInfo.HasDGPUModule();
44 | // set up manager instance
45 | public PowerModeSettingsManager(string configDirectory)
46 | {
47 | _configDirectory = configDirectory;
48 | _settings = new Dictionary();
49 | LoadPresets();
50 | }
51 |
52 | // Get data from preset
53 | public PowerModePresets GetPreset(int _powerMode)
54 | {
55 | if (_settings.ContainsKey($"{_device}_{hasDGPUModule}_{_powerMode}"))
56 | {
57 | return _settings[$"{_device}_{hasDGPUModule}_{_powerMode}"];
58 | }
59 | else
60 | {
61 | return null;
62 | }
63 | }
64 |
65 | // Load all presents into string dictionary
66 | private void LoadPresets()
67 | {
68 | if (File.Exists(_configDirectory))
69 | {
70 | string json = File.ReadAllText(_configDirectory);
71 | _settings = JsonConvert.DeserializeObject>(json);
72 | }
73 | else
74 | {
75 | _settings = new Dictionary();
76 | }
77 | }
78 |
79 | // Save preset to json file
80 | public void SaveSettings(PowerModePresets _newPreset, int _powerMode)
81 | {
82 | _settings[$"{_device}_{hasDGPUModule}_{_powerMode}"] = _newPreset;
83 | SaveAppSettings();
84 | }
85 |
86 | // Save json file changes
87 | private void SaveAppSettings()
88 | {
89 | string json = JsonConvert.SerializeObject(_settings, Newtonsoft.Json.Formatting.Indented);
90 | File.WriteAllText(_configDirectory, json);
91 | }
92 | }
93 | }
94 | }
--------------------------------------------------------------------------------
/Framework Hub/Assets/Framework-Computer.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Framework Hub/Scripts/Linux/RyzenAdj/Backend.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Framework_Hub.Scripts.Linux.RyzenAdj
9 | {
10 | public class RyzenAdj_Backend_Linux
11 | {
12 | [DllImport("libryzenadj.so")] public static extern IntPtr init_ryzenadj();
13 | [DllImport("libryzenadj.so")] public static extern int set_stapm_limit(IntPtr ry, uint value);
14 | [DllImport("libryzenadj.so")] public static extern int set_fast_limit(IntPtr ry, uint value);
15 | [DllImport("libryzenadj.so")] public static extern int set_slow_limit(IntPtr ry, uint value);
16 | [DllImport("libryzenadj.so")] public static extern int set_slow_time(IntPtr ry, uint value);
17 | [DllImport("libryzenadj.so")] public static extern int set_stapm_time(IntPtr ry, uint value);
18 | [DllImport("libryzenadj.so")] public static extern int set_tctl_temp(IntPtr ry, uint value);
19 | [DllImport("libryzenadj.so")] public static extern int set_vrm_current(IntPtr ry, uint value);
20 | [DllImport("libryzenadj.so")] public static extern int set_vrmsoc_current(IntPtr ry, uint value);
21 | [DllImport("libryzenadj.so")] public static extern int set_vrmmax_current(IntPtr ry, uint value);
22 | [DllImport("libryzenadj.so")] public static extern int set_vrmsocmax_current(IntPtr ry, uint value);
23 | [DllImport("libryzenadj.so")] public static extern int set_psi0_current(IntPtr ry, uint value);
24 | [DllImport("libryzenadj.so")] public static extern int set_psi0soc_current(IntPtr ry, uint value);
25 | [DllImport("libryzenadj.so")] public static extern int set_max_gfxclk_freq(IntPtr ry, uint value);
26 | [DllImport("libryzenadj.so")] public static extern int set_min_gfxclk_freq(IntPtr ry, uint value);
27 | [DllImport("libryzenadj.so")] public static extern int set_max_socclk_freq(IntPtr ry, uint value);
28 | [DllImport("libryzenadj.so")] public static extern int set_min_socclk_freq(IntPtr ry, uint value);
29 | [DllImport("libryzenadj.so")] public static extern int set_max_fclk_freq(IntPtr ry, uint value);
30 | [DllImport("libryzenadj.so")] public static extern int set_min_fclk_freq(IntPtr ry, uint value);
31 | [DllImport("libryzenadj.so")] public static extern int set_max_vcn(IntPtr ry, uint value);
32 | [DllImport("libryzenadj.so")] public static extern int set_min_vcn(IntPtr ry, uint value);
33 | [DllImport("libryzenadj.so")] public static extern int set_max_lclk(IntPtr ry, uint value);
34 | [DllImport("libryzenadj.so")] public static extern int set_min_lclk(IntPtr ry, uint value);
35 | [DllImport("libryzenadj.so")] public static extern int set_gfx_clk(IntPtr ry, uint value);
36 | [DllImport("libryzenadj.so")] public static extern int set_oc_clk(IntPtr ry, uint value);
37 | [DllImport("libryzenadj.so")] public static extern int set_per_core_oc_clk(IntPtr ry, uint value);
38 | [DllImport("libryzenadj.so")] public static extern int set_oc_volt(IntPtr ry, uint value);
39 | [DllImport("libryzenadj.so")] public static extern int disable_oc(IntPtr ry);
40 | [DllImport("libryzenadj.so")] public static extern int enable_oc(IntPtr ry);
41 | [DllImport("libryzenadj.so")] public static extern int set_prochot_deassertion_ramp(IntPtr ry, uint value);
42 | [DllImport("libryzenadj.so")] public static extern int set_apu_skin_temp_limit(IntPtr ry, uint value);
43 | [DllImport("libryzenadj.so")] public static extern int set_dgpu_skin_temp_limit(IntPtr ry, uint value);
44 | [DllImport("libryzenadj.so")] public static extern int set_apu_slow_limit(IntPtr ry, uint value);
45 | [DllImport("libryzenadj.so")] public static extern int pbo_scalar(IntPtr ry, [In] uint value);
46 | [DllImport("libryzenadj.so")] public static extern int set_coall(IntPtr ry, uint value);
47 | [DllImport("libryzenadj.so")] public static extern int set_coper(IntPtr ry, uint value);
48 | [DllImport("libryzenadj.so")] public static extern int set_cogfx(IntPtr ry, uint value);
49 | [DllImport("libryzenadj.so")] public static extern int set_power_saving(IntPtr ry);
50 | [DllImport("libryzenadj.so")] public static extern int set_max_performance(IntPtr ry);
51 |
52 | public static IntPtr ry = init_ryzenadj();
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/Framework Hub/Scripts/Windows/RyzenAdj/Backend.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Framework_Hub.Scripts.Windows.RyzenAdj
9 | {
10 | public class RyzenAdj_Backend_Windows
11 | {
12 | [DllImport("libryzenadj.dll")] public static extern IntPtr init_ryzenadj();
13 | [DllImport("libryzenadj.dll")] public static extern int set_stapm_limit(IntPtr ry, [In] uint value);
14 | [DllImport("libryzenadj.dll")] public static extern int set_fast_limit(IntPtr ry, [In] uint value);
15 | [DllImport("libryzenadj.dll")] public static extern int set_slow_limit(IntPtr ry, [In] uint value);
16 | [DllImport("libryzenadj.dll")] public static extern int set_slow_time(IntPtr ry, [In] uint value);
17 | [DllImport("libryzenadj.dll")] public static extern int set_stapm_time(IntPtr ry, [In] uint value);
18 | [DllImport("libryzenadj.dll")] public static extern int set_tctl_temp(IntPtr ry, [In] uint value);
19 | [DllImport("libryzenadj.dll")] public static extern int set_vrm_current(IntPtr ry, [In] uint value);
20 | [DllImport("libryzenadj.dll")] public static extern int set_vrmsoc_current(IntPtr ry, [In] uint value);
21 | [DllImport("libryzenadj.dll")] public static extern int set_vrmmax_current(IntPtr ry, [In] uint value);
22 | [DllImport("libryzenadj.dll")] public static extern int set_vrmsocmax_current(IntPtr ry, [In] uint value);
23 | [DllImport("libryzenadj.dll")] public static extern int set_psi0_current(IntPtr ry, [In] uint value);
24 | [DllImport("libryzenadj.dll")] public static extern int set_psi0soc_current(IntPtr ry, [In] uint value);
25 | [DllImport("libryzenadj.dll")] public static extern int set_max_gfxclk_freq(IntPtr ry, [In] uint value);
26 | [DllImport("libryzenadj.dll")] public static extern int set_min_gfxclk_freq(IntPtr ry, [In] uint value);
27 | [DllImport("libryzenadj.dll")] public static extern int set_max_socclk_freq(IntPtr ry, [In] uint value);
28 | [DllImport("libryzenadj.dll")] public static extern int set_min_socclk_freq(IntPtr ry, [In] uint value);
29 | [DllImport("libryzenadj.dll")] public static extern int set_max_fclk_freq(IntPtr ry, [In] uint value);
30 | [DllImport("libryzenadj.dll")] public static extern int set_min_fclk_freq(IntPtr ry, [In] uint value);
31 | [DllImport("libryzenadj.dll")] public static extern int set_max_vcn(IntPtr ry, [In] uint value);
32 | [DllImport("libryzenadj.dll")] public static extern int set_min_vcn(IntPtr ry, [In] uint value);
33 | [DllImport("libryzenadj.dll")] public static extern int set_max_lclk(IntPtr ry, [In] uint value);
34 | [DllImport("libryzenadj.dll")] public static extern int set_min_lclk(IntPtr ry, [In] uint value);
35 | [DllImport("libryzenadj.dll")] public static extern int set_gfx_clk(IntPtr ry, [In] uint value);
36 | [DllImport("libryzenadj.dll")] public static extern int set_oc_clk(IntPtr ry, [In] uint value);
37 | [DllImport("libryzenadj.dll")] public static extern int set_per_core_oc_clk(IntPtr ry, [In] uint value);
38 | [DllImport("libryzenadj.dll")] public static extern int set_oc_volt(IntPtr ry, [In] uint value);
39 | [DllImport("libryzenadj.dll")] public static extern int disable_oc(IntPtr ry);
40 | [DllImport("libryzenadj.dll")] public static extern int enable_oc(IntPtr ry);
41 | [DllImport("libryzenadj.dll")] public static extern int set_prochot_deassertion_ramp(IntPtr ry, [In] uint value);
42 | [DllImport("libryzenadj.dll")] public static extern int set_apu_skin_temp_limit(IntPtr ry, [In] uint value);
43 | [DllImport("libryzenadj.dll")] public static extern int set_dgpu_skin_temp_limit(IntPtr ry, [In] uint value);
44 | [DllImport("libryzenadj.dll")] public static extern int set_apu_slow_limit(IntPtr ry, [In] uint value);
45 | [DllImport("libryzenadj.dll")] public static extern int pbo_scalar(IntPtr ry, [In] uint value);
46 | [DllImport("libryzenadj.dll")] public static extern int set_coall(IntPtr ry, [In] uint value);
47 | [DllImport("libryzenadj.dll")] public static extern int set_coper(IntPtr ry, [In] uint value);
48 | [DllImport("libryzenadj.dll")] public static extern int set_cogfx(IntPtr ry, [In] uint value);
49 | [DllImport("libryzenadj.dll")] public static extern int set_power_saving(IntPtr ry);
50 | [DllImport("libryzenadj.dll")] public static extern int set_max_performance(IntPtr ry);
51 |
52 | public static IntPtr ry = init_ryzenadj();
53 | }
54 | }
--------------------------------------------------------------------------------
/Framework Hub/Views/MainWindow.axaml:
--------------------------------------------------------------------------------
1 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
42 |
56 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
93 |
109 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Ww][Ii][Nn]32/
27 | [Aa][Rr][Mm]/
28 | [Aa][Rr][Mm]64/
29 | bld/
30 | [Bb]in/
31 | [Oo]bj/
32 | [Ll]og/
33 | [Ll]ogs/
34 |
35 | # Visual Studio 2015/2017 cache/options directory
36 | .vs/
37 | # Uncomment if you have tasks that create the project's static files in wwwroot
38 | #wwwroot/
39 |
40 | # Visual Studio 2017 auto generated files
41 | Generated\ Files/
42 |
43 | # MSTest test Results
44 | [Tt]est[Rr]esult*/
45 | [Bb]uild[Ll]og.*
46 |
47 | # NUnit
48 | *.VisualState.xml
49 | TestResult.xml
50 | nunit-*.xml
51 |
52 | # Build Results of an ATL Project
53 | [Dd]ebugPS/
54 | [Rr]eleasePS/
55 | dlldata.c
56 |
57 | # Benchmark Results
58 | BenchmarkDotNet.Artifacts/
59 |
60 | # .NET Core
61 | project.lock.json
62 | project.fragment.lock.json
63 | artifacts/
64 |
65 | # Tye
66 | .tye/
67 |
68 | # ASP.NET Scaffolding
69 | ScaffoldingReadMe.txt
70 |
71 | # StyleCop
72 | StyleCopReport.xml
73 |
74 | # Files built by Visual Studio
75 | *_i.c
76 | *_p.c
77 | *_h.h
78 | *.ilk
79 | *.meta
80 | *.obj
81 | *.iobj
82 | *.pch
83 | *.pdb
84 | *.ipdb
85 | *.pgc
86 | *.pgd
87 | *.rsp
88 | *.sbr
89 | *.tlb
90 | *.tli
91 | *.tlh
92 | *.tmp
93 | *.tmp_proj
94 | *_wpftmp.csproj
95 | *.log
96 | *.vspscc
97 | *.vssscc
98 | .builds
99 | *.pidb
100 | *.svclog
101 | *.scc
102 |
103 | # Chutzpah Test files
104 | _Chutzpah*
105 |
106 | # Visual C++ cache files
107 | ipch/
108 | *.aps
109 | *.ncb
110 | *.opendb
111 | *.opensdf
112 | *.sdf
113 | *.cachefile
114 | *.VC.db
115 | *.VC.VC.opendb
116 |
117 | # Visual Studio profiler
118 | *.psess
119 | *.vsp
120 | *.vspx
121 | *.sap
122 |
123 | # Visual Studio Trace Files
124 | *.e2e
125 |
126 | # TFS 2012 Local Workspace
127 | $tf/
128 |
129 | # Guidance Automation Toolkit
130 | *.gpState
131 |
132 | # ReSharper is a .NET coding add-in
133 | _ReSharper*/
134 | *.[Rr]e[Ss]harper
135 | *.DotSettings.user
136 |
137 | # TeamCity is a build add-in
138 | _TeamCity*
139 |
140 | # DotCover is a Code Coverage Tool
141 | *.dotCover
142 |
143 | # AxoCover is a Code Coverage Tool
144 | .axoCover/*
145 | !.axoCover/settings.json
146 |
147 | # Coverlet is a free, cross platform Code Coverage Tool
148 | coverage*.json
149 | coverage*.xml
150 | coverage*.info
151 |
152 | # Visual Studio code coverage results
153 | *.coverage
154 | *.coveragexml
155 |
156 | # NCrunch
157 | _NCrunch_*
158 | .*crunch*.local.xml
159 | nCrunchTemp_*
160 |
161 | # MightyMoose
162 | *.mm.*
163 | AutoTest.Net/
164 |
165 | # Web workbench (sass)
166 | .sass-cache/
167 |
168 | # Installshield output folder
169 | [Ee]xpress/
170 |
171 | # DocProject is a documentation generator add-in
172 | DocProject/buildhelp/
173 | DocProject/Help/*.HxT
174 | DocProject/Help/*.HxC
175 | DocProject/Help/*.hhc
176 | DocProject/Help/*.hhk
177 | DocProject/Help/*.hhp
178 | DocProject/Help/Html2
179 | DocProject/Help/html
180 |
181 | # Click-Once directory
182 | publish/
183 |
184 | # Publish Web Output
185 | *.[Pp]ublish.xml
186 | *.azurePubxml
187 | # Note: Comment the next line if you want to checkin your web deploy settings,
188 | # but database connection strings (with potential passwords) will be unencrypted
189 | *.pubxml
190 | *.publishproj
191 |
192 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
193 | # checkin your Azure Web App publish settings, but sensitive information contained
194 | # in these scripts will be unencrypted
195 | PublishScripts/
196 |
197 | # NuGet Packages
198 | *.nupkg
199 | # NuGet Symbol Packages
200 | *.snupkg
201 | # The packages folder can be ignored because of Package Restore
202 | **/[Pp]ackages/*
203 | # except build/, which is used as an MSBuild target.
204 | !**/[Pp]ackages/build/
205 | # Uncomment if necessary however generally it will be regenerated when needed
206 | #!**/[Pp]ackages/repositories.config
207 | # NuGet v3's project.json files produces more ignorable files
208 | *.nuget.props
209 | *.nuget.targets
210 |
211 | # Microsoft Azure Build Output
212 | csx/
213 | *.build.csdef
214 |
215 | # Microsoft Azure Emulator
216 | ecf/
217 | rcf/
218 |
219 | # Windows Store app package directories and files
220 | AppPackages/
221 | BundleArtifacts/
222 | Package.StoreAssociation.xml
223 | _pkginfo.txt
224 | *.appx
225 | *.appxbundle
226 | *.appxupload
227 |
228 | # Visual Studio cache files
229 | # files ending in .cache can be ignored
230 | *.[Cc]ache
231 | # but keep track of directories ending in .cache
232 | !?*.[Cc]ache/
233 |
234 | # Others
235 | ClientBin/
236 | ~$*
237 | *~
238 | *.dbmdl
239 | *.dbproj.schemaview
240 | *.jfm
241 | *.pfx
242 | *.publishsettings
243 | orleans.codegen.cs
244 |
245 | # Including strong name files can present a security risk
246 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
247 | #*.snk
248 |
249 | # Since there are multiple workflows, uncomment next line to ignore bower_components
250 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
251 | #bower_components/
252 |
253 | # RIA/Silverlight projects
254 | Generated_Code/
255 |
256 | # Backup & report files from converting an old project file
257 | # to a newer Visual Studio version. Backup files are not needed,
258 | # because we have git ;-)
259 | _UpgradeReport_Files/
260 | Backup*/
261 | UpgradeLog*.XML
262 | UpgradeLog*.htm
263 | ServiceFabricBackup/
264 | *.rptproj.bak
265 |
266 | # SQL Server files
267 | *.mdf
268 | *.ldf
269 | *.ndf
270 |
271 | # Business Intelligence projects
272 | *.rdl.data
273 | *.bim.layout
274 | *.bim_*.settings
275 | *.rptproj.rsuser
276 | *- [Bb]ackup.rdl
277 | *- [Bb]ackup ([0-9]).rdl
278 | *- [Bb]ackup ([0-9][0-9]).rdl
279 |
280 | # Microsoft Fakes
281 | FakesAssemblies/
282 |
283 | # GhostDoc plugin setting file
284 | *.GhostDoc.xml
285 |
286 | # Node.js Tools for Visual Studio
287 | .ntvs_analysis.dat
288 | node_modules/
289 |
290 | # Visual Studio 6 build log
291 | *.plg
292 |
293 | # Visual Studio 6 workspace options file
294 | *.opt
295 |
296 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
297 | *.vbw
298 |
299 | # Visual Studio LightSwitch build output
300 | **/*.HTMLClient/GeneratedArtifacts
301 | **/*.DesktopClient/GeneratedArtifacts
302 | **/*.DesktopClient/ModelManifest.xml
303 | **/*.Server/GeneratedArtifacts
304 | **/*.Server/ModelManifest.xml
305 | _Pvt_Extensions
306 |
307 | # Paket dependency manager
308 | .paket/paket.exe
309 | paket-files/
310 |
311 | # FAKE - F# Make
312 | .fake/
313 |
314 | # CodeRush personal settings
315 | .cr/personal
316 |
317 | # Python Tools for Visual Studio (PTVS)
318 | __pycache__/
319 | *.pyc
320 |
321 | # Cake - Uncomment if you are using it
322 | # tools/**
323 | # !tools/packages.config
324 |
325 | # Tabs Studio
326 | *.tss
327 |
328 | # Telerik's JustMock configuration file
329 | *.jmconfig
330 |
331 | # BizTalk build output
332 | *.btp.cs
333 | *.btm.cs
334 | *.odx.cs
335 | *.xsd.cs
336 |
337 | # OpenCover UI analysis results
338 | OpenCover/
339 |
340 | # Azure Stream Analytics local run output
341 | ASALocalRun/
342 |
343 | # MSBuild Binary and Structured Log
344 | *.binlog
345 |
346 | # NVidia Nsight GPU debugger configuration file
347 | *.nvuser
348 |
349 | # MFractors (Xamarin productivity tool) working folder
350 | .mfractor/
351 |
352 | # Local History for Visual Studio
353 | .localhistory/
354 |
355 | # BeatPulse healthcheck temp database
356 | healthchecksdb
357 |
358 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
359 | MigrationBackup/
360 |
361 | # Ionide (cross platform F# VS Code tools) working folder
362 | .ionide/
363 |
364 | # Fody - auto-generated XML schema
365 | FodyWeavers.xsd
366 |
367 | ##
368 | ## Visual studio for Mac
369 | ##
370 |
371 |
372 | # globs
373 | Makefile.in
374 | *.userprefs
375 | *.usertasks
376 | config.make
377 | config.status
378 | aclocal.m4
379 | install-sh
380 | autom4te.cache/
381 | *.tar.gz
382 | tarballs/
383 | test-results/
384 |
385 | # Mac bundle stuff
386 | *.dmg
387 | *.app
388 |
389 | # content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
390 | # General
391 | .DS_Store
392 | .AppleDouble
393 | .LSOverride
394 |
395 | # Icon must end with two \r
396 | Icon
397 |
398 |
399 | # Thumbnails
400 | ._*
401 |
402 | # Files that might appear in the root of a volume
403 | .DocumentRevisions-V100
404 | .fseventsd
405 | .Spotlight-V100
406 | .TemporaryItems
407 | .Trashes
408 | .VolumeIcon.icns
409 | .com.apple.timemachine.donotpresent
410 |
411 | # Directories potentially created on remote AFP share
412 | .AppleDB
413 | .AppleDesktop
414 | Network Trash Folder
415 | Temporary Items
416 | .apdisk
417 |
418 | # content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
419 | # Windows thumbnail cache files
420 | Thumbs.db
421 | ehthumbs.db
422 | ehthumbs_vista.db
423 |
424 | # Dump file
425 | *.stackdump
426 |
427 | # Folder config file
428 | [Dd]esktop.ini
429 |
430 | # Recycle Bin used on file shares
431 | $RECYCLE.BIN/
432 |
433 | # Windows Installer files
434 | *.cab
435 | *.msi
436 | *.msix
437 | *.msm
438 | *.msp
439 |
440 | # Windows shortcuts
441 | *.lnk
442 |
443 | # JetBrains Rider
444 | .idea/
445 | *.sln.iml
446 |
447 | ##
448 | ## Visual Studio Code
449 | ##
450 | .vscode/*
451 | !.vscode/settings.json
452 | !.vscode/tasks.json
453 | !.vscode/launch.json
454 | !.vscode/extensions.json
455 |
--------------------------------------------------------------------------------
/Framework Hub/Scripts/Windows/Fan Control/WinRingEC_Management.cs:
--------------------------------------------------------------------------------
1 | using OpenLibSys_Fan;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Framework_Hub.Scripts.Windows.Fan_Control
9 | {
10 | internal class WinRingEC_Management
11 | {
12 | public static ushort reg_addr = 0x0;
13 | public static ushort reg_data = 0x0;
14 | static Ols ols = new Ols();
15 | static Object lockObject = new object();
16 | public static void InitECWin4()
17 |
18 | {
19 |
20 | if (ols == null)
21 |
22 | OlsInit();
23 |
24 | if (ols == null)
25 |
26 | return;
27 |
28 | try
29 |
30 | {
31 |
32 | byte EC_Chip_ID1 = ECRamReadWin4(0x2000);
33 |
34 | if (EC_Chip_ID1 == 0x55)
35 |
36 | {
37 |
38 | byte EC_Chip_Ver = ECRamReadWin4(0x1060);
39 |
40 | EC_Chip_Ver = (Byte)(EC_Chip_Ver | 0x80);
41 |
42 | ECRamWriteWin4(0x1060, EC_Chip_Ver);
43 |
44 |
45 | }
46 |
47 | //if (ols != null)
48 |
49 | // OlsFree();
50 |
51 | }
52 |
53 | catch
54 |
55 | {
56 |
57 | OlsFree();
58 |
59 | return;
60 |
61 | }
62 |
63 | }
64 |
65 |
66 |
67 | public static byte ECRamReadWin4(ushort address)
68 |
69 | {
70 |
71 | if (ols == null)
72 |
73 | OlsInit();
74 |
75 | if (ols == null)
76 |
77 | return 0;
78 |
79 | byte data = 0;
80 |
81 | byte high_byte = (byte)((address >> 8) & 0xFF);
82 |
83 | byte low_byte = (byte)(address & 0xFF);
84 | try
85 | {
86 |
87 | lock (lockObject)
88 |
89 | {
90 |
91 | reg_addr = 0x2E;
92 |
93 | reg_data = 0x2F;
94 |
95 | ols.WriteIoPortByte(reg_addr, 0x2E);
96 |
97 | ols.WriteIoPortByte(reg_data, 0x11);
98 |
99 | ols.WriteIoPortByte(reg_addr, 0x2F);
100 |
101 | ols.WriteIoPortByte(reg_data, high_byte);
102 |
103 |
104 |
105 | ols.WriteIoPortByte(reg_addr, 0x2E);
106 |
107 | ols.WriteIoPortByte(reg_data, 0x10);
108 |
109 | ols.WriteIoPortByte(reg_addr, 0x2F);
110 |
111 | ols.WriteIoPortByte(reg_data, low_byte);
112 |
113 |
114 |
115 | ols.WriteIoPortByte(reg_addr, 0x2E);
116 |
117 | ols.WriteIoPortByte(reg_data, 0x12);
118 |
119 | ols.WriteIoPortByte(reg_addr, 0x2F);
120 |
121 | data = ols.ReadIoPortByte(reg_data);
122 |
123 | }
124 |
125 | //if (ols != null)
126 |
127 | // OlsFree();
128 |
129 | }
130 |
131 | catch
132 |
133 | {
134 |
135 | OlsFree();
136 |
137 | return 0;
138 |
139 | }
140 |
141 | return data;
142 |
143 | }
144 |
145 |
146 |
147 | public static void ECRamWriteWin4(ushort address, byte data)
148 |
149 | {
150 |
151 | if (ols == null)
152 |
153 | OlsInit();
154 |
155 | if (ols == null)
156 |
157 | return;
158 |
159 |
160 |
161 | byte high_byte = (byte)((address >> 8) & 0xFF);
162 |
163 | byte low_byte = (byte)(address & 0xFF);
164 |
165 | try
166 | {
167 |
168 | lock (lockObject)
169 |
170 | {
171 |
172 | reg_addr = 0x2E;
173 |
174 | reg_data = 0x2F;
175 |
176 | ols.WriteIoPortByte(reg_addr, 0x2E);
177 |
178 | ols.WriteIoPortByte(reg_data, 0x11);
179 |
180 | ols.WriteIoPortByte(reg_addr, 0x2F);
181 |
182 | ols.WriteIoPortByte(reg_data, high_byte);
183 |
184 |
185 |
186 | ols.WriteIoPortByte(reg_addr, 0x2E);
187 |
188 | ols.WriteIoPortByte(reg_data, 0x10);
189 |
190 | ols.WriteIoPortByte(reg_addr, 0x2F);
191 |
192 | ols.WriteIoPortByte(reg_data, low_byte);
193 |
194 |
195 |
196 | ols.WriteIoPortByte(reg_addr, 0x2E);
197 |
198 | ols.WriteIoPortByte(reg_data, 0x12);
199 |
200 | ols.WriteIoPortByte(reg_addr, 0x2F);
201 |
202 | ols.WriteIoPortByte(reg_data, data);
203 |
204 | }
205 |
206 | //if (ols != null)
207 |
208 | // OlsFree();
209 |
210 | }
211 |
212 | catch
213 |
214 | {
215 |
216 | OlsFree();
217 |
218 | return;
219 |
220 | }
221 |
222 |
223 |
224 | }
225 | public static void ECRamWrite(ushort address, byte data)
226 | {
227 | if (ols == null)
228 | OlsInit();
229 | if (ols == null)
230 | return;
231 | byte high_byte = (byte)((address >> 8) & 0xFF);
232 | byte low_byte = (byte)(address & 0xFF);
233 | try
234 | {
235 | lock (lockObject)
236 | {
237 | ols.WriteIoPortByte(reg_addr, 0x2E);
238 | ols.WriteIoPortByte(reg_data, 0x11);
239 | ols.WriteIoPortByte(reg_addr, 0x2F);
240 | ols.WriteIoPortByte(reg_data, high_byte);
241 |
242 | ols.WriteIoPortByte(reg_addr, 0x2E);
243 | ols.WriteIoPortByte(reg_data, 0x10);
244 | ols.WriteIoPortByte(reg_addr, 0x2F);
245 | ols.WriteIoPortByte(reg_data, low_byte);
246 |
247 | ols.WriteIoPortByte(reg_addr, 0x2E);
248 | ols.WriteIoPortByte(reg_data, 0x12);
249 | ols.WriteIoPortByte(reg_addr, 0x2F);
250 | ols.WriteIoPortByte(reg_data, data);
251 |
252 |
253 | }
254 | }
255 | catch
256 | {
257 | ols = null;
258 | return;
259 | }
260 |
261 | }
262 |
263 | public static byte ECRamRead(ushort address)
264 | {
265 |
266 | if (ols == null)
267 | OlsInit();
268 | if (ols == null)
269 | return 0;
270 | byte data = 0;
271 | byte high_byte = (byte)((address >> 8) & 0xFF);
272 | byte low_byte = (byte)(address & 0xFF);
273 | try
274 | {
275 | lock (lockObject)
276 | {
277 | ols.WriteIoPortByte(reg_addr, 0x2E);
278 | ols.WriteIoPortByte(reg_data, 0x11);
279 | ols.WriteIoPortByte(reg_addr, 0x2F);
280 | ols.WriteIoPortByte(reg_data, high_byte);
281 |
282 | ols.WriteIoPortByte(reg_addr, 0x2E);
283 | ols.WriteIoPortByte(reg_data, 0x10);
284 | ols.WriteIoPortByte(reg_addr, 0x2F);
285 | ols.WriteIoPortByte(reg_data, low_byte);
286 |
287 | ols.WriteIoPortByte(reg_addr, 0x2E);
288 | ols.WriteIoPortByte(reg_data, 0x12);
289 | ols.WriteIoPortByte(reg_addr, 0x2F);
290 | data = ols.ReadIoPortByte(reg_data);
291 | }
292 |
293 | }
294 | catch
295 | {
296 | ols = null;
297 | return 0;
298 | }
299 |
300 | return data;
301 | }
302 |
303 | unsafe public static void OlsInit()
304 | {
305 | //-----------------------------------------------------------------------------
306 | // Initialize
307 | //-----------------------------------------------------------------------------
308 | ols = new Ols();
309 |
310 | // Check support library sutatus
311 | switch (ols.GetStatus())
312 | {
313 | case (uint)Ols.Status.NO_ERROR:
314 | break;
315 | case (uint)Ols.Status.DLL_NOT_FOUND:
316 | ols = null;
317 | // MessageBox.Show("WingRing0 Status Error!! DLL_NOT_FOUND");
318 | break;
319 | case (uint)Ols.Status.DLL_INCORRECT_VERSION:
320 | ols = null;
321 | // MessageBox.Show("WingRing0 Status Error!! DLL_INCORRECT_VERSION");
322 | break;
323 | case (uint)Ols.Status.DLL_INITIALIZE_ERROR:
324 | ols = null;
325 | // MessageBox.Show("WingRing0 Status Error!! DLL_INITIALIZE_ERROR");
326 | break;
327 | }
328 | if (ols == null)
329 | {
330 | //RaiseOlsInitFailedEvent();
331 | return;
332 | }
333 |
334 | // Check WinRing0 status
335 | switch (ols.GetDllStatus())
336 | {
337 | case (uint)Ols.OlsDllStatus.OLS_DLL_NO_ERROR:
338 | break;
339 | case (uint)Ols.OlsDllStatus.OLS_DLL_DRIVER_NOT_LOADED:
340 | // MessageBox.Show("WingRing0 DLL Status Error!! OLS_DRIVER_NOT_LOADED");
341 | ols = null;
342 | break;
343 | case (uint)Ols.OlsDllStatus.OLS_DLL_UNSUPPORTED_PLATFORM:
344 | // MessageBox.Show("WingRing0 DLL Status Error!! OLS_UNSUPPORTED_PLATFORM");
345 | ols = null;
346 | break;
347 | case (uint)Ols.OlsDllStatus.OLS_DLL_DRIVER_NOT_FOUND:
348 | // MessageBox.Show("WingRing0 DLL Status Error!! OLS_DLL_DRIVER_NOT_FOUND");
349 | ols = null;
350 | break;
351 | case (uint)Ols.OlsDllStatus.OLS_DLL_DRIVER_UNLOADED:
352 | // MessageBox.Show("WingRing0 DLL Status Error!! OLS_DLL_DRIVER_UNLOADED");
353 | ols = null;
354 | break;
355 | case (uint)Ols.OlsDllStatus.OLS_DLL_DRIVER_NOT_LOADED_ON_NETWORK:
356 | // MessageBox.Show("WingRing0 DLL Status Error!! DRIVER_NOT_LOADED_ON_NETWORK");
357 | ols = null;
358 | break;
359 | case (uint)Ols.OlsDllStatus.OLS_DLL_UNKNOWN_ERROR:
360 | // MessageBox.Show("WingRing0 DLL Status Error!! OLS_DLL_UNKNOWN_ERROR");
361 | ols = null;
362 | break;
363 | }
364 | if (ols == null)
365 | {
366 | //RaiseOlsInitFailedEvent();
367 | return;
368 | }
369 | }
370 |
371 | public static void OlsFree()
372 | {
373 | if (ols != null)
374 | ols.DeinitializeOls();
375 | }
376 |
377 | }
378 | }
379 |
--------------------------------------------------------------------------------
/Framework Hub/ViewModels/MainViewModel.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using ReactiveUI;
3 | using ReactiveUI.Fody.Helpers;
4 | using System;
5 | using System.Diagnostics;
6 | using Framework_Hub.Scripts.Windows.RyzenAdj;
7 | using Framework_Hub.Scripts.Linux.RyzenAdj;
8 | using System.Runtime.InteropServices;
9 | using Framework_Hub.Scripts.Windows.Misc;
10 | using System.Linq.Expressions;
11 | using System.Linq;
12 | using System.Reactive.Linq;
13 | using System.Threading.Tasks;
14 | using Framework_Hub.Services;
15 | using static Framework_Hub.Services.AppSettings;
16 | using System.IO;
17 | using static Framework_Hub.Services.PowerModeSettings;
18 |
19 | namespace Framework_Hub.ViewModels
20 | {
21 | public class MainViewModel : ReactiveObject
22 | {
23 | private int _powerIndex = 2;
24 |
25 | private int _pl1 = 999;
26 | private int _pl2 = 999;
27 |
28 | private int _pl1Max = 999;
29 | private int _pl2Max = 999;
30 | private int _pl1Min = 999;
31 | private int _pl2Min = 999;
32 |
33 | private int _temp = 100;
34 |
35 | private int _allCO = 0;
36 | private int _gfxCO = 0;
37 |
38 | private int _pboOffset = 1;
39 |
40 | private int _winPower;
41 | private string _winPowerText;
42 |
43 | public event System.EventHandler PowerUpdated;
44 |
45 | [Reactive]
46 | public int PowerIndex
47 | {
48 | get => _powerIndex;
49 | set => this.RaiseAndSetIfChanged(ref _powerIndex, value);
50 | }
51 |
52 | [Reactive]
53 | public int Temp
54 | {
55 | get => _temp;
56 | set => this.RaiseAndSetIfChanged(ref _temp, value);
57 | }
58 |
59 | [Reactive]
60 | public int PL1
61 | {
62 | get => _pl1;
63 | set => this.RaiseAndSetIfChanged(ref _pl1, value);
64 | }
65 |
66 | [Reactive]
67 | public int PL2
68 | {
69 | get => _pl2;
70 | set => this.RaiseAndSetIfChanged(ref _pl2, value);
71 | }
72 |
73 | public int PL1Max
74 | {
75 | get => _pl1Max;
76 | set => this.RaiseAndSetIfChanged(ref _pl1Max, value);
77 | }
78 |
79 | [Reactive]
80 | public int PL2Max
81 | {
82 | get => _pl2Max;
83 | set => this.RaiseAndSetIfChanged(ref _pl2Max, value);
84 | }
85 |
86 | public int PL1Min
87 | {
88 | get => _pl1Min;
89 | set => this.RaiseAndSetIfChanged(ref _pl1Min, value);
90 | }
91 |
92 | [Reactive]
93 | public int PL2Min
94 | {
95 | get => _pl2Max;
96 | set => this.RaiseAndSetIfChanged(ref _pl2Min, value);
97 | }
98 |
99 | [Reactive]
100 | public int AllCO
101 | {
102 | get => _allCO;
103 | set => this.RaiseAndSetIfChanged(ref _allCO, value);
104 | }
105 |
106 | [Reactive]
107 | public int GfxCO
108 | {
109 | get => _gfxCO;
110 | set => this.RaiseAndSetIfChanged(ref _gfxCO, value);
111 | }
112 |
113 | [Reactive]
114 | public int PboOffset
115 | {
116 | get => _pboOffset;
117 | set => this.RaiseAndSetIfChanged(ref _pboOffset, value);
118 | }
119 |
120 | [Reactive]
121 | public int WinPower
122 | {
123 | get => _winPower;
124 | set => this.RaiseAndSetIfChanged(ref _winPower, value);
125 | }
126 |
127 | [Reactive]
128 | public string WinPowerText
129 | {
130 | get => _winPowerText;
131 | set => this.RaiseAndSetIfChanged(ref _winPowerText, value);
132 | }
133 |
134 | AppSettingsManager appSettings = new AppSettingsManager("Settings.json");
135 | PowerModeSettingsManager powerModeSettings = new PowerModeSettingsManager("PowerSettings.json");
136 |
137 | public MainViewModel()
138 | {
139 | if (File.Exists("Settings.json"))
140 | {
141 | Settings settings = appSettings.GetPreset();
142 | PowerIndex = settings.lastPowerMode;
143 | }
144 | else PowerIndex = 2;
145 |
146 |
147 | // Setup event to detect variable changes
148 | var propertySelectors = new Expression>[]
149 | {
150 | x => x.Temp,
151 | x => x.PL1,
152 | x => x.PL2,
153 | x => x.AllCO,
154 | x => x.GfxCO,
155 | x => x.PboOffset,
156 | x => x.WinPower,
157 | x => x.PowerIndex
158 | };
159 |
160 | var observables = propertySelectors
161 | .Select(selector => this.WhenAnyValue(selector))
162 | .ToArray();
163 |
164 | var mergedObservable = Observable.Merge(observables);
165 |
166 | mergedObservable.Subscribe(_ => OnPowerChange());
167 |
168 | // Setup temp defaults for each power mode
169 | SetUpTempPower();
170 | }
171 |
172 | int lastPowerMode = -1;
173 | private async void OnPowerChange()
174 | {
175 | // Update Windows power mode setting
176 | WinPowerMode.SetWinPowerMode(WinPower);
177 |
178 | // Update Windows power mode icon
179 | if (WinPower == 0) WinPowerText = "\ue8be";
180 | else if (WinPower == 1) WinPowerText = "\uec49";
181 | else if (WinPower == 2) WinPowerText = "\uec4a";
182 |
183 | if (lastPowerMode != PowerIndex)
184 | {
185 | SetUpTempPower();
186 | lastPowerMode = PowerIndex;
187 | }
188 |
189 | SavePreset();
190 |
191 | await ApplyPowerSettings();
192 | }
193 |
194 | public async Task ApplyPowerSettings()
195 | {
196 | await Task.Delay(1500); // Delay for 1.5 seconds
197 |
198 | // RyzenAdj apply code for Windows
199 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
200 | {
201 | // Set temp limit
202 | RyzenAdj_Backend_Windows.set_tctl_temp(RyzenAdj_Backend_Windows.ry, (uint)Temp);
203 | // Set PL1
204 | RyzenAdj_Backend_Windows.set_slow_limit(RyzenAdj_Backend_Windows.ry, (uint)(PL1 * 1000));
205 | // Set PL2
206 | RyzenAdj_Backend_Windows.set_fast_limit(RyzenAdj_Backend_Windows.ry, (uint)(PL2 * 1000));
207 |
208 | // Set all core Curve Optimiser offset
209 | if (AllCO < 0) RyzenAdj_Backend_Windows.set_coall(RyzenAdj_Backend_Windows.ry, Convert.ToUInt32(0x100000 - (uint)(-1 * AllCO)));
210 | else RyzenAdj_Backend_Windows.set_coall(RyzenAdj_Backend_Windows.ry, 0);
211 |
212 | // Set iGPU Curve Optimiser offset
213 | if (GfxCO < 0) RyzenAdj_Backend_Windows.set_cogfx(RyzenAdj_Backend_Windows.ry, Convert.ToUInt32(0x100000 - (uint)(-1 * GfxCO)));
214 | else RyzenAdj_Backend_Windows.set_cogfx(RyzenAdj_Backend_Windows.ry, 0);
215 |
216 | // PBO Scalar Offset
217 | RyzenAdj_Backend_Windows.pbo_scalar(RyzenAdj_Backend_Windows.ry, (uint)(PboOffset * 100));
218 | }
219 | // RyzenAdj apply code for Linux
220 | else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
221 | {
222 | // Set temp limit
223 | RyzenAdj_Backend_Linux.set_tctl_temp(RyzenAdj_Backend_Linux.ry, (uint)Temp);
224 | // Set PL1
225 | RyzenAdj_Backend_Linux.set_slow_limit(RyzenAdj_Backend_Linux.ry, (uint)(PL1 * 1000));
226 | // Set PL2
227 | RyzenAdj_Backend_Linux.set_fast_limit(RyzenAdj_Backend_Linux.ry, (uint)(PL2 * 1000));
228 |
229 | // Set all core Curve Optimiser offset
230 | if (AllCO < 0) RyzenAdj_Backend_Linux.set_coall(RyzenAdj_Backend_Linux.ry, Convert.ToUInt32(0x100000 - (uint)(-1 * AllCO)));
231 | else RyzenAdj_Backend_Linux.set_coall(RyzenAdj_Backend_Linux.ry, 0);
232 |
233 | // Set iGPU Curve Optimiser offset
234 | if (GfxCO < 0) RyzenAdj_Backend_Linux.set_cogfx(RyzenAdj_Backend_Linux.ry, Convert.ToUInt32(0x100000 - (uint)(-1 * GfxCO)));
235 | else RyzenAdj_Backend_Linux.set_cogfx(RyzenAdj_Backend_Linux.ry, 0);
236 |
237 | // PBO Scalar Offset
238 | RyzenAdj_Backend_Linux.pbo_scalar(RyzenAdj_Backend_Linux.ry, (uint)(PboOffset * 100));
239 | }
240 | }
241 |
242 | private void SetUpTempPower()
243 | {
244 | if (powerModeSettings.GetPreset(PowerIndex) != null && File.Exists("PowerSettings.json"))
245 | {
246 | PowerModePresets _powerPreset = powerModeSettings.GetPreset(PowerIndex);
247 | Temp = _powerPreset._temp;
248 | PL1 = _powerPreset._pl1;
249 | PL2 = _powerPreset._pl2;
250 | PL1Max = _powerPreset._pl1Max;
251 | PL2Max = _powerPreset._pl2Max;
252 | PL1Min = _powerPreset._pl1Min;
253 | PL2Min = _powerPreset._pl2Min;
254 | AllCO = _powerPreset._allCO;
255 | GfxCO = _powerPreset._gfxCO;
256 | PboOffset = _powerPreset._pboOffset;
257 | WinPower = _powerPreset._winPower;
258 | }
259 | else
260 | {
261 | // Setup temp defaults for each power mode
262 | if (GetSystemInfo.Product.Contains("16"))
263 | {
264 | if (PowerIndex == 0)
265 | {
266 | PL1 = 85;
267 | PL2 = 85;
268 | WinPower = 0;
269 | }
270 | else if (PowerIndex == 1)
271 | {
272 | PL1 = 95;
273 | PL2 = 95;
274 | WinPower = 1;
275 | }
276 | else if (PowerIndex == 2)
277 | {
278 | PL1 = 100;
279 | PL2 = 120;
280 | WinPower = 2;
281 | }
282 |
283 | PL1Min = 10;
284 | PL2Min = 10;
285 | PL1Max = 140;
286 | PL2Max = 140;
287 | }
288 | else if (GetSystemInfo.Product.Contains("13"))
289 | {
290 | if (PowerIndex == 0)
291 | {
292 | PL1 = 15;
293 | PL2 = 18;
294 | WinPower = 0;
295 | }
296 | else if (PowerIndex == 1)
297 | {
298 | PL1 = 28;
299 | PL2 = 28;
300 | WinPower = 1;
301 | }
302 | else if (PowerIndex == 2)
303 | {
304 | PL1 = 35;
305 | PL2 = 60;
306 | WinPower = 2;
307 | }
308 |
309 | PL1Min = 5;
310 | PL2Min = 5;
311 | PL1Max = 60;
312 | PL2Max = 60;
313 |
314 | SavePreset();
315 | }
316 | }
317 |
318 | Settings _settings = new Settings()
319 | {
320 | lastPowerMode = PowerIndex,
321 | };
322 | appSettings.SaveSettings(_settings);
323 | }
324 |
325 | private void SavePreset()
326 | {
327 | PowerModePresets _powerMode = new PowerModePresets()
328 | {
329 | _temp = Temp,
330 | _pl1Max = PL1Max,
331 | _pl2Max = PL2Max,
332 | _pl1Min = PL1Min,
333 | _pl2Min = PL2Min,
334 | _pl1 = PL1,
335 | _pl2 = PL2,
336 | _winPower = WinPower,
337 | _allCO = AllCO,
338 | _gfxCO = GfxCO,
339 | _pboOffset = PboOffset,
340 | };
341 | powerModeSettings.SaveSettings(_powerMode, PowerIndex);
342 | }
343 | }
344 | }
345 |
--------------------------------------------------------------------------------
/Framework Hub/Views/MainView.axaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | Temperature Limit Controls
35 | Customise preset temperature limits
36 |
37 |
38 |
39 |
40 | Temperature Limit (°C)
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | 15
50 | 15
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | Power Limit Controls
62 | Customise preset power limits
63 |
64 |
65 |
66 |
67 | Slow Boost Power Limit (W)
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 | 15
77 | 15
78 |
79 |
80 |
81 |
82 | Fast Boost Power Limit (W)
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 | 15
92 | 15
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 | Windows Power Mode Controls
105 | Customise preset power mode settings
106 |
107 |
108 |
109 |
110 | Power Mode
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 | 15
120 | 15
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 | Curve Optimiser Controls
133 | Customise preset voltage offsets
134 |
135 |
136 |
137 |
138 | All Core Offset
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 | 15
148 | 15
149 |
150 |
151 |
152 |
153 | iGPU Offset
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 | 15
163 | 15
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 | Precision Boost Overdrive Controls
176 | Customise preset PBO settings
177 |
178 |
179 |
180 |
181 | PBO Scalar
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 | 15
191 | 15
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 | Framework Laptop 13 (2023)
206 | - AMD Ryzen™ 7 7840U w/ Radeon 780M Graphics
207 | - AMD Radeon 780M
208 | - 32GB DDR5 5600MT/s
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
233 |
249 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
--------------------------------------------------------------------------------
/Framework Hub/Scripts/Windows/Fan Control/OpenLibSys_Fan.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | // Author : hiyohiyo
3 | // Mail : hiyohiyo@crystalmark.info
4 | // Web : http://openlibsys.org/
5 | // License : The modified BSD license
6 | //
7 | // Copyright 2007-2009 OpenLibSys.org. All rights reserved.
8 | //-----------------------------------------------------------------------------
9 | // This is support library for WinRing0 1.3.x.
10 |
11 | using System;
12 | using System.Runtime.InteropServices;
13 |
14 | namespace OpenLibSys_Fan
15 | {
16 | public class Ols : IDisposable
17 | {
18 | const string dllNameX64 = "WinRing0x64_Fan.dll";
19 | const string dllName = "WinRing0_Fan.dll";
20 |
21 | // for this support library
22 | public enum Status
23 | {
24 | NO_ERROR = 0,
25 | DLL_NOT_FOUND = 1,
26 | DLL_INCORRECT_VERSION = 2,
27 | DLL_INITIALIZE_ERROR = 3,
28 | }
29 |
30 | // for WinRing0
31 | public enum OlsDllStatus
32 | {
33 | OLS_DLL_NO_ERROR = 0,
34 | OLS_DLL_UNSUPPORTED_PLATFORM = 1,
35 | OLS_DLL_DRIVER_NOT_LOADED = 2,
36 | OLS_DLL_DRIVER_NOT_FOUND = 3,
37 | OLS_DLL_DRIVER_UNLOADED = 4,
38 | OLS_DLL_DRIVER_NOT_LOADED_ON_NETWORK = 5,
39 | OLS_DLL_UNKNOWN_ERROR = 9
40 | }
41 |
42 | // for WinRing0
43 | public enum OlsDriverType
44 | {
45 | OLS_DRIVER_TYPE_UNKNOWN = 0,
46 | OLS_DRIVER_TYPE_WIN_9X = 1,
47 | OLS_DRIVER_TYPE_WIN_NT = 2,
48 | OLS_DRIVER_TYPE_WIN_NT4 = 3, // Obsolete
49 | OLS_DRIVER_TYPE_WIN_NT_X64 = 4,
50 | OLS_DRIVER_TYPE_WIN_NT_IA64 = 5
51 | }
52 |
53 | // for WinRing0
54 | public enum OlsErrorPci : uint
55 | {
56 | OLS_ERROR_PCI_BUS_NOT_EXIST = 0xE0000001,
57 | OLS_ERROR_PCI_NO_DEVICE = 0xE0000002,
58 | OLS_ERROR_PCI_WRITE_CONFIG = 0xE0000003,
59 | OLS_ERROR_PCI_READ_CONFIG = 0xE0000004
60 | }
61 |
62 | // Bus Number, Device Number and Function Number to PCI Device Address
63 | public uint PciBusDevFunc(uint bus, uint dev, uint func)
64 | {
65 | return ((bus & 0xFF) << 8) | ((dev & 0x1F) << 3) | (func & 7);
66 | }
67 |
68 | // PCI Device Address to Bus Number
69 | public uint PciGetBus(uint address)
70 | {
71 | return ((address >> 8) & 0xFF);
72 | }
73 |
74 | // PCI Device Address to Device Number
75 | public uint PciGetDev(uint address)
76 | {
77 | return ((address >> 3) & 0x1F);
78 | }
79 |
80 | // PCI Device Address to Function Number
81 | public uint PciGetFunc(uint address)
82 | {
83 | return (address & 7);
84 | }
85 |
86 | [DllImport("kernel32")]
87 | public extern static IntPtr LoadLibrary(string lpFileName);
88 |
89 |
90 | [DllImport("kernel32", SetLastError = true)]
91 | private static extern bool FreeLibrary(IntPtr hModule);
92 |
93 | [DllImport("kernel32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = false)]
94 | private static extern IntPtr GetProcAddress(IntPtr hModule, [MarshalAs(UnmanagedType.LPStr)] string lpProcName);
95 |
96 | private IntPtr module = IntPtr.Zero;
97 | private uint status = (uint)Status.NO_ERROR;
98 |
99 | public Ols()
100 | {
101 | string fileName;
102 |
103 | if (System.IntPtr.Size == 8)
104 | {
105 | fileName = dllNameX64;
106 | }
107 | else
108 | {
109 | fileName = dllName;
110 | }
111 |
112 | module = Ols.LoadLibrary(fileName);
113 | if (module == IntPtr.Zero)
114 | {
115 | status = (uint)Status.DLL_NOT_FOUND;
116 | }
117 | else
118 | {
119 | GetDllStatus = (_GetDllStatus)GetDelegate("GetDllStatus", typeof(_GetDllStatus));
120 | GetDllVersion = (_GetDllVersion)GetDelegate("GetDllVersion", typeof(_GetDllVersion));
121 | GetDriverVersion = (_GetDriverVersion)GetDelegate("GetDriverVersion", typeof(_GetDriverVersion));
122 | GetDriverType = (_GetDriverType)GetDelegate("GetDriverType", typeof(_GetDriverType));
123 |
124 | InitializeOls = (_InitializeOls)GetDelegate("InitializeOls", typeof(_InitializeOls));
125 | DeinitializeOls = (_DeinitializeOls)GetDelegate("DeinitializeOls", typeof(_DeinitializeOls));
126 |
127 | IsCpuid = (_IsCpuid)GetDelegate("IsCpuid", typeof(_IsCpuid));
128 | IsMsr = (_IsMsr)GetDelegate("IsMsr", typeof(_IsMsr));
129 | IsTsc = (_IsTsc)GetDelegate("IsTsc", typeof(_IsTsc));
130 | Hlt = (_Hlt)GetDelegate("Hlt", typeof(_Hlt));
131 | HltTx = (_HltTx)GetDelegate("HltTx", typeof(_HltTx));
132 | HltPx = (_HltPx)GetDelegate("HltPx", typeof(_HltPx));
133 | Rdmsr = (_Rdmsr)GetDelegate("Rdmsr", typeof(_Rdmsr));
134 | RdmsrTx = (_RdmsrTx)GetDelegate("RdmsrTx", typeof(_RdmsrTx));
135 | RdmsrPx = (_RdmsrPx)GetDelegate("RdmsrPx", typeof(_RdmsrPx));
136 | Wrmsr = (_Wrmsr)GetDelegate("Wrmsr", typeof(_Wrmsr));
137 | WrmsrTx = (_WrmsrTx)GetDelegate("WrmsrTx", typeof(_WrmsrTx));
138 | WrmsrPx = (_WrmsrPx)GetDelegate("WrmsrPx", typeof(_WrmsrPx));
139 | Rdpmc = (_Rdpmc)GetDelegate("Rdpmc", typeof(_Rdpmc));
140 | RdpmcTx = (_RdpmcTx)GetDelegate("RdpmcTx", typeof(_RdpmcTx));
141 | RdpmcPx = (_RdpmcPx)GetDelegate("RdpmcPx", typeof(_RdpmcPx));
142 | Cpuid = (_Cpuid)GetDelegate("Cpuid", typeof(_Cpuid));
143 | CpuidTx = (_CpuidTx)GetDelegate("CpuidTx", typeof(_CpuidTx));
144 | CpuidPx = (_CpuidPx)GetDelegate("CpuidPx", typeof(_CpuidPx));
145 | Rdtsc = (_Rdtsc)GetDelegate("Rdtsc", typeof(_Rdtsc));
146 | RdtscTx = (_RdtscTx)GetDelegate("RdtscTx", typeof(_RdtscTx));
147 | RdtscPx = (_RdtscPx)GetDelegate("RdtscPx", typeof(_RdtscPx));
148 |
149 | ReadIoPortByte = (_ReadIoPortByte)GetDelegate("ReadIoPortByte", typeof(_ReadIoPortByte));
150 | ReadIoPortWord = (_ReadIoPortWord)GetDelegate("ReadIoPortWord", typeof(_ReadIoPortWord));
151 | ReadIoPortDword = (_ReadIoPortDword)GetDelegate("ReadIoPortDword", typeof(_ReadIoPortDword));
152 | ReadIoPortByteEx = (_ReadIoPortByteEx)GetDelegate("ReadIoPortByteEx", typeof(_ReadIoPortByteEx));
153 | ReadIoPortWordEx = (_ReadIoPortWordEx)GetDelegate("ReadIoPortWordEx", typeof(_ReadIoPortWordEx));
154 | ReadIoPortDwordEx = (_ReadIoPortDwordEx)GetDelegate("ReadIoPortDwordEx", typeof(_ReadIoPortDwordEx));
155 |
156 | WriteIoPortByte = (_WriteIoPortByte)GetDelegate("WriteIoPortByte", typeof(_WriteIoPortByte));
157 | WriteIoPortWord = (_WriteIoPortWord)GetDelegate("WriteIoPortWord", typeof(_WriteIoPortWord));
158 | WriteIoPortDword = (_WriteIoPortDword)GetDelegate("WriteIoPortDword", typeof(_WriteIoPortDword));
159 | WriteIoPortByteEx = (_WriteIoPortByteEx)GetDelegate("WriteIoPortByteEx", typeof(_WriteIoPortByteEx));
160 | WriteIoPortWordEx = (_WriteIoPortWordEx)GetDelegate("WriteIoPortWordEx", typeof(_WriteIoPortWordEx));
161 | WriteIoPortDwordEx = (_WriteIoPortDwordEx)GetDelegate("WriteIoPortDwordEx", typeof(_WriteIoPortDwordEx));
162 |
163 | SetPciMaxBusIndex = (_SetPciMaxBusIndex)GetDelegate("SetPciMaxBusIndex", typeof(_SetPciMaxBusIndex));
164 | ReadPciConfigByte = (_ReadPciConfigByte)GetDelegate("ReadPciConfigByte", typeof(_ReadPciConfigByte));
165 | ReadPciConfigWord = (_ReadPciConfigWord)GetDelegate("ReadPciConfigWord", typeof(_ReadPciConfigWord));
166 | ReadPciConfigDword = (_ReadPciConfigDword)GetDelegate("ReadPciConfigDword", typeof(_ReadPciConfigDword));
167 | ReadPciConfigByteEx = (_ReadPciConfigByteEx)GetDelegate("ReadPciConfigByteEx", typeof(_ReadPciConfigByteEx));
168 | ReadPciConfigWordEx = (_ReadPciConfigWordEx)GetDelegate("ReadPciConfigWordEx", typeof(_ReadPciConfigWordEx));
169 | ReadPciConfigDwordEx = (_ReadPciConfigDwordEx)GetDelegate("ReadPciConfigDwordEx", typeof(_ReadPciConfigDwordEx));
170 | WritePciConfigByte = (_WritePciConfigByte)GetDelegate("WritePciConfigByte", typeof(_WritePciConfigByte));
171 | WritePciConfigWord = (_WritePciConfigWord)GetDelegate("WritePciConfigWord", typeof(_WritePciConfigWord));
172 | WritePciConfigDword = (_WritePciConfigDword)GetDelegate("WritePciConfigDword", typeof(_WritePciConfigDword));
173 | WritePciConfigByteEx = (_WritePciConfigByteEx)GetDelegate("WritePciConfigByteEx", typeof(_WritePciConfigByteEx));
174 | WritePciConfigWordEx = (_WritePciConfigWordEx)GetDelegate("WritePciConfigWordEx", typeof(_WritePciConfigWordEx));
175 | WritePciConfigDwordEx = (_WritePciConfigDwordEx)GetDelegate("WritePciConfigDwordEx", typeof(_WritePciConfigDwordEx));
176 | FindPciDeviceById = (_FindPciDeviceById)GetDelegate("FindPciDeviceById", typeof(_FindPciDeviceById));
177 | FindPciDeviceByClass = (_FindPciDeviceByClass)GetDelegate("FindPciDeviceByClass", typeof(_FindPciDeviceByClass));
178 |
179 | #if _PHYSICAL_MEMORY_SUPPORT
180 | ReadDmiMemory = (_ReadDmiMemory)GetDelegate("ReadDmiMemory", typeof(_ReadDmiMemory));
181 | ReadPhysicalMemory = (_ReadPhysicalMemory)GetDelegate("ReadPhysicalMemory", typeof(_ReadPhysicalMemory));
182 | WritePhysicalMemory = (_WritePhysicalMemory)GetDelegate("WritePhysicalMemory", typeof(_WritePhysicalMemory));
183 | #endif
184 | if (!(
185 | GetDllStatus != null
186 | && GetDllVersion != null
187 | && GetDriverVersion != null
188 | && GetDriverType != null
189 | && InitializeOls != null
190 | && DeinitializeOls != null
191 | && IsCpuid != null
192 | && IsMsr != null
193 | && IsTsc != null
194 | && Hlt != null
195 | && HltTx != null
196 | && HltPx != null
197 | && Rdmsr != null
198 | && RdmsrTx != null
199 | && RdmsrPx != null
200 | && Wrmsr != null
201 | && WrmsrTx != null
202 | && WrmsrPx != null
203 | && Rdpmc != null
204 | && RdpmcTx != null
205 | && RdpmcPx != null
206 | && Cpuid != null
207 | && CpuidTx != null
208 | && CpuidPx != null
209 | && Rdtsc != null
210 | && RdtscTx != null
211 | && RdtscPx != null
212 | && ReadIoPortByte != null
213 | && ReadIoPortWord != null
214 | && ReadIoPortDword != null
215 | && ReadIoPortByteEx != null
216 | && ReadIoPortWordEx != null
217 | && ReadIoPortDwordEx != null
218 | && WriteIoPortByte != null
219 | && WriteIoPortWord != null
220 | && WriteIoPortDword != null
221 | && WriteIoPortByteEx != null
222 | && WriteIoPortWordEx != null
223 | && WriteIoPortDwordEx != null
224 | && SetPciMaxBusIndex != null
225 | && ReadPciConfigByte != null
226 | && ReadPciConfigWord != null
227 | && ReadPciConfigDword != null
228 | && ReadPciConfigByteEx != null
229 | && ReadPciConfigWordEx != null
230 | && ReadPciConfigDwordEx != null
231 | && WritePciConfigByte != null
232 | && WritePciConfigWord != null
233 | && WritePciConfigDword != null
234 | && WritePciConfigByteEx != null
235 | && WritePciConfigWordEx != null
236 | && WritePciConfigDwordEx != null
237 | && FindPciDeviceById != null
238 | && FindPciDeviceByClass != null
239 | #if _PHYSICAL_MEMORY_SUPPORT
240 | && ReadDmiMemory != null
241 | && ReadPhysicalMemory != null
242 | && WritePhysicalMemory != null
243 | #endif
244 | ))
245 | {
246 | status = (uint)Status.DLL_INCORRECT_VERSION;
247 | }
248 |
249 | if (InitializeOls() == 0)
250 | {
251 | status = (uint)Status.DLL_INITIALIZE_ERROR;
252 | }
253 | }
254 | }
255 |
256 | public uint GetStatus()
257 | {
258 | return status;
259 | }
260 |
261 | public void Dispose()
262 | {
263 | if (module != IntPtr.Zero)
264 | {
265 | DeinitializeOls();
266 | Ols.FreeLibrary(module);
267 | module = IntPtr.Zero;
268 | }
269 | }
270 |
271 | public Delegate GetDelegate(string procName, Type delegateType)
272 | {
273 | IntPtr ptr = GetProcAddress(module, procName);
274 | if (ptr != IntPtr.Zero)
275 | {
276 | Delegate d = Marshal.GetDelegateForFunctionPointer(ptr, delegateType);
277 | return d;
278 | }
279 |
280 | int result = Marshal.GetHRForLastWin32Error();
281 | throw Marshal.GetExceptionForHR(result);
282 | }
283 |
284 | //-----------------------------------------------------------------------------
285 | // DLL Information
286 | //-----------------------------------------------------------------------------
287 | public delegate uint _GetDllStatus();
288 | public delegate uint _GetDllVersion(ref byte major, ref byte minor, ref byte revision, ref byte release);
289 | public delegate uint _GetDriverVersion(ref byte major, ref byte minor, ref byte revision, ref byte release);
290 | public delegate uint _GetDriverType();
291 |
292 | public delegate int _InitializeOls();
293 | public delegate void _DeinitializeOls();
294 |
295 | public _GetDllStatus GetDllStatus = null;
296 | public _GetDriverType GetDriverType = null;
297 | public _GetDllVersion GetDllVersion = null;
298 | public _GetDriverVersion GetDriverVersion = null;
299 |
300 | public _InitializeOls InitializeOls = null;
301 | public _DeinitializeOls DeinitializeOls = null;
302 |
303 | //-----------------------------------------------------------------------------
304 | // CPU
305 | //-----------------------------------------------------------------------------
306 | public delegate int _IsCpuid();
307 | public delegate int _IsMsr();
308 | public delegate int _IsTsc();
309 | public delegate int _Hlt();
310 | public delegate int _HltTx(UIntPtr threadAffinityMask);
311 | public delegate int _HltPx(UIntPtr processAffinityMask);
312 | public delegate int _Rdmsr(uint index, ref uint eax, ref uint edx);
313 | public delegate int _RdmsrTx(uint index, ref uint eax, ref uint edx, UIntPtr threadAffinityMask);
314 | public delegate int _RdmsrPx(uint index, ref uint eax, ref uint edx, UIntPtr processAffinityMask);
315 | public delegate int _Wrmsr(uint index, uint eax, uint edx);
316 | public delegate int _WrmsrTx(uint index, uint eax, uint edx, UIntPtr threadAffinityMask);
317 | public delegate int _WrmsrPx(uint index, uint eax, uint edx, UIntPtr processAffinityMask);
318 | public delegate int _Rdpmc(uint index, ref uint eax, ref uint edx);
319 | public delegate int _RdpmcTx(uint index, ref uint eax, ref uint edx, UIntPtr threadAffinityMask);
320 | public delegate int _RdpmcPx(uint index, ref uint eax, ref uint edx, UIntPtr processAffinityMask);
321 | public delegate int _Cpuid(uint index, ref uint eax, ref uint ebx, ref uint ecx, ref uint edx);
322 | public delegate int _CpuidTx(uint index, ref uint eax, ref uint ebx, ref uint ecx, ref uint edx, UIntPtr threadAffinityMask);
323 | public delegate int _CpuidPx(uint index, ref uint eax, ref uint ebx, ref uint ecx, ref uint edx, UIntPtr processAffinityMask);
324 | public delegate int _Rdtsc(ref uint eax, ref uint edx);
325 | public delegate int _RdtscTx(ref uint eax, ref uint edx, UIntPtr threadAffinityMask);
326 | public delegate int _RdtscPx(ref uint eax, ref uint edx, UIntPtr processAffinityMask);
327 |
328 | public _IsCpuid IsCpuid = null;
329 | public _IsMsr IsMsr = null;
330 | public _IsTsc IsTsc = null;
331 | public _Hlt Hlt = null;
332 | public _HltTx HltTx = null;
333 | public _HltPx HltPx = null;
334 | public _Rdmsr Rdmsr = null;
335 | public _RdmsrTx RdmsrTx = null;
336 | public _RdmsrPx RdmsrPx = null;
337 | public _Wrmsr Wrmsr = null;
338 | public _WrmsrTx WrmsrTx = null;
339 | public _WrmsrPx WrmsrPx = null;
340 | public _Rdpmc Rdpmc = null;
341 | public _RdpmcTx RdpmcTx = null;
342 | public _RdpmcPx RdpmcPx = null;
343 | public _Cpuid Cpuid = null;
344 | public _CpuidTx CpuidTx = null;
345 | public _CpuidPx CpuidPx = null;
346 | public _Rdtsc Rdtsc = null;
347 | public _RdtscTx RdtscTx = null;
348 | public _RdtscPx RdtscPx = null;
349 |
350 | //-----------------------------------------------------------------------------
351 | // I/O
352 | //-----------------------------------------------------------------------------
353 | public delegate byte _ReadIoPortByte(ushort port);
354 | public delegate ushort _ReadIoPortWord(ushort port);
355 | public delegate uint _ReadIoPortDword(ushort port);
356 | public _ReadIoPortByte ReadIoPortByte;
357 | public _ReadIoPortWord ReadIoPortWord;
358 | public _ReadIoPortDword ReadIoPortDword;
359 |
360 | public delegate int _ReadIoPortByteEx(ushort port, ref byte value);
361 | public delegate int _ReadIoPortWordEx(ushort port, ref ushort value);
362 | public delegate int _ReadIoPortDwordEx(ushort port, ref uint value);
363 | public _ReadIoPortByteEx ReadIoPortByteEx;
364 | public _ReadIoPortWordEx ReadIoPortWordEx;
365 | public _ReadIoPortDwordEx ReadIoPortDwordEx;
366 |
367 | public delegate void _WriteIoPortByte(ushort port, byte value);
368 | public delegate void _WriteIoPortWord(ushort port, ushort value);
369 | public delegate void _WriteIoPortDword(ushort port, uint value);
370 | public _WriteIoPortByte WriteIoPortByte;
371 | public _WriteIoPortWord WriteIoPortWord;
372 | public _WriteIoPortDword WriteIoPortDword;
373 |
374 | public delegate int _WriteIoPortByteEx(ushort port, byte value);
375 | public delegate int _WriteIoPortWordEx(ushort port, ushort value);
376 | public delegate int _WriteIoPortDwordEx(ushort port, uint value);
377 | public _WriteIoPortByteEx WriteIoPortByteEx;
378 | public _WriteIoPortWordEx WriteIoPortWordEx;
379 | public _WriteIoPortDwordEx WriteIoPortDwordEx;
380 |
381 | //-----------------------------------------------------------------------------
382 | // PCI
383 | //-----------------------------------------------------------------------------
384 | public delegate void _SetPciMaxBusIndex(byte max);
385 | public _SetPciMaxBusIndex SetPciMaxBusIndex;
386 |
387 | public delegate byte _ReadPciConfigByte(uint pciAddress, byte regAddress);
388 | public delegate ushort _ReadPciConfigWord(uint pciAddress, byte regAddress);
389 | public delegate uint _ReadPciConfigDword(uint pciAddress, byte regAddress);
390 | public _ReadPciConfigByte ReadPciConfigByte;
391 | public _ReadPciConfigWord ReadPciConfigWord;
392 | public _ReadPciConfigDword ReadPciConfigDword;
393 |
394 | public delegate int _ReadPciConfigByteEx(uint pciAddress, uint regAddress, ref byte value);
395 | public delegate int _ReadPciConfigWordEx(uint pciAddress, uint regAddress, ref ushort value);
396 | public delegate int _ReadPciConfigDwordEx(uint pciAddress, uint regAddress, ref uint value);
397 | public _ReadPciConfigByteEx ReadPciConfigByteEx;
398 | public _ReadPciConfigWordEx ReadPciConfigWordEx;
399 | public _ReadPciConfigDwordEx ReadPciConfigDwordEx;
400 |
401 | public delegate void _WritePciConfigByte(uint pciAddress, byte regAddress, byte value);
402 | public delegate void _WritePciConfigWord(uint pciAddress, byte regAddress, ushort value);
403 | public delegate void _WritePciConfigDword(uint pciAddress, byte regAddress, uint value);
404 | public _WritePciConfigByte WritePciConfigByte;
405 | public _WritePciConfigWord WritePciConfigWord;
406 | public _WritePciConfigDword WritePciConfigDword;
407 |
408 | public delegate int _WritePciConfigByteEx(uint pciAddress, uint regAddress, byte value);
409 | public delegate int _WritePciConfigWordEx(uint pciAddress, uint regAddress, ushort value);
410 | public delegate int _WritePciConfigDwordEx(uint pciAddress, uint regAddress, uint value);
411 | public _WritePciConfigByteEx WritePciConfigByteEx;
412 | public _WritePciConfigWordEx WritePciConfigWordEx;
413 | public _WritePciConfigDwordEx WritePciConfigDwordEx;
414 |
415 | public delegate uint _FindPciDeviceById(ushort vendorId, ushort deviceId, byte index);
416 | public delegate uint _FindPciDeviceByClass(byte baseClass, byte subClass, byte programIf, byte index);
417 | public _FindPciDeviceById FindPciDeviceById;
418 | public _FindPciDeviceByClass FindPciDeviceByClass;
419 |
420 | //-----------------------------------------------------------------------------
421 | // Physical Memory (unsafe)
422 | //-----------------------------------------------------------------------------
423 | #if _PHYSICAL_MEMORY_SUPPORT
424 | public unsafe delegate uint _ReadDmiMemory(byte* buffer, uint count, uint unitSize);
425 | public _ReadDmiMemory ReadDmiMemory;
426 |
427 | public unsafe delegate uint _ReadPhysicalMemory(UIntPtr address, byte* buffer, uint count, uint unitSize);
428 | public unsafe delegate uint _WritePhysicalMemory(UIntPtr address, byte* buffer, uint count, uint unitSize);
429 |
430 | public _ReadPhysicalMemory ReadPhysicalMemory;
431 | public _WritePhysicalMemory WritePhysicalMemory;
432 | #endif
433 | }
434 | }
--------------------------------------------------------------------------------
/Framework Hub/Scripts/Windows/Misc/GetSystemInfo.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Framework_Hub.Scripts.Misc;
3 | using Microsoft.Win32;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.IO;
7 | using System.Linq;
8 | using System.Management;
9 | using System.Text;
10 | using System.Threading.Tasks;
11 |
12 | namespace Framework_Hub.Scripts.Windows.Misc
13 | {
14 | internal class GetSystemInfo
15 | {
16 | private static ManagementObjectSearcher baseboardSearcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_BaseBoard");
17 | private static ManagementObjectSearcher motherboardSearcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_MotherboardDevice");
18 | private static ManagementObjectSearcher ComputerSsystemInfo = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_ComputerSystemProduct");
19 |
20 | public static bool HasDGPUModule() {
21 | if (IsGPUPresent("RX 7700S")) return true;
22 | else return false;
23 | }
24 |
25 | public static bool IsGPUPresent(string gpuName)
26 | {
27 | // Create a query to search for GPU devices
28 | var query = new SelectQuery("SELECT * FROM Win32_VideoController");
29 |
30 | // Create a ManagementObjectSearcher object with the query
31 | using (var searcher = new ManagementObjectSearcher(query))
32 | {
33 | // Execute the query and get the collection of ManagementObject
34 | var results = searcher.Get();
35 |
36 | // Iterate through each ManagementObject in the collection
37 | foreach (var result in results)
38 | {
39 | // Get the Name property of the GPU
40 | var name = result["Name"]?.ToString();
41 |
42 | // Check if the GPU name matches the specified name
43 | if (!string.IsNullOrEmpty(name) && name.Contains(gpuName, StringComparison.OrdinalIgnoreCase))
44 | {
45 | // GPU with the specified name found, return true
46 | return true;
47 | }
48 | }
49 | }
50 |
51 | // GPU with the specified name not found, return false
52 | return false;
53 | }
54 |
55 | public static string GetCPUName()
56 | {
57 | try
58 | {
59 | ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_Processor");
60 | ManagementObjectCollection collection = searcher.Get();
61 | foreach (ManagementObject obj in collection)
62 | {
63 | return obj["Name"].ToString();
64 | }
65 | }
66 | catch (Exception ex) { }
67 | return "";
68 | }
69 | public static string GetGPUName(int i)
70 | {
71 | try
72 | {
73 | int count = 0;
74 | ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", $"SELECT * FROM Win32_VideoController"); // Change AdapterCompatibility as per your requirement
75 | ManagementObjectCollection collection = searcher.Get();
76 |
77 | foreach (ManagementObject obj in collection)
78 | {
79 | if (count == i)
80 | {
81 | Garbage.Garbage_Collect();
82 | return obj["Name"].ToString();
83 | }
84 | count++;
85 | }
86 | }
87 | catch (Exception ex) { }
88 |
89 | Garbage.Garbage_Collect();
90 | return "";
91 | }
92 |
93 | static public string Availability
94 | {
95 | get
96 | {
97 | try
98 | {
99 | foreach (ManagementObject queryObj in motherboardSearcher.Get())
100 | {
101 | return GetAvailability(int.Parse(queryObj["Availability"].ToString()));
102 | }
103 | return "";
104 | }
105 | catch (Exception e)
106 | {
107 | return "";
108 | }
109 | }
110 | }
111 |
112 | static public bool HostingBoard
113 | {
114 | get
115 | {
116 | try
117 | {
118 | foreach (ManagementObject queryObj in baseboardSearcher.Get())
119 | {
120 | if (queryObj["HostingBoard"].ToString() == "True")
121 | return true;
122 | else
123 | return false;
124 | }
125 | return false;
126 | }
127 | catch (Exception e)
128 | {
129 | return false;
130 | }
131 | }
132 | }
133 |
134 | static public string InstallDate
135 | {
136 | get
137 | {
138 | try
139 | {
140 | foreach (ManagementObject queryObj in baseboardSearcher.Get())
141 | {
142 | return ConvertToDateTime(queryObj["InstallDate"].ToString());
143 | }
144 | return "";
145 | }
146 | catch (Exception e)
147 | {
148 | return "";
149 | }
150 | }
151 | }
152 |
153 | static public string Manufacturer
154 | {
155 | get
156 | {
157 | try
158 | {
159 | foreach (ManagementObject queryObj in baseboardSearcher.Get())
160 | {
161 | return queryObj["Manufacturer"].ToString();
162 | }
163 | return "";
164 | }
165 | catch (Exception e)
166 | {
167 | return "";
168 | }
169 | }
170 | }
171 |
172 | static public string Model
173 | {
174 | get
175 | {
176 | try
177 | {
178 | foreach (ManagementObject queryObj in baseboardSearcher.Get())
179 | {
180 | return Convert.ToString(queryObj["Model"]);
181 | }
182 | return "";
183 | }
184 | catch (Exception e)
185 | {
186 | return "";
187 | }
188 | }
189 | }
190 |
191 | static public string PartNumber
192 | {
193 | get
194 | {
195 | try
196 | {
197 | foreach (ManagementObject queryObj in baseboardSearcher.Get())
198 | {
199 | return queryObj["PartNumber"].ToString();
200 | }
201 | return "";
202 | }
203 | catch (Exception e)
204 | {
205 | return "";
206 | }
207 | }
208 | }
209 |
210 | static public string PNPDeviceID
211 | {
212 | get
213 | {
214 | try
215 | {
216 | foreach (ManagementObject queryObj in motherboardSearcher.Get())
217 | {
218 | return queryObj["PNPDeviceID"].ToString();
219 | }
220 | return "";
221 | }
222 | catch (Exception e)
223 | {
224 | return "";
225 | }
226 | }
227 | }
228 |
229 | static public string PrimaryBusType
230 | {
231 | get
232 | {
233 | try
234 | {
235 | foreach (ManagementObject queryObj in motherboardSearcher.Get())
236 | {
237 | return queryObj["PrimaryBusType"].ToString();
238 | }
239 | return "";
240 | }
241 | catch (Exception e)
242 | {
243 | return "";
244 | }
245 | }
246 | }
247 |
248 | static public string Product
249 | {
250 | get
251 | {
252 | try
253 | {
254 | foreach (ManagementObject queryObj in ComputerSsystemInfo.Get())
255 | {
256 | return queryObj["Name"].ToString();
257 | }
258 | return "";
259 | }
260 | catch (Exception e)
261 | {
262 | return "";
263 | }
264 | }
265 | }
266 |
267 | static public bool Removable
268 | {
269 | get
270 | {
271 | try
272 | {
273 | foreach (ManagementObject queryObj in baseboardSearcher.Get())
274 | {
275 | if (queryObj["Removable"].ToString() == "True")
276 | return true;
277 | else
278 | return false;
279 | }
280 | return false;
281 | }
282 | catch (Exception e)
283 | {
284 | return false;
285 | }
286 | }
287 | }
288 |
289 | static public bool Replaceable
290 | {
291 | get
292 | {
293 | try
294 | {
295 | foreach (ManagementObject queryObj in baseboardSearcher.Get())
296 | {
297 | if (queryObj["Replaceable"].ToString() == "True")
298 | return true;
299 | else
300 | return false;
301 | }
302 | return false;
303 | }
304 | catch (Exception e)
305 | {
306 | return false;
307 | }
308 | }
309 | }
310 |
311 | static public string RevisionNumber
312 | {
313 | get
314 | {
315 | try
316 | {
317 | foreach (ManagementObject queryObj in motherboardSearcher.Get())
318 | {
319 | return queryObj["RevisionNumber"].ToString();
320 | }
321 | return "";
322 | }
323 | catch (Exception e)
324 | {
325 | return "";
326 | }
327 | }
328 | }
329 |
330 | static public string SecondaryBusType
331 | {
332 | get
333 | {
334 | try
335 | {
336 | foreach (ManagementObject queryObj in motherboardSearcher.Get())
337 | {
338 | return queryObj["SecondaryBusType"].ToString();
339 | }
340 | return "";
341 | }
342 | catch (Exception e)
343 | {
344 | return "";
345 | }
346 | }
347 | }
348 |
349 | static public string SerialNumber
350 | {
351 | get
352 | {
353 | try
354 | {
355 | foreach (ManagementObject queryObj in baseboardSearcher.Get())
356 | {
357 | return queryObj["SerialNumber"].ToString();
358 | }
359 | return "";
360 | }
361 | catch (Exception e)
362 | {
363 | return "";
364 | }
365 | }
366 | }
367 |
368 | static public string Status
369 | {
370 | get
371 | {
372 | try
373 | {
374 | foreach (ManagementObject querObj in baseboardSearcher.Get())
375 | {
376 | return querObj["Status"].ToString();
377 | }
378 | return "";
379 | }
380 | catch (Exception e)
381 | {
382 | return "";
383 | }
384 | }
385 | }
386 |
387 | static public string SystemName
388 | {
389 | get
390 | {
391 | try
392 | {
393 | foreach (ManagementObject queryObj in motherboardSearcher.Get())
394 | {
395 | return queryObj["SystemName"].ToString();
396 | }
397 | return "";
398 | }
399 | catch (Exception e)
400 | {
401 | return "";
402 | }
403 | }
404 | }
405 |
406 | static public string Version
407 | {
408 | get
409 | {
410 | try
411 | {
412 | foreach (ManagementObject queryObj in baseboardSearcher.Get())
413 | {
414 | return queryObj["Version"].ToString();
415 | }
416 | return "";
417 | }
418 | catch (Exception e)
419 | {
420 | return "";
421 | }
422 | }
423 | }
424 |
425 | private static string GetAvailability(int availability)
426 | {
427 | switch (availability)
428 | {
429 | case 1: return "Other";
430 | case 2: return "Unknown";
431 | case 3: return "Running or Full Power";
432 | case 4: return "Warning";
433 | case 5: return "In Test";
434 | case 6: return "Not Applicable";
435 | case 7: return "Power Off";
436 | case 8: return "Off Line";
437 | case 9: return "Off Duty";
438 | case 10: return "Degraded";
439 | case 11: return "Not Installed";
440 | case 12: return "Install Error";
441 | case 13: return "Power Save - Unknown";
442 | case 14: return "Power Save - Low Power Mode";
443 | case 15: return "Power Save - Standby";
444 | case 16: return "Power Cycle";
445 | case 17: return "Power Save - Warning";
446 | default: return "Unknown";
447 | }
448 | }
449 |
450 | private static string ConvertToDateTime(string unconvertedTime)
451 | {
452 | string convertedTime = "";
453 | int year = int.Parse(unconvertedTime.Substring(0, 4));
454 | int month = int.Parse(unconvertedTime.Substring(4, 2));
455 | int date = int.Parse(unconvertedTime.Substring(6, 2));
456 | int hours = int.Parse(unconvertedTime.Substring(8, 2));
457 | int minutes = int.Parse(unconvertedTime.Substring(10, 2));
458 | int seconds = int.Parse(unconvertedTime.Substring(12, 2));
459 | string meridian = "AM";
460 | if (hours > 12)
461 | {
462 | hours -= 12;
463 | meridian = "PM";
464 | }
465 | convertedTime = date.ToString() + "/" + month.ToString() + "/" + year.ToString() + " " +
466 | hours.ToString() + ":" + minutes.ToString() + ":" + seconds.ToString() + " " + meridian;
467 | return convertedTime;
468 | }
469 |
470 | public static decimal GetBatteryRate()
471 | {
472 |
473 | try
474 | {
475 | ManagementScope scope = new ManagementScope("root\\WMI");
476 | ObjectQuery query = new ObjectQuery("SELECT * FROM BatteryStatus");
477 |
478 | using ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
479 | foreach (ManagementObject obj in searcher.Get().Cast())
480 | {
481 | decimal chargeRate = Convert.ToDecimal(obj["ChargeRate"]);
482 | decimal dischargeRate = Convert.ToDecimal(obj["DischargeRate"]);
483 | if (chargeRate > 0)
484 | return chargeRate;
485 | else
486 | return -dischargeRate;
487 | }
488 |
489 | return 0;
490 |
491 | }
492 | catch (Exception ex)
493 | {
494 | return 0;
495 | }
496 | }
497 |
498 | public static decimal ReadFullChargeCapacity()
499 | {
500 |
501 | try
502 | {
503 | ManagementScope scope = new ManagementScope("root\\WMI");
504 | ObjectQuery query = new ObjectQuery("SELECT * FROM BatteryFullChargedCapacity");
505 |
506 | using ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
507 | foreach (ManagementObject obj in searcher.Get().Cast())
508 | {
509 | return Convert.ToDecimal(obj["FullChargedCapacity"]);
510 | }
511 | return 0;
512 | }
513 | catch (Exception ex)
514 | {
515 | return 0;
516 | }
517 |
518 | }
519 |
520 | public static decimal ReadDesignCapacity()
521 | {
522 | try
523 | {
524 | ManagementScope scope = new ManagementScope("root\\WMI");
525 | ObjectQuery query = new ObjectQuery("SELECT * FROM BatteryStaticData");
526 |
527 | using ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
528 | foreach (ManagementObject obj in searcher.Get().Cast())
529 | {
530 | return Convert.ToDecimal(obj["DesignedCapacity"]);
531 | }
532 | return 0;
533 | }
534 | catch (Exception ex)
535 | {
536 | return 0;
537 | }
538 | }
539 |
540 | public static int GetBatteryCycle()
541 | {
542 | try
543 | {
544 | ManagementObjectSearcher searcher =
545 | new ManagementObjectSearcher("root\\WMI",
546 | "SELECT * FROM BatteryCycleCount");
547 |
548 | foreach (ManagementObject queryObj in searcher.Get())
549 | {
550 |
551 | return Convert.ToInt32(queryObj["CycleCount"]);
552 | }
553 | return 0;
554 | }
555 | catch (ManagementException e)
556 | {
557 | return 0;
558 | }
559 | }
560 |
561 | public static decimal GetBatteryHealth()
562 | {
563 | var designCap = ReadDesignCapacity();
564 | var fullCap = ReadFullChargeCapacity();
565 |
566 | decimal health = (decimal)fullCap / (decimal)designCap;
567 |
568 | return health;
569 | }
570 |
571 | public enum CacheLevel : ushort
572 | {
573 | Level1 = 3,
574 | Level2 = 4,
575 | Level3 = 5,
576 | }
577 |
578 | public static List GetCacheSizes(CacheLevel level)
579 | {
580 | ManagementClass mc = new ManagementClass("Win32_CacheMemory");
581 | ManagementObjectCollection moc = mc.GetInstances();
582 | List cacheSizes = new List(moc.Count);
583 |
584 | cacheSizes.AddRange(moc
585 | .Cast()
586 | .Where(p => (ushort)(p.Properties["Level"].Value) == (ushort)level)
587 | .Select(p => (uint)(p.Properties["MaxCacheSize"].Value)));
588 |
589 | return cacheSizes;
590 | }
591 |
592 | public static string GetWindowsEdition()
593 | {
594 | using (var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion"))
595 | {
596 | return key?.GetValue("EditionID")?.ToString();
597 | }
598 | }
599 |
600 | public static string GetWindowsVersion()
601 | {
602 | using (var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion"))
603 | {
604 | return key?.GetValue("CurrentVersion")?.ToString();
605 | }
606 | }
607 |
608 | public static DateTime GetWindowsInstallDate()
609 | {
610 | using (var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion"))
611 | {
612 | string installDateValue = key?.GetValue("InstallDate")?.ToString();
613 | if (installDateValue != null && long.TryParse(installDateValue, out long installDateTicks))
614 | {
615 | return DateTime.FromFileTime(installDateTicks);
616 | }
617 | }
618 |
619 | return DateTime.MinValue;
620 | }
621 |
622 | public static string GetWindowsFeaturePack()
623 | {
624 | using (var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion"))
625 | {
626 | return key?.GetValue("ProductName")?.ToString();
627 | }
628 | }
629 |
630 | public static async void GetRAMInfo(TextBlock tbxRam)
631 | {
632 | double capacity = 0;
633 | int speed = 0;
634 | int type = 0;
635 | string producer = "";
636 |
637 | try
638 | {
639 | ManagementObjectSearcher searcher =
640 | new ManagementObjectSearcher("root\\CIMV2",
641 | "SELECT * FROM Win32_PhysicalMemory");
642 | await Task.Run(() =>
643 | {
644 | foreach (ManagementObject queryObj in searcher.Get())
645 | {
646 | capacity = capacity + Convert.ToDouble(queryObj["Capacity"]);
647 | speed = Convert.ToInt32(queryObj["ConfiguredClockSpeed"]);
648 | type = Convert.ToInt32(queryObj["SMBIOSMemoryType"]);
649 | }
650 | });
651 |
652 |
653 | capacity = capacity / 1024 / 1024 / 1024;
654 |
655 | string DDRType = "";
656 | if (type == 20) DDRType = "DDR";
657 | else if (type == 21) DDRType = "DDR2";
658 | else if (type == 24) DDRType = "DDR3";
659 | else if (type == 26) DDRType = "DDR4";
660 | else if (type == 30) DDRType = "LPDDR4";
661 | else if (type == 34) DDRType = "DDR5";
662 | else if (type == 35) DDRType = "LPDDR5";
663 | else DDRType = $"Unknown ({type})";
664 |
665 | tbxRam.Text = $"- {capacity}GB {DDRType} @ {speed} MT/s";
666 |
667 | }
668 | catch (Exception ex)
669 | {
670 |
671 | }
672 | }
673 | }
674 | }
675 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------