IQueueCallbackCreate OnCreateFile callback question

I am developing a driver based on umdf and have
IQueueCallbackCreate::OnCreateFile working as I expect. I allocate
some memory during the callback, and need to free it when closed. I
have not found the “OnCloseFile” type of interface that works on the
IQueue… type interfaces. I have found the OnCleanupFile and
OnCloseFile in the IFileCallback… interfaces. I added them in but
they do not get called, so I am missing something entirely. What is
the correct method handle a CloseHandle() from the application if the
IQueueCallbackCreate::OnCreateFile was the interface called during the
application’s call to CreateFile()?

Thanks,
Donald

xorg at kayser dot net

Hi Donald,

The UMDF driver callback to be called in your case when you have CreateFile() from an app is IQueueCallbackCreate::OnCreateFile(). When you call CloseFile() the callback IFileCallbackCleanup::OnCleanupFile() is called first and next if you don’t have a pending i/o - the IFileCallbackClose::OnCloseFile() callback is called.

Hope this information helps,
Tanya

1 Like

While adding them to your list of derivations, did you also update your QI code to handle the query for them?

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Donald Kayser
Sent: Monday, March 08, 2010 9:20 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] IQueueCallbackCreate OnCreateFile callback question

I am developing a driver based on umdf and have IQueueCallbackCreate::OnCreateFile working as I expect. I allocate some memory during the callback, and need to free it when closed. I have not found the “OnCloseFile” type of interface that works on the IQueue… type interfaces. I have found the OnCleanupFile and OnCloseFile in the IFileCallback… interfaces. I added them in but they do not get called, so I am missing something entirely. What is the correct method handle a CloseHandle() from the application if the IQueueCallbackCreate::OnCreateFile was the interface called during the application’s call to CreateFile()?

Thanks,
Donald

xorg at kayser dot net


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

On Mar 8, 2010, at 12:53 PM, Doron Holan wrote:

While adding them to your list of derivations, did you also update
your QI code to handle the query for them?

Yes. All the query’s with addRef() calls are there. I will double
check that they are getting called. Of course I have a bug somewhere,
I just didn’t know for sure which callbacks applied and hadn’t found
an explanation that I understood.

Thanks for the help.

Donald

Tanya,

Thank you for the order of callbacks. My application calls
CloseHandle() not CloseFile(). From my understanding it is proper to
call CloseHandle(). Now that you have given me the correct order of
events, I will retry. Also, I have configured the
IUsbTargetPipeContinuousReaderCallbackReadComplete interface. Do I
need to handle or cancel this interface before the OnCloseFile
callbacks are made? Just a hunch I have that I need to cancel any
pending I/O before the close callbacks are made.

Thanks again,
Donald

On Mar 8, 2010, at 12:49 PM, xxxxx@microsoft.com wrote:

Hi Donald,

The UMDF driver callback to be called in your case when you have
CreateFile() from an app is IQueueCallbackCreate::OnCreateFile().
When you call CloseFile() the callback
IFileCallbackCleanup::OnCleanupFile() is called first and next if
you don’t have a pending i/o - the IFileCallbackClose::OnCloseFile()
callback is called.

Hope this information helps,
Tanya


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

As it turns out, I forgot to add to the QueryInterface() method the
check for equality and returning the correct interface.

Thanks everyone.

Donald

On Mar 8, 2010, at 12:53 PM, Doron Holan wrote:

While adding them to your list of derivations, did you also update
your QI code to handle the query for them?

> As it turns out, I forgot to add to the QueryInterface() method the

check for equality and returning the correct interface.

QueryInterface on IID_IUnknown must succeed.

More so, the returned pointer value of such a call must always be the same during the whole object lifetime. It can match with some other interface pointer though.

These are the basic COM rules.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com