标识符FilterConnect Communiatport不确定

发布于 2025-02-11 09:04:02 字数 1741 浏览 1 评论 0原文

我有一个小型驱动程序,该驱动程序使用通信端口连接到用户模式。小型内核驱动器很好。不幸的是,用户模式代码存在一些问题。

用户模式代码:

#include <fltUser.h>
#include <stdio.h>

#pragma comment(lib, "user32.lib")
#pragma comment(lib, "kernel32.lib")
#pragma comment(lib, "fltlib.lib")
#pragma comment(lib, "fltmgr.lib")

HANDLE port = NULL;
int main() {
    printf("Hello there\n");
    if (port == NULL) {
        if (FilterConnectCommunicationPort(L"\\nmf", 0, NULL, 0, NULL, &port)) {
            printf("Connected to Kernel\n");
        }
    }
    return 0;
}

错误列表:

Severity    Code    Description Project File    Line    Suppression State
Error (active)  E0059   function call is not allowed in a constant expression   kernelConnect   C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\fltUser.h    94  
Error (active)  E0059   function call is not allowed in a constant expression   kernelConnect   C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\fltUserStructures.h  27  
Error (active)  E0020   identifier "HANDLE" is undefined    kernelConnect   C:\Users\Abdul\source\repos\kernelConnect\Source.cpp    9   
Error (active)  E0020   identifier "FilterConnectCommunicationPort" is undefined    kernelConnect   C:\Users\Abdul\source\repos\kernelConnect\Source.cpp    13  
Error   C1012   unmatched parenthesis: missing ')'  kernelConnect   C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\fltUserStructures.h  27  

如您所见,有两个错误,我不明白:

  1. 标识符“ handle”是未定义的kernelconnect
  2. 标识符“ FilterConnectCommunicationPort”未定义,

我确认确实在FLTUSER HEADER中确实存在FilterConnectConnectCommunicationPort。但是在源代码中,Visual Studio可以找到该函数的定义,而不是声明。

谁能告诉我这里有什么问题?

I have a minifilter driver that use communication ports to connect to user mode. The minifilter kernel driver is fine. The user mode code unfortunately have some issues.

User-mode code:

#include <fltUser.h>
#include <stdio.h>

#pragma comment(lib, "user32.lib")
#pragma comment(lib, "kernel32.lib")
#pragma comment(lib, "fltlib.lib")
#pragma comment(lib, "fltmgr.lib")

HANDLE port = NULL;
int main() {
    printf("Hello there\n");
    if (port == NULL) {
        if (FilterConnectCommunicationPort(L"\\nmf", 0, NULL, 0, NULL, &port)) {
            printf("Connected to Kernel\n");
        }
    }
    return 0;
}

List of errors:

Severity    Code    Description Project File    Line    Suppression State
Error (active)  E0059   function call is not allowed in a constant expression   kernelConnect   C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\fltUser.h    94  
Error (active)  E0059   function call is not allowed in a constant expression   kernelConnect   C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\fltUserStructures.h  27  
Error (active)  E0020   identifier "HANDLE" is undefined    kernelConnect   C:\Users\Abdul\source\repos\kernelConnect\Source.cpp    9   
Error (active)  E0020   identifier "FilterConnectCommunicationPort" is undefined    kernelConnect   C:\Users\Abdul\source\repos\kernelConnect\Source.cpp    13  
Error   C1012   unmatched parenthesis: missing ')'  kernelConnect   C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\fltUserStructures.h  27  

As you can see, there are two errors, that I don't understand:

  1. identifier "HANDLE" is undefined kernelConnect
  2. identifier "FilterConnectCommunicationPort" is undefined

I confirmed that FilterConnectCommunicationPort is indeed in the fltuser header. but in the source code, visual studio could find a definition to the function but not a declaration.

Can anyone tell me what is wrong here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文