none
synchronous access to embedded pointers in kernel space RRS feed

  • Question

  • hi,

    is it possible to do synchronous access to embedded pointers in kernel space without any marshaling, the embedded pointer have to send from user space

    regards

    sineesh

    Tuesday, July 24, 2012 1:24 PM

All replies

  • That depends on what version of CE you are using. If 5.0 or prior; yes. If 6.0 or later; no.

    It also depends on your definition of an embedded pointer. If you have that right, then the above is right, but I've seen much confusion with many of my customers about what an embedded pointer is and when to use marshaling.

    Maybe it is better to let us know what you are trying to do or workaround, so we can help you better.


    Good luck,

    Michel Verhagen, eMVP
    Check out my blog: http://guruce.com/blog

    GuruCE
    Microsoft Embedded Partner
    http://guruce.com
    Consultancy, training and development services.

    Tuesday, July 24, 2012 9:52 PM
    Moderator
  • hi,

    platform is WinCE 6.00 R3

    from application i calls an ioctl to driver.

    #define HT_READ_EVENT  L"ReadEvent"
    typedef struct _HTD_CONFIG_INTR_PARAM
    {
         BOOL fEnable;
         HANDLE hIntrEvent;
         LPTSTR lpEventName;
    }HTD_CONFIG_INTR_PARAM;

    HTD_CONFIG_INTR_PARAM stIntrParam = {0};

    stIntrParam.fEnable            = fEnable;
    stIntrParam.hIntrEvent       = INVALID_HANDLE_VALUE;
    stIntrParam.lpEventName   = HT_READ_EVENT ; 
     
    fSuccess = DeviceIoControl(g_hHTD,
                                            IOCTL_HTD_CONFIG_INTR,
                                           (LPVOID)&stIntrParam,
                                           sizeof(stIntrParam) ,
                                           NULL,
                                           0 ,
                                           NULL,
                                           NULL);

    In driver i recieves this pointer like this , is there any thing wrong with this methode?
            
    LPTSTR  lpIntrEventName = NULL;        
    lpIntrEventName =(((HTD_CONFIG_INTR_PARAM *)pbBufIn)->lpEventName); 


    • Edited by sineesh Thursday, July 26, 2012 4:35 AM
    Thursday, July 26, 2012 4:06 AM
  • Yes, it is wrong to access the pointer in that way. You need to marshal that embedded pointer. For easy marshaling, see the MarshalledBuffer_t class.

    Good luck,

    Michel Verhagen, eMVP
    Check out my blog: http://guruce.com/blog

    GuruCE
    Microsoft Embedded Partner
    http://guruce.com
    Consultancy, training and development services.


    Thursday, July 26, 2012 5:26 AM
    Moderator
  • There's an old but very good and up to date post on the ce_base blog about marshalling which can help you understand marshalling, embedded pointers, synchronous/asynchronous access: http://blogs.msdn.com/b/ce_base/archive/2006/11/09/memory-marshalling-in-windows-ce.aspx


    Luca Calligaris lucaDOTcalligarisATeurotechDOTcom www.eurotech.com Check my blog: http://lcalligaris.wordpress.com

    Tuesday, July 31, 2012 2:10 PM
  • This is also a case where you don't actually need to use an embedded pointer at all.  Microsoft would typically use a structure that contains offsets to data outside of the structure, then allocate enough space for the struct and the string.  Then just copy the string to the extra space.

    Wala, no embedded pointer.

    Something like this:

    #define HT_READ_EVENT  L"ReadEvent"
    typedef struct _HTD_CONFIG_INTR_PARAM
    {
         BOOL fEnable;
         HANDLE hIntrEvent;
         int EventNameOffset;
    }HTD_CONFIG_INTR_PARAM;

    HTD_CONFIG_INTR_PARAM *stIntrParam = malloc( sizeof(HTD_CONFIG_INTR_PARAM) + wcslen(HT_READ_EVENT) + 2);

    stIntrParam->fEnable            = fEnable;
    stIntrParam->hIntrEvent       = INVALID_HANDLE_VALUE;
    stIntrParam->EventNameOffset   = sizeof(HTD_CONFIG_INTR_PARAM);

    wcscpy( stIntrParam + stIntrParam->EventNameOffset, HT_READ_EVENT );


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

    Eurotech Inc.
    www.Eurotech.com


    Tuesday, July 31, 2012 8:22 PM
    Moderator