dllmain.cpp 944 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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]; if (GetModuleFileName(NULL, Buffer, MAX_PATH))
  15. {
  16. TCHAR* a = Buffer;
  17. }
  18. else
  19. {
  20. // You better call GetLastError() here
  21. }
  22. Hook();
  23. }
  24. else if (ul_reason_for_call == DLL_THREAD_ATTACH)
  25. {
  26. }
  27. else if (ul_reason_for_call == DLL_THREAD_DETACH)
  28. {
  29. }
  30. else if (ul_reason_for_call == DLL_PROCESS_DETACH)
  31. {
  32. TCHAR Buffer[MAX_PATH]; if (GetModuleFileName(NULL, Buffer, MAX_PATH))
  33. {
  34. TCHAR* a = Buffer;
  35. }
  36. else
  37. {
  38. // You better call GetLastError() here
  39. }
  40. UnHook();
  41. }
  42. return TRUE;
  43. }