Skip to content

nexus-devs/nexus-hook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Argument Description Default
None None None

bool HookSwapChain(DWORD_PTR newFunc, int index);

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

Argument Description Default
newFunc Pointer to your replacement function. None
url Vtable 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