3

I am running a fresh installation of Windows. No other programs installed except VC and SDK's

  • Include Directories

    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

  • Target OS Version

    Windows 8.1

  • Target Platform

    Desktop

  • Run Wpp Tracing

    No

  • Enable minimal rebuild

    No


Source:
#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   

Hack: The driver builds successfully if I edit wdm.h and remove #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;

Sorry for the length of this post!!
I'm pretty sure I am doing something wrong while following this MSDN Driver Example Link but I can't figure out what.

Thanks for your time,

Kris

I .
  • 113
  • 1
  • 9
  • driver annotations are defined in Driverspecs.h. (for such things as `_IRQL_requires_same_` ). Do you have this .h file included anywhere? – ryyker Feb 24 '16 at 14:01
  • @ryyker I am not directly including `driverspecs.h` but I have included the directory that it is located in; namely `10.0.10586.0\shared`. Directly including it, above ``, has no effect. – I . Feb 24 '16 at 14:04
  • The `syntax error: missing )` is common when a macro has not been defined. you have to make sure all the identifiers are defined. Once that is done, the rest of the error messages are likely to be resolved as well. – ryyker Feb 24 '16 at 14:12
  • @ryyker Removing `_ETW_KM_` solves **all** errors because `EVENT_INFO_CLASS` in `evntprov.h` isn't reached otherwise. But that's a hack, something is wrong. – I . Feb 24 '16 at 14:16
  • I followed the MSDN guide word by word on a clean windows installation, a bug in WDK maybe? – I . Feb 24 '16 at 14:17
  • _Removing _ETW_KM_ _solves all errors_... Yes, I read that in your post. But the real question is that once built, does the driver do what it needs to do? Have you tested that? If not, then the identifiers that are not defined, must be defined before going on. Can you do a grep through all of your existing project header files to see if the identifiers are defined in any other file, that you can then `#include`? – ryyker Feb 24 '16 at 14:19
  • The first error listed refers to line 31789. Can you confirm (post) the exact line in your source file corresponding to that line? – ryyker Feb 24 '16 at 14:25
  • @ryyker My source file ~30 lines of code and it's the one posted above ^^. I tried deploying the test driver (Driver Install->Deployment) but VC crashes. I don't understand what's going on, this is a crystal clear windows installation yet everything seems to fail horribly. – I . Feb 24 '16 at 14:34
  • Actually, the source code for your project is thousands of lines long :). With Microsoft, sometimes you can grow your project exponentially by including just one header file. Did you successfully execute step 14 in your MSDN Driver Example link? – ryyker Feb 24 '16 at 14:38
  • @ryyker Had I completed step 14 I wouldn't be posting this since it means I wouldn't have had any errors. – I . Feb 24 '16 at 14:41
  • Sorry - was trying to establish where in the steps of that procedure things went wrong. – ryyker Feb 24 '16 at 14:44
  • @ryyker All ok, thanks for your time and effort (: !! I will reinstall Windows, VC, WDK and SDK again. If it persists I'll just file a bug report. You should try and relax a bit (friendly comment) – I . Feb 24 '16 at 14:47
  • This is sometimes how I relax. (sad commentary). I wonder if the example needs to be updated (or retro-fitted) for Windows 8.1? In any case, the error messages you posted are indicative of an undefined identifier. Sorry we could not get this resolved. Good luck. By the way, very nice question format :) – ryyker Feb 24 '16 at 14:52

3 Answers3

3

Encountered similar problem with next version of WDK (10.0.14393). Looks like in both cases the problem is different versions of Win SDK and WDK. Solved by installing the corresponding version of Win SDK. More detail in this answer.

Community
  • 1
  • 1
IsXanDe
  • 61
  • 6
0

Looks like an undefined identifier or macro...
The first of your error messages ( syntax error: missing ')' before identifier ) is probably the best key to understanding the issue. The rest likely are a consequence of that one, which may be complaining that _IRQL_requires_same_, (or one of the other identifiers) is not defined.

As suggested in the error message, look in the file C:\WinSDK10\Include\10.0.10586.0\km\wdm.h for a clue as to what is not defined before InformationClass. Then include the header file that provides definition.

(Currently, There is no information in your post tying the line number 31789 listed in the error message to the exact corresponding line in your source code.)

This link has information on driver annotations (Microsoft Source Code Annotation Language (SAL)).

ryyker
  • 22,849
  • 3
  • 43
  • 87
0

The error indicates the definition for EVENT_INFO_CLASS (Defined in evntprov.h) was not found. Another interesting thing is you are getting this for line number 31789 for method EtwSetInformation. This method needs to be imported only for (NTDDI_VERSION >= NTDDI_THRESHOLD) and you are targeting Win8.1. Something is wrong here. Please share the diagnostic msbuild log. It would be helpful to analyze.

ajbarb
  • 148
  • 8