PNDIS_GENERIC_OBJECT 错误 C2061

发布于 2025-01-06 19:55:06 字数 660 浏览 1 评论 0原文

声明 PNDIS_GENERIC_OBJECT 变量后,我收到编译器错误。为什么会发生这种情况,我该如何避免?

#include <ntddk.h>
#include <ndis.h>

PNDIS_GENERIC_OBJECT gNdisGenericObj;

VOID DriverUnload(IN PDRIVER_OBJECT driverObject){
        UNREFERENCED_PARAMETER(driverObject);   
}


NTSTATUS DriverEntry(   IN  PDRIVER_OBJECT  driverObject,
                        IN  PUNICODE_STRING registryPath)
{
    NTSTATUS status = STATUS_SUCCESS;


    if (driverObject != NULL)
        driverObject->DriverUnload = DriverUnload;

    return status;
}

错误 C2061:语法错误:标识符“gNdisGenericObj”

错误 C2059:语法错误:';'

I get compiler errors after declaring the PNDIS_GENERIC_OBJECT variable. Why does this happen, and how can I avoid it?

#include <ntddk.h>
#include <ndis.h>

PNDIS_GENERIC_OBJECT gNdisGenericObj;

VOID DriverUnload(IN PDRIVER_OBJECT driverObject){
        UNREFERENCED_PARAMETER(driverObject);   
}


NTSTATUS DriverEntry(   IN  PDRIVER_OBJECT  driverObject,
                        IN  PUNICODE_STRING registryPath)
{
    NTSTATUS status = STATUS_SUCCESS;


    if (driverObject != NULL)
        driverObject->DriverUnload = DriverUnload;

    return status;
}

error C2061: syntax error : identifier 'gNdisGenericObj'

error C2059: syntax error : ';'

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

注定孤独终老 2025-01-13 19:55:06

您必须使用适当的 NDIS 版本定义来编译代码。我将引用 Windows 开发人员预览版中 NDIS.H 的顶部内容:

/*
Before including this header, you must define one or more macros.  In all
examples, "630" can be any version number (as explained later).

1.  If you are compiling a kernel-mode miniport driver, define:
        #define NDIS_MINIPORT_DRIVER 1
        #define NDIS630_MINIPORT 1
    Additionally, if you are compiling a WDM or WDF (i.e., KMDF) driver,
    you must include wdm.h/wdf.h before including ndis.h, and also define:
        #define NDIS_WDM

2.  If you are compiling any other kernel-mode code (including protocol
    drivers, lightweight filters, or generic code not using the NDIS
    driver model), define:
        #define NDIS630

3.  An IM driver, because it is both a protocol and a miniport, should
    follow both 1. and 2. above.

4.  If you would like to use NDIS definitions from user-mode, do not
    include this ndis.h header.  Instead, include ntddndis.h from the SDK.
    Before including it, include windows.h, and define:
        #define UM_NDIS630

Definitions with NDIS version numbers may use any of the following:

    Version     First available in
    ------------------------------------------------------------------
    630         Windows "8" / Windows Server "8"
    620         Windows 7 / Windows Server 2008 R2
    61          Windows Vista SP1 / Windows Server 2008 RTM
    60          Windows Vista RTM
    52          Windows Server 2003 R2 / Windows Server 2003 + SNP
    51          Windows XP / Windows Server 2003
    50          Windows 2000
    40          Windows 95

Code should define only the versions it explicitly supports at runtime.  In
most cases, this is exactly one version (e.g., your driver only defines
NDIS630 and no other versions).  But if you have a driver that can register
either a 6.0 or a 6.20 protocol at runtime based on the results of
NdisGetVersion(), then you may define support for multiple macros (e.g.,
define both NDIS60 and NDIS630).
*/

因此,总而言之,使用 -DNDIS60=1 等标志进行编译,然后就可以开始了。

You must compile your code with the appropriate NDIS version definition. I'll quote from the top of NDIS.H in the Windows Developer Preview version:

/*
Before including this header, you must define one or more macros.  In all
examples, "630" can be any version number (as explained later).

1.  If you are compiling a kernel-mode miniport driver, define:
        #define NDIS_MINIPORT_DRIVER 1
        #define NDIS630_MINIPORT 1
    Additionally, if you are compiling a WDM or WDF (i.e., KMDF) driver,
    you must include wdm.h/wdf.h before including ndis.h, and also define:
        #define NDIS_WDM

2.  If you are compiling any other kernel-mode code (including protocol
    drivers, lightweight filters, or generic code not using the NDIS
    driver model), define:
        #define NDIS630

3.  An IM driver, because it is both a protocol and a miniport, should
    follow both 1. and 2. above.

4.  If you would like to use NDIS definitions from user-mode, do not
    include this ndis.h header.  Instead, include ntddndis.h from the SDK.
    Before including it, include windows.h, and define:
        #define UM_NDIS630

Definitions with NDIS version numbers may use any of the following:

    Version     First available in
    ------------------------------------------------------------------
    630         Windows "8" / Windows Server "8"
    620         Windows 7 / Windows Server 2008 R2
    61          Windows Vista SP1 / Windows Server 2008 RTM
    60          Windows Vista RTM
    52          Windows Server 2003 R2 / Windows Server 2003 + SNP
    51          Windows XP / Windows Server 2003
    50          Windows 2000
    40          Windows 95

Code should define only the versions it explicitly supports at runtime.  In
most cases, this is exactly one version (e.g., your driver only defines
NDIS630 and no other versions).  But if you have a driver that can register
either a 6.0 or a 6.20 protocol at runtime based on the results of
NdisGetVersion(), then you may define support for multiple macros (e.g.,
define both NDIS60 and NDIS630).
*/

So in summary, compile with a flag like -DNDIS60=1, and you should be good to go.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文