Leaked source code of windows server 2003
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.

227 lines
5.4 KiB

  1. //=================================================================
  2. //
  3. // Kernel32Api.h
  4. //
  5. // Copyright (c) 1999-2001 Microsoft Corporation, All Rights Reserved
  6. //
  7. //=================================================================
  8. #ifndef _KERNEL32API_H_
  9. #define _KERNEL32API_H_
  10. #include <tlhelp32.h>
  11. //#include <resource.h>
  12. /******************************************************************************
  13. * #includes to Register this class with the CResourceManager.
  14. *****************************************************************************/
  15. #include "DllWrapperBase.h"
  16. extern const GUID g_guidKernel32Api;
  17. extern const TCHAR g_tstrKernel32[];
  18. /******************************************************************************
  19. * Function pointer typedefs. Add new functions here as required.
  20. *****************************************************************************/
  21. typedef BOOL (WINAPI *PFN_KERNEL32_GET_DISK_FREE_SPACE_EX)
  22. (
  23. LPCTSTR lpDirectoryName,
  24. PULARGE_INTEGER lpFreeBytesAvailableToCaller,
  25. PULARGE_INTEGER lpTotalNumberOfBytes,
  26. PULARGE_INTEGER lpTotalNumberOfFreeBytes
  27. );
  28. typedef HANDLE (WINAPI *PFN_KERNEL32_CREATE_TOOLHELP32_SNAPSHOT)
  29. (
  30. DWORD,
  31. DWORD
  32. );
  33. typedef BOOL (WINAPI *PFN_KERNEL32_THREAD32_FIRST)
  34. (
  35. HANDLE,
  36. LPTHREADENTRY32
  37. );
  38. typedef BOOL (WINAPI *PFN_KERNEL32_THREAD32_NEXT)
  39. (
  40. HANDLE,
  41. LPTHREADENTRY32
  42. );
  43. typedef BOOL (WINAPI *PFN_KERNEL32_PROCESS32_FIRST)
  44. (
  45. HANDLE,
  46. LPPROCESSENTRY32
  47. );
  48. typedef BOOL (WINAPI *PFN_KERNEL32_PROCESS32_NEXT)
  49. (
  50. HANDLE,
  51. LPPROCESSENTRY32
  52. );
  53. typedef BOOL (WINAPI *PFN_KERNEL32_MODULE32_FIRST)
  54. (
  55. HANDLE,
  56. LPMODULEENTRY32
  57. );
  58. typedef BOOL (WINAPI *PFN_KERNEL32_MODULE32_NEXT)
  59. (
  60. HANDLE,
  61. LPMODULEENTRY32
  62. );
  63. typedef BOOL (WINAPI *PFN_KERNEL32_HEAP32_LIST_FIRST)
  64. (
  65. HANDLE,
  66. LPHEAPLIST32
  67. );
  68. typedef BOOL (WINAPI *PFN_KERNEL32_GLOBAL_MEMORY_STATUS_EX)
  69. (
  70. IN OUT LPMEMORYSTATUSEX lpBuffer
  71. );
  72. typedef LANGID (WINAPI *PFN_KERNEL32_GET_SYSTEM_DEFAULT_U_I_LANGUAGE)
  73. (
  74. );
  75. typedef BOOL (WINAPI *PFN_KERNEL32_GET_VOLUME_PATH_NAME)
  76. (
  77. LPCTSTR lpszFileName,
  78. LPTSTR lpszVolumePathName,
  79. DWORD cchBufferLength
  80. );
  81. /******************************************************************************
  82. * Wrapper class for Kernel32 load/unload, for registration with CResourceManager.
  83. ******************************************************************************/
  84. class
  85. __declspec(uuid("3CA401C6-D477-11d2-B35E-00104BC97924"))
  86. CKernel32Api : public CDllWrapperBase
  87. {
  88. private:
  89. // Member variables (function pointers) pointing to kernel32 functions.
  90. // Add new functions here as required.
  91. PFN_KERNEL32_GET_DISK_FREE_SPACE_EX m_pfnGetDiskFreeSpaceEx;
  92. PFN_KERNEL32_CREATE_TOOLHELP32_SNAPSHOT m_pfnCreateToolhelp32Snapshot;
  93. PFN_KERNEL32_THREAD32_FIRST m_pfnThread32First;
  94. PFN_KERNEL32_THREAD32_NEXT m_pfnThread32Next;
  95. PFN_KERNEL32_PROCESS32_FIRST m_pfnProcess32First;
  96. PFN_KERNEL32_PROCESS32_NEXT m_pfnProcess32Next;
  97. PFN_KERNEL32_MODULE32_FIRST m_pfnModule32First;
  98. PFN_KERNEL32_MODULE32_NEXT m_pfnModule32Next;
  99. PFN_KERNEL32_HEAP32_LIST_FIRST m_pfnHeap32ListFirst;
  100. PFN_KERNEL32_GLOBAL_MEMORY_STATUS_EX m_pfnGlobalMemoryStatusEx;
  101. PFN_KERNEL32_GET_SYSTEM_DEFAULT_U_I_LANGUAGE m_pfnGetSystemDefaultUILanguage;
  102. PFN_KERNEL32_GET_VOLUME_PATH_NAME m_pfnGetVolumePathName;
  103. public:
  104. // Constructor and destructor:
  105. CKernel32Api(LPCTSTR a_tstrWrappedDllName);
  106. ~CKernel32Api();
  107. // Inherrited initialization function.
  108. virtual bool Init();
  109. // Member functions wrapping kernel32 functions.
  110. // Add new functions here as required:
  111. bool GetDiskFreeSpaceEx
  112. (
  113. LPCTSTR lpDirectoryName,
  114. PULARGE_INTEGER a_lpFreeBytesAvailableToCaller,
  115. PULARGE_INTEGER a_lpTotalNumberOfBytes,
  116. PULARGE_INTEGER a_lpTotalNumberOfFreeBytes,
  117. BOOL *a_pfRetval
  118. );
  119. bool CreateToolhelp32Snapshot
  120. (
  121. DWORD a_dwFlags,
  122. DWORD a_th32ProcessID,
  123. HANDLE *a_hRetval
  124. );
  125. bool Thread32First
  126. (
  127. HANDLE a_hSnapshot,
  128. LPTHREADENTRY32 a_lpte,
  129. BOOL *a_pfRetval
  130. );
  131. bool Thread32Next
  132. (
  133. HANDLE a_hSnapshot,
  134. LPTHREADENTRY32 a_lpte,
  135. BOOL *a_pfRetval
  136. );
  137. bool Process32First
  138. (
  139. HANDLE a_hSnapshot,
  140. LPPROCESSENTRY32 a_lppe,
  141. BOOL *a_pfRetval
  142. );
  143. bool Process32Next
  144. (
  145. HANDLE a_hSnapshot,
  146. LPPROCESSENTRY32 a_lppe,
  147. BOOL *a_pfRetval
  148. );
  149. bool Module32First
  150. (
  151. HANDLE a_hSnapshot,
  152. LPMODULEENTRY32 a_lpme,
  153. BOOL *a_pfRetval
  154. );
  155. bool Module32Next
  156. (
  157. HANDLE a_hSnapshot,
  158. LPMODULEENTRY32 a_lpme,
  159. BOOL *a_pfRetval
  160. );
  161. bool Heap32ListFirst
  162. (
  163. HANDLE a_hSnapshot,
  164. LPHEAPLIST32 a_lphl,
  165. BOOL *a_pfRetval
  166. );
  167. bool GlobalMemoryStatusEx
  168. (
  169. IN OUT LPMEMORYSTATUSEX a_lpBuffer,
  170. BOOL *a_pfRetval
  171. );
  172. bool GetSystemDefaultUILanguage
  173. (
  174. LANGID *a_plidRetval
  175. );
  176. bool GetVolumePathName
  177. (
  178. LPCTSTR lpszFileName,
  179. LPTSTR lpszVolumePathName,
  180. DWORD cchBufferLength,
  181. BOOL *pfRetval
  182. );
  183. };
  184. #endif