none
Cookie RRS feed

  • Question

  • Hi,

    I am referring the Keypad Driver from keypad.c which is in the following path (_WINCEROOT)\PLATFORM\COMMON\src\soc\OMAP2420_MS_V1\keypad\.

    I see usage of KPD_DEVICE_COOKIE macro.

    I don't understand why that is required. What is the benefit that the driver gets by using it in Deinit and IoControl functions?

    Thank You & Regards,

    GSR

    Friday, May 20, 2011 7:07 AM

All replies

  • I think it can be useful for debugging purposes: it's the 1st member of the struct which holds the device driver context and, being a string, you can easily find in a memory dump, although I would have spelled it backeards (*). In addition (I guess) checking it in deinit is done so you're sure that LocalFree will free the device driver context memory rather than some other memory.

    (*) 'pool tagging' is a debugging aid and it's a good practice in Windows WDM device driver programming, see for example http://msdn.microsoft.com/en-us/library/ff544520(v=vs.85).aspx

     


    Luca Calligaris lucaDOTcalligarisATeurotechDOTcom www.eurotech.com Check my blog: http://lcalligaris.wordpress.com
    Friday, May 20, 2011 9:51 AM