README.md

July 31, 2017 ยท View on GitHub

NexusHook

SwapChain hooking functionality for DirectX11 applications.


Installation

Download the latest release, include NexusHook.h and link the .lib against your project.


Usage

#include "NexusHook.h"
#pragma comment(lib, "NexusHook.lib")

typedef HRESULT(__stdcall *D3D11PresentHook) (IDXGISwapChain* pThis, UINT SyncInterval, UINT Flags);
NexusHook hkMngr;

// Present hook
HRESULT __stdcall SwapChainPresentHook(IDXGISwapChain* pThis, UINT SyncInterval, UINT Flags) {
    std::cout << "Hook called!" << std::endl;
    return ((D3D11PresentHook)hkMngr.oFunctions[SC_PRESENT])(pThis, SyncInterval, Flags);
}

void main() {
	// Init hook manager
	hkMngr.Init();

	// Hook present
	hkMngr.HookSwapChain((DWORD_PTR)SwapChainPresentHook, SC_PRESENT);
}


API

Methods

bool Init();

Initializes the hook manager. Returns true on success, false otherwise.

ArgumentDescriptionDefault
NoneNoneNone

bool HookSwapChain(DWORD_PTR newFunc, int index);

Hooks the specified function of the current SwapChain. Returns true on success, false otherwise.

ArgumentDescriptionDefault
newFuncPointer to your replacement function.None
urlVtable index of the function you want to hook.None

Fields

const static int iHookNumber = SC_GETLASTPRESENTCOUNT + 1;

Number of functions you can hook. Specified in Dx11Indexes.h


VMTHook hkHooks[iHookNumber];

All hooks stored in their respecting index number.


DWORD oFunctions[iHookNumber] = { NULL };;

All original functions from the original SwapChain.


SwapChainManager hMngr;

SwapChainManager, you shouldn't need to access this.


License

MIT