本文整理汇总了C++中HardHook类的典型用法代码示例。如果您正苦于以下问题:C++ HardHook类的具体用法?C++ HardHook怎么用?C++ HardHook使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HardHook类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: myRelease
static ULONG __stdcall myRelease(ID3D10Device *pDevice) {
//TODO: Move logic to HardHook.
// Call base without active hook in case of no trampoline.
ReleaseType oRelease = (ReleaseType) hhRelease.call;
hhRelease.restore();
ULONG res = oRelease(pDevice);
hhRelease.inject();
Mutex m;
DeviceMap::iterator it = devices.find(pDevice);
if (it != devices.end()) {
D10State *ds = it->second;
// If we are receiving a lot of subsequent releases lets eagerly drop
// our state object. If the device presents something again a state
// object is created again just fine anyway.
if (res < ds->lHighMark / 2) {
ods("D3D10: Deleting resources %u < 0.5 * %u", res, ds->lHighMark);
devices.erase(it);
chains.erase(ds->pSwapChain);
delete ds;
ods("D3D10: Deleted");
ds = NULL;
}
}
return res;
}
示例2: myResetEx
static HRESULT __stdcall myResetEx(IDirect3DDevice9Ex *idd, D3DPRESENT_PARAMETERS *param, D3DDISPLAYMODEEX *param2) {
ods("D3D9: Chaining ResetEx");
DevMapType::iterator it = devMap.find(idd);
DevState *ds = it != devMap.end() ? it->second : NULL;
if (ds) {
if (ds->dwMyThread) {
ods("D3D9: myResetEx from other thread");
}
Stash<DWORD> stashThread(&(ds->dwMyThread), GetCurrentThreadId());
ds->releaseAll();
}
//TODO: Move logic to HardHook.
// Call base without active hook in case of no trampoline.
ResetExType oResetEx = (ResetExType) hhResetEx.call;
hhResetEx.restore();
HRESULT hr = oResetEx(idd, param, param2);
hhResetEx.inject();
if (ds)
ds->createCleanState();
return hr;
}
示例3: myWin8AddRef
static ULONG __stdcall myWin8AddRef(IDirect3DDevice9 *idd) {
Mutex m;
DevMapType::iterator it = devMap.find(idd);
DevState *ds = it != devMap.end() ? it->second : NULL;
if (ds && ds->dwMyThread == GetCurrentThreadId()) {
// AddRef is called very often. Thus, we do not want to always log here.
#ifdef EXTENDED_OVERLAY_DEBUGOUTPUT
ods("D3D9: Using own Refcount implementation for call to AddRef (Win8).");
#endif
ds->myRefCount++;
return ds->refCount;
}
//TODO: Move logic to HardHook.
// Call base without active hook in case of no trampoline.
AddRefType oAddRef = (AddRefType) hhAddRef.call;
hhAddRef.restore();
ULONG res = oAddRef(idd);
hhAddRef.inject();
if (ds)
ds->refCount = res;
// AddRef is called very often. Thus, we do not want to always log here.
#ifdef EXTENDED_OVERLAY_DEBUGOUTPUT
ods("D3D9: Chained AddRef (Win8) with result %d", res);
#endif
return res;
}
示例4: myReset
static HRESULT __stdcall myReset(IDirect3DDevice9 * idd, D3DPRESENT_PARAMETERS *param) {
ods("D3D9: Chaining Reset");
DevState *ds = devMap[idd];
if (ds) {
DWORD dwOldThread = ds->dwMyThread;
if (dwOldThread)
ods("D3D9: myReset from other thread");
ds->dwMyThread = GetCurrentThreadId();
ds->releaseAll();
ds->dwMyThread = dwOldThread;
}
//TODO: Move logic to HardHook.
// Call base without active hook in case of no trampoline.
ResetType oReset = (ResetType) hhReset.call;
hhReset.restore();
HRESULT hr = oReset(idd, param);
hhReset.inject();
if (ds)
ds->createCleanState();
return hr;
}
示例5: myWin8AddRef
static ULONG __stdcall myWin8AddRef(IDirect3DDevice9 *idd) {
Mutex m;
ods("D3D9: Chaining AddRef (Win8)");
DevState *ds = devMap[idd];
if (ds && ds->dwMyThread == GetCurrentThreadId()) {
ds->myRefCount++;
return ds->refCount;
}
//TODO: Move logic to HardHook.
// Call base without active hook in case of no trampoline.
AddRefType oAddRef = (AddRefType) hhAddRef.call;
hhAddRef.restore();
ULONG res = oAddRef(idd);
hhAddRef.inject();
if (ds)
ds->refCount = res;
ods("D3D9: Chained AddRef (Win8) with result %d", res);
return res;
}
示例6: myRelease
static ULONG __stdcall myRelease(IDirect3DDevice9 *idd) {
Mutex m;
DevMapType::iterator it = devMap.find(idd);
DevState *ds = it != devMap.end() ? it->second : NULL;
if (ds) {
// Release is called very often. Thus, we do not want to always log here.
#ifdef EXTENDED_OVERLAY_DEBUGOUTPUT
ods("D3D9: Using own Refcount implementation for call to Release.");
#endif
if (ds->dwMyThread == GetCurrentThreadId()) {
ds->myRefCount--;
return ds->initRefCount + ds->refCount;
} else {
ds->refCount--;
}
if (ds->refCount <= 1) {
ds->disconnect();
}
if (ds->refCount >= 0) {
return ds->initRefCount + ds->refCount;
}
ods("D3D9: Final release is following. MyRefs = %d, Tot = %d", ds->myRefCount, ds->refCount);
if (ds->dwMyThread != 0) {
ods("D3D9: finalRelease from other thread");
}
// Codeblock for stashing threadid
{
Stash<DWORD> stashThread(&(ds->dwMyThread), GetCurrentThreadId());
ds->releaseAll();
}
ods("D3D9: Final release of %p. MyRefs = %d Tot = %d", idd, ds->myRefCount, ds->refCount);
devMap.erase(it);
delete ds;
ds = NULL;
}
//TODO: Move logic to HardHook.
// Call base without active hook in case of no trampoline.
ReleaseType oRelease = (ReleaseType) hhRelease.call;
hhRelease.restore();
ULONG res = oRelease(idd);
hhRelease.inject();
// Release is called very often. Thus, we do not want to always log here.
#ifdef EXTENDED_OVERLAY_DEBUGOUTPUT
ods("D3D9: Chained Release with result %d", res);
#endif
return res;
}
示例7: myCreateDeviceEx
static HRESULT __stdcall myCreateDeviceEx(IDirect3D9Ex * id3d, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, D3DDISPLAYMODEEX* pFullscreenDisplayMode, IDirect3DDevice9Ex** ppReturnedDeviceInterface) {
Mutex m;
ods("D3D9: Chaining CreateDeviceEx");
// BehaviorFlags &= ~D3DCREATE_PUREDEVICE;
//TODO: Move logic to HardHook.
// Call base without active hook in case of no trampoline.
CreateDeviceExType oCreateDeviceEx = (CreateDeviceExType) hhCreateDeviceEx.call;
hhCreateDeviceEx.restore();
HRESULT hr = oCreateDeviceEx(id3d, Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, pFullscreenDisplayMode, ppReturnedDeviceInterface);
hhCreateDeviceEx.inject();
if (FAILED(hr))
return hr;
IDirect3DDevice9Ex *idd = *ppReturnedDeviceInterface;
DevState *ds = new DevState;
ds->dev = idd;
idd->AddRef();
ds->initRefCount = idd->Release();
devMap[idd] = ds;
// The offsets are dependent on the declaration order of the struct.
// See IDirect3DDevice9 (2nd, 3rd, 17th, 18th functions)
const unsigned int offsetAddref = 1;
const unsigned int offsetRelease = 2;
const unsigned int offsetReset = 16;
const unsigned int offsetPresent = 17;
if (bIsWin8) {
hhAddRef.setupInterface(idd, offsetAddref, reinterpret_cast<voidFunc>(myWin8AddRef));
hhRelease.setupInterface(idd, offsetRelease, reinterpret_cast<voidFunc>(myWin8Release));
} else {
hhAddRef.setupInterface(idd, offsetAddref, reinterpret_cast<voidFunc>(myAddRef));
hhRelease.setupInterface(idd, offsetRelease, reinterpret_cast<voidFunc>(myRelease));
}
hhReset.setupInterface(idd, offsetReset, reinterpret_cast<voidFunc>(myReset));
hhPresent.setupInterface(idd, offsetPresent, reinterpret_cast<voidFunc>(myPresent));
IDirect3DSwapChain9 *pSwap = NULL;
idd->GetSwapChain(0, &pSwap);
if (pSwap) {
// The offset is dependent on the declaration order of the struct.
// See IDirect3DSwapChain9 (Present is the fourth function)
const unsigned int offsetPresent = 3;
hhSwapPresent.setupInterface(pSwap, offsetPresent, reinterpret_cast<voidFunc>(mySwapPresent));
pSwap->Release();
} else {
ods("D3D9: Failed to get swapchain for DevEx");
}
ds->createCleanState();
return hr;
}
示例8: myPresent
static HRESULT __stdcall myPresent(IDirect3DDevice9 * idd, CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) {
ods("D3D9: Device Present");
doPresent(idd);
//TODO: Move logic to HardHook.
// Call base without active hook in case of no trampoline.
PresentType oPresent = (PresentType) hhPresent.call;
hhPresent.restore();
HRESULT hr = oPresent(idd,pSourceRect,pDestRect,hDestWindowOverride,pDirtyRegion);
hhPresent.inject();
return hr;
}
示例9: myRelease
static ULONG __stdcall myRelease(IDirect3DDevice9 *idd) {
Mutex m;
ods("D3D9: Chaining Release");
DevState *ds = devMap[idd];
if (ds) {
if (ds->dwMyThread == GetCurrentThreadId()) {
ds->myRefCount--;
return ds->refCount + ds->initRefCount;
} else {
ds->refCount--;
}
if (ds->refCount <= 1)
ds->disconnect();
if (ds->refCount >= 0)
return ds->refCount + ds->initRefCount;
ods("D3D9: Final release is following. MyRefs = %d, Tot = %d", ds->myRefCount, ds->refCount);
DWORD dwOldThread = ds->dwMyThread;
if (dwOldThread)
ods("D3D9: finalRelease from other thread");
ds->dwMyThread = GetCurrentThreadId();
ds->releaseAll();
ds->dwMyThread = dwOldThread;
ods("D3D9: Final release. MyRefs = %d Tot = %d", ds->myRefCount, ds->refCount);
devMap.erase(idd);
delete ds;
}
//TODO: Move logic to HardHook.
// Call base without active hook in case of no trampoline.
ReleaseType oRelease = (ReleaseType) hhRelease.call;
hhRelease.restore();
ULONG res = oRelease(idd);
hhRelease.inject();
ods("D3D9: Chained Release with result %d", res);
return res;
}
示例10: myAddRef
static ULONG __stdcall myAddRef(ID3D10Device *pDevice) {
//TODO: Move logic to HardHook.
// Call base without active hook in case of no trampoline.
AddRefType oAddRef = (AddRefType) hhAddRef.call;
hhAddRef.restore();
ULONG res = oAddRef(pDevice);
hhAddRef.inject();
Mutex m;
DeviceMap::iterator it = devices.find(pDevice);
if (it != devices.end()) {
it->second->lHighMark = res;
}
return res;
}
示例11: myResize
static HRESULT __stdcall myResize(IDXGISwapChain *pSwapChain, UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags) {
#ifdef EXTENDED_OVERLAY_DEBUGOUTPUT
ods("DXGI: Call to Resize. Forwarding to D3D10 and D3D11 custom implementations before calling original logic ...");
#endif
resizeD3D10(pSwapChain);
resizeD3D11(pSwapChain);
//TODO: Move logic to HardHook.
// Call base without active hook in case of no trampoline.
ResizeBuffersType oResize = (ResizeBuffersType) hhResize.call;
hhResize.restore();
HRESULT hr = oResize(pSwapChain, BufferCount, Width, Height, NewFormat, SwapChainFlags);
hhResize.inject();
return hr;
}
示例12: MyLoadLibrary
static HMODULE WINAPI MyLoadLibrary(const char *lpFileName) {
//TODO: Move logic to HardHook.
// Call base without active hook in case of no trampoline.
LoadLibraryAType oLoadLibrary = (LoadLibraryAType) hhLoad.call;
hhLoad.restore();
HMODULE h = oLoadLibrary(lpFileName);
hhLoad.inject();
ods("Lib: Library %s loaded to %p", lpFileName, h);
if (! bBlackListed) {
checkHooks();
}
return h;
}
示例13: myPresent
static HRESULT __stdcall myPresent(IDirect3DDevice9 *idd, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride,CONST RGNDATA *pDirtyRegion) {
// Present is called for each frame. Thus, we do not want to always log here.
#ifdef EXTENDED_OVERLAY_DEBUGOUTPUT
ods("D3D9: Device Present");
#endif
doPresent(idd);
//TODO: Move logic to HardHook.
// Call base without active hook in case of no trampoline.
PresentType oPresent = (PresentType) hhPresent.call;
hhPresent.restore();
HRESULT hr = oPresent(idd, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
hhPresent.inject();
return hr;
}
示例14: myReset
static HRESULT __stdcall myReset(IDirect3DDevice9 * idd, D3DPRESENT_PARAMETERS *param) {
ods("D3D9: Chaining Reset");
DevState *ds = devMap[idd];
if (ds) {
DWORD dwOldThread = ds->dwMyThread;
if (dwOldThread)
ods("myReset from other thread");
ds->dwMyThread = GetCurrentThreadId();
ds->releaseAll();
ds->dwMyThread = dwOldThread;
resetAdditions();
}
ResetType oReset = (ResetType) hhReset.call;
hhReset.restore();
HRESULT hr=oReset(idd, param);
hhReset.inject();
if (ds)
ds->createCleanState();
return hr;
}
示例15: myPresent
static HRESULT __stdcall myPresent(IDirect3DDevice9 * idd, CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) {
ods("D3D9: Device Present");
myAdditions(idd);
doPresent(idd);
PresentType oPresent = (PresentType) hhPresent.call;
hhPresent.restore();
HRESULT hr = oPresent(idd,pSourceRect,pDestRect,hDestWindowOverride,pDirtyRegion);
hhPresent.inject();
return hr;
}