dllmain.cpp 948 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // dllmain.cpp : 定义 DLL 应用程序的入口点。
  2. #include "stdafx.h"
  3. #include "Hook.h"
  4. #include <windows.h>
  5. HINSTANCE g_Inst = NULL; //DLL模块句柄
  6. BOOL APIENTRY DllMain(HMODULE hModule,
  7. DWORD ul_reason_for_call,
  8. LPVOID lpReserved
  9. )
  10. {
  11. g_Inst = (HINSTANCE)hModule;
  12. if (ul_reason_for_call == DLL_PROCESS_ATTACH)
  13. {
  14. TCHAR Buffer[MAX_PATH];
  15. if (GetModuleFileName(NULL, Buffer, MAX_PATH))
  16. {
  17. TCHAR* a = Buffer;
  18. }
  19. else
  20. {
  21. // You better call GetLastError() here
  22. }
  23. Hook();
  24. }
  25. else if (ul_reason_for_call == DLL_THREAD_ATTACH)
  26. {
  27. }
  28. else if (ul_reason_for_call == DLL_THREAD_DETACH)
  29. {
  30. }
  31. else if (ul_reason_for_call == DLL_PROCESS_DETACH)
  32. {
  33. TCHAR Buffer[MAX_PATH];
  34. if (GetModuleFileName(NULL, Buffer, MAX_PATH))
  35. {
  36. TCHAR* a = Buffer;
  37. }
  38. else
  39. {
  40. // You better call GetLastError() here
  41. }
  42. UnHook();
  43. }
  44. return TRUE;
  45. }