none
Error C4028: formal parameter 1 different from declaration RRS feed

  • Question

  • Hi,

    Finally getting hold of the strict warning level of WDK (Windows Driver Development Kit), anyway I am trying my first communication driver using IOCTL's, therefore logically I started to create a MajorFunction[IRP_MJ_CREATE] just to start the communication-model and already I am experienced problem regarding to creating any of the MajorFunction part, any one know the problem. 

    #include<wdm.h>
    #define  UNREFERENCED_PARAMETER(P) (P)
    
    NTSTATUS _stdcall IOOpen(IN PDRIVER_OBJECT theDriverObject, IN PIRP Irp)
    {
    	UNREFERENCED_PARAMETER(theDriverObject);
    	IofCompleteRequest(Irp,IO_NO_INCREMENT);
    	return STATUS_SUCCESS;
    }
    VOID DriverUnload(IN PDRIVER_OBJECT theDriverObject)
    {
    	UNREFERENCED_PARAMETER(theDriverObject);
    	DbgPrint("Unloading Proc");
    }
    
    NTSTATUS DriverEntry(IN PDRIVER_OBJECT theDriverObject, IN PUNICODE_STRING theRegistryPath)
    {
    	UNREFERENCED_PARAMETER(theRegistryPath);
    	DbgPrint("Loading Proc");
    	theDriverObject->DriverUnload = DriverUnload;
    	theDriverObject->MajorFunction[IRP_MJ_CREATE] = &IOOpen;
    	return STATUS_SUCCESS;
    }

    The WDK supplies me with the following errors:

    IntelliSense: a value of type "NTSTATUS (__stdcall *)(PDRIVER_OBJECT theDriverObject, PIRP Irp)" cannot be assigned to an entity of type "PDRIVER_DISPATCH"

    Error C4028: formal parameter 1 different from declaration

    I am pretty sure it is to due with PDRIVER_OBJECT being changed to PDRIVER_DISPATCH yet, it throws out same baseless errors. 

    Any help will be appreciated,

    Rohan Vijjhalwar

    Monday, November 25, 2013 9:33 PM

Answers

  • Several questions:

    1.  Why are you using _stdcall anywhere?  The driver development environment takes care of the calling convention and so you should drop this usage, which is what I suspect is the problem.

    2.  Why are you developing a driver with WDM instead of KMDF?  These days that is just a bad idea.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Monday, November 25, 2013 9:52 PM
  • An Io dispatch routine takes a PDEVICE_OBJECT, not PDRIVER. As don said , no reason to start with wdk anymore. Also, if you use the built in wdk toolset and projects, you shouldn't need to specify calling convention. Don't roll your own build project, the settings are not simple

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Monday, November 25, 2013 10:26 PM

All replies

  • Several questions:

    1.  Why are you using _stdcall anywhere?  The driver development environment takes care of the calling convention and so you should drop this usage, which is what I suspect is the problem.

    2.  Why are you developing a driver with WDM instead of KMDF?  These days that is just a bad idea.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Monday, November 25, 2013 9:52 PM
  • An Io dispatch routine takes a PDEVICE_OBJECT, not PDRIVER. As don said , no reason to start with wdk anymore. Also, if you use the built in wdk toolset and projects, you shouldn't need to specify calling convention. Don't roll your own build project, the settings are not simple

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Monday, November 25, 2013 10:26 PM
  • Hi,

    Correctly pointed out about the PDEVICE_OBJECT and PDRIVER_OBJECT however the VS project is compiling correctly IntelliSense says:

    1 IntelliSense: a value of type "NTSTATUS (__stdcall *)(PDEVICE_OBJECT theDriverObject, PIRP Irp)" cannot be assigned to an entity of type "PDRIVER_DISPATCH"

    What is all that about? 

    Additionally, would you recommend typecasting like this: 

    theDriverObject->DriverUnload = DriverUnload;
    	theDriverObject->MajorFunction[IRP_MJ_CREATE] = (PDRIVER_DISPATCH)&IOOpen;

    Rather than just put:

    theDriverObject->DriverUnload = DriverUnload;
    	theDriverObject->MajorFunction[IRP_MJ_CREATE] =  &IOOpen;

    Which throws some IntelliSense Error 

    Monday, November 25, 2013 11:20 PM
  • Get rid of the _stdcall this will just create problems.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Monday, November 25, 2013 11:43 PM
  • Intellisense has issues with native C projects, so take some the warnings it gives with a grain of salt

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, November 26, 2013 12:34 AM