Hey guys, umm i was trying to hook endscene using detours and i used a method that i hooked many other functions with before but it just doesnt seem to work.
Here is what i have:

Code:
DWORD ThreadID;
LPDIRECT3DDEVICE9 pDEVICE;
D3DCOLOR fontRed = D3DCOLOR_ARGB(, , , );
Hacks hack; HRESULT (APIENTRY *oEndScene)(LPDIRECT3DDEVICE9 pDevice); HRESULT APIENTRY dEndScene(LPDIRECT3DDEVICE9 pDevice)
{
DrawBorderBox(, , , , , fontRed, pDevice); return oEndScene(pDevice);
} void APIENTRY HookAPI(LPVOID param)
{
HANDLE Endsceneaddy = GetProcAddress(GetModuleHandleA("d3d9.dll"),"EndScene"); if (Endsceneaddy)
{
oEndScene = (HRESULT (WINAPI *)(LPDIRECT3DDEVICE9 pDevice))(DetourFunction((PBYTE)Endsceneaddy,(PBYTE)dEndScene));
}
}; bool __stdcall DllMain(HINSTANCE hinst, DWORD _Reason, _In_opt_ LPVOID _Reserved)
{
DisableThreadLibraryCalls(hinst); CreateThread(,,(LPTHREAD_START_ROUTINE)HookAPI,,,&ThreadID); return true;
} void Hacks::DrawBorderBox( int x, int y, int w, int h, int thickness, D3DCOLOR Colour, IDirect3DDevice9 *pDevice)
{
//Top horiz line
DrawFilledRect( x, y, w, thickness, Colour, pDevice );
//Left vertical line
DrawFilledRect( x, y, thickness, h, Colour, pDevice );
//right vertical line
DrawFilledRect( (x + w), y, thickness, h, Colour, pDevice );
//bottom horiz line
DrawFilledRect( x, y + h, w+thickness, thickness, Colour, pDevice );
} //We receive the 2-D Coordinates the colour and the device we want to use to draw those colours with
void Hacks::DrawFilledRect(int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* dev)
{
//We create our rectangle to draw on screen
D3DRECT BarRect = { x, y, x + w, y + h };
//We clear that portion of the screen and display our rectangle
dev->Clear(, &BarRect, D3DCLEAR_TARGET | D3DCLEAR_TARGET, color, , );
}

I have no idea y this code does not seem to work
Please help me 
Thanks,
Konsowa.

Answer:

What learn_more said..

You would have to do something on the lines of Create a Device and get the EndScene address or you could retrieve it with a Byte Pattern such as

Code C++
Patterns.AddPattern( "DirectX9 VirtualTable",      (PBYTE)"\xC7\x06\x00\x00\x00\x00\x89\x86\x00\x00\x00\x00\x89\x86", "xx????xx????xx", NULL, "d3d9.dll" );

Functions.MemoryCopy( &Renderer_DX9.m_VTable, (void*)( Patterns.FindPatternByName( "DirectX9 VirtualTable" ).m_Address +  ),  );
void APIENTRY HookAPI(LPVOID param)
{
HANDLE Endsceneaddy = GetProcAddress(GetModuleHandleA("d3d9.dll"),"EndScene"); if (Endsceneaddy)
{
oEndScene = (HRESULT (WINAPI *)(LPDIRECT3DDEVICE9 pDevice))(DetourFunction((PBYTE)Endsceneaddy,(PBYTE)dEndScene));
}
};

that code not retrieve correct EndScene address because EndScene not exported in d3d9.dll

try this:

Code:
bool bCompare(const BYTE* pData, const BYTE* bMask, const char* szMask)
{
for(;*szMask;++szMask,++pData,++bMask)
if(*szMask=='x' && *pData!=*bMask )
return false; return (*szMask) == NULL;
}
DWORD FindPattern(DWORD dwAddress,DWORD dwLen,BYTE *bMask,char * szMask)
{
for(DWORD i=; i < dwLen; i++)
if( bCompare( (BYTE*)( dwAddress+i ),bMask,szMask) )
return (DWORD)(dwAddress+i); return ;
} DWORD EndSceneaddy;
void APIENTRY HookAPI(LPVOID param)
{
DWORD* vtbl = ;
DWORD table = FindPattern((DWORD)GetModuleHandle("d3d9.dll"), 0x128000, (PBYTE)"\xC7\x06\x00\x00\x00\x00\x89\x86\x00\x00\x00\x00\x89\x86", "xx????xx????xx");
memcpy(&vtbl, (void*)(table+), );
EndSceneaddy = vtbl[];
if (Endsceneaddy)
{
oEndScene = (HRESULT (WINAPI *)(LPDIRECT3DDEVICE9 pDevice))(DetourFunction((PBYTE)Endsceneaddy,(PBYTE)dEndScene));
} }

it's a different way of doing the same,
but that is not going to work with GetProcAddress either,
if you want the addresses of these functions you will have to create a dummy dx device, and get them from the vtable (more than enough examples around for that)

They are virtual functions which is why they aren't exported.
You can also do a simple vtable hook on them depending on A/C.

I love that question 

Seems you can't do a straight up VMT hook so explore other hook methods of functions to hook. If we all said here is our undetected hook for a game it would then become detected. It all depends on game and A/C used so you need to get creative and come up with your own.

最新文章

  1. 源码编译安装mysql
  2. ReadMe.md MarkDown file
  3. Delphi的文件操作
  4. 全排列(java版)
  5. OpenJudge计算概论-点和正方形的关系【判断点是否在正方形内部】
  6. OC基础(10)
  7. WebSocket API简介
  8. 剑指 offer set 2 从头到尾打印链表
  9. webkit,HTML5头部标签
  10. 使用jenkins + python + selenium一步步搭建web自动化测试“框架”(1) - 各部件简介
  11. Scut DirCenter 网站编辑、搭建与调试
  12. GCD 续集
  13. Objective-C基础教程读书笔记(7)
  14. Vertica对于所计算的时间SQL声明大全
  15. LR11关联问题
  16. 自己使用Vue全家桶问题合集(很多eslint规范问题)
  17. IntelliJ IDEA中项目报错org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 8 或maven操作compile报resource使用utf8这样的编码错
  18. Java开发笔记(三十七)利用正则串分割字符串
  19. web服务-3、epoll高效率实现并发服务器
  20. js--深拷贝与浅拷贝

热门文章

  1. 在Linux上安装MySQL
  2. Web Service-第一篇什么是Web Service
  3. Excelvba从另一个工作簿取值
  4. 用vuex写了一个购物车H5页面的示例代码
  5. mybatis动态注解sql编写注意事项
  6. POJ 3764 The xor-longest Path (01字典树)
  7. Springboot-技术专区-war包部署在Tomcat上并修改默认端口
  8. style中各种选择器
  9. Sass函数-comparable 判断两个数是否可进行加减、合并
  10. 百度MIP技术快速入门(上)