Rise
The Vieneo Province
Toggle main menu visibility
Loading...
Searching...
No Matches
CpuInformation.h
Go to the documentation of this file.
1
#pragma once
2
#include <windows.h>
3
#include <powrprof.h>
4
#include <vector>
5
6
#pragma comment(lib, "PowrProf.lib")
7
8
namespace
CpuInformation
9
{
10
// Login telemetry needs the specified CPU frequency, not a one-second
11
// timestamp-counter benchmark on the window/network thread. Windows reports
12
// this metadata directly; zero means unavailable. No power policy is changed.
13
inline
ULONG
MaximumSpecifiedMhz
()
14
{
15
// PROCESSOR_POWER_INFORMATION is omitted from some Windows SDK headers.
16
// Layout: learn.microsoft.com/windows/win32/power/processor-power-information-str
17
struct
ProcessorPowerInformation
18
{
19
ULONG number, maxMhz, currentMhz, mhzLimit, maxIdleState, currentIdleState;
20
};
21
static_assert
(
sizeof
(ProcessorPowerInformation) == 6 *
sizeof
(ULONG));
22
const
DWORD
count = GetActiveProcessorCount(ALL_PROCESSOR_GROUPS);
23
if
(!count || count > MAXDWORD /
sizeof
(ProcessorPowerInformation))
return
0;
24
std::vector<ProcessorPowerInformation> processors(count);
25
const
ULONG bytes =
static_cast<
ULONG
>
(processors.size() *
sizeof
(ProcessorPowerInformation));
26
if
(CallNtPowerInformation(ProcessorInformation,
nullptr
, 0, processors.data(), bytes) != 0)
return
0;
27
ULONG result = 0;
28
for
(
const
auto
& processor : processors)
29
if
(processor.maxMhz > result) result = processor.maxMhz;
30
return
result;
31
}
32
}
DWORD
SCRIPT_CONTROL SCRIPT_STATE const void DWORD
Definition
Controls.cpp:5032
CpuInformation
Definition
CpuInformation.h:9
CpuInformation::MaximumSpecifiedMhz
ULONG MaximumSpecifiedMhz()
Definition
CpuInformation.h:13
CpuInformation.h
Generated on
for Rise by
1.18.0