views:

118

answers:

1

Hi there!

I'm trying to make my own ioctl driver command for calling it from an user-mode application dll. For now I just wanted to make sure the dll succesfuly calls that command on the driver code. So I defined my command (in the dll and in the driver's code) like this:

#define BUSENUM_IOCTL(_index_) \
    CTL_CODE (FILE_DEVICE_BUS_EXTENDER, _index_, METHOD_BUFFERED, FILE_ANY_ACCESS)
...
#define IOCTL_DEBUG_LOG_INFO            BUSENUM_IOCTL (0x4) 

in the driver code, in my corresponding IRP_MJ_DEVICE_CONTROL function, I have something like this:

switch ( command )
    {
  case IOCTL_DEBUG_LOG_INFO: 
   KdPrint(("IOCTL_DEBUG_LOG_INFO:\n"));
   if(devExt->Type==0)
   { 
    status = STATUS_SUCCESS;
   }
   else
   {
    status=STATUS_INVALID_DEVICE_REQUEST;
    KdPrint(("Wrong device on IOCTL_DEBUG_LOG_INFO command\n"));
   }
   break;
...
}

and in the dll code I'm calling the driver's command like this:

if (DeviceIoControl(h, IOCTL_DEBUG_LOG_INFO,
      &debugLogInfoData, sizeof(DEBUG_LOG_INFO),
      &debugLogInfoData, sizeof(DEBUG_LOG_INFO),
      &junk, NULL))
 {   
  CloseHandle(h);

  ...

  return VDD_NO_ERROR;
 }

 PrintLastError(prefix);

 return VDD_UNKNOWN_ERROR;
}

(where h is the handle initialized when I opened the stub driver (devExt->Type==0) )

but it always goes to the "VDD_UNKNOWN_ERROR" with the error code 1: Incorrect function

What am I doing wrong? ...

Help please!

A: 

but DeviceIoControl wouldn't call it? What code should I post? ... this is the code related to this operation at kernel level ... the source in the kernel mode driver source code and the code in the user-mode source code –

Cosmin Popescu
Please use comments (as you did before) rather than adding a new (non) answer.
Hasturkun