本文整理汇总了C++中HardHook::setupInterface方法的典型用法代码示例。如果您正苦于以下问题:C++ HardHook::setupInterface方法的具体用法?C++ HardHook::setupInterface怎么用?C++ HardHook::setupInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HardHook
的用法示例。
在下文中一共展示了HardHook::setupInterface方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
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;
if (bIsWin8) {
hhAddRef.setupInterface(idd, 1, reinterpret_cast<voidFunc>(myWin8AddRef));
hhRelease.setupInterface(idd, 2, reinterpret_cast<voidFunc>(myWin8Release));
} else {
hhAddRef.setupInterface(idd, 1, reinterpret_cast<voidFunc>(myAddRef));
hhRelease.setupInterface(idd, 2, reinterpret_cast<voidFunc>(myRelease));
}
hhReset.setupInterface(idd, 16, reinterpret_cast<voidFunc>(myReset));
hhPresent.setupInterface(idd, 17, reinterpret_cast<voidFunc>(myPresent));
IDirect3DSwapChain9 *pSwap = NULL;
idd->GetSwapChain(0, &pSwap);
if (pSwap) {
hhSwapPresent.setupInterface(pSwap, 3, reinterpret_cast<voidFunc>(mySwapPresent));
pSwap->Release();
} else {
ods("D3D9: Failed to get swapchain for DevEx");
}
ds->createCleanState();
return hr;
}
示例2: HookCreate
static void HookCreate(IDirect3D9 *pD3D) {
ods("D3D9: Injecting CreateDevice");
hhCreateDevice.setupInterface(pD3D, VTABLE_OFFSET_ID3D_CREATEDEVICE, reinterpret_cast<voidFunc>(myCreateDevice));
}
示例3: 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();
DevMapType::iterator it = devMap.find(idd);
if (it != devMap.end()) {
ods("Device exists in devMap already - canceling injection into device. Thread prev: %d ; new: %d", it->second->dwMyThread, GetCurrentThreadId());
delete ds;
return hr;
}
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;
// On IDirect3DDevice9Ex
const unsigned int offsetPresentEx = 121;
const unsigned int offsetResetEx = 132;
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));
hhResetEx.setupInterface(idd, offsetResetEx, reinterpret_cast<voidFunc>(myResetEx));
hhPresent.setupInterface(idd, offsetPresent, reinterpret_cast<voidFunc>(myPresent));
hhPresentEx.setupInterface(idd, offsetPresentEx, reinterpret_cast<voidFunc>(myPresentEx));
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;
}
示例4: HookCreateEx
static void HookCreateEx(IDirect3D9Ex *pD3D) {
ods("D3D9Ex: Injecting CreateDevice / CreateDeviceEx");
hhCreateDevice.setupInterface(pD3D, 16, reinterpret_cast<voidFunc>(myCreateDevice));
hhCreateDeviceEx.setupInterface(pD3D, 20, reinterpret_cast<voidFunc>(myCreateDeviceEx));
}
示例5: HookCreate
static void HookCreate(IDirect3D9 *pD3D) {
ods("D3D9: Injecting CreateDevice");
hhCreateDevice.setupInterface(pD3D, 16, reinterpret_cast<voidFunc>(myCreateDevice));
}
示例6: myCreateDevice
static HRESULT __stdcall myCreateDevice(IDirect3D9 * id3d, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, IDirect3DDevice9 **ppReturnedDeviceInterface) {
ods("D3D9: Chaining CreateDevice");
Mutex m;
// BehaviorFlags &= ~D3DCREATE_PUREDEVICE;
CreateDeviceType oCreateDevice = (CreateDeviceType) hhCreateDevice.call;
hhCreateDevice.restore();
HRESULT hr=oCreateDevice(id3d, Adapter,DeviceType,hFocusWindow,BehaviorFlags,pPresentationParameters,ppReturnedDeviceInterface);
hhCreateDevice.inject();
if (FAILED(hr))
return hr;
IDirect3DDevice9 *idd = *ppReturnedDeviceInterface;
IDirect3DSwapChain9 *pSwap = NULL;
// Get real interface, please.
bool bfound;
do {
bfound = false;
idd->GetSwapChain(0, &pSwap);
if (pSwap) {
IDirect3DDevice9 *idorig = NULL;
if (SUCCEEDED(pSwap->GetDevice(&idorig))) {
if (idorig != idd) {
ods("Prepatched device, using original. %p => %p", idorig, idd);
if (idd != *ppReturnedDeviceInterface)
idd->Release();
idd = idorig;
bfound = true;
} else {
idorig->Release();
}
}
pSwap->Release();
}
} while (bfound);
DevState *ds = new DevState;
ds->dev = idd;
idd->AddRef();
ds->initRefCount = idd->Release();
devMap[idd] = ds;
if (bIsWin8) {
hhAddRef.setupInterface(idd, 1, reinterpret_cast<voidFunc>(myWin8AddRef));
hhRelease.setupInterface(idd, 2, reinterpret_cast<voidFunc>(myWin8Release));
} else {
hhAddRef.setupInterface(idd, 1, reinterpret_cast<voidFunc>(myAddRef));
hhRelease.setupInterface(idd, 2, reinterpret_cast<voidFunc>(myRelease));
}
hhReset.setupInterface(idd, 16, reinterpret_cast<voidFunc>(myReset));
hhPresent.setupInterface(idd, 17, reinterpret_cast<voidFunc>(myPresent));
pSwap = NULL;
idd->GetSwapChain(0, &pSwap);
if (pSwap) {
hhSwapPresent.setupInterface(pSwap, 3, reinterpret_cast<voidFunc>(mySwapPresent));
pSwap->Release();
} else {
ods("D3D9: Failed to get swapchain");
}
ds->createCleanState();
return hr;
}
示例7: myCreateDevice
static HRESULT __stdcall myCreateDevice(IDirect3D9 * id3d, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, IDirect3DDevice9 **ppReturnedDeviceInterface) {
Mutex m;
ods("D3D9: Chaining CreateDevice");
// BehaviorFlags &= ~D3DCREATE_PUREDEVICE;
//TODO: Move logic to HardHook.
// Call base without active hook in case of no trampoline.
CreateDeviceType oCreateDevice = (CreateDeviceType) hhCreateDevice.call;
hhCreateDevice.restore();
HRESULT hr = oCreateDevice(id3d, Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface);
hhCreateDevice.inject();
if (FAILED(hr))
return hr;
IDirect3DDevice9 *idd = *ppReturnedDeviceInterface;
// Get real interface, please.
bool bfound = false;
do {
bfound = false;
IDirect3DSwapChain9 *pSwap = NULL;
idd->GetSwapChain(0, &pSwap);
if (pSwap) {
IDirect3DDevice9 *idorig = NULL;
if (SUCCEEDED(pSwap->GetDevice(&idorig))) {
if (idorig != idd) {
ods("D3D9: Prepatched device, using original. %p => %p", idorig, idd);
if (idd != *ppReturnedDeviceInterface)
idd->Release();
idd = idorig;
bfound = true;
} else {
idorig->Release();
}
}
pSwap->Release();
}
} while (bfound);
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");
}
ds->createCleanState();
return hr;
}