Monday 11 May 2009

Application Interrupt threads

Most of us know (or even have seen) code with the interrupt service thread (IST) running in context of an application. Up to CE5.0 this could be achieved quite easy (thanks to SetKMode + SetProcPermission).

Is this still possible with CE6.0? Most CE developers would say "no" without hesitating a second.

When I saw the following line I thought "that doesn't work, that's not possible!":

InterruptInitialize(dwSysIntr, hDriverInterruptEvent, NULL, 0);

But I have been disabused :-) It is possible to create to initialize an interrupt without the interrupt thread function parameter (i.e. NULL pointer)!

And if the driver provide a method to duplicate the interrupt event (usually via Ioctl call)

DuplicateHandle(GetCurrentProcess(),
hDriverInterruptEvent,
(HANDLE)GetCallerVMProcessId,
(LPHANDLE)pOutBuf,
FALSE, DUPLICATE_SAME_ACCESS);

you can wait for the interrupt event in an application thread.

I won't say that this is a standard driver/application architecture. But there might be situations where this way is a simple and pragmatic approach (e.g. during driver development).

No comments: