Snorflake

d3d9 steam hook

Jun 17th, 2016
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include "scan.hpp"
  3. #include <Windows.h>
  4. #include <future>
  5. #include <iostream>
  6. #include <d3d9.h>
  7.  
  8.  
  9. using present_t = HRESULT(__stdcall*)(IDirect3DDevice9Ex* pDevice, RECT* pSourceRect, RECT* pDestRect, HWND hDestWindowOverride, RGNDATA* pDirtyRegion);
  10. present_t oPresent = nullptr;
  11. HRESULT __stdcall hkPresent(IDirect3DDevice9Ex* pDevice, RECT* pSourceRect, RECT* pDestRect, HWND hDestWindowOverride, RGNDATA* pDirtyRegion)
  12. {
  13.     D3DRECT rec{ 10, 10, 55, 100 };
  14.  
  15.     pDevice->Clear(1, &rec, D3DCLEAR_TARGET, D3DCOLOR_XRGB(255, 255, 255), 0, 0);
  16.  
  17.  
  18.     return oPresent(pDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
  19. }
  20.  
  21. void init()
  22. {
  23.  
  24.     Sigscan scan("gameoverlayrenderer.dll");
  25.     uintptr_t* present_V = *(uintptr_t**)scan.scan("FF 15 ? ? ? ? 8B F8 85 DB", 2);
  26.     oPresent = (present_t)*present_V;
  27.     *present_V = (uintptr_t)(&hkPresent);
  28. }
  29.  
  30.  
  31. BOOL WINAPI DllMain(void* inst, unsigned long reason, void* reserved)
  32. {
  33.     if (reason == 1) {
  34.         DisableThreadLibraryCalls((HMODULE)inst);
  35.         std::async(std::launch::async, init);
  36.     }
  37.     return 1;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment