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.

2362 lines
56 KiB

  1. /*++ BUILD Version: 0008 // Increment this if a change has global effects
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. ntexapi.h
  5. Abstract:
  6. This module is the header file for the all the system services that
  7. are contained in the "ex" directory.
  8. Author:
  9. David N. Cutler (davec) 5-May-1989
  10. Revision History:
  11. --*/
  12. #ifndef _NTEXAPI_
  13. #define _NTEXAPI_
  14. #if _MSC_VER > 1000
  15. #pragma once
  16. #endif
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. //
  21. // Delay thread execution.
  22. //
  23. NTSYSCALLAPI
  24. NTSTATUS
  25. NTAPI
  26. NtDelayExecution (
  27. IN BOOLEAN Alertable,
  28. IN PLARGE_INTEGER DelayInterval
  29. );
  30. //
  31. // Query and set system environment variables.
  32. //
  33. NTSYSCALLAPI
  34. NTSTATUS
  35. NTAPI
  36. NtQuerySystemEnvironmentValue (
  37. IN PUNICODE_STRING VariableName,
  38. OUT PWSTR VariableValue,
  39. IN USHORT ValueLength,
  40. OUT PUSHORT ReturnLength OPTIONAL
  41. );
  42. NTSYSCALLAPI
  43. NTSTATUS
  44. NTAPI
  45. NtSetSystemEnvironmentValue (
  46. IN PUNICODE_STRING VariableName,
  47. IN PUNICODE_STRING VariableValue
  48. );
  49. NTSYSCALLAPI
  50. NTSTATUS
  51. NTAPI
  52. NtQuerySystemEnvironmentValueEx (
  53. IN PUNICODE_STRING VariableName,
  54. IN LPGUID VendorGuid,
  55. OUT PVOID Value,
  56. IN OUT PULONG ValueLength,
  57. OUT PULONG Attributes OPTIONAL
  58. );
  59. NTSYSCALLAPI
  60. NTSTATUS
  61. NTAPI
  62. NtSetSystemEnvironmentValueEx (
  63. IN PUNICODE_STRING VariableName,
  64. IN LPGUID VendorGuid,
  65. IN PVOID Value,
  66. IN ULONG ValueLength,
  67. IN ULONG Attributes
  68. );
  69. NTSYSCALLAPI
  70. NTSTATUS
  71. NTAPI
  72. NtEnumerateSystemEnvironmentValuesEx (
  73. IN ULONG InformationClass,
  74. OUT PVOID Buffer,
  75. IN OUT PULONG BufferLength
  76. );
  77. // begin_nthal
  78. #define VARIABLE_ATTRIBUTE_NON_VOLATILE 0x00000001
  79. #define VARIABLE_INFORMATION_NAMES 1
  80. #define VARIABLE_INFORMATION_VALUES 2
  81. typedef struct _VARIABLE_NAME {
  82. ULONG NextEntryOffset;
  83. GUID VendorGuid;
  84. WCHAR Name[ANYSIZE_ARRAY];
  85. } VARIABLE_NAME, *PVARIABLE_NAME;
  86. typedef struct _VARIABLE_NAME_AND_VALUE {
  87. ULONG NextEntryOffset;
  88. ULONG ValueOffset;
  89. ULONG ValueLength;
  90. ULONG Attributes;
  91. GUID VendorGuid;
  92. WCHAR Name[ANYSIZE_ARRAY];
  93. //UCHAR Value[ANYSIZE_ARRAY];
  94. } VARIABLE_NAME_AND_VALUE, *PVARIABLE_NAME_AND_VALUE;
  95. // end_nthal
  96. //
  97. // Boot entry management APIs.
  98. //
  99. typedef struct _FILE_PATH {
  100. ULONG Version;
  101. ULONG Length;
  102. ULONG Type;
  103. UCHAR FilePath[ANYSIZE_ARRAY];
  104. } FILE_PATH, *PFILE_PATH;
  105. #define FILE_PATH_VERSION 1
  106. #define FILE_PATH_TYPE_ARC 1
  107. #define FILE_PATH_TYPE_ARC_SIGNATURE 2
  108. #define FILE_PATH_TYPE_NT 3
  109. #define FILE_PATH_TYPE_EFI 4
  110. #define FILE_PATH_TYPE_MIN FILE_PATH_TYPE_ARC
  111. #define FILE_PATH_TYPE_MAX FILE_PATH_TYPE_EFI
  112. typedef struct _WINDOWS_OS_OPTIONS {
  113. UCHAR Signature[8];
  114. ULONG Version;
  115. ULONG Length;
  116. ULONG OsLoadPathOffset;
  117. WCHAR OsLoadOptions[ANYSIZE_ARRAY];
  118. //FILE_PATH OsLoadPath;
  119. } WINDOWS_OS_OPTIONS, *PWINDOWS_OS_OPTIONS;
  120. #define WINDOWS_OS_OPTIONS_SIGNATURE "WINDOWS"
  121. #define WINDOWS_OS_OPTIONS_VERSION 1
  122. typedef struct _BOOT_ENTRY {
  123. ULONG Version;
  124. ULONG Length;
  125. ULONG Id;
  126. ULONG Attributes;
  127. ULONG FriendlyNameOffset;
  128. ULONG BootFilePathOffset;
  129. ULONG OsOptionsLength;
  130. UCHAR OsOptions[ANYSIZE_ARRAY];
  131. //WCHAR FriendlyName[ANYSIZE_ARRAY];
  132. //FILE_PATH BootFilePath;
  133. } BOOT_ENTRY, *PBOOT_ENTRY;
  134. #define BOOT_ENTRY_VERSION 1
  135. #define BOOT_ENTRY_ATTRIBUTE_ACTIVE 0x00000001
  136. #define BOOT_ENTRY_ATTRIBUTE_DEFAULT 0x00000002
  137. #define BOOT_ENTRY_ATTRIBUTE_WINDOWS 0x00000004
  138. #define BOOT_ENTRY_ATTRIBUTE_REMOVABLE_MEDIA 0x00000008
  139. #define BOOT_ENTRY_ATTRIBUTE_VALID_BITS ( \
  140. BOOT_ENTRY_ATTRIBUTE_ACTIVE | \
  141. BOOT_ENTRY_ATTRIBUTE_DEFAULT \
  142. )
  143. typedef struct _BOOT_OPTIONS {
  144. ULONG Version;
  145. ULONG Length;
  146. ULONG Timeout;
  147. ULONG CurrentBootEntryId;
  148. ULONG NextBootEntryId;
  149. WCHAR HeadlessRedirection[ANYSIZE_ARRAY];
  150. } BOOT_OPTIONS, *PBOOT_OPTIONS;
  151. #define BOOT_OPTIONS_VERSION 1
  152. #define BOOT_OPTIONS_FIELD_TIMEOUT 0x00000001
  153. #define BOOT_OPTIONS_FIELD_NEXT_BOOT_ENTRY_ID 0x00000002
  154. #define BOOT_OPTIONS_FIELD_HEADLESS_REDIRECTION 0x00000004
  155. NTSYSCALLAPI
  156. NTSTATUS
  157. NTAPI
  158. NtAddBootEntry (
  159. IN PBOOT_ENTRY BootEntry,
  160. OUT PULONG Id OPTIONAL
  161. );
  162. NTSYSCALLAPI
  163. NTSTATUS
  164. NTAPI
  165. NtDeleteBootEntry (
  166. IN ULONG Id
  167. );
  168. NTSYSCALLAPI
  169. NTSTATUS
  170. NTAPI
  171. NtModifyBootEntry (
  172. IN PBOOT_ENTRY BootEntry
  173. );
  174. NTSYSCALLAPI
  175. NTSTATUS
  176. NTAPI
  177. NtEnumerateBootEntries (
  178. OUT PVOID Buffer,
  179. IN OUT PULONG BufferLength
  180. );
  181. typedef struct _BOOT_ENTRY_LIST {
  182. ULONG NextEntryOffset;
  183. BOOT_ENTRY BootEntry;
  184. } BOOT_ENTRY_LIST, *PBOOT_ENTRY_LIST;
  185. NTSYSCALLAPI
  186. NTSTATUS
  187. NTAPI
  188. NtQueryBootEntryOrder (
  189. OUT PULONG Ids,
  190. IN OUT PULONG Count
  191. );
  192. NTSYSCALLAPI
  193. NTSTATUS
  194. NTAPI
  195. NtSetBootEntryOrder (
  196. IN PULONG Ids,
  197. IN ULONG Count
  198. );
  199. NTSYSCALLAPI
  200. NTSTATUS
  201. NTAPI
  202. NtQueryBootOptions (
  203. OUT PBOOT_OPTIONS BootOptions,
  204. IN OUT PULONG BootOptionsLength
  205. );
  206. NTSYSCALLAPI
  207. NTSTATUS
  208. NTAPI
  209. NtSetBootOptions (
  210. IN PBOOT_OPTIONS BootOptions,
  211. IN ULONG FieldsToChange
  212. );
  213. #define BOOT_OPTIONS_FIELD_COUNTDOWN 0x00000001
  214. #define BOOT_OPTIONS_FIELD_NEXT_BOOT_ENTRY_ID 0x00000002
  215. #define BOOT_OPTIONS_FIELD_HEADLESS_REDIRECTION 0x00000004
  216. NTSYSCALLAPI
  217. NTSTATUS
  218. NTAPI
  219. NtTranslateFilePath (
  220. IN PFILE_PATH InputFilePath,
  221. IN ULONG OutputType,
  222. OUT PFILE_PATH OutputFilePath,
  223. IN OUT PULONG OutputFilePathLength
  224. );
  225. // begin_ntifs begin_wdm begin_ntddk
  226. //
  227. // Event Specific Access Rights.
  228. //
  229. #define EVENT_QUERY_STATE 0x0001
  230. #define EVENT_MODIFY_STATE 0x0002 // winnt
  231. #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3) // winnt
  232. // end_ntifs end_wdm end_ntddk
  233. //
  234. // Event Information Classes.
  235. //
  236. typedef enum _EVENT_INFORMATION_CLASS {
  237. EventBasicInformation
  238. } EVENT_INFORMATION_CLASS;
  239. //
  240. // Event Information Structures.
  241. //
  242. typedef struct _EVENT_BASIC_INFORMATION {
  243. EVENT_TYPE EventType;
  244. LONG EventState;
  245. } EVENT_BASIC_INFORMATION, *PEVENT_BASIC_INFORMATION;
  246. //
  247. // Event object function definitions.
  248. //
  249. NTSYSCALLAPI
  250. NTSTATUS
  251. NTAPI
  252. NtClearEvent (
  253. IN HANDLE EventHandle
  254. );
  255. NTSYSCALLAPI
  256. NTSTATUS
  257. NTAPI
  258. NtCreateEvent (
  259. OUT PHANDLE EventHandle,
  260. IN ACCESS_MASK DesiredAccess,
  261. IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
  262. IN EVENT_TYPE EventType,
  263. IN BOOLEAN InitialState
  264. );
  265. NTSYSCALLAPI
  266. NTSTATUS
  267. NTAPI
  268. NtOpenEvent (
  269. OUT PHANDLE EventHandle,
  270. IN ACCESS_MASK DesiredAccess,
  271. IN POBJECT_ATTRIBUTES ObjectAttributes
  272. );
  273. NTSYSCALLAPI
  274. NTSTATUS
  275. NTAPI
  276. NtPulseEvent (
  277. IN HANDLE EventHandle,
  278. OUT PLONG PreviousState OPTIONAL
  279. );
  280. NTSYSCALLAPI
  281. NTSTATUS
  282. NTAPI
  283. NtQueryEvent (
  284. IN HANDLE EventHandle,
  285. IN EVENT_INFORMATION_CLASS EventInformationClass,
  286. OUT PVOID EventInformation,
  287. IN ULONG EventInformationLength,
  288. OUT PULONG ReturnLength OPTIONAL
  289. );
  290. NTSYSCALLAPI
  291. NTSTATUS
  292. NTAPI
  293. NtResetEvent (
  294. IN HANDLE EventHandle,
  295. OUT PLONG PreviousState OPTIONAL
  296. );
  297. NTSYSCALLAPI
  298. NTSTATUS
  299. NTAPI
  300. NtSetEvent (
  301. IN HANDLE EventHandle,
  302. OUT PLONG PreviousState OPTIONAL
  303. );
  304. NTSYSCALLAPI
  305. NTSTATUS
  306. NTAPI
  307. NtSetEventBoostPriority (
  308. IN HANDLE EventHandle
  309. );
  310. //
  311. // Event Specific Access Rights.
  312. //
  313. #define EVENT_PAIR_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE)
  314. //
  315. // Event pair object function definitions.
  316. //
  317. NTSYSCALLAPI
  318. NTSTATUS
  319. NTAPI
  320. NtCreateEventPair (
  321. OUT PHANDLE EventPairHandle,
  322. IN ACCESS_MASK DesiredAccess,
  323. IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL
  324. );
  325. NTSYSCALLAPI
  326. NTSTATUS
  327. NTAPI
  328. NtOpenEventPair(
  329. OUT PHANDLE EventPairHandle,
  330. IN ACCESS_MASK DesiredAccess,
  331. IN POBJECT_ATTRIBUTES ObjectAttributes
  332. );
  333. NTSYSCALLAPI
  334. NTSTATUS
  335. NTAPI
  336. NtWaitLowEventPair(
  337. IN HANDLE EventPairHandle
  338. );
  339. NTSYSCALLAPI
  340. NTSTATUS
  341. NTAPI
  342. NtWaitHighEventPair(
  343. IN HANDLE EventPairHandle
  344. );
  345. NTSYSCALLAPI
  346. NTSTATUS
  347. NTAPI
  348. NtSetLowWaitHighEventPair(
  349. IN HANDLE EventPairHandle
  350. );
  351. NTSYSCALLAPI
  352. NTSTATUS
  353. NTAPI
  354. NtSetHighWaitLowEventPair(
  355. IN HANDLE EventPairHandle
  356. );
  357. NTSYSCALLAPI
  358. NTSTATUS
  359. NTAPI
  360. NtSetLowEventPair(
  361. IN HANDLE EventPairHandle
  362. );
  363. NTSYSCALLAPI
  364. NTSTATUS
  365. NTAPI
  366. NtSetHighEventPair(
  367. IN HANDLE EventPairHandle
  368. );
  369. //
  370. // Mutant Specific Access Rights.
  371. //
  372. // begin_winnt
  373. #define MUTANT_QUERY_STATE 0x0001
  374. #define MUTANT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|\
  375. MUTANT_QUERY_STATE)
  376. // end_winnt
  377. //
  378. // Mutant Information Classes.
  379. //
  380. typedef enum _MUTANT_INFORMATION_CLASS {
  381. MutantBasicInformation
  382. } MUTANT_INFORMATION_CLASS;
  383. //
  384. // Mutant Information Structures.
  385. //
  386. typedef struct _MUTANT_BASIC_INFORMATION {
  387. LONG CurrentCount;
  388. BOOLEAN OwnedByCaller;
  389. BOOLEAN AbandonedState;
  390. } MUTANT_BASIC_INFORMATION, *PMUTANT_BASIC_INFORMATION;
  391. //
  392. // Mutant object function definitions.
  393. //
  394. NTSYSCALLAPI
  395. NTSTATUS
  396. NTAPI
  397. NtCreateMutant (
  398. OUT PHANDLE MutantHandle,
  399. IN ACCESS_MASK DesiredAccess,
  400. IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
  401. IN BOOLEAN InitialOwner
  402. );
  403. NTSYSCALLAPI
  404. NTSTATUS
  405. NTAPI
  406. NtOpenMutant (
  407. OUT PHANDLE MutantHandle,
  408. IN ACCESS_MASK DesiredAccess,
  409. IN POBJECT_ATTRIBUTES ObjectAttributes
  410. );
  411. NTSYSCALLAPI
  412. NTSTATUS
  413. NTAPI
  414. NtQueryMutant (
  415. IN HANDLE MutantHandle,
  416. IN MUTANT_INFORMATION_CLASS MutantInformationClass,
  417. OUT PVOID MutantInformation,
  418. IN ULONG MutantInformationLength,
  419. OUT PULONG ReturnLength OPTIONAL
  420. );
  421. NTSYSCALLAPI
  422. NTSTATUS
  423. NTAPI
  424. NtReleaseMutant (
  425. IN HANDLE MutantHandle,
  426. OUT PLONG PreviousCount OPTIONAL
  427. );
  428. // begin_ntifs begin_wdm begin_ntddk
  429. //
  430. // Semaphore Specific Access Rights.
  431. //
  432. #define SEMAPHORE_QUERY_STATE 0x0001
  433. #define SEMAPHORE_MODIFY_STATE 0x0002 // winnt
  434. #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3) // winnt
  435. // end_ntifs end_wdm end_ntddk
  436. //
  437. // Semaphore Information Classes.
  438. //
  439. typedef enum _SEMAPHORE_INFORMATION_CLASS {
  440. SemaphoreBasicInformation
  441. } SEMAPHORE_INFORMATION_CLASS;
  442. //
  443. // Semaphore Information Structures.
  444. //
  445. typedef struct _SEMAPHORE_BASIC_INFORMATION {
  446. LONG CurrentCount;
  447. LONG MaximumCount;
  448. } SEMAPHORE_BASIC_INFORMATION, *PSEMAPHORE_BASIC_INFORMATION;
  449. //
  450. // Semaphore object function definitions.
  451. //
  452. NTSYSCALLAPI
  453. NTSTATUS
  454. NTAPI
  455. NtCreateSemaphore (
  456. OUT PHANDLE SemaphoreHandle,
  457. IN ACCESS_MASK DesiredAccess,
  458. IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
  459. IN LONG InitialCount,
  460. IN LONG MaximumCount
  461. );
  462. NTSYSCALLAPI
  463. NTSTATUS
  464. NTAPI
  465. NtOpenSemaphore(
  466. OUT PHANDLE SemaphoreHandle,
  467. IN ACCESS_MASK DesiredAccess,
  468. IN POBJECT_ATTRIBUTES ObjectAttributes
  469. );
  470. NTSYSCALLAPI
  471. NTSTATUS
  472. NTAPI
  473. NtQuerySemaphore (
  474. IN HANDLE SemaphoreHandle,
  475. IN SEMAPHORE_INFORMATION_CLASS SemaphoreInformationClass,
  476. OUT PVOID SemaphoreInformation,
  477. IN ULONG SemaphoreInformationLength,
  478. OUT PULONG ReturnLength OPTIONAL
  479. );
  480. NTSYSCALLAPI
  481. NTSTATUS
  482. NTAPI
  483. NtReleaseSemaphore(
  484. IN HANDLE SemaphoreHandle,
  485. IN LONG ReleaseCount,
  486. OUT PLONG PreviousCount OPTIONAL
  487. );
  488. // begin_winnt
  489. //
  490. // Timer Specific Access Rights.
  491. //
  492. #define TIMER_QUERY_STATE 0x0001
  493. #define TIMER_MODIFY_STATE 0x0002
  494. #define TIMER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|\
  495. TIMER_QUERY_STATE|TIMER_MODIFY_STATE)
  496. // end_winnt
  497. //
  498. // Timer Information Classes.
  499. //
  500. typedef enum _TIMER_INFORMATION_CLASS {
  501. TimerBasicInformation
  502. } TIMER_INFORMATION_CLASS;
  503. //
  504. // Timer Information Structures.
  505. //
  506. typedef struct _TIMER_BASIC_INFORMATION {
  507. LARGE_INTEGER RemainingTime;
  508. BOOLEAN TimerState;
  509. } TIMER_BASIC_INFORMATION, *PTIMER_BASIC_INFORMATION;
  510. // begin_ntddk
  511. //
  512. // Timer APC routine definition.
  513. //
  514. typedef
  515. VOID
  516. (*PTIMER_APC_ROUTINE) (
  517. IN PVOID TimerContext,
  518. IN ULONG TimerLowValue,
  519. IN LONG TimerHighValue
  520. );
  521. // end_ntddk
  522. //
  523. // Timer object function definitions.
  524. //
  525. NTSYSCALLAPI
  526. NTSTATUS
  527. NTAPI
  528. NtCreateTimer (
  529. OUT PHANDLE TimerHandle,
  530. IN ACCESS_MASK DesiredAccess,
  531. IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
  532. IN TIMER_TYPE TimerType
  533. );
  534. NTSYSCALLAPI
  535. NTSTATUS
  536. NTAPI
  537. NtOpenTimer (
  538. OUT PHANDLE TimerHandle,
  539. IN ACCESS_MASK DesiredAccess,
  540. IN POBJECT_ATTRIBUTES ObjectAttributes
  541. );
  542. NTSYSCALLAPI
  543. NTSTATUS
  544. NTAPI
  545. NtCancelTimer (
  546. IN HANDLE TimerHandle,
  547. OUT PBOOLEAN CurrentState OPTIONAL
  548. );
  549. NTSYSCALLAPI
  550. NTSTATUS
  551. NTAPI
  552. NtQueryTimer (
  553. IN HANDLE TimerHandle,
  554. IN TIMER_INFORMATION_CLASS TimerInformationClass,
  555. OUT PVOID TimerInformation,
  556. IN ULONG TimerInformationLength,
  557. OUT PULONG ReturnLength OPTIONAL
  558. );
  559. NTSYSCALLAPI
  560. NTSTATUS
  561. NTAPI
  562. NtSetTimer (
  563. IN HANDLE TimerHandle,
  564. IN PLARGE_INTEGER DueTime,
  565. IN PTIMER_APC_ROUTINE TimerApcRoutine OPTIONAL,
  566. IN PVOID TimerContext OPTIONAL,
  567. IN BOOLEAN ResumeTimer,
  568. IN LONG Period OPTIONAL,
  569. OUT PBOOLEAN PreviousState OPTIONAL
  570. );
  571. //
  572. // System Time and Timer function definitions
  573. //
  574. NTSYSCALLAPI
  575. NTSTATUS
  576. NTAPI
  577. NtQuerySystemTime (
  578. OUT PLARGE_INTEGER SystemTime
  579. );
  580. NTSYSCALLAPI
  581. NTSTATUS
  582. NTAPI
  583. NtSetSystemTime (
  584. IN PLARGE_INTEGER SystemTime,
  585. OUT PLARGE_INTEGER PreviousTime OPTIONAL
  586. );
  587. NTSYSCALLAPI
  588. NTSTATUS
  589. NTAPI
  590. NtQueryTimerResolution (
  591. OUT PULONG MaximumTime,
  592. OUT PULONG MinimumTime,
  593. OUT PULONG CurrentTime
  594. );
  595. NTSYSCALLAPI
  596. NTSTATUS
  597. NTAPI
  598. NtSetTimerResolution (
  599. IN ULONG DesiredTime,
  600. IN BOOLEAN SetResolution,
  601. OUT PULONG ActualTime
  602. );
  603. //
  604. // Locally Unique Identifier (LUID) allocation
  605. //
  606. NTSYSCALLAPI
  607. NTSTATUS
  608. NTAPI
  609. NtAllocateLocallyUniqueId(
  610. OUT PLUID Luid
  611. );
  612. //
  613. // Universally Unique Identifier (UUID) time allocation
  614. //
  615. NTSYSCALLAPI
  616. NTSTATUS
  617. NTAPI
  618. NtSetUuidSeed (
  619. IN PCHAR Seed
  620. );
  621. NTSYSCALLAPI
  622. NTSTATUS
  623. NTAPI
  624. NtAllocateUuids(
  625. OUT PULARGE_INTEGER Time,
  626. OUT PULONG Range,
  627. OUT PULONG Sequence,
  628. OUT PCHAR Seed
  629. );
  630. //
  631. // Profile Object Definitions
  632. //
  633. #define PROFILE_CONTROL 0x0001
  634. #define PROFILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | PROFILE_CONTROL)
  635. NTSYSCALLAPI
  636. NTSTATUS
  637. NTAPI
  638. NtCreateProfile (
  639. OUT PHANDLE ProfileHandle,
  640. IN HANDLE Process OPTIONAL,
  641. IN PVOID ProfileBase,
  642. IN SIZE_T ProfileSize,
  643. IN ULONG BucketSize,
  644. IN PULONG Buffer,
  645. IN ULONG BufferSize,
  646. IN KPROFILE_SOURCE ProfileSource,
  647. IN KAFFINITY Affinity
  648. );
  649. NTSYSCALLAPI
  650. NTSTATUS
  651. NTAPI
  652. NtStartProfile (
  653. IN HANDLE ProfileHandle
  654. );
  655. NTSYSCALLAPI
  656. NTSTATUS
  657. NTAPI
  658. NtStopProfile (
  659. IN HANDLE ProfileHandle
  660. );
  661. NTSYSCALLAPI
  662. NTSTATUS
  663. NTAPI
  664. NtSetIntervalProfile (
  665. IN ULONG Interval,
  666. IN KPROFILE_SOURCE Source
  667. );
  668. NTSYSCALLAPI
  669. NTSTATUS
  670. NTAPI
  671. NtQueryIntervalProfile (
  672. IN KPROFILE_SOURCE ProfileSource,
  673. OUT PULONG Interval
  674. );
  675. //
  676. // Performance Counter Definitions
  677. //
  678. NTSYSCALLAPI
  679. NTSTATUS
  680. NTAPI
  681. NtQueryPerformanceCounter (
  682. OUT PLARGE_INTEGER PerformanceCounter,
  683. OUT PLARGE_INTEGER PerformanceFrequency OPTIONAL
  684. );
  685. #define KEYEDEVENT_WAIT 0x0001
  686. #define KEYEDEVENT_WAKE 0x0002
  687. #define KEYEDEVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | KEYEDEVENT_WAIT | KEYEDEVENT_WAKE)
  688. NTSYSCALLAPI
  689. NTSTATUS
  690. NTAPI
  691. NtCreateKeyedEvent (
  692. OUT PHANDLE KeyedEventHandle,
  693. IN ACCESS_MASK DesiredAccess,
  694. IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
  695. IN ULONG Flags
  696. );
  697. NTSYSCALLAPI
  698. NTSTATUS
  699. NTAPI
  700. NtOpenKeyedEvent (
  701. OUT PHANDLE KeyedEventHandle,
  702. IN ACCESS_MASK DesiredAccess,
  703. IN POBJECT_ATTRIBUTES ObjectAttributes
  704. );
  705. NTSYSCALLAPI
  706. NTSTATUS
  707. NTAPI
  708. NtReleaseKeyedEvent (
  709. IN HANDLE KeyedEventHandle,
  710. IN PVOID KeyValue,
  711. IN BOOLEAN Alertable,
  712. IN PLARGE_INTEGER Timeout OPTIONAL
  713. );
  714. NTSYSCALLAPI
  715. NTSTATUS
  716. NTAPI
  717. NtWaitForKeyedEvent (
  718. IN HANDLE KeyedEventHandle,
  719. IN PVOID KeyValue,
  720. IN BOOLEAN Alertable,
  721. IN PLARGE_INTEGER Timeout OPTIONAL
  722. );
  723. //
  724. // Nt Api Profile Definitions
  725. //
  726. //
  727. // Nt Api Profiling data structure
  728. //
  729. typedef struct _NAPDATA {
  730. ULONG NapLock;
  731. ULONG Calls;
  732. ULONG TimingErrors;
  733. LARGE_INTEGER TotalTime;
  734. LARGE_INTEGER FirstTime;
  735. LARGE_INTEGER MaxTime;
  736. LARGE_INTEGER MinTime;
  737. } NAPDATA, *PNAPDATA;
  738. NTSTATUS
  739. NapClearData (
  740. VOID
  741. );
  742. NTSTATUS
  743. NapRetrieveData (
  744. OUT NAPDATA *NapApiData,
  745. OUT PCHAR **NapApiNames,
  746. OUT PLARGE_INTEGER *NapCounterFrequency
  747. );
  748. NTSTATUS
  749. NapGetApiCount (
  750. OUT PULONG NapApiCount
  751. );
  752. NTSTATUS
  753. NapPause (
  754. VOID
  755. );
  756. NTSTATUS
  757. NapResume (
  758. VOID
  759. );
  760. // begin_ntifs begin_ntddk
  761. //
  762. // Driver Verifier Definitions
  763. //
  764. typedef ULONG_PTR (*PDRIVER_VERIFIER_THUNK_ROUTINE) (
  765. IN PVOID Context
  766. );
  767. //
  768. // This structure is passed in by drivers that want to thunk callers of
  769. // their exports.
  770. //
  771. typedef struct _DRIVER_VERIFIER_THUNK_PAIRS {
  772. PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine;
  773. PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine;
  774. } DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS;
  775. //
  776. // Driver Verifier flags.
  777. //
  778. #define DRIVER_VERIFIER_SPECIAL_POOLING 0x0001
  779. #define DRIVER_VERIFIER_FORCE_IRQL_CHECKING 0x0002
  780. #define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES 0x0004
  781. #define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008
  782. #define DRIVER_VERIFIER_IO_CHECKING 0x0010
  783. // end_ntifs end_ntddk
  784. #define DRIVER_VERIFIER_DEADLOCK_DETECTION 0x0020
  785. #define DRIVER_VERIFIER_ENHANCED_IO_CHECKING 0x0040
  786. #define DRIVER_VERIFIER_DMA_VERIFIER 0x0080
  787. #define DRIVER_VERIFIER_HARDWARE_VERIFICATION 0x0100
  788. #define DRIVER_VERIFIER_SYSTEM_BIOS_VERIFICATION 0x0200
  789. //
  790. // System Information Classes.
  791. //
  792. typedef enum _SYSTEM_INFORMATION_CLASS {
  793. SystemBasicInformation,
  794. SystemProcessorInformation, // obsolete...delete
  795. SystemPerformanceInformation,
  796. SystemTimeOfDayInformation,
  797. SystemPathInformation,
  798. SystemProcessInformation,
  799. SystemCallCountInformation,
  800. SystemDeviceInformation,
  801. SystemProcessorPerformanceInformation,
  802. SystemFlagsInformation,
  803. SystemCallTimeInformation,
  804. SystemModuleInformation,
  805. SystemLocksInformation,
  806. SystemStackTraceInformation,
  807. SystemPagedPoolInformation,
  808. SystemNonPagedPoolInformation,
  809. SystemHandleInformation,
  810. SystemObjectInformation,
  811. SystemPageFileInformation,
  812. SystemVdmInstemulInformation,
  813. SystemVdmBopInformation,
  814. SystemFileCacheInformation,
  815. SystemPoolTagInformation,
  816. SystemInterruptInformation,
  817. SystemDpcBehaviorInformation,
  818. SystemFullMemoryInformation,
  819. SystemLoadGdiDriverInformation,
  820. SystemUnloadGdiDriverInformation,
  821. SystemTimeAdjustmentInformation,
  822. SystemSummaryMemoryInformation,
  823. SystemMirrorMemoryInformation,
  824. SystemPerformanceTraceInformation,
  825. SystemObsolete0,
  826. SystemExceptionInformation,
  827. SystemCrashDumpStateInformation,
  828. SystemKernelDebuggerInformation,
  829. SystemContextSwitchInformation,
  830. SystemRegistryQuotaInformation,
  831. SystemExtendServiceTableInformation,
  832. SystemPrioritySeperation,
  833. SystemVerifierAddDriverInformation,
  834. SystemVerifierRemoveDriverInformation,
  835. SystemProcessorIdleInformation,
  836. SystemLegacyDriverInformation,
  837. SystemCurrentTimeZoneInformation,
  838. SystemLookasideInformation,
  839. SystemTimeSlipNotification,
  840. SystemSessionCreate,
  841. SystemSessionDetach,
  842. SystemSessionInformation,
  843. SystemRangeStartInformation,
  844. SystemVerifierInformation,
  845. SystemVerifierThunkExtend,
  846. SystemSessionProcessInformation,
  847. SystemLoadGdiDriverInSystemSpace,
  848. SystemNumaProcessorMap,
  849. SystemPrefetcherInformation,
  850. SystemExtendedProcessInformation,
  851. SystemRecommendedSharedDataAlignment,
  852. SystemComPlusPackage,
  853. SystemNumaAvailableMemory,
  854. SystemProcessorPowerInformation,
  855. SystemEmulationBasicInformation,
  856. SystemEmulationProcessorInformation,
  857. SystemExtendedHandleInformation,
  858. SystemLostDelayedWriteInformation
  859. } SYSTEM_INFORMATION_CLASS;
  860. //
  861. // System Information Structures.
  862. //
  863. // begin_winnt
  864. #define TIME_ZONE_ID_UNKNOWN 0
  865. #define TIME_ZONE_ID_STANDARD 1
  866. #define TIME_ZONE_ID_DAYLIGHT 2
  867. // end_winnt
  868. typedef struct _SYSTEM_VDM_INSTEMUL_INFO {
  869. ULONG SegmentNotPresent ;
  870. ULONG VdmOpcode0F ;
  871. ULONG OpcodeESPrefix ;
  872. ULONG OpcodeCSPrefix ;
  873. ULONG OpcodeSSPrefix ;
  874. ULONG OpcodeDSPrefix ;
  875. ULONG OpcodeFSPrefix ;
  876. ULONG OpcodeGSPrefix ;
  877. ULONG OpcodeOPER32Prefix;
  878. ULONG OpcodeADDR32Prefix;
  879. ULONG OpcodeINSB ;
  880. ULONG OpcodeINSW ;
  881. ULONG OpcodeOUTSB ;
  882. ULONG OpcodeOUTSW ;
  883. ULONG OpcodePUSHF ;
  884. ULONG OpcodePOPF ;
  885. ULONG OpcodeINTnn ;
  886. ULONG OpcodeINTO ;
  887. ULONG OpcodeIRET ;
  888. ULONG OpcodeINBimm ;
  889. ULONG OpcodeINWimm ;
  890. ULONG OpcodeOUTBimm ;
  891. ULONG OpcodeOUTWimm ;
  892. ULONG OpcodeINB ;
  893. ULONG OpcodeINW ;
  894. ULONG OpcodeOUTB ;
  895. ULONG OpcodeOUTW ;
  896. ULONG OpcodeLOCKPrefix ;
  897. ULONG OpcodeREPNEPrefix ;
  898. ULONG OpcodeREPPrefix ;
  899. ULONG OpcodeHLT ;
  900. ULONG OpcodeCLI ;
  901. ULONG OpcodeSTI ;
  902. ULONG BopCount ;
  903. } SYSTEM_VDM_INSTEMUL_INFO, *PSYSTEM_VDM_INSTEMUL_INFO;
  904. typedef struct _SYSTEM_TIMEOFDAY_INFORMATION {
  905. LARGE_INTEGER BootTime;
  906. LARGE_INTEGER CurrentTime;
  907. LARGE_INTEGER TimeZoneBias;
  908. ULONG TimeZoneId;
  909. ULONG Reserved;
  910. ULONGLONG BootTimeBias;
  911. ULONGLONG SleepTimeBias;
  912. } SYSTEM_TIMEOFDAY_INFORMATION, *PSYSTEM_TIMEOFDAY_INFORMATION;
  913. typedef struct _SYSTEM_BASIC_INFORMATION {
  914. ULONG Reserved;
  915. ULONG TimerResolution;
  916. ULONG PageSize;
  917. ULONG NumberOfPhysicalPages;
  918. ULONG LowestPhysicalPageNumber;
  919. ULONG HighestPhysicalPageNumber;
  920. ULONG AllocationGranularity;
  921. ULONG_PTR MinimumUserModeAddress;
  922. ULONG_PTR MaximumUserModeAddress;
  923. ULONG_PTR ActiveProcessorsAffinityMask;
  924. CCHAR NumberOfProcessors;
  925. } SYSTEM_BASIC_INFORMATION, *PSYSTEM_BASIC_INFORMATION;
  926. typedef struct _SYSTEM_PROCESSOR_INFORMATION {
  927. USHORT ProcessorArchitecture;
  928. USHORT ProcessorLevel;
  929. USHORT ProcessorRevision;
  930. USHORT Reserved;
  931. ULONG ProcessorFeatureBits;
  932. } SYSTEM_PROCESSOR_INFORMATION, *PSYSTEM_PROCESSOR_INFORMATION;
  933. typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION {
  934. LARGE_INTEGER IdleTime;
  935. LARGE_INTEGER KernelTime;
  936. LARGE_INTEGER UserTime;
  937. LARGE_INTEGER DpcTime; // DEVL only
  938. LARGE_INTEGER InterruptTime; // DEVL only
  939. ULONG InterruptCount;
  940. } SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION, *PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION;
  941. typedef struct _SYSTEM_PROCESSOR_IDLE_INFORMATION {
  942. ULONGLONG IdleTime;
  943. ULONGLONG C1Time;
  944. ULONGLONG C2Time;
  945. ULONGLONG C3Time;
  946. ULONG C1Transitions;
  947. ULONG C2Transitions;
  948. ULONG C3Transitions;
  949. ULONG Padding;
  950. } SYSTEM_PROCESSOR_IDLE_INFORMATION, *PSYSTEM_PROCESSOR_IDLE_INFORMATION;
  951. // begin_winnt
  952. #define MAXIMUM_NUMA_NODES 16
  953. typedef struct _SYSTEM_NUMA_INFORMATION {
  954. ULONG HighestNodeNumber;
  955. ULONG Reserved;
  956. union {
  957. ULONGLONG ActiveProcessorsAffinityMask[MAXIMUM_NUMA_NODES];
  958. ULONGLONG AvailableMemory[MAXIMUM_NUMA_NODES];
  959. };
  960. } SYSTEM_NUMA_INFORMATION, *PSYSTEM_NUMA_INFORMATION;
  961. // end_winnt
  962. typedef struct _SYSTEM_PROCESSOR_POWER_INFORMATION {
  963. UCHAR CurrentFrequency;
  964. UCHAR ThermalLimitFrequency;
  965. UCHAR ConstantThrottleFrequency;
  966. UCHAR DegradedThrottleFrequency;
  967. UCHAR LastBusyFrequency;
  968. UCHAR LastC3Frequency;
  969. UCHAR LastAdjustedBusyFrequency;
  970. UCHAR ProcessorMinThrottle;
  971. UCHAR ProcessorMaxThrottle;
  972. ULONG NumberOfFrequencies;
  973. ULONG PromotionCount;
  974. ULONG DemotionCount;
  975. ULONG ErrorCount;
  976. ULONG RetryCount;
  977. ULONGLONG CurrentFrequencyTime;
  978. ULONGLONG CurrentProcessorTime;
  979. ULONGLONG CurrentProcessorIdleTime;
  980. ULONGLONG LastProcessorTime;
  981. ULONGLONG LastProcessorIdleTime;
  982. } SYSTEM_PROCESSOR_POWER_INFORMATION, *PSYSTEM_PROCESSOR_POWER_INFORMATION;
  983. typedef struct _SYSTEM_QUERY_TIME_ADJUST_INFORMATION {
  984. ULONG TimeAdjustment;
  985. ULONG TimeIncrement;
  986. BOOLEAN Enable;
  987. } SYSTEM_QUERY_TIME_ADJUST_INFORMATION, *PSYSTEM_QUERY_TIME_ADJUST_INFORMATION;
  988. typedef struct _SYSTEM_SET_TIME_ADJUST_INFORMATION {
  989. ULONG TimeAdjustment;
  990. BOOLEAN Enable;
  991. } SYSTEM_SET_TIME_ADJUST_INFORMATION, *PSYSTEM_SET_TIME_ADJUST_INFORMATION;
  992. typedef struct _SYSTEM_PERFORMANCE_INFORMATION {
  993. LARGE_INTEGER IdleProcessTime;
  994. LARGE_INTEGER IoReadTransferCount;
  995. LARGE_INTEGER IoWriteTransferCount;
  996. LARGE_INTEGER IoOtherTransferCount;
  997. ULONG IoReadOperationCount;
  998. ULONG IoWriteOperationCount;
  999. ULONG IoOtherOperationCount;
  1000. ULONG AvailablePages;
  1001. ULONG CommittedPages;
  1002. ULONG CommitLimit;
  1003. ULONG PeakCommitment;
  1004. ULONG PageFaultCount;
  1005. ULONG CopyOnWriteCount;
  1006. ULONG TransitionCount;
  1007. ULONG CacheTransitionCount;
  1008. ULONG DemandZeroCount;
  1009. ULONG PageReadCount;
  1010. ULONG PageReadIoCount;
  1011. ULONG CacheReadCount;
  1012. ULONG CacheIoCount;
  1013. ULONG DirtyPagesWriteCount;
  1014. ULONG DirtyWriteIoCount;
  1015. ULONG MappedPagesWriteCount;
  1016. ULONG MappedWriteIoCount;
  1017. ULONG PagedPoolPages;
  1018. ULONG NonPagedPoolPages;
  1019. ULONG PagedPoolAllocs;
  1020. ULONG PagedPoolFrees;
  1021. ULONG NonPagedPoolAllocs;
  1022. ULONG NonPagedPoolFrees;
  1023. ULONG FreeSystemPtes;
  1024. ULONG ResidentSystemCodePage;
  1025. ULONG TotalSystemDriverPages;
  1026. ULONG TotalSystemCodePages;
  1027. ULONG NonPagedPoolLookasideHits;
  1028. ULONG PagedPoolLookasideHits;
  1029. ULONG AvailablePagedPoolPages;
  1030. ULONG ResidentSystemCachePage;
  1031. ULONG ResidentPagedPoolPage;
  1032. ULONG ResidentSystemDriverPage;
  1033. ULONG CcFastReadNoWait;
  1034. ULONG CcFastReadWait;
  1035. ULONG CcFastReadResourceMiss;
  1036. ULONG CcFastReadNotPossible;
  1037. ULONG CcFastMdlReadNoWait;
  1038. ULONG CcFastMdlReadWait;
  1039. ULONG CcFastMdlReadResourceMiss;
  1040. ULONG CcFastMdlReadNotPossible;
  1041. ULONG CcMapDataNoWait;
  1042. ULONG CcMapDataWait;
  1043. ULONG CcMapDataNoWaitMiss;
  1044. ULONG CcMapDataWaitMiss;
  1045. ULONG CcPinMappedDataCount;
  1046. ULONG CcPinReadNoWait;
  1047. ULONG CcPinReadWait;
  1048. ULONG CcPinReadNoWaitMiss;
  1049. ULONG CcPinReadWaitMiss;
  1050. ULONG CcCopyReadNoWait;
  1051. ULONG CcCopyReadWait;
  1052. ULONG CcCopyReadNoWaitMiss;
  1053. ULONG CcCopyReadWaitMiss;
  1054. ULONG CcMdlReadNoWait;
  1055. ULONG CcMdlReadWait;
  1056. ULONG CcMdlReadNoWaitMiss;
  1057. ULONG CcMdlReadWaitMiss;
  1058. ULONG CcReadAheadIos;
  1059. ULONG CcLazyWriteIos;
  1060. ULONG CcLazyWritePages;
  1061. ULONG CcDataFlushes;
  1062. ULONG CcDataPages;
  1063. ULONG ContextSwitches;
  1064. ULONG FirstLevelTbFills;
  1065. ULONG SecondLevelTbFills;
  1066. ULONG SystemCalls;
  1067. } SYSTEM_PERFORMANCE_INFORMATION, *PSYSTEM_PERFORMANCE_INFORMATION;
  1068. typedef struct _SYSTEM_PROCESS_INFORMATION {
  1069. ULONG NextEntryOffset;
  1070. ULONG NumberOfThreads;
  1071. LARGE_INTEGER SpareLi1;
  1072. LARGE_INTEGER SpareLi2;
  1073. LARGE_INTEGER SpareLi3;
  1074. LARGE_INTEGER CreateTime;
  1075. LARGE_INTEGER UserTime;
  1076. LARGE_INTEGER KernelTime;
  1077. UNICODE_STRING ImageName;
  1078. KPRIORITY BasePriority;
  1079. HANDLE UniqueProcessId;
  1080. HANDLE InheritedFromUniqueProcessId;
  1081. ULONG HandleCount;
  1082. ULONG SessionId;
  1083. ULONG_PTR PageDirectoryBase;
  1084. SIZE_T PeakVirtualSize;
  1085. SIZE_T VirtualSize;
  1086. ULONG PageFaultCount;
  1087. SIZE_T PeakWorkingSetSize;
  1088. SIZE_T WorkingSetSize;
  1089. SIZE_T QuotaPeakPagedPoolUsage;
  1090. SIZE_T QuotaPagedPoolUsage;
  1091. SIZE_T QuotaPeakNonPagedPoolUsage;
  1092. SIZE_T QuotaNonPagedPoolUsage;
  1093. SIZE_T PagefileUsage;
  1094. SIZE_T PeakPagefileUsage;
  1095. SIZE_T PrivatePageCount;
  1096. LARGE_INTEGER ReadOperationCount;
  1097. LARGE_INTEGER WriteOperationCount;
  1098. LARGE_INTEGER OtherOperationCount;
  1099. LARGE_INTEGER ReadTransferCount;
  1100. LARGE_INTEGER WriteTransferCount;
  1101. LARGE_INTEGER OtherTransferCount;
  1102. } SYSTEM_PROCESS_INFORMATION, *PSYSTEM_PROCESS_INFORMATION;
  1103. typedef struct _SYSTEM_SESSION_PROCESS_INFORMATION {
  1104. ULONG SessionId;
  1105. ULONG SizeOfBuf;
  1106. PVOID Buffer;
  1107. } SYSTEM_SESSION_PROCESS_INFORMATION, *PSYSTEM_SESSION_PROCESS_INFORMATION;
  1108. typedef struct _SYSTEM_THREAD_INFORMATION {
  1109. LARGE_INTEGER KernelTime;
  1110. LARGE_INTEGER UserTime;
  1111. LARGE_INTEGER CreateTime;
  1112. ULONG WaitTime;
  1113. PVOID StartAddress;
  1114. CLIENT_ID ClientId;
  1115. KPRIORITY Priority;
  1116. LONG BasePriority;
  1117. ULONG ContextSwitches;
  1118. ULONG ThreadState;
  1119. ULONG WaitReason;
  1120. } SYSTEM_THREAD_INFORMATION, *PSYSTEM_THREAD_INFORMATION;
  1121. typedef struct _SYSTEM_EXTENDED_THREAD_INFORMATION {
  1122. SYSTEM_THREAD_INFORMATION ThreadInfo;
  1123. PVOID StackBase;
  1124. PVOID StackLimit;
  1125. PVOID Win32StartAddress;
  1126. ULONG_PTR Reserved1;
  1127. ULONG_PTR Reserved2;
  1128. ULONG_PTR Reserved3;
  1129. ULONG_PTR Reserved4;
  1130. } SYSTEM_EXTENDED_THREAD_INFORMATION, *PSYSTEM_EXTENDED_THREAD_INFORMATION;
  1131. typedef struct _SYSTEM_MEMORY_INFO {
  1132. PUCHAR StringOffset;
  1133. USHORT ValidCount;
  1134. USHORT TransitionCount;
  1135. USHORT ModifiedCount;
  1136. USHORT PageTableCount;
  1137. } SYSTEM_MEMORY_INFO, *PSYSTEM_MEMORY_INFO;
  1138. typedef struct _SYSTEM_MEMORY_INFORMATION {
  1139. ULONG InfoSize;
  1140. ULONG_PTR StringStart;
  1141. SYSTEM_MEMORY_INFO Memory[1];
  1142. } SYSTEM_MEMORY_INFORMATION, *PSYSTEM_MEMORY_INFORMATION;
  1143. typedef struct _SYSTEM_CALL_COUNT_INFORMATION {
  1144. ULONG Length;
  1145. ULONG NumberOfTables;
  1146. //ULONG NumberOfEntries[NumberOfTables];
  1147. //ULONG CallCounts[NumberOfTables][NumberOfEntries];
  1148. } SYSTEM_CALL_COUNT_INFORMATION, *PSYSTEM_CALL_COUNT_INFORMATION;
  1149. typedef struct _SYSTEM_DEVICE_INFORMATION {
  1150. ULONG NumberOfDisks;
  1151. ULONG NumberOfFloppies;
  1152. ULONG NumberOfCdRoms;
  1153. ULONG NumberOfTapes;
  1154. ULONG NumberOfSerialPorts;
  1155. ULONG NumberOfParallelPorts;
  1156. } SYSTEM_DEVICE_INFORMATION, *PSYSTEM_DEVICE_INFORMATION;
  1157. typedef struct _SYSTEM_EXCEPTION_INFORMATION {
  1158. ULONG AlignmentFixupCount;
  1159. ULONG ExceptionDispatchCount;
  1160. ULONG FloatingEmulationCount;
  1161. ULONG ByteWordEmulationCount;
  1162. } SYSTEM_EXCEPTION_INFORMATION, *PSYSTEM_EXCEPTION_INFORMATION;
  1163. typedef struct _SYSTEM_KERNEL_DEBUGGER_INFORMATION {
  1164. BOOLEAN KernelDebuggerEnabled;
  1165. BOOLEAN KernelDebuggerNotPresent;
  1166. } SYSTEM_KERNEL_DEBUGGER_INFORMATION, *PSYSTEM_KERNEL_DEBUGGER_INFORMATION;
  1167. typedef struct _SYSTEM_REGISTRY_QUOTA_INFORMATION {
  1168. ULONG RegistryQuotaAllowed;
  1169. ULONG RegistryQuotaUsed;
  1170. SIZE_T PagedPoolSize;
  1171. } SYSTEM_REGISTRY_QUOTA_INFORMATION, *PSYSTEM_REGISTRY_QUOTA_INFORMATION;
  1172. typedef struct _SYSTEM_GDI_DRIVER_INFORMATION {
  1173. UNICODE_STRING DriverName;
  1174. PVOID ImageAddress;
  1175. PVOID SectionPointer;
  1176. PVOID EntryPoint;
  1177. PIMAGE_EXPORT_DIRECTORY ExportSectionPointer;
  1178. ULONG ImageLength;
  1179. } SYSTEM_GDI_DRIVER_INFORMATION, *PSYSTEM_GDI_DRIVER_INFORMATION;
  1180. #if DEVL
  1181. typedef struct _SYSTEM_FLAGS_INFORMATION {
  1182. ULONG Flags;
  1183. } SYSTEM_FLAGS_INFORMATION, *PSYSTEM_FLAGS_INFORMATION;
  1184. typedef struct _SYSTEM_CALL_TIME_INFORMATION {
  1185. ULONG Length;
  1186. ULONG TotalCalls;
  1187. LARGE_INTEGER TimeOfCalls[1];
  1188. } SYSTEM_CALL_TIME_INFORMATION, *PSYSTEM_CALL_TIME_INFORMATION;
  1189. typedef struct _SYSTEM_HANDLE_TABLE_ENTRY_INFO {
  1190. USHORT UniqueProcessId;
  1191. USHORT CreatorBackTraceIndex;
  1192. UCHAR ObjectTypeIndex;
  1193. UCHAR HandleAttributes;
  1194. USHORT HandleValue;
  1195. PVOID Object;
  1196. ULONG GrantedAccess;
  1197. } SYSTEM_HANDLE_TABLE_ENTRY_INFO, *PSYSTEM_HANDLE_TABLE_ENTRY_INFO;
  1198. typedef struct _SYSTEM_HANDLE_INFORMATION {
  1199. ULONG NumberOfHandles;
  1200. SYSTEM_HANDLE_TABLE_ENTRY_INFO Handles[ 1 ];
  1201. } SYSTEM_HANDLE_INFORMATION, *PSYSTEM_HANDLE_INFORMATION;
  1202. typedef struct _SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX {
  1203. PVOID Object;
  1204. ULONG_PTR UniqueProcessId;
  1205. ULONG_PTR HandleValue;
  1206. ULONG GrantedAccess;
  1207. USHORT CreatorBackTraceIndex;
  1208. USHORT ObjectTypeIndex;
  1209. ULONG HandleAttributes;
  1210. ULONG Reserved;
  1211. } SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX, *PSYSTEM_HANDLE_TABLE_ENTRY_INFO_EX;
  1212. typedef struct _SYSTEM_HANDLE_INFORMATION_EX {
  1213. ULONG_PTR NumberOfHandles;
  1214. ULONG_PTR Reserved;
  1215. SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX Handles[ 1 ];
  1216. } SYSTEM_HANDLE_INFORMATION_EX, *PSYSTEM_HANDLE_INFORMATION_EX;
  1217. typedef struct _SYSTEM_OBJECTTYPE_INFORMATION {
  1218. ULONG NextEntryOffset;
  1219. ULONG NumberOfObjects;
  1220. ULONG NumberOfHandles;
  1221. ULONG TypeIndex;
  1222. ULONG InvalidAttributes;
  1223. GENERIC_MAPPING GenericMapping;
  1224. ULONG ValidAccessMask;
  1225. ULONG PoolType;
  1226. BOOLEAN SecurityRequired;
  1227. BOOLEAN WaitableObject;
  1228. UNICODE_STRING TypeName;
  1229. } SYSTEM_OBJECTTYPE_INFORMATION, *PSYSTEM_OBJECTTYPE_INFORMATION;
  1230. typedef struct _SYSTEM_OBJECT_INFORMATION {
  1231. ULONG NextEntryOffset;
  1232. PVOID Object;
  1233. HANDLE CreatorUniqueProcess;
  1234. USHORT CreatorBackTraceIndex;
  1235. USHORT Flags;
  1236. LONG PointerCount;
  1237. LONG HandleCount;
  1238. ULONG PagedPoolCharge;
  1239. ULONG NonPagedPoolCharge;
  1240. HANDLE ExclusiveProcessId;
  1241. PVOID SecurityDescriptor;
  1242. OBJECT_NAME_INFORMATION NameInfo;
  1243. } SYSTEM_OBJECT_INFORMATION, *PSYSTEM_OBJECT_INFORMATION;
  1244. typedef struct _SYSTEM_PAGEFILE_INFORMATION {
  1245. ULONG NextEntryOffset;
  1246. ULONG TotalSize;
  1247. ULONG TotalInUse;
  1248. ULONG PeakUsage;
  1249. UNICODE_STRING PageFileName;
  1250. } SYSTEM_PAGEFILE_INFORMATION, *PSYSTEM_PAGEFILE_INFORMATION;
  1251. typedef struct _SYSTEM_VERIFIER_INFORMATION {
  1252. ULONG NextEntryOffset;
  1253. ULONG Level;
  1254. UNICODE_STRING DriverName;
  1255. ULONG RaiseIrqls;
  1256. ULONG AcquireSpinLocks;
  1257. ULONG SynchronizeExecutions;
  1258. ULONG AllocationsAttempted;
  1259. ULONG AllocationsSucceeded;
  1260. ULONG AllocationsSucceededSpecialPool;
  1261. ULONG AllocationsWithNoTag;
  1262. ULONG TrimRequests;
  1263. ULONG Trims;
  1264. ULONG AllocationsFailed;
  1265. ULONG AllocationsFailedDeliberately;
  1266. ULONG Loads;
  1267. ULONG Unloads;
  1268. ULONG UnTrackedPool;
  1269. ULONG CurrentPagedPoolAllocations;
  1270. ULONG CurrentNonPagedPoolAllocations;
  1271. ULONG PeakPagedPoolAllocations;
  1272. ULONG PeakNonPagedPoolAllocations;
  1273. SIZE_T PagedPoolUsageInBytes;
  1274. SIZE_T NonPagedPoolUsageInBytes;
  1275. SIZE_T PeakPagedPoolUsageInBytes;
  1276. SIZE_T PeakNonPagedPoolUsageInBytes;
  1277. } SYSTEM_VERIFIER_INFORMATION, *PSYSTEM_VERIFIER_INFORMATION;
  1278. typedef struct _SYSTEM_FILECACHE_INFORMATION {
  1279. SIZE_T CurrentSize;
  1280. SIZE_T PeakSize;
  1281. ULONG PageFaultCount;
  1282. SIZE_T MinimumWorkingSet;
  1283. SIZE_T MaximumWorkingSet;
  1284. SIZE_T CurrentSizeIncludingTransitionInPages;
  1285. SIZE_T PeakSizeIncludingTransitionInPages;
  1286. ULONG spare[2];
  1287. } SYSTEM_FILECACHE_INFORMATION, *PSYSTEM_FILECACHE_INFORMATION;
  1288. #if _MSC_VER >= 1200
  1289. #pragma warning(push)
  1290. #endif
  1291. #pragma warning(disable:4201) // unnamed struct/union
  1292. typedef struct _SYSTEM_POOL_ENTRY {
  1293. BOOLEAN Allocated;
  1294. BOOLEAN Spare0;
  1295. USHORT AllocatorBackTraceIndex;
  1296. ULONG Size;
  1297. union {
  1298. UCHAR Tag[4];
  1299. ULONG TagUlong;
  1300. PVOID ProcessChargedQuota;
  1301. };
  1302. } SYSTEM_POOL_ENTRY, *PSYSTEM_POOL_ENTRY;
  1303. typedef struct _SYSTEM_POOL_INFORMATION {
  1304. SIZE_T TotalSize;
  1305. PVOID FirstEntry;
  1306. USHORT EntryOverhead;
  1307. BOOLEAN PoolTagPresent;
  1308. BOOLEAN Spare0;
  1309. ULONG NumberOfEntries;
  1310. SYSTEM_POOL_ENTRY Entries[1];
  1311. } SYSTEM_POOL_INFORMATION, *PSYSTEM_POOL_INFORMATION;
  1312. typedef struct _SYSTEM_POOLTAG {
  1313. union {
  1314. UCHAR Tag[4];
  1315. ULONG TagUlong;
  1316. };
  1317. ULONG PagedAllocs;
  1318. ULONG PagedFrees;
  1319. SIZE_T PagedUsed;
  1320. ULONG NonPagedAllocs;
  1321. ULONG NonPagedFrees;
  1322. SIZE_T NonPagedUsed;
  1323. } SYSTEM_POOLTAG, *PSYSTEM_POOLTAG;
  1324. #if _MSC_VER >= 1200
  1325. #pragma warning(pop)
  1326. #else
  1327. #pragma warning( default : 4201 )
  1328. #endif
  1329. typedef struct _SYSTEM_POOLTAG_INFORMATION {
  1330. ULONG Count;
  1331. SYSTEM_POOLTAG TagInfo[1];
  1332. } SYSTEM_POOLTAG_INFORMATION, *PSYSTEM_POOLTAG_INFORMATION;
  1333. typedef struct _SYSTEM_CONTEXT_SWITCH_INFORMATION {
  1334. ULONG ContextSwitches;
  1335. ULONG FindAny;
  1336. ULONG FindLast;
  1337. ULONG FindIdeal;
  1338. ULONG IdleAny;
  1339. ULONG IdleCurrent;
  1340. ULONG IdleLast;
  1341. ULONG IdleIdeal;
  1342. ULONG PreemptAny;
  1343. ULONG PreemptCurrent;
  1344. ULONG PreemptLast;
  1345. ULONG SwitchToIdle;
  1346. } SYSTEM_CONTEXT_SWITCH_INFORMATION, *PSYSTEM_CONTEXT_SWITCH_INFORMATION;
  1347. typedef struct _SYSTEM_INTERRUPT_INFORMATION {
  1348. ULONG ContextSwitches;
  1349. ULONG DpcCount;
  1350. ULONG DpcRate;
  1351. ULONG TimeIncrement;
  1352. ULONG DpcBypassCount;
  1353. ULONG ApcBypassCount;
  1354. } SYSTEM_INTERRUPT_INFORMATION, *PSYSTEM_INTERRUPT_INFORMATION;
  1355. typedef struct _SYSTEM_DPC_BEHAVIOR_INFORMATION {
  1356. ULONG Spare;
  1357. ULONG DpcQueueDepth;
  1358. ULONG MinimumDpcRate;
  1359. ULONG AdjustDpcThreshold;
  1360. ULONG IdealDpcRate;
  1361. } SYSTEM_DPC_BEHAVIOR_INFORMATION, *PSYSTEM_DPC_BEHAVIOR_INFORMATION;
  1362. #endif // DEVL
  1363. typedef struct _SYSTEM_LOOKASIDE_INFORMATION {
  1364. USHORT CurrentDepth;
  1365. USHORT MaximumDepth;
  1366. ULONG TotalAllocates;
  1367. ULONG AllocateMisses;
  1368. ULONG TotalFrees;
  1369. ULONG FreeMisses;
  1370. ULONG Type;
  1371. ULONG Tag;
  1372. ULONG Size;
  1373. } SYSTEM_LOOKASIDE_INFORMATION, *PSYSTEM_LOOKASIDE_INFORMATION;
  1374. typedef struct _SYSTEM_LEGACY_DRIVER_INFORMATION {
  1375. ULONG VetoType;
  1376. UNICODE_STRING VetoList;
  1377. } SYSTEM_LEGACY_DRIVER_INFORMATION, *PSYSTEM_LEGACY_DRIVER_INFORMATION;
  1378. // begin_winnt
  1379. #define PROCESSOR_INTEL_386 386
  1380. #define PROCESSOR_INTEL_486 486
  1381. #define PROCESSOR_INTEL_PENTIUM 586
  1382. #define PROCESSOR_INTEL_IA64 2200
  1383. #define PROCESSOR_MIPS_R4000 4000 // incl R4101 & R3910 for Windows CE
  1384. #define PROCESSOR_ALPHA_21064 21064
  1385. #define PROCESSOR_PPC_601 601
  1386. #define PROCESSOR_PPC_603 603
  1387. #define PROCESSOR_PPC_604 604
  1388. #define PROCESSOR_PPC_620 620
  1389. #define PROCESSOR_HITACHI_SH3 10003 // Windows CE
  1390. #define PROCESSOR_HITACHI_SH3E 10004 // Windows CE
  1391. #define PROCESSOR_HITACHI_SH4 10005 // Windows CE
  1392. #define PROCESSOR_MOTOROLA_821 821 // Windows CE
  1393. #define PROCESSOR_SHx_SH3 103 // Windows CE
  1394. #define PROCESSOR_SHx_SH4 104 // Windows CE
  1395. #define PROCESSOR_STRONGARM 2577 // Windows CE - 0xA11
  1396. #define PROCESSOR_ARM720 1824 // Windows CE - 0x720
  1397. #define PROCESSOR_ARM820 2080 // Windows CE - 0x820
  1398. #define PROCESSOR_ARM920 2336 // Windows CE - 0x920
  1399. #define PROCESSOR_ARM_7TDMI 70001 // Windows CE
  1400. #define PROCESSOR_OPTIL 0x494f // MSIL
  1401. #define PROCESSOR_ARCHITECTURE_INTEL 0
  1402. #define PROCESSOR_ARCHITECTURE_MIPS 1
  1403. #define PROCESSOR_ARCHITECTURE_ALPHA 2
  1404. #define PROCESSOR_ARCHITECTURE_PPC 3
  1405. #define PROCESSOR_ARCHITECTURE_SHX 4
  1406. #define PROCESSOR_ARCHITECTURE_ARM 5
  1407. #define PROCESSOR_ARCHITECTURE_IA64 6
  1408. #define PROCESSOR_ARCHITECTURE_ALPHA64 7
  1409. #define PROCESSOR_ARCHITECTURE_MSIL 8
  1410. #define PROCESSOR_ARCHITECTURE_AMD64 9
  1411. #define PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 10
  1412. #define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF
  1413. // end_winnt
  1414. NTSYSCALLAPI
  1415. NTSTATUS
  1416. NTAPI
  1417. NtQuerySystemInformation (
  1418. IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
  1419. OUT PVOID SystemInformation,
  1420. IN ULONG SystemInformationLength,
  1421. OUT PULONG ReturnLength OPTIONAL
  1422. );
  1423. NTSYSCALLAPI
  1424. NTSTATUS
  1425. NTAPI
  1426. NtSetSystemInformation (
  1427. IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
  1428. IN PVOID SystemInformation,
  1429. IN ULONG SystemInformationLength
  1430. );
  1431. //
  1432. // SysDbg APIs are available to user-mode processes via
  1433. // NtSystemDebugControl.
  1434. //
  1435. typedef enum _SYSDBG_COMMAND {
  1436. SysDbgQueryModuleInformation,
  1437. SysDbgQueryTraceInformation,
  1438. SysDbgSetTracepoint,
  1439. SysDbgSetSpecialCall,
  1440. SysDbgClearSpecialCalls,
  1441. SysDbgQuerySpecialCalls,
  1442. SysDbgBreakPoint,
  1443. SysDbgQueryVersion,
  1444. SysDbgReadVirtual,
  1445. SysDbgWriteVirtual,
  1446. SysDbgReadPhysical,
  1447. SysDbgWritePhysical,
  1448. SysDbgReadControlSpace,
  1449. SysDbgWriteControlSpace,
  1450. SysDbgReadIoSpace,
  1451. SysDbgWriteIoSpace,
  1452. SysDbgReadMsr,
  1453. SysDbgWriteMsr,
  1454. SysDbgReadBusData,
  1455. SysDbgWriteBusData,
  1456. SysDbgCheckLowMemory
  1457. } SYSDBG_COMMAND, *PSYSDBG_COMMAND;
  1458. typedef struct _SYSDBG_VIRTUAL {
  1459. PVOID Address;
  1460. PVOID Buffer;
  1461. ULONG Request;
  1462. } SYSDBG_VIRTUAL, *PSYSDBG_VIRTUAL;
  1463. typedef struct _SYSDBG_PHYSICAL {
  1464. PHYSICAL_ADDRESS Address;
  1465. PVOID Buffer;
  1466. ULONG Request;
  1467. } SYSDBG_PHYSICAL, *PSYSDBG_PHYSICAL;
  1468. typedef struct _SYSDBG_CONTROL_SPACE {
  1469. ULONG64 Address;
  1470. PVOID Buffer;
  1471. ULONG Request;
  1472. ULONG Processor;
  1473. } SYSDBG_CONTROL_SPACE, *PSYSDBG_CONTROL_SPACE;
  1474. typedef struct _SYSDBG_IO_SPACE {
  1475. ULONG64 Address;
  1476. PVOID Buffer;
  1477. ULONG Request;
  1478. INTERFACE_TYPE InterfaceType;
  1479. ULONG BusNumber;
  1480. ULONG AddressSpace;
  1481. } SYSDBG_IO_SPACE, *PSYSDBG_IO_SPACE;
  1482. typedef struct _SYSDBG_MSR {
  1483. ULONG Msr;
  1484. ULONG64 Data;
  1485. } SYSDBG_MSR, *PSYSDBG_MSR;
  1486. typedef struct _SYSDBG_BUS_DATA {
  1487. ULONG Address;
  1488. PVOID Buffer;
  1489. ULONG Request;
  1490. BUS_DATA_TYPE BusDataType;
  1491. ULONG BusNumber;
  1492. ULONG SlotNumber;
  1493. } SYSDBG_BUS_DATA, *PSYSDBG_BUS_DATA;
  1494. NTSYSCALLAPI
  1495. NTSTATUS
  1496. NTAPI
  1497. NtSystemDebugControl (
  1498. IN SYSDBG_COMMAND Command,
  1499. IN PVOID InputBuffer,
  1500. IN ULONG InputBufferLength,
  1501. OUT PVOID OutputBuffer,
  1502. IN ULONG OutputBufferLength,
  1503. OUT PULONG ReturnLength
  1504. );
  1505. typedef enum _HARDERROR_RESPONSE_OPTION {
  1506. OptionAbortRetryIgnore,
  1507. OptionOk,
  1508. OptionOkCancel,
  1509. OptionRetryCancel,
  1510. OptionYesNo,
  1511. OptionYesNoCancel,
  1512. OptionShutdownSystem,
  1513. OptionOkNoWait,
  1514. OptionCancelTryContinue
  1515. } HARDERROR_RESPONSE_OPTION;
  1516. typedef enum _HARDERROR_RESPONSE {
  1517. ResponseReturnToCaller,
  1518. ResponseNotHandled,
  1519. ResponseAbort,
  1520. ResponseCancel,
  1521. ResponseIgnore,
  1522. ResponseNo,
  1523. ResponseOk,
  1524. ResponseRetry,
  1525. ResponseYes,
  1526. ResponseTryAgain,
  1527. ResponseContinue
  1528. } HARDERROR_RESPONSE;
  1529. #define HARDERROR_PARAMETERS_FLAGSPOS 4
  1530. #define HARDERROR_FLAGS_DEFDESKTOPONLY 0x00020000
  1531. #define MAXIMUM_HARDERROR_PARAMETERS 5
  1532. #define HARDERROR_OVERRIDE_ERRORMODE 0x10000000
  1533. typedef struct _HARDERROR_MSG {
  1534. PORT_MESSAGE h;
  1535. NTSTATUS Status;
  1536. LARGE_INTEGER ErrorTime;
  1537. ULONG ValidResponseOptions;
  1538. ULONG Response;
  1539. ULONG NumberOfParameters;
  1540. ULONG UnicodeStringParameterMask;
  1541. ULONG_PTR Parameters[MAXIMUM_HARDERROR_PARAMETERS];
  1542. } HARDERROR_MSG, *PHARDERROR_MSG;
  1543. NTSYSCALLAPI
  1544. NTSTATUS
  1545. NTAPI
  1546. NtRaiseHardError(
  1547. IN NTSTATUS ErrorStatus,
  1548. IN ULONG NumberOfParameters,
  1549. IN ULONG UnicodeStringParameterMask,
  1550. IN PULONG_PTR Parameters,
  1551. IN ULONG ValidResponseOptions,
  1552. OUT PULONG Response
  1553. );
  1554. // begin_wdm begin_ntddk begin_nthal begin_ntifs
  1555. //
  1556. // Defined processor features
  1557. //
  1558. #define PF_FLOATING_POINT_PRECISION_ERRATA 0 // winnt
  1559. #define PF_FLOATING_POINT_EMULATED 1 // winnt
  1560. #define PF_COMPARE_EXCHANGE_DOUBLE 2 // winnt
  1561. #define PF_MMX_INSTRUCTIONS_AVAILABLE 3 // winnt
  1562. #define PF_PPC_MOVEMEM_64BIT_OK 4 // winnt
  1563. #define PF_ALPHA_BYTE_INSTRUCTIONS 5 // winnt
  1564. #define PF_XMMI_INSTRUCTIONS_AVAILABLE 6 // winnt
  1565. #define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7 // winnt
  1566. #define PF_RDTSC_INSTRUCTION_AVAILABLE 8 // winnt
  1567. #define PF_PAE_ENABLED 9 // winnt
  1568. #define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10 // winnt
  1569. typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE {
  1570. StandardDesign, // None == 0 == standard design
  1571. NEC98x86, // NEC PC98xx series on X86
  1572. EndAlternatives // past end of known alternatives
  1573. } ALTERNATIVE_ARCHITECTURE_TYPE;
  1574. // correctly define these run-time definitions for non X86 machines
  1575. #ifndef _X86_
  1576. #ifndef IsNEC_98
  1577. #define IsNEC_98 (FALSE)
  1578. #endif
  1579. #ifndef IsNotNEC_98
  1580. #define IsNotNEC_98 (TRUE)
  1581. #endif
  1582. #ifndef SetNEC_98
  1583. #define SetNEC_98
  1584. #endif
  1585. #ifndef SetNotNEC_98
  1586. #define SetNotNEC_98
  1587. #endif
  1588. #endif
  1589. #define PROCESSOR_FEATURE_MAX 64
  1590. // end_wdm
  1591. #if defined(REMOTE_BOOT)
  1592. //
  1593. // Defined system flags.
  1594. //
  1595. /* the following two lines should be tagged with "winnt" when REMOTE_BOOT is on. */
  1596. #define SYSTEM_FLAG_REMOTE_BOOT_CLIENT 0x00000001
  1597. #define SYSTEM_FLAG_DISKLESS_CLIENT 0x00000002
  1598. #endif // defined(REMOTE_BOOT)
  1599. //
  1600. // Define data shared between kernel and user mode.
  1601. //
  1602. // N.B. User mode has read only access to this data
  1603. //
  1604. #ifdef _MAC
  1605. #pragma warning( disable : 4121)
  1606. #endif
  1607. //
  1608. // Note: When adding a new field that's processor-architecture-specific (for example, bound with #if i386),
  1609. // then place this field to be the last element in the KUSER_SHARED_DATA so that offsets into common
  1610. // fields are the same for Wow6432 and Win64.
  1611. //
  1612. typedef struct _KUSER_SHARED_DATA {
  1613. //
  1614. // Current low 32-bit of tick count and tick count multiplier.
  1615. //
  1616. // N.B. The tick count is updated each time the clock ticks.
  1617. //
  1618. volatile ULONG TickCountLow;
  1619. ULONG TickCountMultiplier;
  1620. //
  1621. // Current 64-bit interrupt time in 100ns units.
  1622. //
  1623. volatile KSYSTEM_TIME InterruptTime;
  1624. //
  1625. // Current 64-bit system time in 100ns units.
  1626. //
  1627. volatile KSYSTEM_TIME SystemTime;
  1628. //
  1629. // Current 64-bit time zone bias.
  1630. //
  1631. volatile KSYSTEM_TIME TimeZoneBias;
  1632. //
  1633. // Support image magic number range for the host system.
  1634. //
  1635. // N.B. This is an inclusive range.
  1636. //
  1637. USHORT ImageNumberLow;
  1638. USHORT ImageNumberHigh;
  1639. //
  1640. // Copy of system root in Unicode
  1641. //
  1642. WCHAR NtSystemRoot[ 260 ];
  1643. //
  1644. // Maximum stack trace depth if tracing enabled.
  1645. //
  1646. ULONG MaxStackTraceDepth;
  1647. //
  1648. // Crypto Exponent
  1649. //
  1650. ULONG CryptoExponent;
  1651. //
  1652. // TimeZoneId
  1653. //
  1654. ULONG TimeZoneId;
  1655. ULONG Reserved2[ 8 ];
  1656. //
  1657. // product type
  1658. //
  1659. NT_PRODUCT_TYPE NtProductType;
  1660. BOOLEAN ProductTypeIsValid;
  1661. //
  1662. // NT Version. Note that each process sees a version from its PEB, but
  1663. // if the process is running with an altered view of the system version,
  1664. // the following two fields are used to correctly identify the version
  1665. //
  1666. ULONG NtMajorVersion;
  1667. ULONG NtMinorVersion;
  1668. //
  1669. // Processor Feature Bits
  1670. //
  1671. BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
  1672. //
  1673. // Reserved fields - do not use
  1674. //
  1675. ULONG Reserved1;
  1676. ULONG Reserved3;
  1677. //
  1678. // Time slippage while in debugger
  1679. //
  1680. volatile ULONG TimeSlip;
  1681. //
  1682. // Alternative system architecture. Example: NEC PC98xx on x86
  1683. //
  1684. ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
  1685. //
  1686. // If the system is an evaluation unit, the following field contains the
  1687. // date and time that the evaluation unit expires. A value of 0 indicates
  1688. // that there is no expiration. A non-zero value is the UTC absolute time
  1689. // that the system expires.
  1690. //
  1691. LARGE_INTEGER SystemExpirationDate;
  1692. //
  1693. // Suite Support
  1694. //
  1695. ULONG SuiteMask;
  1696. //
  1697. // TRUE if a kernel debugger is connected/enabled
  1698. //
  1699. BOOLEAN KdDebuggerEnabled;
  1700. //
  1701. // Current console session Id. Always zero on non-TS systems
  1702. //
  1703. volatile ULONG ActiveConsoleId;
  1704. //
  1705. // Force-dismounts cause handles to become invalid. Rather than
  1706. // always probe handles, we maintain a serial number of
  1707. // dismounts that clients can use to see if they need to probe
  1708. // handles.
  1709. //
  1710. volatile ULONG DismountCount;
  1711. //
  1712. // This field indicates the status of the 64-bit COM+ package on the system.
  1713. // It indicates whether the Itermediate Language (IL) COM+ images need to
  1714. // use the 64-bit COM+ runtime or the 32-bit COM+ runtime.
  1715. //
  1716. ULONG ComPlusPackage;
  1717. //
  1718. // Time in tick count for system-wide last user input across all
  1719. // terminal sessions. For MP performance, it is not updated all
  1720. // the time (e.g. once a minute per session). It is used for idle
  1721. // detection.
  1722. //
  1723. ULONG LastSystemRITEventTickCount;
  1724. //
  1725. // Number of physical pages in the system. This can dynamically
  1726. // change as physical memory can be added or removed from a running
  1727. // system.
  1728. //
  1729. ULONG NumberOfPhysicalPages;
  1730. //
  1731. // True if the system was booted in safe boot mode.
  1732. //
  1733. BOOLEAN SafeBootMode;
  1734. //
  1735. // The following field is used for Heap and CritSec Tracing
  1736. // The last bit is set for Critical Sec Collision tracing and
  1737. // second Last bit is for Heap Tracing
  1738. // Also the first 16 bits are used as counter.
  1739. //
  1740. ULONG TraceLogging;
  1741. #if defined(i386)
  1742. //
  1743. // Depending on the processor, the code for fast system call
  1744. // will differ, the following buffer is filled with the appropriate
  1745. // code sequence and user mode code will branch through it.
  1746. //
  1747. // (32 bytes, using ULONGLONG for alignment).
  1748. //
  1749. ULONGLONG Fill0; // alignment
  1750. ULONGLONG SystemCall[4];
  1751. #endif
  1752. } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
  1753. #ifdef _MAC
  1754. #pragma warning( default : 4121 )
  1755. #endif
  1756. // end_ntddk end_nthal end_ntifs
  1757. #define DOSDEVICE_DRIVE_UNKNOWN 0
  1758. #define DOSDEVICE_DRIVE_CALCULATE 1
  1759. #define DOSDEVICE_DRIVE_REMOVABLE 2
  1760. #define DOSDEVICE_DRIVE_FIXED 3
  1761. #define DOSDEVICE_DRIVE_REMOTE 4
  1762. #define DOSDEVICE_DRIVE_CDROM 5
  1763. #define DOSDEVICE_DRIVE_RAMDISK 6
  1764. #if defined(USER_SHARED_DATA)
  1765. #if defined(_M_IX86) && !defined(_CROSS_PLATFORM_) && !defined(MIDL_PASS)
  1766. #if _MSC_VER >= 1200
  1767. #pragma warning(push)
  1768. #endif
  1769. #pragma warning(disable:4035)
  1770. __inline ULONG
  1771. NTAPI
  1772. NtGetTickCount (
  1773. VOID
  1774. )
  1775. {
  1776. __asm {
  1777. mov edx, MM_SHARED_USER_DATA_VA
  1778. mov eax, [edx] KUSER_SHARED_DATA.TickCountLow
  1779. mul dword ptr [edx] KUSER_SHARED_DATA.TickCountMultiplier
  1780. shrd eax,edx,24
  1781. }
  1782. }
  1783. #if _MSC_VER >= 1200
  1784. #pragma warning(pop)
  1785. #else
  1786. #pragma warning(default:4035)
  1787. #endif
  1788. #else
  1789. #define NtGetTickCount() \
  1790. ((ULONG)(UInt32x32To64(USER_SHARED_DATA->TickCountLow, \
  1791. USER_SHARED_DATA->TickCountMultiplier) >> 24))
  1792. #endif
  1793. #else
  1794. NTSYSCALLAPI
  1795. ULONG
  1796. NTAPI
  1797. NtGetTickCount(
  1798. VOID
  1799. );
  1800. #endif
  1801. NTSYSCALLAPI
  1802. NTSTATUS
  1803. NTAPI
  1804. NtQueryDefaultLocale(
  1805. IN BOOLEAN UserProfile,
  1806. OUT PLCID DefaultLocaleId
  1807. );
  1808. NTSYSCALLAPI
  1809. NTSTATUS
  1810. NTAPI
  1811. NtSetDefaultLocale(
  1812. IN BOOLEAN UserProfile,
  1813. IN LCID DefaultLocaleId
  1814. );
  1815. NTSYSCALLAPI
  1816. NTSTATUS
  1817. NTAPI
  1818. NtQueryInstallUILanguage(
  1819. OUT LANGID *InstallUILanguageId
  1820. );
  1821. NTSYSCALLAPI
  1822. NTSTATUS
  1823. NTAPI
  1824. NtQueryDefaultUILanguage(
  1825. OUT LANGID *DefaultUILanguageId
  1826. );
  1827. NTSYSCALLAPI
  1828. NTSTATUS
  1829. NTAPI
  1830. NtSetDefaultUILanguage(
  1831. IN LANGID DefaultUILanguageId
  1832. );
  1833. NTSYSCALLAPI
  1834. NTSTATUS
  1835. NTAPI
  1836. NtSetDefaultHardErrorPort(
  1837. IN HANDLE DefaultHardErrorPort
  1838. );
  1839. typedef enum _SHUTDOWN_ACTION {
  1840. ShutdownNoReboot,
  1841. ShutdownReboot,
  1842. ShutdownPowerOff
  1843. } SHUTDOWN_ACTION;
  1844. NTSYSCALLAPI
  1845. NTSTATUS
  1846. NTAPI
  1847. NtShutdownSystem(
  1848. IN SHUTDOWN_ACTION Action
  1849. );
  1850. NTSYSCALLAPI
  1851. NTSTATUS
  1852. NTAPI
  1853. NtDisplayString(
  1854. IN PUNICODE_STRING String
  1855. );
  1856. //
  1857. // Global flags that can be set to control system behavior.
  1858. // Flag word is 32 bits.
  1859. //
  1860. #define FLG_STOP_ON_EXCEPTION 0x00000001 // user and kernel mode
  1861. #define FLG_SHOW_LDR_SNAPS 0x00000002 // user and kernel mode
  1862. #define FLG_DEBUG_INITIAL_COMMAND 0x00000004 // kernel mode only up until WINLOGON started
  1863. #define FLG_STOP_ON_HUNG_GUI 0x00000008 // kernel mode only while running
  1864. #define FLG_HEAP_ENABLE_TAIL_CHECK 0x00000010 // user mode only
  1865. #define FLG_HEAP_ENABLE_FREE_CHECK 0x00000020 // user mode only
  1866. #define FLG_HEAP_VALIDATE_PARAMETERS 0x00000040 // user mode only
  1867. #define FLG_HEAP_VALIDATE_ALL 0x00000080 // user mode only
  1868. #define FLG_APPLICATION_VERIFIER 0x00000100 // user mode only
  1869. #define FLG_POOL_ENABLE_TAGGING 0x00000400 // kernel mode only
  1870. #define FLG_HEAP_ENABLE_TAGGING 0x00000800 // user mode only
  1871. #define FLG_USER_STACK_TRACE_DB 0x00001000 // x86 user mode only
  1872. #define FLG_KERNEL_STACK_TRACE_DB 0x00002000 // x86 kernel mode only at boot time
  1873. #define FLG_MAINTAIN_OBJECT_TYPELIST 0x00004000 // kernel mode only at boot time
  1874. #define FLG_HEAP_ENABLE_TAG_BY_DLL 0x00008000 // user mode only
  1875. #define FLG_DISABLE_STACK_EXTENSION 0x00010000 // user mode only
  1876. #define FLG_ENABLE_CSRDEBUG 0x00020000 // kernel mode only at boot time
  1877. #define FLG_ENABLE_KDEBUG_SYMBOL_LOAD 0x00040000 // kernel mode only
  1878. #define FLG_DISABLE_PAGE_KERNEL_STACKS 0x00080000 // kernel mode only at boot time
  1879. #define FLG_ENABLE_SYSTEM_CRIT_BREAKS 0x00100000 // user mode only
  1880. #define FLG_HEAP_DISABLE_COALESCING 0x00200000 // user mode only
  1881. #define FLG_ENABLE_CLOSE_EXCEPTIONS 0x00400000 // kernel mode only
  1882. #define FLG_ENABLE_EXCEPTION_LOGGING 0x00800000 // kernel mode only
  1883. #define FLG_ENABLE_HANDLE_TYPE_TAGGING 0x01000000 // kernel mode only
  1884. #define FLG_HEAP_PAGE_ALLOCS 0x02000000 // user mode only
  1885. #define FLG_DEBUG_INITIAL_COMMAND_EX 0x04000000 // kernel mode only up until WINLOGON started
  1886. #define FLG_DISABLE_DBGPRINT 0x08000000 // kernel mode only
  1887. #define FLG_CRITSEC_EVENT_CREATION 0x10000000 // user mode only, Force early creation of resource events
  1888. #define FLG_LDR_TOP_DOWN 0x20000000 // user mode only, win64 only
  1889. #define FLG_ENABLE_HANDLE_EXCEPTIONS 0x40000000 // kernel mode only
  1890. #define FLG_DISABLE_PROTDLLS 0x80000000 // user mode only (smss/winlogon)
  1891. #define FLG_VALID_BITS 0xFFFFFDFF
  1892. #define FLG_USERMODE_VALID_BITS (FLG_STOP_ON_EXCEPTION | \
  1893. FLG_SHOW_LDR_SNAPS | \
  1894. FLG_HEAP_ENABLE_TAIL_CHECK | \
  1895. FLG_HEAP_ENABLE_FREE_CHECK | \
  1896. FLG_HEAP_VALIDATE_PARAMETERS | \
  1897. FLG_HEAP_VALIDATE_ALL | \
  1898. FLG_APPLICATION_VERIFIER | \
  1899. FLG_HEAP_ENABLE_TAGGING | \
  1900. FLG_USER_STACK_TRACE_DB | \
  1901. FLG_HEAP_ENABLE_TAG_BY_DLL | \
  1902. FLG_DISABLE_STACK_EXTENSION | \
  1903. FLG_ENABLE_SYSTEM_CRIT_BREAKS | \
  1904. FLG_HEAP_DISABLE_COALESCING | \
  1905. FLG_DISABLE_PROTDLLS | \
  1906. FLG_HEAP_PAGE_ALLOCS | \
  1907. FLG_CRITSEC_EVENT_CREATION | \
  1908. FLG_LDR_TOP_DOWN)
  1909. #define FLG_BOOTONLY_VALID_BITS (FLG_KERNEL_STACK_TRACE_DB | \
  1910. FLG_MAINTAIN_OBJECT_TYPELIST | \
  1911. FLG_ENABLE_CSRDEBUG | \
  1912. FLG_DEBUG_INITIAL_COMMAND | \
  1913. FLG_DEBUG_INITIAL_COMMAND_EX | \
  1914. FLG_DISABLE_PAGE_KERNEL_STACKS)
  1915. #define FLG_KERNELMODE_VALID_BITS (FLG_STOP_ON_EXCEPTION | \
  1916. FLG_SHOW_LDR_SNAPS | \
  1917. FLG_STOP_ON_HUNG_GUI | \
  1918. FLG_POOL_ENABLE_TAGGING | \
  1919. FLG_ENABLE_KDEBUG_SYMBOL_LOAD | \
  1920. FLG_ENABLE_CLOSE_EXCEPTIONS | \
  1921. FLG_ENABLE_EXCEPTION_LOGGING | \
  1922. FLG_ENABLE_HANDLE_TYPE_TAGGING | \
  1923. FLG_DISABLE_DBGPRINT | \
  1924. FLG_ENABLE_HANDLE_EXCEPTIONS \
  1925. )
  1926. //
  1927. // Routines for manipulating global atoms stored in kernel space
  1928. //
  1929. typedef USHORT RTL_ATOM, *PRTL_ATOM;
  1930. NTSYSCALLAPI
  1931. NTSTATUS
  1932. NTAPI
  1933. NtAddAtom(
  1934. IN PWSTR AtomName OPTIONAL,
  1935. IN ULONG Length OPTIONAL,
  1936. OUT PRTL_ATOM Atom OPTIONAL
  1937. );
  1938. NTSYSCALLAPI
  1939. NTSTATUS
  1940. NTAPI
  1941. NtFindAtom(
  1942. IN PWSTR AtomName,
  1943. IN ULONG Length,
  1944. OUT PRTL_ATOM Atom OPTIONAL
  1945. );
  1946. NTSYSCALLAPI
  1947. NTSTATUS
  1948. NTAPI
  1949. NtDeleteAtom(
  1950. IN RTL_ATOM Atom
  1951. );
  1952. typedef enum _ATOM_INFORMATION_CLASS {
  1953. AtomBasicInformation,
  1954. AtomTableInformation
  1955. } ATOM_INFORMATION_CLASS;
  1956. typedef struct _ATOM_BASIC_INFORMATION {
  1957. USHORT UsageCount;
  1958. USHORT Flags;
  1959. USHORT NameLength;
  1960. WCHAR Name[ 1 ];
  1961. } ATOM_BASIC_INFORMATION, *PATOM_BASIC_INFORMATION;
  1962. typedef struct _ATOM_TABLE_INFORMATION {
  1963. ULONG NumberOfAtoms;
  1964. RTL_ATOM Atoms[ 1 ];
  1965. } ATOM_TABLE_INFORMATION, *PATOM_TABLE_INFORMATION;
  1966. NTSYSCALLAPI
  1967. NTSTATUS
  1968. NTAPI
  1969. NtQueryInformationAtom(
  1970. IN RTL_ATOM Atom,
  1971. IN ATOM_INFORMATION_CLASS AtomInformationClass,
  1972. OUT PVOID AtomInformation,
  1973. IN ULONG AtomInformationLength,
  1974. OUT PULONG ReturnLength OPTIONAL
  1975. );
  1976. #ifdef __cplusplus
  1977. }
  1978. #endif
  1979. #endif // _NTEXAPI_