About DDI Redirection

[This is preliminary documentation and subject to change.]

Client applications can set a DDI hook by using the SetDDIHook function. This function accepts parameters that describe the hook class, the location of the hook procedure, and private data that will be sent to the hook procedure when a DDI function call occurs. All of an application's DDI hook procedures must be written in a 16-bit DLL.

The hook class describes the type of application that owns the DDI hook procedure. Active Accessibility uses this class to determine the order in which it calls the registered hook procedures. Hook classes are defined in winddi.h and are called in the following descending order. This is because each step depends on what the DDI function's screen changes.

Class Description
DDIHOOK_RECORDER Screen readers and screen capture utilities.
DDIHOOK_REMOTE Remoting utilities.
DDIHOOK_FONTS Font enhancers.
DDIHOOK_MAGNIFIER Screen magnifiers.

If multiple hooks are registered for a given class, Active Accessibility still uses the preceding order, but sends event notifications within a class to the most recently registered hook procedures first.

When Active Accessibility calls a DDI hook procedure, it receives parameters describing the DDI hook instance, the type of DDI function being called, and the address of a DDI stack structure. DDI stack structures, defined in winddi.h, are the parameters being passed to the specified DDI function as they exist on the stack. The hook procedure can examine these values, change them if necessary, and pass the event by calling the CallNextDDI function and using that return value as its own return. This function returns control to Active Accessibility, which sends event notifications to other registered hook procedures, finally calling the DDI function when all hook procedures have been notified and have passed the call. If a callback procedure changes a stack value, the new value will be reflected by any subsequent DDI hook procedures. If a hook procedure doesn't call CallNextDDI, the DDI function fails and never reaches the display device.