从CallNtPowerInformation()获取ProcessorInformation。

huangapple go评论56阅读模式
英文:

Getting ProcessorInformation from CallNtPowerInformation()

问题

以前,我可以在Windows 10中获取当前的CPU核心频率,使用以下调用:

	const NTSTATUS gotinfo = CallNtPowerInformation
	(
		ProcessorInformation,
		NULL,
		0,
		pinf,
		sizeof(pinf)
	);
	assert(gotinfo != ERROR_INSUFFICIENT_BUFFER);
	assert(gotinfo != ERROR_ACCESS_DENIED);
	assert(gotinfo == ERROR_SUCCESS);

但是当我今天尝试时,无论是Max还是Cur freq,我的i5 12600k所有核心都返回3700MHz。这是不正确的。该函数返回SUCCESS状态,但产生了不正确的结果。

发生了什么?为什么CallNtPowerInformation停止工作?

注意:Microsoft忘记包括PROCESSOR_POWER_INFORMATION的结构定义,并告诉你自己定义它。他们声称它会在新版本的WINNT.H中修复,但从未修复。

英文:

Formerly, I was able to get the current cpu core frequencies in Windows 10, using this call:

	const NTSTATUS gotinfo = CallNtPowerInformation
	(
		ProcessorInformation,
		NULL,
		0,
		pinf,
		sizeof(pinf)
	);
	assert(gotinfo != ERROR_INSUFFICIENT_BUFFER);
	assert(gotinfo != ERROR_ACCESS_DENIED);
	assert(gotinfo == ERROR_SUCCESS);

But when I try that today, I always see 3700Mhz returned for both Max and Cur freq on my core i5 12600k, for all cores. This is incorrect. The function returns SUCCESS status, but yields incorrect results.

What happened here? Why did CallNtPowerInformation stop working?

NOTE: Microsoft forgot to include the struct definition for PROCESSOR_POWER_INFORMATION, and tells you do define it yourself. They claimed it would be fixed in new versions of WINNT.H but it never was.

答案1

得分: 3

Microsoft已经悄悄从API中移除了这个功能。

https://github.com/microsoft/Windows-Dev-Performance/issues/100

英文:

Microsoft has silently removed the functionality from the API.

https://github.com/microsoft/Windows-Dev-Performance/issues/100

huangapple
  • 本文由 发表于 2023年4月17日 06:32:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/76030647.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定