Windows 有用于用户空间中的链表的 C API 吗?

问题描述 投票:0回答:1

我发现了

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 没有它。

c windows linked-list
1个回答
0
投票

用户模式 sdk 在 Msputils.h 中有一个 InitializeListHead,请注意,它是一个定义,而不是实际上的函数,尽管文档称其为函数。

© www.soinside.com 2019 - 2024. All rights reserved.