VDDInstallMemoryHook

BOOL VDDInstallMemoryHook(hVdd, pStart, count, MemoryHandler)
IN HANDLE  hVdd;
IN PVOID  pStart;
IN DWORD  count;
IN PVDD_MEMORY_HANDLER  MemoryHandler;

VDDInstallMemoryHook releases the memory-mapped I/O addresses a VDD controls.

Parameters

hVdd
Identifies the VDD.
pStart
Points to the starting linear address.
count
Identifies the number of bytes of mapped memory.
MemoryHandler
Points to the VDD handler for the memory address range.

Return Value

VDDInstallMemoryHook returns TRUE if successful. Otherwise, it returns FALSE and logs one of the following errors:

Value

Meaning

ERROR_ACCESS_DENIED

One of the requested ports is already hooked.

ERROR_OUTOFMEMORY

There are insufficient resources.

Comments

The first VDD to hook an address will get control of the memory. There is no chaining of hooks. A VDD should grab the memory during its initialization routine. After all VDDs are loaded, the EMM component will use all remaining memory ranges for UMB support.

Installing a hook on a memory range results in the consumption of memory based on page boundaries. The pStart is rounded down. count is rounded up to the next page boundary. The VDD’s memory hook handler is called for all addresses within the page(s) used. The page(s) are set aside as mapped reserved sections, and will no longer be available for use by the Win32 VDM component or other VDDs. The VDD is permitted to manipulate the memory (commit, free, etc.). Only one VDD is allowed to have memory hooks in a particular page.

The VDD’s memory handler will be called with the address of any page fault and with a flag identifying whether the fault was caused by a read or write operation.

On return from the VDD hook handler, Windows NT will assume that the page fault was handled and returns control to the VDM component.

After calling the VDD’s MemoryHandler, VDM returns to the faulting cs:ip in the 16-bit application. If the VDD doesn’t need this, it can adjust the cs:ip using the setCS and setIP functions.

See Also

VDDDeinstallMemoryHook