Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8a185c404 |
@@ -53,25 +53,6 @@ class SystemInfo extends FramerateCategory {
|
|||||||
if (osName != "")
|
if (osName != "")
|
||||||
osInfo = '${osName} ${osVersion}'.trim();
|
osInfo = '${osName} ${osVersion}'.trim();
|
||||||
}
|
}
|
||||||
#elseif windows
|
|
||||||
var windowsCurrentVersionPath = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
|
|
||||||
var buildNumber = Std.parseInt(RegistryUtil.get(HKEY_LOCAL_MACHINE, windowsCurrentVersionPath, "CurrentBuildNumber"));
|
|
||||||
var edition = RegistryUtil.get(HKEY_LOCAL_MACHINE, windowsCurrentVersionPath, "ProductName");
|
|
||||||
|
|
||||||
var lcuKey = "WinREVersion"; // Last Cumulative Update Key On Older Windows Versions
|
|
||||||
if (buildNumber >= 22000) { // Windows 11 Initial Release Build Number
|
|
||||||
edition = edition.replace("Windows 10", "Windows 11");
|
|
||||||
lcuKey = "LCUVer"; // Last Cumulative Update Key On Windows 11
|
|
||||||
}
|
|
||||||
|
|
||||||
var lcuVersion = RegistryUtil.get(HKEY_LOCAL_MACHINE, windowsCurrentVersionPath, lcuKey);
|
|
||||||
|
|
||||||
osInfo = edition;
|
|
||||||
|
|
||||||
if (lcuVersion != null && lcuVersion != "")
|
|
||||||
osInfo += ' ${lcuVersion}';
|
|
||||||
else if (lime.system.System.platformVersion != null && lime.system.System.platformVersion != "")
|
|
||||||
osInfo += ' ${lime.system.System.platformVersion}';
|
|
||||||
#else
|
#else
|
||||||
if (lime.system.System.platformLabel != null && lime.system.System.platformLabel != "" && lime.system.System.platformVersion != null && lime.system.System.platformVersion != "")
|
if (lime.system.System.platformLabel != null && lime.system.System.platformLabel != "" && lime.system.System.platformVersion != null && lime.system.System.platformVersion != "")
|
||||||
osInfo = '${lime.system.System.platformLabel.replace(lime.system.System.platformVersion, "").trim()} ${lime.system.System.platformVersion}';
|
osInfo = '${lime.system.System.platformLabel.replace(lime.system.System.platformVersion, "").trim()} ${lime.system.System.platformVersion}';
|
||||||
@@ -81,7 +62,10 @@ class SystemInfo extends FramerateCategory {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
#if windows
|
#if windows
|
||||||
cpuName = RegistryUtil.get(HKEY_LOCAL_MACHINE, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", "ProcessorNameString");
|
var process = new HiddenProcess("wmic", ["cpu", "get", "name"]);
|
||||||
|
if (process.exitCode() != 0) throw 'Could not fetch CPU information';
|
||||||
|
|
||||||
|
cpuName = process.stdout.readAll().toString().trim().split("\n")[1].trim();
|
||||||
#elseif mac
|
#elseif mac
|
||||||
var process = new HiddenProcess("sysctl -a | grep brand_string"); // Somehow this isn't able to use the args but it still works
|
var process = new HiddenProcess("sysctl -a | grep brand_string"); // Somehow this isn't able to use the args but it still works
|
||||||
if (process.exitCode() != 0) throw 'Could not fetch CPU information';
|
if (process.exitCode() != 0) throw 'Could not fetch CPU information';
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ final class MemoryUtil {
|
|||||||
public static function getMemType():String {
|
public static function getMemType():String {
|
||||||
#if windows
|
#if windows
|
||||||
var memoryMap:Map<Int, String> = [
|
var memoryMap:Map<Int, String> = [
|
||||||
0 => null,
|
0 => "Unknown",
|
||||||
1 => "Other",
|
1 => "Other",
|
||||||
2 => "DRAM",
|
2 => "DRAM",
|
||||||
3 => "Synchronous DRAM",
|
3 => "Synchronous DRAM",
|
||||||
@@ -152,23 +152,13 @@ final class MemoryUtil {
|
|||||||
22 => "DDR2 FB-DIMM",
|
22 => "DDR2 FB-DIMM",
|
||||||
24 => "DDR3",
|
24 => "DDR3",
|
||||||
25 => "FBD2",
|
25 => "FBD2",
|
||||||
26 => "DDR4",
|
26 => "DDR4"
|
||||||
27 => "LPDDR",
|
|
||||||
28 => "LPDDR2",
|
|
||||||
29 => "LPDDR3",
|
|
||||||
30 => "LPDDR4",
|
|
||||||
31 => "Logical Non-volatile device",
|
|
||||||
32 => "HBM",
|
|
||||||
33 => "HBM2",
|
|
||||||
34 => "DDR5",
|
|
||||||
35 => "LPDDR5",
|
|
||||||
36 => "HBM3",
|
|
||||||
];
|
];
|
||||||
var memoryOutput:Int = -1;
|
var memoryOutput:Int = -1;
|
||||||
|
|
||||||
var process = new HiddenProcess("powershell", ["-Command", "Get-CimInstance Win32_PhysicalMemory | Select-Object -ExpandProperty SMBIOSMemoryType" ]);
|
var process = new HiddenProcess("wmic", ["memorychip", "get", "SMBIOSMemoryType"]);
|
||||||
if (process.exitCode() == 0) memoryOutput = Std.int(Std.parseFloat(process.stdout.readAll().toString().trim().split("\n")[1]));
|
if (process.exitCode() == 0) memoryOutput = Std.int(Std.parseFloat(process.stdout.readAll().toString().trim().split("\n")[1]));
|
||||||
if (memoryOutput != -1) return memoryMap[memoryOutput] == null ? 'Unknown ($memoryOutput)' : memoryMap[memoryOutput];
|
if (memoryOutput != -1) return memoryMap[memoryOutput];
|
||||||
#elseif mac
|
#elseif mac
|
||||||
var process = new HiddenProcess("system_profiler", ["SPMemoryDataType"]);
|
var process = new HiddenProcess("system_profiler", ["SPMemoryDataType"]);
|
||||||
var reg = ~/Type: (.+)/;
|
var reg = ~/Type: (.+)/;
|
||||||
|
|||||||
@@ -1,120 +0,0 @@
|
|||||||
package funkin.backend.utils;
|
|
||||||
|
|
||||||
enum abstract RegistryHive(Int) {
|
|
||||||
var HKEY_CLASSES_ROOT = 0x80000000;
|
|
||||||
var HKEY_CURRENT_USER = 0x80000001;
|
|
||||||
var HKEY_LOCAL_MACHINE = 0x80000002;
|
|
||||||
var HKEY_USERS = 0x80000003;
|
|
||||||
var HKEY_CURRENT_CONFIG = 0x80000005;
|
|
||||||
}
|
|
||||||
#if windows
|
|
||||||
@:cppFileCode('
|
|
||||||
#include <windows.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
')
|
|
||||||
#end
|
|
||||||
class RegistryUtil {
|
|
||||||
#if windows
|
|
||||||
@:functionCode('
|
|
||||||
HKEY hKey;
|
|
||||||
LONG result;
|
|
||||||
DWORD dataSize = 0;
|
|
||||||
DWORD dataType = 0;
|
|
||||||
|
|
||||||
std::wstring subkey = std::wstring(key.wchar_str());
|
|
||||||
std::wstring valname = std::wstring(string.wchar_str());
|
|
||||||
|
|
||||||
result = RegOpenKeyExW((HKEY)reinterpret_cast<HKEY>(static_cast<uintptr_t>(hive)), subkey.c_str(), 0, KEY_READ, &hKey);
|
|
||||||
if (result != ERROR_SUCCESS) return null();
|
|
||||||
|
|
||||||
result = RegQueryValueExW(hKey, valname.c_str(), NULL, &dataType, NULL, &dataSize);
|
|
||||||
if (result != ERROR_SUCCESS || dataSize == 0) {
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
return null();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<wchar_t> buffer(dataSize / sizeof(wchar_t));
|
|
||||||
result = RegQueryValueExW(hKey, valname.c_str(), NULL, NULL, (LPBYTE)buffer.data(), &dataSize);
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
|
|
||||||
if (result == ERROR_SUCCESS) {
|
|
||||||
return ::String(buffer.data());
|
|
||||||
}
|
|
||||||
return null();
|
|
||||||
')
|
|
||||||
#end
|
|
||||||
public static function get(hive:RegistryHive, key:String, string:String):Null<String>
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if windows
|
|
||||||
@:functionCode('
|
|
||||||
HKEY hKey;
|
|
||||||
LONG result;
|
|
||||||
|
|
||||||
std::wstring subkey = std::wstring(key.wchar_str());
|
|
||||||
std::wstring valname = std::wstring(string.wchar_str());
|
|
||||||
std::wstring data = std::wstring(value.wchar_str());
|
|
||||||
|
|
||||||
result = RegCreateKeyExW((HKEY)reinterpret_cast<HKEY>(static_cast<uintptr_t>(hive)), subkey.c_str(), 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL);
|
|
||||||
if (result != ERROR_SUCCESS) return false;
|
|
||||||
|
|
||||||
result = RegSetValueExW(hKey, valname.c_str(), 0, REG_SZ, (const BYTE*)data.c_str(), (DWORD)((data.length() + 1) * sizeof(wchar_t)));
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
|
|
||||||
return result == ERROR_SUCCESS;
|
|
||||||
')
|
|
||||||
#end
|
|
||||||
public static function set(hive:RegistryHive, key:String, string:String, value:String):Bool
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if windows
|
|
||||||
@:functionCode('
|
|
||||||
HKEY hKey;
|
|
||||||
LONG result;
|
|
||||||
|
|
||||||
std::wstring subkey = std::wstring(key.wchar_str());
|
|
||||||
std::wstring valname = std::wstring(string.wchar_str());
|
|
||||||
|
|
||||||
result = RegOpenKeyExW((HKEY)reinterpret_cast<HKEY>(static_cast<uintptr_t>(hive)), subkey.c_str(), 0, KEY_READ, &hKey);
|
|
||||||
if (result != ERROR_SUCCESS) return false;
|
|
||||||
|
|
||||||
DWORD dataType = 0;
|
|
||||||
result = RegQueryValueExW(hKey, valname.c_str(), NULL, &dataType, NULL, NULL);
|
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
|
|
||||||
return result == ERROR_SUCCESS;
|
|
||||||
')
|
|
||||||
#end
|
|
||||||
public static function exists(hive:RegistryHive, key:String, string:String):Bool
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if windows
|
|
||||||
@:functionCode('
|
|
||||||
HKEY hKey;
|
|
||||||
LONG result;
|
|
||||||
|
|
||||||
std::wstring subkey = std::wstring(key.wchar_str());
|
|
||||||
std::wstring valname = std::wstring(string.wchar_str());
|
|
||||||
|
|
||||||
result = RegOpenKeyExW((HKEY)reinterpret_cast<HKEY>(static_cast<uintptr_t>(hive)), subkey.c_str(), 0, KEY_SET_VALUE, &hKey);
|
|
||||||
if (result != ERROR_SUCCESS) return false;
|
|
||||||
|
|
||||||
result = RegDeleteValueW(hKey, valname.c_str());
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
|
|
||||||
return result == ERROR_SUCCESS;
|
|
||||||
')
|
|
||||||
#end
|
|
||||||
public static function delete(hive:RegistryHive, key:String, string:String):Bool {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user