NVDA Helper
In-process and lite high-speed utilities for NVDA
apiHook.h File Reference

Go to the source code of this file.

Functions

bool apiHook_beginTransaction ()
 Initializes an API hooking transaction.
 
bool apiHook_hookFunction (void *realFunction, void *fakeFunction, void **targetPointerRef)
 Requests that the given function from the given module should be hooked with the given hook procedure.
 
template<typename funcType >
bool apiHook_hookFunction_safe (funcType realFunction, funcType fakeFunction, funcType *targetPointerRef)
 Safely hooks a given function from a given module with a given fake function.
 
bool apiHook_commitTransaction ()
 Commits an API hooking transaction.
 
bool apiHook_terminate ()
 unhooks all functions previously hooked with apiHook_hookFunction and terminates API hooking subsystem.
 

Function Documentation

◆ apiHook_beginTransaction()

bool apiHook_beginTransaction ( )

Initializes an API hooking transaction.

Returns
success flag

References LOG_DEBUG, and LOG_ERROR.

Referenced by apiHook_terminate(), inprocMgrThreadFunc(), and nvdaHelperLocal_initialize().

◆ apiHook_hookFunction()

bool apiHook_hookFunction ( void * realFunction,
void * fakeFunction,
void ** targetPointerRef )

Requests that the given function from the given module should be hooked with the given hook procedure.

Warning, this function has no safety checks, you should usually use the apiHook_hookFunction_safe template

Parameters
realFunctionthe function you wish to hook.
fakeFunctionthe function you wish to be called instead of the original one.
targetPointerRefPointer variable that will contain a pointer to the original function after hooking. This is used to unhook.

References g_hookedFunctions, LOG_DEBUG, and LOG_ERROR.

Referenced by apiHook_hookFunction_safe().

◆ apiHook_hookFunction_safe()

template<typename funcType >
bool apiHook_hookFunction_safe ( funcType realFunction,
funcType fakeFunction,
funcType * targetPointerRef )

Safely hooks a given function from a given module with a given fake function.

This is a safer wrapper around apiHook_hookFunction that ensures that the real and fake function have matching signatures.

Parameters
realFunctionthe function you wish to hook.
fakeFunctionthe function you wish to be called instead of the original one.
targetPointerRefPointer variable that will contain a pointer to the original function after hooking. This is used to unhook.

References apiHook_hookFunction().

Referenced by gdiHooks_inProcess_initialize(), inprocMgrThreadFunc(), and nvdaHelperLocal_initialize().

◆ apiHook_commitTransaction()

bool apiHook_commitTransaction ( )

Commits an API hooking transaction.

References LOG_DEBUG, and LOG_ERROR.

Referenced by apiHook_terminate(), inprocMgrThreadFunc(), and nvdaHelperLocal_initialize().

◆ apiHook_terminate()

bool apiHook_terminate ( )

unhooks all functions previously hooked with apiHook_hookFunction and terminates API hooking subsystem.

References apiHook_beginTransaction(), apiHook_commitTransaction(), g_hookedFunctions, LOG_DEBUG, and LOG_ERROR.

Referenced by DllMain(), inprocMgrThreadFunc(), and nvdaHelperLocal_terminate().