Thursday 25 March 2010

Registry notifications to pass data between kernel to Apps/drivers

This breifly outlines the technique of passing information or state changes between the Windows CE Kernel/OAL and running drivers or applications. Passing events and notification from the kernel to a driver or application can be a little problematic, information flow the other way is straight forward using the kernel IOCtls.

One thing we can use here is the registry and the registry change notifications, for instance, both drivers/applications and kernel can change the registry, the kernel calls are all preceeded by NK, for instance:

Kernel:

NKRegOpenKeyEx
NKRegCreateKeyEx
NKRegSetValueEx

Driver/App:

RegOpenKeyEx
RegCreateKeyEx
RegSetValueEx

So why not set a state or value to pass in the registry, then wait on a particular registry key or value being changed using the following:


// create an event on a particular registry change
HANDLE event = CeFindFirstRegChange(....)

while(1)
{
// wait for notification of a change
WaitForSingleObject(event, INFINITE);

// clear event
CeFindNextRegChange(event);

}

Using this technique small, or large complex data can be shared very easily.

No comments: