3

我正在运行全新安装的 Windows。除了 VC 和 SDK 没有安装其他程序

  • 包括目录

    C:\WinSDK10\Include\10.0.10586.0\shared;
    C:\WinSDK10\Include\10.0.10586.0\km;
    C:\WinSDK10\Include\10.0.10586.0\km\crt;
    C:\WinSDK10\Include\wdf\kmdf\1.11

  • 目标操作系统版本

    视窗 8.1

  • 目标平台

    桌面

  • 运行 Wpp 跟踪

  • 启用最小重建


资源:

#include <ntddk.h>
#include <wdf.h>
DRIVER_INITIALIZE DriverEntry;
EVT_WDF_DRIVER_DEVICE_ADD KmdfHelloWorldEvtDeviceAdd;

NTSTATUS DriverEntry(_In_ PDRIVER_OBJECT  DriverObject, _In_ PUNICODE_STRING RegistryPath)
{
    NTSTATUS status;
    WDF_DRIVER_CONFIG config;

    KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "KmdfHelloWorld: DriverEntry\n"));
    WDF_DRIVER_CONFIG_INIT(&config, KmdfHelloWorldEvtDeviceAdd);
    status = WdfDriverCreate(DriverObject, RegistryPath, WDF_NO_OBJECT_ATTRIBUTES, &config, WDF_NO_HANDLE);
    return status;
}

NTSTATUS KmdfHelloWorldEvtDeviceAdd(_In_ WDFDRIVER Driver, _Inout_ PWDFDEVICE_INIT DeviceInit)
{
    NTSTATUS status;
    WDFDEVICE hDevice;
    UNREFERENCED_PARAMETER(Driver);

    KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "KmdfHelloWorld: KmdfHelloWorldEvtDeviceAdd\n"));
    status = WdfDeviceCreate(&DeviceInit, WDF_NO_OBJECT_ATTRIBUTES, &hDevice);
    return status;
}

Severity    Code    Description Project File    Line    Suppression State
Error   C2146   syntax error: missing ')' before identifier 'InformationClass'  Test1   C:\WinSDK10\Include\10.0.10586.0\km\wdm.h   31789   
Error   C2146   syntax error: missing ')' before identifier 'InformationClass'  Test1   C:\WinSDK10\Include\10.0.10586.0\km\wdm.h   31789   
Error   C2061   syntax error: identifier 'InformationClass' Test1   C:\WinSDK10\Include\10.0.10586.0\km\wdm.h   31789   
Error   C2061   syntax error: identifier 'InformationClass' Test1   C:\WinSDK10\Include\10.0.10586.0\km\wdm.h   31789   
Error   C2059   syntax error: ';'   Test1   C:\WinSDK10\Include\10.0.10586.0\km\wdm.h   31789   
Error   C2059   syntax error: ';'   Test1   C:\WinSDK10\Include\10.0.10586.0\km\wdm.h   31789   
Error   C2059   syntax error: ','   Test1   C:\WinSDK10\Include\10.0.10586.0\km\wdm.h   31789   
Error   C2059   syntax error: ','   Test1   C:\WinSDK10\Include\10.0.10586.0\km\wdm.h   31789   
Error   C2059   syntax error: ')'   Test1   C:\WinSDK10\Include\10.0.10586.0\km\wdm.h   31792   
Error   C2059   syntax error: ')'   Test1   C:\WinSDK10\Include\10.0.10586.0\km\wdm.h   31792   
Error   C2081   'EVENT_INFO_CLASS': name in formal parameter list illegal   Test1   C:\WinSDK10\Include\10.0.10586.0\km\wdm.h   31789   
Error   C2081   'EVENT_INFO_CLASS': name in formal parameter list illegal   Test1   C:\WinSDK10\Include\10.0.10586.0\km\wdm.h   31789   

哈克:如果我编辑wdm.h和删除驱动程序会成功构建#define _ETW_KM_

wdm.h

#ifndef _ETW_KM_
#define _ETW_KM_
#endif

#include <evntprov.h>


//
// Optional callback function that users provide.
//

typedef
_IRQL_requires_max_(PASSIVE_LEVEL)
_IRQL_requires_same_
VOID
NTAPI 
ETWENABLECALLBACK (
    _In_ LPCGUID SourceId,
    _In_ ULONG ControlCode,
    _In_ UCHAR Level,
    _In_ ULONGLONG MatchAnyKeyword,
    _In_ ULONGLONG MatchAllKeyword,
    _In_opt_ PEVENT_FILTER_DESCRIPTOR FilterData,
    _Inout_opt_ PVOID CallbackContext
    );

typedef ETWENABLECALLBACK *PETWENABLECALLBACK;

抱歉这篇文章太长了!!我很确定在遵循此MSDN 驱动程序示例链接
时我做错了,但我不知道是什么。

谢谢你的时间,

克里斯

4

3 回答 3

3

下一个版本的 WDK (10.0.14393) 遇到了类似的问题。看起来在这两种情况下,问题都是不同版本的 Win SDK 和 WDK。通过安装对应版本的Win SDK解决。此答案中的更多详细信息。

于 2016-11-09T09:58:32.913 回答
0

看起来像一个未定义的标识符或宏...
您的第一条错误消息 ( syntax error: missing ')' before identifier) 可能是理解问题的最佳关键。其余的可能是该结果的结果,它可能会抱怨_IRQL_requires_same_, (或其他标识符之一)未定义。

正如错误消息中所建议的,在文件中查找关于InformationClassC:\WinSDK10\Include\10.0.10586.0\km\wdm.h之前未定义的内容的线索。然后包含提供定义的头文件。

(目前,您的帖子中没有任何信息将错误消息中列出的行号31789与源代码中的确切对应行联系起来。)

此链接包含有关驱动程序注释(Microsoft 源代码注释语言 (SAL))的信息。

于 2016-02-24T14:05:09.993 回答
0

该错误表明未找到 EVENT_INFO_CLASS(在 evntprov.h 中定义)的定义。另一件有趣的事情是,您在 EtwSetInformation 方法的第 31789 行得到了这个。只需为 (NTDDI_VERSION >= NTDDI_THRESHOLD) 导入此方法,并且您的目标是 Win8.1。这里不对劲。请分享诊断 msbuild 日志。分析起来会很有帮助。

于 2016-02-24T16:34:43.553 回答