HookAPI.h
上传用户:nbcables
上传日期:2007-01-11
资源大小:1243k
文件大小:2k
源码类别:

钩子与API截获

开发平台:

Visual C++

  1. // ------------------------------------- //
  2. // 您如果要使用本文件,请不要删除本说明  //
  3. // ------------------------------------- //
  4. //             HOOKAPI v1.0              //
  5. //   Copyright 2002 编程沙龙 Paladin     //
  6. //       www.ProgramSalon.com            //
  7. // ------------------------------------- //
  8. #ifndef __HookAPI_H__
  9. #define __HookAPI_H__
  10. #include <windows.h>
  11. #include "mydll.h"
  12. #include "apiinfo.h"
  13. #define MsgBox(msg) MessageBox(NULL, msg, "http://www.programsalon.com - HookAPI", MB_OK)
  14. typedef MYAPIINFO *(*tagGetMyAPIInfo)();
  15. #ifdef WIN95
  16. #define HOOKAPI_DLL_NAME "HookAPI9x.dll"
  17. #define MY_DLL_NAME "mydll_9x.dll"
  18. #else
  19. #define HOOKAPI_DLL_NAME "HookAPINT.dll"
  20. #define MY_DLL_NAME "mydll.dll"
  21. #endif
  22. class CHookAPI  
  23. {
  24. public:
  25. CHookAPI();
  26. virtual ~CHookAPI();
  27. int m_hook_type; // 0 - hook all, 1 - hook one process
  28. HINSTANCE m_hMyDll;
  29. int Init();
  30. int InitPSAPI();
  31. int FreePSAPI();
  32. int LoadMyDll();
  33. void FreeMyDll();
  34. int HookOneAPI(APIINFO *api_info);
  35. int UnhookOneAPI(APIINFO *api_info);
  36. int UnhookOneProcess(DWORD process_id);
  37. int HookAllAPI();
  38. void UnhookAllAPI();
  39. static void ProcessCall();
  40. static int RestoreAPICodes(char *my_api_name);
  41. static int ChangeAPICodes(char *my_api_name);
  42. static int RemoveProtection(APIINFO *);
  43. #ifdef WINNT
  44. int InjectDll(char *dll_name);
  45. int UninjectDll(char *dll_name);
  46. static DWORD WINAPI myCreateProcessW2003(
  47. LPCWSTR lpApplicationName,
  48. LPWSTR lpCommandLine, 
  49. LPSECURITY_ATTRIBUTES lpProcessAttributes,
  50. LPSECURITY_ATTRIBUTES lpThreadAttributes,
  51. BOOL bInheritHandles,
  52. DWORD dwCreationFlags,
  53. LPVOID lpEnvironment,
  54. LPCWSTR lpCurrentDirectory,
  55. LPSTARTUPINFOW lpStartupInfo,
  56. LPPROCESS_INFORMATION lpProcessInformation);
  57. static DWORD WINAPI myCreateProcessA2003(
  58. LPCSTR lpApplicationName,
  59. LPSTR lpCommandLine, 
  60. LPSECURITY_ATTRIBUTES lpProcessAttributes,
  61. LPSECURITY_ATTRIBUTES lpThreadAttributes,
  62. BOOL bInheritHandles,
  63. DWORD dwCreationFlags,
  64. LPVOID lpEnvironment,
  65. LPCSTR lpCurrentDirectory,
  66. LPSTARTUPINFO lpStartupInfo,
  67. LPPROCESS_INFORMATION lpProcessInformation);
  68. #endif
  69. };
  70. #endif