Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
5.3 KiB

  1. // DelayLoad.h: interface for the CDelayLoad class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_DELAYLOAD_H__7DFF0A14_DD50_4E3A_AC8D_5B89BD2D5A3B__INCLUDED_)
  5. #define AFX_DELAYLOAD_H__7DFF0A14_DD50_4E3A_AC8D_5B89BD2D5A3B__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #ifndef NO_STRICT
  10. #ifndef STRICT
  11. #define STRICT 1
  12. #endif
  13. #endif /* NO_STRICT */
  14. #include <WINDOWS.H>
  15. #include <TCHAR.H>
  16. #include <TLHELP32.H>
  17. class CDelayLoad
  18. {
  19. public:
  20. CDelayLoad();
  21. virtual ~CDelayLoad();
  22. // DBGHELP Functions (Publicly accessible for ease of use)
  23. bool Initialize_DBGHELP();
  24. BOOL MakeSureDirectoryPathExists(LPTSTR DirPath);
  25. // PSAPI Functions (Publicly accessible for ease of use)
  26. bool Initialize_PSAPI();
  27. BOOL WINAPI EnumProcesses(DWORD * lpidProcess, DWORD cb, DWORD * cbNeeded);
  28. BOOL WINAPI EnumProcessModules(HANDLE hProcess, HMODULE * lphModule, DWORD cb, LPDWORD lpcbNeeded);
  29. DWORD WINAPI GetModuleFileNameEx(HANDLE hHandle, HMODULE hModule, LPTSTR lpFilename, DWORD nSize);
  30. BOOL WINAPI EnumDeviceDrivers(LPVOID *lpImageBase, DWORD cb, LPDWORD lpcbNeeded);
  31. DWORD WINAPI GetDeviceDriverFileName(LPVOID ImageBase, LPTSTR lpFilename, DWORD nSize);
  32. // TOOLHELP32 Functions (Publicly accessible for ease of use)
  33. bool Initialize_TOOLHELP32();
  34. HANDLE WINAPI CreateToolhelp32Snapshot(DWORD dwFlags, DWORD th32ProcessID);
  35. BOOL WINAPI Process32First(HANDLE hSnapshot, LPPROCESSENTRY32 lppe);
  36. BOOL WINAPI Process32Next(HANDLE hSnapshot, LPPROCESSENTRY32 lppe);
  37. BOOL WINAPI Module32First(HANDLE hSnapshot, LPMODULEENTRY32 lpme);
  38. BOOL WINAPI Module32Next(HANDLE hSnapshot, LPMODULEENTRY32 lpme);
  39. // SYMSRV Functions (Publicly accessible for each of use)
  40. bool Initialize_SYMSRV(LPCTSTR tszSymSrvDLL);
  41. LPTSTR inline GetCurrentSymSrvDLL() { return m_tszSymSrvDLL; };
  42. BOOL WINAPI SymbolServer(LPCSTR params, LPCSTR filename, DWORD num1, DWORD num2, DWORD num3, LPSTR path);
  43. BOOL WINAPI SymbolServerClose(VOID);
  44. private:
  45. // DBGHELP functions
  46. HINSTANCE m_hDBGHELP;
  47. bool m_fDBGHELPInitialized;
  48. bool m_fDBGHELPInitializedAttempted;
  49. // DBGHELP functions TypeDef'ed for simplicity
  50. typedef BOOL (WINAPI *PfnMakeSureDirectoryPathExists)(PCSTR DirPath);
  51. // DBGHELP Function Pointers
  52. BOOL (WINAPI *m_lpfMakeSureDirectoryPathExists)(PCSTR DirPath);
  53. // Windows NT 4.0/2000 Support for Querying Processes and Modules
  54. // PSAPI functions
  55. HINSTANCE m_hPSAPI;
  56. bool m_fPSAPIInitialized;
  57. bool m_fPSAPIInitializedAttempted;
  58. // PSAPI functions TypeDef'ed for simplicity
  59. typedef BOOL (WINAPI *PfnEnumProcesses)(DWORD * lpidProcess, DWORD cb, DWORD * cbNeeded);
  60. typedef BOOL (WINAPI *PfnEnumProcessModules)(HANDLE hProcess, HMODULE * lphModule, DWORD cb, LPDWORD lpcbNeeded);
  61. typedef DWORD (WINAPI *PfnGetModuleFileNameEx)(HANDLE hHandle, HMODULE hModule, LPTSTR lpFilename, DWORD nSize);
  62. typedef BOOL (WINAPI *PfnEnumDeviceDrivers)(LPVOID *lpImageBase, DWORD cb, LPDWORD lpcbNeeded);
  63. typedef DWORD (WINAPI *PfnGetDeviceDriverFileName)(LPVOID ImageBase, LPTSTR lpFilename, DWORD nSize);
  64. // PSAPI Function Pointers
  65. BOOL (WINAPI *m_lpfEnumProcesses)(DWORD * lpidProcess, DWORD cb, DWORD * cbNeeded);
  66. BOOL (WINAPI *m_lpfEnumProcessModules)(HANDLE hProcess, HMODULE * lphModule, DWORD cb, LPDWORD lpcbNeeded);
  67. DWORD (WINAPI *m_lpfGetModuleFileNameEx)(HANDLE hHandle, HMODULE hModule, LPTSTR lpFilename, DWORD nSize);
  68. BOOL (WINAPI *m_lpfEnumDeviceDrivers)(LPVOID *lpImageBase, DWORD cb, LPDWORD lpcbNeeded);
  69. DWORD (WINAPI *m_lpfGetDeviceDriverFileName)(LPVOID ImageBase, LPTSTR lpFilename, DWORD nSize);
  70. // Windows 95 / Windows 2000 Support for Querying Processes and Modules
  71. // TOOLHELP32 functions
  72. HINSTANCE m_hTOOLHELP32;
  73. bool m_fTOOLHELP32Initialized;
  74. bool m_fTOOLHELP32InitializedAttempted;
  75. // TOOLHELP32 functions TypeDef'ed for simplicity
  76. typedef HANDLE (WINAPI *PfnCreateToolhelp32Snapshot)(DWORD dwFlags, DWORD th32ProcessID);
  77. typedef BOOL (WINAPI *PfnProcess32First)(HANDLE hSnapshot, LPPROCESSENTRY32 lppe);
  78. typedef BOOL (WINAPI *PfnProcess32Next)(HANDLE hSnapshot, LPPROCESSENTRY32 lppe);
  79. typedef BOOL (WINAPI *PfnModule32First)(HANDLE hSnapshot, LPMODULEENTRY32 lpme);
  80. typedef BOOL (WINAPI *PfnModule32Next)(HANDLE hSnapshot, LPMODULEENTRY32 lpme);
  81. // TOOLHELP32 Function Pointers
  82. HANDLE (WINAPI *m_lpfCreateToolhelp32Snapshot)(DWORD dwFlags, DWORD th32ProcessID);
  83. BOOL (WINAPI *m_lpfProcess32First)(HANDLE hSnapshot, LPPROCESSENTRY32 lppe);
  84. BOOL (WINAPI *m_lpfProcess32Next)(HANDLE hSnapshot, LPPROCESSENTRY32 lppe);
  85. BOOL (WINAPI *m_lpfModule32First)(HANDLE hSnapshot, LPMODULEENTRY32 lpme);
  86. BOOL (WINAPI *m_lpfModule32Next)(HANDLE hSnapshot, LPMODULEENTRY32 lpme);
  87. // SYMSRV functions
  88. HINSTANCE m_hSYMSRV;
  89. bool m_fSYMSRVInitialized;
  90. bool m_fSYMSRVInitializedAttempted;
  91. LPTSTR m_tszSymSrvDLL;
  92. // SYMSRV functions TypeDef'ed for simplicity
  93. typedef BOOL (WINAPI *PfnSymbolServer)(LPCSTR params, LPCSTR filename, DWORD num1, DWORD num2, DWORD num3, LPSTR path);
  94. // typedef BOOL (WINAPI *PfnSymbolServerOpen)(VOID);
  95. typedef BOOL (WINAPI *PfnSymbolServerClose)(VOID);
  96. // SYMSRV Function Pointers
  97. BOOL (WINAPI *m_lpfSymbolServer)(LPCSTR params, LPCSTR filename, DWORD num1, DWORD num2, DWORD num3, LPSTR path);
  98. // BOOL (WINAPI *m_lpfSymbolServerOpen)(VOID);
  99. BOOL (WINAPI *m_lpfSymbolServerClose)(VOID);
  100. };
  101. #endif // !defined(AFX_DELAYLOAD_H__7DFF0A14_DD50_4E3A_AC8D_5B89BD2D5A3B__INCLUDED_)