Inverted Call Question(s)

Hi everyone, i currently have a driver and GUI user application, where the driver detects process creation using PsSetCreateProcessNotifyRoutine and will send the process information to the user application, like process id and such. I create a named event at kernel mode, and when a process executes or terminates, i will signal the event in which at the application level, it MsgWaitForMultipleObjects for the event, and sends down an IOCTL to collect the process data. However, i have been losing data, especially when the process executes or terminates very quickly. Therefore, after some read up and googling, i decided that i should use the Inverted Call model. I read the article here : http://insider.osr.com/2013/ntinsider_2013_01.pdf

However, i realised that the example given in the article uses WDF and all the functions are very different from what i am currently using. For example, the inverted call example do not have DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] and such. I am also using IoCreateDevice, IoCreateSymbolicLink and such functions, whereas the inverted call example does not use such functions.

Do i have to change my entire driver to make the inverted call work? I am really confused right now

sorry for the wall of text, and thanks for taking the time!

You have a wdm driver. For inverted call to work you need a queue of requests to pend and support cancelation of those queued requests. Your best bet is to use an IO_CSQ.

d

Bent from my phone


From: xxxxx@hotmail.commailto:xxxxx
Sent: ?9/?3/?2014 6:58 PM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: [ntdev] Inverted Call Question(s)

Hi everyone, i currently have a driver and GUI user application, where the driver detects process creation using PsSetCreateProcessNotifyRoutine and will send the process information to the user application, like process id and such. I create a named event at kernel mode, and when a process executes or terminates, i will signal the event in which at the application level, it MsgWaitForMultipleObjects for the event, and sends down an IOCTL to collect the process data. However, i have been losing data, especially when the process executes or terminates very quickly. Therefore, after some read up and googling, i decided that i should use the Inverted Call model. I read the article here : http://insider.osr.com/2013/ntinsider_2013_01.pdf

However, i realised that the example given in the article uses WDF and all the functions are very different from what i am currently using. For example, the inverted call example do not have DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] and such. I am also using IoCreateDevice, IoCreateSymbolicLink and such functions, whereas the inverted call example does not use such functions.

Do i have to change my entire driver to make the inverted call work? I am really confused right now

sorry for the wall of text, and thanks for taking the time!

—
NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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</mailto:xxxxx></mailto:xxxxx>

Thanks for the reply.

So it is still possible to implement the inverted call model for WDM? Are there any articles/examples for WDM inverted call?

Also, if inverted call model is used, how does the user mode application “wait” for the completed IOCTLs? Since in my case, the user application waits on an event for the kernel to signal it to send the IOCTL down to collect data.

Sure, you can do it in wdm. It is harder than in kmdf, lots of corner cases for you to handle. The app opens the handle as overlapped and then waits on the OVERLAPPED::hEvent that it passed in to the Ioctl() call

d

Bent from my phone


From: xxxxx@hotmail.commailto:xxxxx
Sent: ?9/?3/?2014 7:44 PM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: RE:[ntdev] Inverted Call Question(s)

Thanks for the reply.

So it is still possible to implement the inverted call model for WDM? Are there any articles/examples for WDM inverted call?

Also, if inverted call model is used, how does the user mode application “wait” for the completed IOCTLs? Since in my case, the user application waits on an event for the kernel to signal it to send the IOCTL down to collect data.

—
NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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</mailto:xxxxx></mailto:xxxxx>

Hi,

I suspect the article you need to read is this,

Kernel: Calling User Mode - Using the Inverted Call Model
http://www.osronline.com/article.cfm?id=94

A legacy article I keep as a treasure.

From: xxxxx@microsoft.com
To: xxxxx@lists.osr.com
Subject: RE: [ntdev] Inverted Call Question(s)
Date: Thu, 4 Sep 2014 03:09:15 +0000

Sure, you can do it in wdm. It is harder than in kmdf, lots of corner cases for you to handle. The app opens the handle as overlapped and then waits on the OVERLAPPED::hEvent that it passed in to the
Ioctl() call

d

Bent from my phone

From:
xxxxx@hotmail.com

Sent:
?9/?3/?2014 7:44 PM

To:
Windows System Software Devs Interest List

Subject:
RE:[ntdev] Inverted Call Question(s)

Thanks for the reply.

So it is still possible to implement the inverted call model for WDM? Are there any articles/examples for WDM inverted call?

Also, if inverted call model is used, how does the user mode application “wait” for the completed IOCTLs? Since in my case, the user application waits on an event for the kernel to signal it to send the IOCTL down to collect data.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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

xxxxx@hotmail.com wrote:

So it is still possible to implement the inverted call model for WDM? Are there any articles/examples for WDM inverted call?

“Inverted call” is just a fancy name for a very simple concept. All it
means is the application submits an ioctl that waits for a very long
time. When the driver has stuff for the app to do, it completes the
ioctl. It’s called “inverted call” because it lets you pretend that the
driver is calling the app. The reality is that it’s exactly like
regular I/O. The app submits the request, the driver completes it.
Eventually.

Also, if inverted call model is used, how does the user mode application “wait” for the completed IOCTLs? Since in my case, the user application waits on an event for the kernel to signal it to send the IOCTL down to collect data.

You use overlapped I/O. You still have an event, but it’s embedded in
the OVERLAPPED structure. You submit a bunch of request, each with its
own OVERLAPPED structure, each with its own event. You then do
WaitForMultipleObjects to wait until one of them completes, then
GetOverlappedResult to make sure the request completed normally.

You can also use an I/O completion port. Many people find that model
more sensible.

–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Any time performance is an issue, you want to use a completion port. End of story.

The Windows I/O Subsystem does a great job of optimizing I/O specifically for completion port handling. You should take advantage of this.

Of course, if performance is not a concern then use whatever model is easiest.

Peter
OSR
@OSRDrivers