none
Driver always enter in default case of IOCTL when application uses only open driver instead of DeviceIoControl???? RRS feed

  • Question

  • Hello Friends,

    I have created an application that only calling driver using CreateFile.

    And in driver .def file the entries are as -

    xxx_Init

    xxx_DeInit

    xxx_Open

    xxx_Close

    xxx_Read

    xxx_write

    xxx_IOControl

    and in .cpp

    under xxx_IOControl function.

    RETAILMSG(TRUE,(TEXT("ADC_IOControl(): START\r\n")));
    	
    
    	switch(dwCode)
    	{
    		case IOCTL_ADC_CHANNEL:
    			RETAILMSG(TRUE,(TEXT("ADC_IOControl(): In IOCTL_ADC_CHANNEL ----------------\r\n")));
    			break;
    
    		default:
    			RETAILMSG(TRUE,(TEXT("ADC_IOControl(): ERROR in IOCTL \r\n")));
    
    
    	}
     But in my application I am not using DeviceIoControl and still when application call the driver, it automatically enters in xxx_IOControl function and in that function it enters in default case and display message as "ADC_IOControl(): ERROR in IOCTL"

    I am confused why it enters in XXX_IOControl because I am not calling it from application????????????


    Friday, August 1, 2014 12:42 PM

Answers

  • I now see that this is related to your other question about driver IOCTLs.  The information that you gave there is quite a bit different, and more useful, than the information that you gave here.

    Here you say that all you do is call CreateFile, there you show calling into the driver several more times - a couple of XXX_IoControl() calls and a call to XXX_Close().

    The interesting thing is that the call into XXX_IoControl(IOCTL_PSL_NOTIFY) happens just before calling XXX_Close().  Even more interesting is that this matches the documentation for IOCTL_PSL_NOTIFY (which is vague enough to allow it to match.)

    Do you call CloseHandle() from your application?   If not, do so.


    Bruce Eitman (eMVP) Senior Engineer Bruce.Eitman AT Eurotech DOT com My BLOG http://geekswithblogs.net/bruceeitman Eurotech Inc. www.Eurotech.com

    Friday, August 1, 2014 3:54 PM
    Moderator

All replies

  • I would start with outputting the value of dwCode.

    Once you know the value of dwCode, you can Google for it to see if it is a standard IOCTL value.


    Bruce Eitman (eMVP) Senior Engineer Bruce.Eitman AT Eurotech DOT com My BLOG http://geekswithblogs.net/bruceeitman Eurotech Inc. www.Eurotech.com

    Friday, August 1, 2014 12:48 PM
    Moderator
  • I will print and share and google it also
    Friday, August 1, 2014 12:52 PM
  • The dwCode value after printing in default case is - 16974847 and in hex it is 10303FF.

    when I did certain R&D related to this number then I come to know that its using device ID 0x103 and when i search it in winioctl.h I found that FILE_DEVICE_PSL is the macro and again i searched for this macro then I come to know that it is used by IOCTL_PSL_NOTIFY some where and again i searched that then i come to knw that it is used in 

    ..\public\common\oak\drivers\serial\com_mdd2\mdd.c

    But the thing is that why this IOCTL is calling my driver.....??????????

    Friday, August 1, 2014 1:01 PM
  • I now see that this is related to your other question about driver IOCTLs.  The information that you gave there is quite a bit different, and more useful, than the information that you gave here.

    Here you say that all you do is call CreateFile, there you show calling into the driver several more times - a couple of XXX_IoControl() calls and a call to XXX_Close().

    The interesting thing is that the call into XXX_IoControl(IOCTL_PSL_NOTIFY) happens just before calling XXX_Close().  Even more interesting is that this matches the documentation for IOCTL_PSL_NOTIFY (which is vague enough to allow it to match.)

    Do you call CloseHandle() from your application?   If not, do so.


    Bruce Eitman (eMVP) Senior Engineer Bruce.Eitman AT Eurotech DOT com My BLOG http://geekswithblogs.net/bruceeitman Eurotech Inc. www.Eurotech.com

    Friday, August 1, 2014 3:54 PM
    Moderator
  • Hello Bruce Eitman Sir,

    I was not closing the handler in application. Now, the full driver with small IOCTL functionality is working fine wiht API and application.... Thanks for your moral support......

    Monday, August 4, 2014 6:02 AM