SYSTEM_INFORMATION_CLASS定义在哪里?

3

我发现了一段旨在使用DLL注入防止应用程序窃取焦点的C++短代码。像往常一样,由于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温度的结果,但是我看不出应该包含什么...


1
文档在这里:https://msdn.microsoft.com/en-us/library/windows/desktop/ms724509.aspx,并包括头文件引用。但这是一个私有API。你可能会发现头文件不容易找到,或者没有你需要的所有内容。准备好动手吧。同时请注意保护机密信息。 - David Heffernan
它是私有API是什么意思?需要购买吗? - Tomáš Zato
不,它只是没有完全记录,并且在SDK中支持较弱。你现在处于野西。 - David Heffernan
"Native api" 是正确的术语。Windows 内部与 Winapi 文档中所见的非常不同。你正在依赖于一种几乎没有文档记录的函数,微软不保证在将来的版本中保持兼容性。Winternal.h 存在的唯一原因是因为他们被美国司法部门迫使记录了一些内容。"使用 CryptGenRandom 函数代替"只是一个玩笑。 - Hans Passant
1
法官可以强迫公司做他们不想做的事情。司法部有一个很有力的案例,微软在他们自己的产品中使用了这个功能。这是不公平竞争,在美国反垄断法下是非法的。欧盟有非常类似的法律。 - Hans Passant
显示剩余2条评论
3个回答

8

正如文档中所述,此枚举定义在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函数的文档相对较少。你可以通过搜索在线信息找到其他值。至于如何使用这些其他值,可能需要您冒一点风险,并依赖于从网络搜索中找到的反向工程信息。

使用未经记录的功能是有风险的。如果微软在未来版本中更改或删除功能,从而破坏您的程序,请不要感到惊讶。在使用未经记录的功能或标记为未来可能更改的功能之前,请三思而后行。再次强调,我提供的文档以以下方式警告您:

NtQuerySystemInformation在Windows的未来版本中可能被更改或取消。应用程序应使用本主题中列出的替代函数。


看起来这是 USHORT 类型,对吧? - Noitidart
@Noitidart 不,C枚举类型的基本类型是int。 - David Heffernan

3
最后,我使用“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文件,并将上面的代码添加到其中。

2

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接