none
OpenMsgQueue RRS feed

  • Question

  • Hi,

    I have created a queue using CreateMsgQueue in User Application (Read Only).

    Know i wanted to write into the queue by the Kernel Driver. For this I am passing Handle Returned by the CreateMsgQueue and Source Process Handle using Get CurrentProcess using a Device IOCTL. When I use OpenMsgQUeue in the Kernel Driver it returns a NULL value.

    User Process Id and Message Queue handle are passed to the Kernel driver in a structure parameter struct { DWORD hProc;  DOWRD HHnd;}

    GetLastError returns a value of 87, which means ERROR_INVALID_PARAMETER.

    Any inputs?

    Regards,

    GSR

    Wednesday, May 25, 2011 5:07 AM

All replies

  • Your approch -probably- miss a call to DuplicateHandle but why don't you use a named queue?

    From the app:

    CreateMsgQueue(_T("aUniqueNameOfYourChoice"), &MsgQueueOpt);

    from the driver:

    CreateMsgQueue(_T("aUniqueNameOfYourChoice"), &MsgQueueOpt);

    You do not need necessaryly to call OpenMsgQueue the 2nd time since CreateMsgQueue will work as well: it won't fail,  simply GetLastError() will return ERROR_ALREADY_EXISTS.

    If you do not want to hardcode the name of the queue you can pass it to the device driver using an IOCTL.

     

     

     


    Luca Calligaris lucaDOTcalligarisATeurotechDOTcom www.eurotech.com Check my blog: http://lcalligaris.wordpress.com
    Wednesday, May 25, 2011 8:34 AM
  • Hi Luca Calligaris,

    Thank You for reply.

    I had tried those methods and they passed (Named queue).

    I am trying to exercise OpenMsgQueue API.

    By the way you have mentioned that we need to use DuplicateHandle. Can I get URL or anything else when and why we have to use that API?

    Regards,

    GSR

     


    • Edited by GSRid Wednesday, May 25, 2011 8:51 AM Modified
    Wednesday, May 25, 2011 8:46 AM
  • You can check how OpenMsgQueue is used in the power manager (%_WINCEEROOT%\PUBLIC\COMMON\OAK\DRIVERS\PM\MDD\pmutils.cpp) and in NDISUIO driver

    (%_WINCEEROOT%\PUBLIC\COMMON\OAK\DRIVERS\NDISUIO\uio_ce.c)


    Luca Calligaris lucaDOTcalligarisATeurotechDOTcom www.eurotech.com Check my blog: http://lcalligaris.wordpress.com
    Wednesday, May 25, 2011 9:36 AM