Advertisement
Guest User

Untitled

a guest
May 25th, 2011
507
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. #pragma comment (lib,"detours.lib")
  2. #include <windows.h>
  3. #include "detours.h"
  4.  
  5. #include "ddraw.h"
  6. #pragma comment(lib,"ddraw.lib")
  7.  
  8. DETOUR_TRAMPOLINE(HRESULT __stdcall Real_DirectDrawCreate(GUID *lpGUID,LPDIRECTDRAW *lplpDD,IUnknown *pUnkOuter), DirectDrawCreate);
  9. DETOUR_TRAMPOLINE(HRESULT __stdcall Real_DirectDrawCreateEx(GUID *lpGUID,LPVOID *lplpDD,REFIID iid,IUnknown *pUnkOuter), DirectDrawCreateEx);
  10.  
  11. HRESULT __stdcall Mine_DirectDrawCreate(GUID *lpGUID,LPDIRECTDRAW *lplpDD,IUnknown *pUnkOuter)
  12. {
  13. HRESULT hr = Real_DirectDrawCreate((GUID *)DDCREATE_EMULATIONONLY,lplpDD,pUnkOuter);
  14. return hr;
  15. }
  16.  
  17. HRESULT __stdcall Mine_DirectDrawCreateEx(GUID *lpGUID,LPVOID *lplpDD,REFIID iid,IUnknown *pUnkOuter)
  18. {
  19. HRESULT hr = Real_DirectDrawCreateEx((GUID *)DDCREATE_EMULATIONONLY,lplpDD,iid,pUnkOuter);
  20. return hr;
  21. }
  22.  
  23. void hook()
  24. {
  25. DetourFunctionWithTrampoline((PBYTE) Real_DirectDrawCreate,(PBYTE) Mine_DirectDrawCreate);
  26. DetourFunctionWithTrampoline((PBYTE) Real_DirectDrawCreateEx,(PBYTE) Mine_DirectDrawCreateEx);
  27. }
  28.  
  29. BOOL APIENTRY DllMain(HINSTANCE hModule, DWORD dwReason, PVOID lpReserved)
  30. {
  31. if(dwReason == DLL_PROCESS_ATTACH)
  32. {
  33. void hook();
  34. }
  35. return TRUE;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement