- 168
- 107
Сталкнулся с вопросом. Я смог хукнуть функцию DrawIndexedPrimitive, однако все отрисовки видны в OBS. Возможно ли как-то обойти это?
Просто например Функция present спокойно отрисовывает и не виден в OBS
C++:
HRESULT __stdcall CD3DHook::hkDrawIndexedPrimitive(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimitiveType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount) {
if (pD3DHook->bInit) {
if (pWallhack->ChamsStatus) {
LPDIRECT3DVERTEXBUFFER9 Stream_Data;
UINT offset = 0;
UINT stride = 0;
D3DMATRIX matTrans;
if (pD3DHook->pD3DDevice->GetStreamSource(0, &Stream_Data, &offset, &stride) == S_OK)
Stream_Data->Release();
if (stride == 40 || stride == 44 || stride == 36) {
pD3DHook->pD3DDevice->SetRenderState(D3DRS_ZENABLE, false);
pD3DHook->pD3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
pD3DHook->pD3DDevice->SetTexture(0, pTextures->Red);
pD3DHook->oDrawIndexedPrimitive(pDevice, PrimitiveType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
pD3DHook->pD3DDevice->SetRenderState(D3DRS_ZENABLE, true);
pD3DHook->pD3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
pD3DHook->pD3DDevice->SetTexture(0, pTextures->Green);
pD3DHook->pD3DDevice->GetTransform(D3DTRANSFORMSTATETYPE::D3DTS_VIEW, &matTrans);
printf_s("%d %d %d %d %d %d\n", PrimitiveType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
}
}
}
return pD3DHook->oDrawIndexedPrimitive(pDevice, PrimitiveType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
}
C++:
class CD3DHook
{
public:
CD3DHook()
{
bInit = false;
oPresent = (tPresent)GetDeviceAddress(17);
oReset = (tReset)GetDeviceAddress(16);
oDrawIndexedPrimitive = (tDrawIndexedPrimitive)GetDeviceAddress(82);
DetourRestoreAfterWith();
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
pSecure->SDetourAttach(&(PVOID&)oPresent, hkPresent);
pSecure->SDetourAttach(&(PVOID&)oReset, hkReset);
pSecure->SDetourAttach(&(PVOID&)oDrawIndexedPrimitive, hkDrawIndexedPrimitive);
DetourTransactionCommit();
};
~CD3DHook()
{
DetourRestoreAfterWith();
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourDetach(&(PVOID&)oPresent, hkPresent);
DetourDetach(&(PVOID&)oReset, hkReset);
DetourDetach(&(PVOID&)oDrawIndexedPrimitive, hkDrawIndexedPrimitive);
DetourTransactionCommit();
};
bool bInit;
IDirect3DDevice9* pD3DDevice;
private:
DWORD FindDevice(DWORD dwLen)
{
DWORD dwObjBase = 0;
char infoBuf[MAX_PATH];
GetSystemDirectoryA(infoBuf, MAX_PATH);
strcat_s(infoBuf, MAX_PATH, "\\d3d9.dll");
dwObjBase = (DWORD)LoadLibraryA(infoBuf);
while (dwObjBase++ < dwObjBase + dwLen)
{
if ((*(WORD*)(dwObjBase + 0x00)) == 0x06C7 &&
(*(WORD*)(dwObjBase + 0x06)) == 0x8689 &&
(*(WORD*)(dwObjBase + 0x0C)) == 0x8689)
{
dwObjBase += 2;
break;
}
}
return(dwObjBase);
};
DWORD GetDeviceAddress(int VTableIndex)
{
PDWORD VTable;
*(DWORD*)&VTable = *(DWORD*)FindDevice(0x128000);
return VTable[VTableIndex];
};
typedef HRESULT(__stdcall* tPresent)(IDirect3DDevice9*, CONST RECT*, CONST RECT*, HWND, CONST RGNDATA*);
typedef HRESULT(__stdcall* tReset)(IDirect3DDevice9*, D3DPRESENT_PARAMETERS*);
typedef HRESULT(__stdcall* tDrawIndexedPrimitive)(LPDIRECT3DDEVICE9, D3DPRIMITIVETYPE, INT, UINT, UINT, UINT, UINT);
static HRESULT __stdcall hkPresent(IDirect3DDevice9* pDevice, CONST RECT* pSrcRect, CONST RECT* pDestRect, HWND hDestWindow, CONST RGNDATA* pDirtyRegion);
static HRESULT __stdcall hkReset(IDirect3DDevice9* pDevice, D3DPRESENT_PARAMETERS* pPresentParams);
static HRESULT __stdcall hkDrawIndexedPrimitive(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimitiveType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount);
tPresent oPresent;
tReset oReset;
tDrawIndexedPrimitive oDrawIndexedPrimitive;
};