NVDA Helper
In-process and lite high-speed utilities for NVDA
apiHook.cpp File Reference
#include <iostream>
#include <set>
#include <windows.h>
#include <delayimp.h>
#include <detours/src/detours.h>
#include "log.h"
#include "apiHook.h"

Go to the source code of this file.

Macros

#define WIN32_LEAN_AND_MEAN
 

Typedefs

typedef set< pair< void **, void * > > functionSet_t
 

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.
 
bool apiHook_commitTransaction ()
 Commits an API hooking transaction.
 
bool apiHook_terminate ()
 unhooks all functions previously hooked with apiHook_hookFunction and terminates API hooking subsystem.
 

Variables

functionSet_t g_hookedFunctions
 

Macro Definition Documentation

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Typedef Documentation

◆ functionSet_t

typedef set<pair<void**, void*> > functionSet_t

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_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().

Variable Documentation

◆ g_hookedFunctions

functionSet_t g_hookedFunctions