Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include "dllmain.h"
  2.  
  3. typedef HMODULE(__stdcall* hLoadLibrary)(LPCTSTR lpFileName);
  4. hLoadLibrary oLoadLibrary;
  5.  
  6. HMODULE WINAPI mLoadLibrary(LPCTSTR lpFileName)
  7. {
  8. char buff[256];
  9. sprintf(buff, "lpFileName %s", lpFileName);
  10. OutputDebugString("mLoadLibrary()");
  11. OutputDebugString(buff);
  12. return GetModuleHandle(NULL);
  13. }
  14.  
  15. void WINAPI DllThread()
  16. {
  17. char buffer[MAX_PATH];
  18. GetModuleFileName(NULL, buffer, MAX_PATH);
  19. char buff[2048];
  20. sprintf(buff, "Hello from %s", buffer);
  21. OutputDebugString(buff);
  22.  
  23.  
  24. OutputDebugString("Installing LoadLibrary hook");
  25. oLoadLibrary = (hLoadLibrary)DetourFunction((PBYTE)LoadLibrary, (PBYTE)mLoadLibrary);
  26. }
  27.  
  28. BOOL WINAPI DllMain(
  29. __in HINSTANCE hInstance,
  30. __in DWORD Reason,
  31. __in LPVOID Reserved
  32. )
  33. {
  34. switch (Reason)
  35. {
  36. case DLL_PROCESS_ATTACH:
  37. CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)DllThread, NULL, NULL, NULL);
  38. break;
  39.  
  40. case DLL_PROCESS_DETACH:
  41. //Unhook wen
  42. break;
  43. }
  44.  
  45. return TRUE;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement