none
syntax error in fwpsk.h RRS feed

  • Question

  • Hi, I'm really new at the drivers development, I am trying to simply make a driver that filter by the source port, but that's not the problem, the problem is when I try to compile any simple code, even microsoft samples, I got a lot of syntax errors that come from the "fwpsk.h" header, like these:

    .

    .

    .

    1>------ Operación Compilar iniciada: proyecto: firewall, configuración: Debug Win32 ------
    1>  Building 'firewall' with toolset 'WindowsKernelModeDriver10.0' and the 'Desktop' target platform.
    1>  Stamping Debug\firewall.inf [Version] section with DriverVer=09/16/2015,21.47.18.19
    1>  Main.c
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2226): error C2143: error de sintaxis: falta ')' delante de '*'
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2226): error C2143: error de sintaxis: falta '{' delante de '*'
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2227): warning C4142: nueva definición de tipo sin efecto
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2227): error C2370: 'UINT32': nueva definición; clase de almacenamiento distinta
    1>  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\shared\basetsd.h(81): note: vea la declaración de 'UINT32'
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2227): error C2146: error de sintaxis: falta ';' delante del identificador 'queryFlags'
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2227): warning C4218: se ha utilizado una extensión no estándar: se debe especificar al menos una clase de almacenamiento o un tipo
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2228): error C2371: 'FWPS_PACKET_LIST_INFORMATION0': nueva definición; tipos básicos distintos
    1>  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2220): note: vea la declaración de 'FWPS_PACKET_LIST_INFORMATION0'
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2228): error C2143: error de sintaxis: falta ';' delante de '*'
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2228): warning C4218: se ha utilizado una extensión no estándar: se debe especificar al menos una clase de almacenamiento o un tipo
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2229): error C2059: error de sintaxis: ')'
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2229): warning C4218: se ha utilizado una extensión no estándar: se debe especificar al menos una clase de almacenamiento o un tipo
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2250): error C2146: error de sintaxis: falta ')' delante del identificador 'netBufferList'
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2250): error C2081: 'PNET_BUFFER_LIST': el nombre de la lista de parámetros formales no es válido
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2250): error C2061: error de sintaxis: identificador 'netBufferList'
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2250): error C2059: error de sintaxis: ';'
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2251): error C2059: error de sintaxis: ')'
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2450): error C2143: error de sintaxis: falta ')' delante de '*'
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2450): error C2081: 'NET_BUFFER_LIST': el nombre de la lista de parámetros formales no es válido
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2450): error C2143: error de sintaxis: falta '{' delante de '*'
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2451): error C2371: 'BOOLEAN': nueva definición; tipos básicos distintos
    1>  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\shared\ntdef.h(1517): note: vea la declaración de 'BOOLEAN'
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2451): error C2146: error de sintaxis: falta ';' delante del identificador 'dispatchLevel'
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2451): warning C4218: se ha utilizado una extensión no estándar: se debe especificar al menos una clase de almacenamiento o un tipo
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2452): error C2059: error de sintaxis: ')'
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2452): warning C4218: se ha utilizado una extensión no estándar: se debe especificar al menos una clase de almacenamiento o un tipo
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2464): error C2143: error de sintaxis: falta ')' delante de '*'
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2464): error C2081: 'NET_BUFFER_LIST': el nombre de la lista de parámetros formales no es válido
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2464): error C2143: error de sintaxis: falta '{' delante de '*'
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2465): error C2059: error de sintaxis: ')'
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2465): error C2040: 'netBufferList: 'int **' se diferencia en los niveles de direccionamiento indirecto de 'int *'
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2465): warning C4218: se ha utilizado una extensión no estándar: se debe especificar al menos una clase de almacenamiento o un tipo
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2471): error C2143: error de sintaxis: falta ')' delante de '*'
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2471): error C2143: error de sintaxis: falta '{' delante de '*'
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2472): error C2059: error de sintaxis: ')'
    1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\km\fwpsk.h(2472): fatal error C1903: no se puede recuperar de errores anteriores; se detiene la compilación
    1>  ERROR INTERNO DEL COMPILADOR en 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\CL.exe'
    1>      Elija el comando Soporte técnico del menú Ayuda de Visual C++,
    1>  o abra el archivo de ayuda de Soporte técnico para obtener más información
    ========== Compilar: 0 correctos, 1 incorrectos, 0 actualizados, 0 omitidos ==========

    .

    .

    .

    I'm using Visual Studio 2015 and I have installed WDK10 and WDK8, I really don't know what to do, I can't continue writing anything because of this. this driver will be for win7 or later versions.

    something else, How can I get message from the driver?, I mean, how can I see the status of the driver in a console

    here is de code, as you will see is very simple.

    #pragma warning(push)
    #pragma warning(disable:4201)       // unnamed struct/union
    
    #include <wdm.h>
    #include <fwpsk.h>
    
    #pragma warning(pop)
    
    DRIVER_UNLOAD Unload;	
    DRIVER_INITIALIZE DriverEntry;	
    
    
    VOID Unload(
    	IN PDRIVER_OBJECT DriverObject
    	) {
    	//clean the object
    }
    
    VOID NTAPI ClassifyFn(
    	IN const FWPS_INCOMING_VALUES0  *inFixedValues,
    	IN const FWPS_INCOMING_METADATA_VALUES0  *inMetaValues,
    	IN OUT VOID  *layerData,
    	IN const FWPS_FILTER0  *filter,
    	IN UINT64  flowContext,
    	IN OUT FWPS_CLASSIFY_OUT0  *classifyOut
    	);
    
    NTSTATUS NTAPI NotifyFn(
    	IN FWPS_CALLOUT_NOTIFY_TYPE notifyType,
    	IN const GUID  *filterKey,
    	IN const FWPS_FILTER0  *filter
    	);
    
    VOID NTAPI FlowDeleteFn(
    	IN UINT16  layerId,
    	IN UINT32  calloutId,
    	IN UINT64  flowContext
    	);
    
    const FWPS_CALLOUT0 Callout = {
    	{	//GUID
    		0x20b59285,
    		0x7611,
    		0x4485,
    		0x9b, 0x46, 0x1c, 0x17, 0xab, 0x8a, 0x75, 0x16
    	},
    	0,
    	ClassifyFn,
    	NotifyFn,
    	FlowDeleteFn
    };
    
    
    NTSTATUS DriverEntry(
    	IN PDRIVER_OBJECT DriverObject,
    	IN PUNICODE_STRING RegistryPath
    	) {
    
    	short type_of_error;
    	NTSTATUS status;	//variable de control
    	PDEVICE_OBJECT deviceObject;	
    	UINT32 CalloutId;	
    
    	DriverObject->DriverUnload = Unload;
    
    	status = IoCreateDevice(
    		DriverObject,
    		0,	
    		NULL,	
    		FILE_DEVICE_UNKNOWN,
    		FILE_DEVICE_SECURE_OPEN,
    		FALSE,
    		&deviceObject);
    
    	if (!NT_SUCCESS(status)) {
    		type_of_error = 1;
    		goto Exit;
    	}
    
    	status = FwpsCalloutRegister0(
    		deviceObject,
    		&Callout,
    		&CalloutId);
    
    	if (!NT_SUCCESS(status)) {
    		type_of_error = 2;
    		goto Exit;
    	}
    
    Exit:
    	// show "type_of_error" in console, How to?
    	return status;
    }

    Thanks




    • Edited by quetzalfir Thursday, September 17, 2015 4:39 PM
    Thursday, September 17, 2015 3:24 AM

Answers

    • Your errors in fwpsk.h are caused by a missing NDIS_SUPPORT_NDIS6; preprocessor macro in the project settings
    • You can use KdPrint() to print the output, it operates like printf. You may also need to do this to have output show up in the debugger.

    Jason

    • Marked as answer by quetzalfir Monday, September 21, 2015 10:24 PM
    • Unmarked as answer by quetzalfir Wednesday, September 23, 2015 4:09 AM
    • Proposed as answer by JST86 Wednesday, September 23, 2015 10:41 AM
    • Marked as answer by quetzalfir Thursday, September 24, 2015 3:14 AM
    Friday, September 18, 2015 10:29 AM
  • Project Settings -> C/C++ -> Preprocessor -> Preprocessor definitions
    • Proposed as answer by JST86 Wednesday, September 23, 2015 10:41 AM
    • Marked as answer by quetzalfir Thursday, September 24, 2015 2:28 AM
    Wednesday, September 23, 2015 10:41 AM

All replies

    • Your errors in fwpsk.h are caused by a missing NDIS_SUPPORT_NDIS6; preprocessor macro in the project settings
    • You can use KdPrint() to print the output, it operates like printf. You may also need to do this to have output show up in the debugger.

    Jason

    • Marked as answer by quetzalfir Monday, September 21, 2015 10:24 PM
    • Unmarked as answer by quetzalfir Wednesday, September 23, 2015 4:09 AM
    • Proposed as answer by JST86 Wednesday, September 23, 2015 10:41 AM
    • Marked as answer by quetzalfir Thursday, September 24, 2015 3:14 AM
    Friday, September 18, 2015 10:29 AM
  • How can I set the NDIS_SUPPORT_NDIS6?
    Wednesday, September 23, 2015 4:04 AM
  • Project Settings -> C/C++ -> Preprocessor -> Preprocessor definitions
    • Proposed as answer by JST86 Wednesday, September 23, 2015 10:41 AM
    • Marked as answer by quetzalfir Thursday, September 24, 2015 2:28 AM
    Wednesday, September 23, 2015 10:41 AM
  • Wow, that, really works!!!!, thank you very much, you save me, I was starting to frustrate me.

    one thing else, How did you know it?, I mean, Is that written in a book?, in a web page, in the reference, documentation?

    Thursday, September 24, 2015 2:36 AM