LIST_ENTRY
。
该页面显示 Kernel-Mode Driver Reference
。显然,我没有按照预期在用户空间中使用它。
这是我的测试:
#include <windows.h>
#include <stdio.h>
int main() {
LIST_ENTRY message_list;
InitializeListHead(&message_list);
if (!IsListEmpty(&message_list)) {
puts("Not expected");
return -1;
}
puts("Hello World");
return 0;
}
使用我的 CMake:
cmake_minimum_required (VERSION 2.8)
project (CMakeHelloWorld)
add_executable (CMakeHelloWorld main.c)
target_link_libraries(CMakeHelloWorld ntdll kernel32)
构建错误是:
main.obj : error LNK2019: unresolved external symbol InitializeListHead referenced in function main [C:\test\build\CMakeHelloWorl
d.vcxproj]
main.obj : error LNK2019: unresolved external symbol IsListEmpty referenced in function main [C:\test\build\CMakeHelloWorld.vcxpr
oj]
C:\test\build\Debug\CMakeHelloWorld.exe : fatal error LNK1120: 2 unresolved externals [C:\test\build\CMakeHelloWorld.vcxproj]
显然我可以创建自己的 LinkedList API,但我发现奇怪的是 Windows 没有它。
用户模式 sdk 在 Msputils.h 中有一个 InitializeListHead,请注意,它是一个定义,而不是实际上的函数,尽管文档称其为函数。