I cant get hidden process working >:((((
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
[string[]]$MEMORY_TYPES = @(
|
||||
'Invalid', 'Other', 'Unknown', 'DRAM', # 00-03h
|
||||
'EDRAM', 'VRAM', 'SRAM', 'RAM', # 04-07h
|
||||
'ROM', 'FLASH', 'EEPROM', 'FEPROM', # 08-0Bh
|
||||
'EPROM', 'CDRAM', '3DRAM', 'SDRAM', # 0C-0Fh
|
||||
'SGRAM', 'RDRAM', 'DDR', 'DDR2', # 10-13h
|
||||
'DDR2 FB-DIMM', 'Reserved', 'Reserved', 'Reserved', # 14-17h
|
||||
'DDR3', 'FBD2', 'DDR4', 'LPDDR', # 18-1Bh
|
||||
'LPDDR2', 'LPDDR3', 'LPDDR4', 'Logical non-volatile device' # 1C-1Fh
|
||||
'HBM (High Bandwidth Memory)', 'HBM2 (High Bandwidth Memory Generation 2)',
|
||||
'DDR5', 'LPDDR5' # 20-23h
|
||||
)
|
||||
|
||||
function lookUp([string[]]$table, [int]$value){$table[$value]}
|
||||
|
||||
function parseTable([array]$table, [int]$begin, [int]$end)
|
||||
{
|
||||
[int]$index = $begin
|
||||
$type = $table[$index + 0x12]
|
||||
$(lookUp $MEMORY_TYPES $type)
|
||||
}
|
||||
$index = 0
|
||||
|
||||
$END_OF_TABLES = 127
|
||||
$MEMORY_DEVICE = 17
|
||||
$BiosTables = (Get-WmiObject -ComputerName . -Namespace root\wmi -Query `
|
||||
'SELECT SMBiosData FROM MSSmBios_RawSMBiosTables' `
|
||||
).SMBiosData
|
||||
|
||||
do
|
||||
{
|
||||
$startIndex = $index
|
||||
$tableType = $BiosTables[$index]
|
||||
if ($tableType -eq $END_OF_TABLES) { break }
|
||||
$tableLength = $BiosTables[$index + 1]
|
||||
$index += $tableLength
|
||||
while ([BitConverter]::ToUInt16($BiosTables, $index) -ne 0) { $index++ }
|
||||
$index += 2
|
||||
if ($BiosTables[$index] -eq 0) { $index++ }
|
||||
if ($tableType -eq $MEMORY_DEVICE) { parseTable $BiosTables $startIndex $index }
|
||||
} until ($tableType -eq $END_OF_TABLES -or $index -ge $BiosTables.length)
|
||||
+1
-1
@@ -1 +1 @@
|
||||
2655
|
||||
2675
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 69 KiB |
@@ -95,6 +95,11 @@ class Paths
|
||||
return getPath('data/$key.json', TEXT, library);
|
||||
}
|
||||
|
||||
inline static public function ps1(key:String, ?library:String)
|
||||
{
|
||||
return getPath('data/$key.ps1', TEXT, library);
|
||||
}
|
||||
|
||||
static public function sound(key:String, ?library:String)
|
||||
{
|
||||
return getPath('sounds/$key.$SOUND_EXT', SOUND, library);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package funkin.system.framerate;
|
||||
|
||||
import funkin.utils.MemoryUtil;
|
||||
|
||||
class FlixelInfo extends FramerateCategory {
|
||||
public function new() {
|
||||
super("Flixel Info");
|
||||
|
||||
@@ -1,28 +1,29 @@
|
||||
package funkin.system.framerate;
|
||||
|
||||
import native.HiddenProcess;
|
||||
import funkin.utils.MemoryUtil;
|
||||
|
||||
using StringTools;
|
||||
|
||||
class SystemInfo extends FramerateCategory {
|
||||
public static var osInfo:String = "Unknown";
|
||||
public static var gpuName:String = "Unknown";
|
||||
public static var vRAM:String = "-1 MB";
|
||||
public static var vRAM:String = "Unknown";
|
||||
public static var cpuName:String = "Unknown";
|
||||
public static var totalMem:String = "Unknown";
|
||||
public static var memType:String = "Unknown";
|
||||
|
||||
public static inline function init() {
|
||||
osInfo = '${lime.system.System.platformLabel} ${lime.system.System.platformVersion}';
|
||||
@:privateAccess {
|
||||
gpuName = Std.string(flixel.FlxG.stage.context3D.gl.getParameter(flixel.FlxG.stage.context3D.gl.RENDERER)).split("/")[0];
|
||||
vRAM = CoolUtil.getSizeString(cast(flixel.FlxG.stage.context3D.gl.getParameter(openfl.display3D.Context3D.__glMemoryTotalAvailable), UInt) * 1000);
|
||||
}
|
||||
osInfo = '${lime.system.System.platformLabel.replace(lime.system.System.platformVersion, "")} ${lime.system.System.platformVersion}';
|
||||
|
||||
#if windows
|
||||
var process = new sys.io.Process("wmic", ["cpu", "get", "name"]);
|
||||
var process = new HiddenProcess("wmic", ["cpu", "get", "name"]);
|
||||
if (process.exitCode() == 0) cpuName = process.stdout.readAll().toString().trim().split("\n")[1].trim();
|
||||
#elseif (mac)
|
||||
var process = new sys.io.Process("sysctl -a | grep brand");
|
||||
#elseif mac
|
||||
var process = new HiddenProcess("sysctl -a | grep brand");
|
||||
if (process.exitCode() == 0) cpuName = process.stdout.readAll().toString().trim().split(":")[1].trim();
|
||||
#else
|
||||
var process = new sys.io.Process("cat", ["/proc/cpuinfo"]);
|
||||
#elseif linux
|
||||
var process = new HiddenProcess("cat", ["/proc/cpuinfo"]);
|
||||
if (process.exitCode() != 0) return;
|
||||
|
||||
for (line in process.stdout.readAll().toString().split("\n")) {
|
||||
@@ -32,6 +33,16 @@ class SystemInfo extends FramerateCategory {
|
||||
}
|
||||
}
|
||||
#end
|
||||
|
||||
@:privateAccess {
|
||||
gpuName = Std.string(flixel.FlxG.stage.context3D.gl.getParameter(flixel.FlxG.stage.context3D.gl.RENDERER)).split("/")[0];
|
||||
vRAM = CoolUtil.getSizeString(cast(flixel.FlxG.stage.context3D.gl.getParameter(openfl.display3D.Context3D.__glMemoryTotalAvailable), UInt) * 1000);
|
||||
}
|
||||
|
||||
#if cpp
|
||||
totalMem = Std.string(MemoryUtil.getTotalMem() / 1024) + " GB";
|
||||
#end
|
||||
memType = MemoryUtil.getMemType();
|
||||
}
|
||||
|
||||
public function new() {
|
||||
@@ -42,7 +53,8 @@ class SystemInfo extends FramerateCategory {
|
||||
if (alpha <= 0.05) return;
|
||||
_text = 'System: $osInfo';
|
||||
_text += '\nCPU: ${cpuName} ${openfl.system.Capabilities.cpuArchitecture} ${(openfl.system.Capabilities.supports64BitProcesses ? '64-Bit' : '32-Bit')}';
|
||||
_text += '\nGPU: ${gpuName} | VRAM $vRAM';
|
||||
if (gpuName != cpuName) _text += '\nGPU: ${gpuName} | VRAM $vRAM'; // 1000 bytes of vram (apus)
|
||||
_text += '\nTotal MEM: ${totalMem} $memType';
|
||||
_text += '\nGarbage Collector: ${MemoryUtil.disableCount > 0 ? "OFF" : "ON"} (${MemoryUtil.disableCount})';
|
||||
|
||||
this.text.text = _text;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package funkin.utils;
|
||||
|
||||
import native.HiddenProcess;
|
||||
#if cpp
|
||||
import cpp.vm.Gc;
|
||||
#elseif hl
|
||||
@@ -11,6 +12,56 @@ import neko.vm.Gc;
|
||||
#end
|
||||
import openfl.system.System;
|
||||
|
||||
#if cpp
|
||||
@:cppFileCode("
|
||||
#if defined(HX_WINDOWS)
|
||||
#include <windows.h>
|
||||
|
||||
long long totalMem() {
|
||||
unsigned long long allocatedRAM = 0;
|
||||
GetPhysicallyInstalledSystemMemory(&allocatedRAM);
|
||||
return (allocatedRAM / 1024);
|
||||
}
|
||||
#endif
|
||||
#if define(HX_MAC)
|
||||
#include <stdio.h>
|
||||
|
||||
long long totalMem() {
|
||||
int mib [] = { CTL_HW, HW_MEMSIZE };
|
||||
int64_t value = 0;
|
||||
size_t length = sizeof(value);
|
||||
|
||||
if(-1 == sysctl(mib, 2, &value, &length, NULL, 0))
|
||||
return -1; // An error occurred
|
||||
|
||||
return value / 1024 / 1024;
|
||||
}
|
||||
#endif
|
||||
#if defined(HX_LINUX)
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
long long totalMem() {
|
||||
FILE *meminfo = fopen('/proc/meminfo', 'r');
|
||||
|
||||
if(meminfo == NULL) return -1;
|
||||
|
||||
char line[256];
|
||||
while(fgets(line, sizeof(line), meminfo))
|
||||
{
|
||||
int ram;
|
||||
if(sscanf(line, 'MemTotal: %d kB', &ram) == 1)
|
||||
{
|
||||
fclose(meminfo);
|
||||
return (ram / 1024);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(meminfo);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
")
|
||||
#end
|
||||
class MemoryUtil {
|
||||
public static var disableCount:Int = 0;
|
||||
|
||||
@@ -60,6 +111,14 @@ class MemoryUtil {
|
||||
#end
|
||||
}
|
||||
|
||||
#if cpp
|
||||
@:functionCode("return totalMem();")
|
||||
public static function getTotalMem():Float
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#end
|
||||
|
||||
public static inline function currentMemUsage() {
|
||||
#if cpp
|
||||
return Gc.memInfo64(Gc.MEM_INFO_USAGE);
|
||||
@@ -70,6 +129,30 @@ class MemoryUtil {
|
||||
#end
|
||||
}
|
||||
|
||||
|
||||
public static function getMemType():String {
|
||||
#if windows
|
||||
if (Assets.exists(Paths.ps1("powershell/ramtype"))) {
|
||||
var process = new HiddenProcess("powershell", ["-ExecutionPolicy", "ByPass", "-File", (Sys.getCwd() + Paths.ps1("powershell/ramtype")).replace("/", "\\")]);
|
||||
if (process.exitCode() == 0) return process.stdout.readAll().toString().trim().split("\n")[0].trim();
|
||||
}
|
||||
#elseif mac
|
||||
var process = new HiddenProcess("system_profiler", ["SPMemoryDataType"]);
|
||||
if (process.exitCode() == 0) return process.stdout.readAll().toString().match(/Type: (.+)/)[1];
|
||||
#elseif linux
|
||||
var process = HiddenProcess("sudo", ["dmidecode", "--type", "17"]);
|
||||
if (process.exitCode() != 0) return "Unknown";
|
||||
var lines = process.stdout.readAll().toString().split("\n");
|
||||
for (line in lines) {
|
||||
if (line.indexOf("Type:") == 0) {
|
||||
return line.substring("Type:".length).trim();
|
||||
}
|
||||
}
|
||||
#end
|
||||
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
private static var _nb:Int = 0;
|
||||
private static var _nbD:Int = 0;
|
||||
private static var _zombie:Dynamic;
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
package native;
|
||||
|
||||
typedef HiddenProcess = sys.io.Process;
|
||||
Reference in New Issue
Block a user