其中定义了SYSTEM_INFORMATION_CLASS

Where is SYSTEM_INFORMATION_CLASS defined?

本文关键字:INFORMATION CLASS SYSTEM 定义      更新时间:2023-10-16

我发现了一个简短的C++代码,旨在防止应用程序使用DLL注入窃取焦点。和C++一样,我遇到了一些未定义的东西和缺少库的问题。

具体来说,这个常数是未定义的:SYSTEM_INFORMATION_CLASS。在此代码中:

typedef NTSTATUS( WINAPI* PNT_QUERY_SYSTEM_INFORMATION ) ( 
  __in       SYSTEM_INFORMATION_CLASS SystemInformationClass,     
  __inout    PVOID SystemInformation, 
  __in       ULONG SystemInformationLength, 
  __out_opt  PULONG ReturnLength    
);

windows.h已经包含在内,所以它一定缺少其他内容。在谷歌上搜索时,我得到了很多关于CPU温度的结果,但我看不出应该在其中包含什么。。。

如文档中所述,此枚举在Winternl.h头文件中定义。7.1版SDK头文件中的定义是:

typedef enum _SYSTEM_INFORMATION_CLASS {
    SystemBasicInformation = 0,
    SystemPerformanceInformation = 2,
    SystemTimeOfDayInformation = 3,
    SystemProcessInformation = 5,
    SystemProcessorPerformanceInformation = 8,
    SystemInterruptInformation = 23,
    SystemExceptionInformation = 33,
    SystemRegistryQuotaInformation = 37,
    SystemLookasideInformation = 45
} SYSTEM_INFORMATION_CLASS;

此NT API函数的文档编制有些不足。您可以通过在线搜索找到其他值。至于如何使用这些其他价值观,你可能需要再次树立信心,依靠你可以从网络搜索中找到的逆向工程信息。

使用未记录的功能是有风险的业务。如果Microsoft在将来的版本中更改或删除功能,从而破坏您的程序,请不要感到惊讶。在使用未记录的功能或记录为将来可能更改的功能之前,您可能需要三思而后行。同样,我链接到的文档确实以这种方式警告您:

NtQuerySystemInformation可能在未来版本的Windows中更改或不可用。应用程序应使用本主题中列出的备用函数。

最后,我使用搜索词"typedef SYSTEM_INFORMATION_CLASS"找到了一些SYSTEM_INFORMATION_class定义。虽然在发布这篇文章的时候,我自己的问题是第三个结果。。。

这是我得到的:

typedef enum _SYSTEM_INFORMATION_CLASS {
    SystemBasicInformation,
    SystemProcessorInformation,
    SystemPerformanceInformation,
    SystemTimeOfDayInformation,
    SystemPathInformation,
    SystemProcessInformation,
    SystemCallCountInformation,
    SystemDeviceInformation,
    SystemProcessorPerformanceInformation,
    SystemFlagsInformation,
    SystemCallTimeInformation,
    SystemModuleInformation,
    SystemLocksInformation,
    SystemStackTraceInformation,
    SystemPagedPoolInformation,
    SystemNonPagedPoolInformation,
    SystemHandleInformation,
    SystemObjectInformation,
    SystemPageFileInformation,
    SystemVdmInstemulInformation,
    SystemVdmBopInformation,
    SystemFileCacheInformation,
    SystemPoolTagInformation,
    SystemInterruptInformation,
    SystemDpcBehaviorInformation,
    SystemFullMemoryInformation,
    SystemLoadGdiDriverInformation,
    SystemUnloadGdiDriverInformation,
    SystemTimeAdjustmentInformation,
    SystemSummaryMemoryInformation,
    SystemNextEventIdInformation,
    SystemEventIdsInformation,
    SystemCrashDumpInformation,
    SystemExceptionInformation,
    SystemCrashDumpStateInformation,
    SystemKernelDebuggerInformation,
    SystemContextSwitchInformation,
    SystemRegistryQuotaInformation,
    SystemExtendServiceTableInformation,
    SystemPrioritySeperation,
    SystemPlugPlayBusInformation,
    SystemDockInformation,
    SystemPowerInformation,
    SystemProcessorSpeedInformation,
    SystemCurrentTimeZoneInformation,
    SystemLookasideInformation

} SYSTEM_INFORMATION_CLASS, *PSYSTEM_INFORMATION_CLASS;

由于无法编译任何内容,我不能确定它是否正确。我刚刚创建了新的.hpp文件并添加了上面的代码。

看看这个:http://www.geoffchappell.com/studies/windows/km/ntoskrnl/api/ex/sysinfo/query.htm.

[Nt]|[Zw]QuerySystemInformation和输入参数有一个很好的描述。