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.

407 lines
10 KiB

  1. //=================================================================
  2. //
  3. // NTDllApi.h
  4. //
  5. // Copyright (c) 1999-2001 Microsoft Corporation, All Rights Reserved
  6. //
  7. //=================================================================
  8. #ifndef _NTDLLAPI_H_
  9. #define _NTDLLAPI_H_
  10. /******************************************************************************
  11. * #includes to Register this class with the CResourceManager.
  12. *****************************************************************************/
  13. extern const GUID g_guidNtDllApi;
  14. extern const TCHAR g_tstrNtDll[];
  15. /******************************************************************************
  16. * Function pointer typedefs. Add new functions here as required.
  17. *****************************************************************************/
  18. typedef DWORD (WINAPI *PFN_NTDLL_RTL_INIT_UNICODE_STRING)
  19. (
  20. UNICODE_STRING*,
  21. LPCWSTR
  22. );
  23. typedef void ( NTAPI *PFN_NTDLL_RTL_FREE_UNICODE_STRING )
  24. (
  25. PUNICODE_STRING UnicodeString
  26. );
  27. typedef DWORD (WINAPI *PFN_NTDLL_NT_SET_SYSTEM_ENVIRONMENT_VALUE)
  28. (
  29. UNICODE_STRING*,
  30. UNICODE_STRING*
  31. );
  32. typedef DWORD (WINAPI *PFN_NTDLL_NT_QUERY_SYSTEM_ENVIRONMENT_VALUE)
  33. (
  34. PUNICODE_STRING,
  35. PWSTR,
  36. USHORT,
  37. PUSHORT
  38. );
  39. //#if defined(EFI_NVRAM_ENABLED)
  40. #if defined(_IA64_)
  41. typedef DWORD (WINAPI *PFN_NTDLL_NT_QUERY_BOOT_OPTIONS)
  42. (
  43. PBOOT_OPTIONS,
  44. PULONG
  45. );
  46. typedef DWORD (WINAPI *PFN_NTDLL_NT_SET_BOOT_OPTIONS)
  47. (
  48. PBOOT_OPTIONS,
  49. ULONG
  50. );
  51. typedef DWORD (WINAPI *PFN_NTDLL_NT_QUERY_BOOT_ENTRY_ORDER)
  52. (
  53. PULONG,
  54. PULONG
  55. );
  56. typedef DWORD (WINAPI *PFN_NTDLL_NT_SET_BOOT_ENTRY_ORDER)
  57. (
  58. PULONG,
  59. ULONG
  60. );
  61. typedef DWORD (WINAPI *PFN_NTDLL_NT_ENUMERATE_BOOT_ENTRIES)
  62. (
  63. PVOID,
  64. PULONG
  65. );
  66. #endif // defined(EFI_NVRAM_ENABLED)
  67. typedef NTSTATUS (WINAPI *PFN_NTDLL_NT_CREATE_FILE)
  68. (
  69. HANDLE*,
  70. ACCESS_MASK,
  71. POBJECT_ATTRIBUTES,
  72. PIO_STATUS_BLOCK,
  73. PLARGE_INTEGER,
  74. ULONG,
  75. ULONG,
  76. ULONG,
  77. ULONG,
  78. PVOID,
  79. ULONG
  80. );
  81. typedef NTSTATUS (NTAPI *PFN_NT_QUERY_SYSTEM_INFORMATION)
  82. (
  83. IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
  84. OUT PVOID SystemInformation,
  85. IN ULONG SystemInformationLength,
  86. OUT PULONG ReturnLength OPTIONAL
  87. );
  88. typedef NTSTATUS (NTAPI *PFN_NTQUERYINFORMATIONPROCESS)
  89. (
  90. IN HANDLE ProcessHandle,
  91. IN PROCESSINFOCLASS ProcessInformationClass,
  92. OUT PVOID ProcessInformation,
  93. IN ULONG ProcessInformationLength,
  94. OUT PULONG ReturnLength OPTIONAL
  95. );
  96. typedef NTSTATUS (NTAPI *PFN_NT_QUERY_DIRECTORY_OBJECT)
  97. (
  98. IN HANDLE DirectoryHandle,
  99. OUT PVOID Buffer,
  100. IN ULONG Length,
  101. IN BOOLEAN ReturnSingleEntry,
  102. IN BOOLEAN RestartScan,
  103. IN OUT PULONG Context,
  104. OUT PULONG ReturnLength OPTIONAL
  105. );
  106. typedef NTSTATUS (NTAPI *PFN_NT_QUERY_OBJECT)
  107. (
  108. IN HANDLE Handle,
  109. IN OBJECT_INFORMATION_CLASS ObjectInformationClass,
  110. OUT PVOID ObjectInformation,
  111. IN ULONG Length,
  112. OUT PULONG ReturnLength OPTIONAL
  113. );
  114. typedef NTSTATUS (NTAPI *PFN_NT_OPEN_DIRECTORY_OBJECT)
  115. (
  116. OUT PHANDLE DirectoryHandle,
  117. IN ACCESS_MASK DesiredAccess,
  118. IN POBJECT_ATTRIBUTES ObjectAttributes
  119. );
  120. typedef NTSTATUS ( NTAPI *PFN_NT_QUERY_INFORMATION_TOKEN )
  121. (
  122. IN HANDLE TokenHandle,
  123. IN TOKEN_INFORMATION_CLASS TokenInformationClass,
  124. OUT PVOID TokenInformation,
  125. IN ULONG TokenInformationLength,
  126. OUT PULONG ReturnLength
  127. );
  128. typedef NTSTATUS ( NTAPI *PFN_NT_OPEN_FILE )
  129. (
  130. OUT PHANDLE FileHandle,
  131. IN ACCESS_MASK DesiredAccess,
  132. IN POBJECT_ATTRIBUTES ObjectAttributes,
  133. OUT PIO_STATUS_BLOCK IoStatusBlock,
  134. IN ULONG ShareAccess,
  135. IN ULONG OpenOptions
  136. );
  137. typedef NTSTATUS ( NTAPI *PFN_NT_CLOSE )
  138. (
  139. IN HANDLE Handle
  140. );
  141. typedef NTSTATUS ( NTAPI *PFN_NT_FS_CONTROL_FILE )
  142. (
  143. IN HANDLE FileHandle,
  144. IN HANDLE Event OPTIONAL,
  145. IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
  146. IN PVOID ApcContext OPTIONAL,
  147. OUT PIO_STATUS_BLOCK IoStatusBlock,
  148. IN ULONG FsControlCode,
  149. IN PVOID InputBuffer OPTIONAL,
  150. IN ULONG InputBufferLength,
  151. OUT PVOID OutputBuffer OPTIONAL,
  152. IN ULONG OutputBufferLength
  153. );
  154. typedef NTSTATUS ( NTAPI *PFN_NT_QUERY_VOLUME_INFORMATION_FILE )
  155. (
  156. IN HANDLE FileHandle,
  157. OUT PIO_STATUS_BLOCK IoStatusBlock,
  158. OUT PVOID FsInformation,
  159. IN ULONG Length,
  160. IN FS_INFORMATION_CLASS FsInformationClass
  161. );
  162. /******************************************************************************
  163. * Wrapper class for NtDll load/unload, for registration with CResourceManager.
  164. *****************************************************************************/
  165. class CNtDllApi : public CDllWrapperBase
  166. {
  167. private:
  168. // Member variables (function pointers) pointing to NtDll functions.
  169. // Add new functions here as required.
  170. PFN_NTDLL_RTL_INIT_UNICODE_STRING m_pfnRtlInitUnicodeString;
  171. PFN_NTDLL_RTL_FREE_UNICODE_STRING m_pfnRtlFreeUnicodeString;
  172. PFN_NTDLL_NT_SET_SYSTEM_ENVIRONMENT_VALUE m_pfnNtSetSystemEnvironmentValue;
  173. PFN_NTDLL_NT_QUERY_SYSTEM_ENVIRONMENT_VALUE m_pfnNtQuerySystemEnvironmentValue;
  174. //#if defined(EFI_NVRAM_ENABLED)
  175. #if defined(_IA64_)
  176. PFN_NTDLL_NT_QUERY_BOOT_OPTIONS m_pfnNtQueryBootOptions;
  177. PFN_NTDLL_NT_SET_BOOT_OPTIONS m_pfnNtSetBootOptions;
  178. PFN_NTDLL_NT_QUERY_BOOT_ENTRY_ORDER m_pfnNtQueryBootEntryOrder;
  179. PFN_NTDLL_NT_SET_BOOT_ENTRY_ORDER m_pfnNtSetBootEntryOrder;
  180. PFN_NTDLL_NT_ENUMERATE_BOOT_ENTRIES m_pfnNtEnumerateBootEntries;
  181. #endif // defined(EFI_NVRAM_ENABLED)
  182. PFN_NTDLL_NT_CREATE_FILE m_pfnNtCreateFile;
  183. PFN_NT_QUERY_SYSTEM_INFORMATION m_pfnNtQuerySystemInformation;
  184. PFN_NT_QUERY_DIRECTORY_OBJECT m_pfnNtQueryDirectoryObject;
  185. PFN_NT_QUERY_OBJECT m_pfnNtQueryObject;
  186. PFN_NT_OPEN_DIRECTORY_OBJECT m_pfnNtOpenDirectoryObject;
  187. PFN_NTQUERYINFORMATIONPROCESS m_pfnNtQueryInformationProcess ;
  188. PFN_NT_QUERY_INFORMATION_TOKEN m_pfnNtQueryInformationToken ;
  189. PFN_NT_OPEN_FILE m_pfnNtOpenFile ;
  190. PFN_NT_CLOSE m_pfnNtClose ;
  191. PFN_NT_FS_CONTROL_FILE m_pfnNtFsControlFile ;
  192. PFN_NT_QUERY_VOLUME_INFORMATION_FILE m_pfnNtQueryVolumeInformationFile;
  193. public:
  194. // Constructor and destructor:
  195. CNtDllApi(LPCTSTR a_tstrWrappedDllName);
  196. ~CNtDllApi();
  197. // Initialization function to check function pointers.
  198. virtual bool Init();
  199. // Member functions wrapping NtDll functions.
  200. // Add new functions here as required:
  201. DWORD RtlInitUnicodeString (
  202. UNICODE_STRING* a_pustr,
  203. LPCWSTR a_wstr
  204. );
  205. VOID RtlFreeUnicodeString (
  206. PUNICODE_STRING UnicodeString
  207. ) ;
  208. DWORD NtSetSystemEnvironmentValue (
  209. UNICODE_STRING* a_pustr1,
  210. UNICODE_STRING* a_pustr2
  211. );
  212. DWORD NtQuerySystemEnvironmentValue (
  213. PUNICODE_STRING a_pustr,
  214. PWSTR a_pwstr,
  215. USHORT a_us,
  216. PUSHORT a_pus
  217. );
  218. //#if defined(EFI_NVRAM_ENABLED)
  219. #if defined(_IA64_)
  220. DWORD NtQueryBootOptions (
  221. PBOOT_OPTIONS BootOptions,
  222. PULONG BootOptionsLength
  223. );
  224. DWORD NtSetBootOptions (
  225. PBOOT_OPTIONS BootOptions,
  226. ULONG FieldsToChange
  227. );
  228. DWORD NtQueryBootEntryOrder (
  229. PULONG Ids,
  230. PULONG Count
  231. );
  232. DWORD NtSetBootEntryOrder (
  233. PULONG Ids,
  234. ULONG Count
  235. );
  236. DWORD NtEnumerateBootEntries (
  237. PVOID Buffer,
  238. PULONG BufferLength
  239. );
  240. #endif // defined(EFI_NVRAM_ENABLED)
  241. NTSTATUS NtCreateFile (
  242. HANDLE *a_ph,
  243. ACCESS_MASK a_am,
  244. POBJECT_ATTRIBUTES a_pa,
  245. PIO_STATUS_BLOCK a_sb,
  246. PLARGE_INTEGER a_pla,
  247. ULONG a_ul1,
  248. ULONG a_ul2,
  249. ULONG a_ul3,
  250. ULONG a_ul4,
  251. PVOID a_pv,
  252. ULONG a_ul5
  253. );
  254. NTSTATUS NtQuerySystemInformation
  255. (
  256. SYSTEM_INFORMATION_CLASS a_SystemInformationClass,
  257. PVOID a_SystemInformation,
  258. ULONG a_SystemInformationLength,
  259. PULONG a_ReturnLength
  260. );
  261. NTSTATUS NtQueryDirectoryObject
  262. (
  263. HANDLE a_DirectoryHandle,
  264. PVOID a_Buffer,
  265. ULONG a_Length,
  266. BOOLEAN a_ReturnSingleEntry,
  267. BOOLEAN a_RestartScan,
  268. PULONG a_Context,
  269. PULONG a_ReturnLength
  270. );
  271. NTSTATUS NtQueryObject
  272. (
  273. HANDLE a_Handle,
  274. OBJECT_INFORMATION_CLASS a_ObjectInformationClass,
  275. PVOID a_ObjectInformation,
  276. ULONG a_Length,
  277. PULONG a_ReturnLength
  278. );
  279. NTSTATUS NtOpenDirectoryObject
  280. (
  281. PHANDLE a_DirectoryHandle,
  282. ACCESS_MASK a_DesiredAccess,
  283. POBJECT_ATTRIBUTES a_ObjectAttributes
  284. );
  285. NTSTATUS NtQueryInformationProcess (
  286. IN HANDLE ProcessHandle,
  287. IN PROCESSINFOCLASS ProcessInformationClass,
  288. OUT PVOID ProcessInformation,
  289. IN ULONG ProcessInformationLength,
  290. OUT PULONG ReturnLength OPTIONAL
  291. );
  292. NTSTATUS NtQueryInformationToken (
  293. IN HANDLE TokenHandle,
  294. IN TOKEN_INFORMATION_CLASS TokenInformationClass,
  295. OUT PVOID TokenInformation,
  296. IN ULONG TokenInformationLength,
  297. OUT PULONG ReturnLength
  298. ) ;
  299. NTSTATUS NtOpenFile (
  300. OUT PHANDLE FileHandle,
  301. IN ACCESS_MASK DesiredAccess,
  302. IN POBJECT_ATTRIBUTES ObjectAttributes,
  303. OUT PIO_STATUS_BLOCK IoStatusBlock,
  304. IN ULONG ShareAccess,
  305. IN ULONG OpenOptions
  306. );
  307. NTSTATUS NtClose (
  308. IN HANDLE Handle
  309. );
  310. NTSTATUS NtFsControlFile (
  311. IN HANDLE FileHandle,
  312. IN HANDLE Event OPTIONAL,
  313. IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
  314. IN PVOID ApcContext OPTIONAL,
  315. OUT PIO_STATUS_BLOCK IoStatusBlock,
  316. IN ULONG FsControlCode,
  317. IN PVOID InputBuffer OPTIONAL,
  318. IN ULONG InputBufferLength,
  319. OUT PVOID OutputBuffer OPTIONAL,
  320. IN ULONG OutputBufferLength
  321. );
  322. NTSTATUS NtQueryVolumeInformationFile(
  323. IN HANDLE FileHandle,
  324. OUT PIO_STATUS_BLOCK IoStatusBlock,
  325. OUT PVOID FsInformation,
  326. IN ULONG Length,
  327. IN FS_INFORMATION_CLASS FsInformationClass);
  328. };
  329. #endif