[*] Windows 7 and predecessors: AuHwInfo memory usage queries seem... off

This commit is contained in:
Reece Wilson 2023-08-03 23:26:42 +01:00
parent c85d65aa59
commit 262d76ddee

View File

@ -36,12 +36,38 @@ namespace Aurora::HWInfo
#if defined(AURORA_IS_MODERNNT_DERIVED)
PROCESS_MEMORY_COUNTERS_EX pmc;
PROCESS_MEMORY_COUNTERS pm;
if (pGetProcessMemoryInfo(GetCurrentProcess(),
reinterpret_cast<PPROCESS_MEMORY_COUNTERS>(&pm),
sizeof(PROCESS_MEMORY_COUNTERS)))
if (pGetProcessMemoryInfo)
{
return RamStat {pm.WorkingSetSize, max};
if (pGetProcessMemoryInfo(GetCurrentProcess(),
reinterpret_cast<PPROCESS_MEMORY_COUNTERS>(&pmc),
sizeof(PROCESS_MEMORY_COUNTERS_EX)))
{
if (pm.PagefileUsage)
{
return RamStat { pmc.PagefileUsage, max };
}
else
{
return RamStat { pmc.PrivateUsage, max };
}
}
if (pGetProcessMemoryInfo(GetCurrentProcess(),
reinterpret_cast<PPROCESS_MEMORY_COUNTERS>(&pm),
sizeof(PROCESS_MEMORY_COUNTERS)))
{
if (pm.PagefileUsage)
{
return RamStat { pm.PagefileUsage, max };
}
else
{
return RamStat { pm.WorkingSetSize, max };
}
}
}
return RamStat {0, max};
@ -97,10 +123,13 @@ namespace Aurora::HWInfo
ULONGLONG SharedCommitUsage;
} vm;
static const PROCESSINFOCLASS kProcessVmCounters = static_cast<PROCESSINFOCLASS>(3);
if (pNtQueryInformationProcess(GetCurrentProcess(), kProcessVmCounters, &vm, sizeof(vm), 0))
if (pNtQueryInformationProcess(GetCurrentProcess(),
kProcessVmCounters,
&vm,
sizeof(vm),
0))
{
// I WILL NOT USE A BLOATED OS THAT LIES TO US
// I WILL NOT USE A BLOATED OS THAT LIES TO US
@ -113,24 +142,12 @@ namespace Aurora::HWInfo
}
#endif
PROCESS_MEMORY_COUNTERS_EX pmc;
PROCESS_MEMORY_COUNTERS pm;
if (pGetProcessMemoryInfo)
if (pGetProcessMemoryInfo(GetCurrentProcess(),
reinterpret_cast<PPROCESS_MEMORY_COUNTERS>(&pm),
sizeof(PROCESS_MEMORY_COUNTERS)))
{
if (pGetProcessMemoryInfo(GetCurrentProcess(),
reinterpret_cast<PPROCESS_MEMORY_COUNTERS>(&pmc),
sizeof(PROCESS_MEMORY_COUNTERS_EX)))
{
return RamStat { pmc.PrivateUsage, max };
}
if (pGetProcessMemoryInfo(GetCurrentProcess(),
reinterpret_cast<PPROCESS_MEMORY_COUNTERS>(&pm),
sizeof(PROCESS_MEMORY_COUNTERS)))
{
return RamStat { pm.WorkingSetSize, max };
}
return RamStat { pm.WorkingSetSize, max };
}
return RamStat {};