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.

1340 lines
32 KiB

  1. /*++ BUILD Version: 0007 // Increment this if a change has global effects
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. ntpsapi.h
  5. Abstract:
  6. This module contains the process structure APIs and any public data
  7. structures needed to call these APIs.
  8. Author:
  9. Mark Lucovsky (markl) 24-Feb-1989
  10. Revision History:
  11. --*/
  12. #ifndef _NTPSAPI_
  13. #define _NTPSAPI_
  14. #if _MSC_VER > 1000
  15. #pragma once
  16. #endif
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. //
  21. // Process Specific Access Rights
  22. //
  23. #define PROCESS_TERMINATE (0x0001) // winnt
  24. #define PROCESS_CREATE_THREAD (0x0002) // winnt
  25. #define PROCESS_SET_SESSIONID (0x0004) // winnt
  26. #define PROCESS_VM_OPERATION (0x0008) // winnt
  27. #define PROCESS_VM_READ (0x0010) // winnt
  28. #define PROCESS_VM_WRITE (0x0020) // winnt
  29. // begin_ntddk begin_wdm begin_ntifs
  30. #define PROCESS_DUP_HANDLE (0x0040) // winnt
  31. // end_ntddk end_wdm end_ntifs
  32. #define PROCESS_CREATE_PROCESS (0x0080) // winnt
  33. #define PROCESS_SET_QUOTA (0x0100) // winnt
  34. #define PROCESS_SET_INFORMATION (0x0200) // winnt
  35. #define PROCESS_QUERY_INFORMATION (0x0400) // winnt
  36. #define PROCESS_SET_PORT (0x0800)
  37. #define PROCESS_SUSPEND_RESUME (0x0800) // winnt
  38. // begin_winnt begin_ntddk begin_wdm begin_ntifs
  39. #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
  40. 0xFFF)
  41. // begin_nthal
  42. #if defined(_WIN64)
  43. #define MAXIMUM_PROCESSORS 64
  44. #else
  45. #define MAXIMUM_PROCESSORS 32
  46. #endif
  47. // end_nthal
  48. // end_winnt
  49. //
  50. // Thread Specific Access Rights
  51. //
  52. #define THREAD_TERMINATE (0x0001) // winnt
  53. // end_ntddk end_wdm end_ntifs
  54. #define THREAD_SUSPEND_RESUME (0x0002) // winnt
  55. #define THREAD_ALERT (0x0004)
  56. #define THREAD_GET_CONTEXT (0x0008) // winnt
  57. #define THREAD_SET_CONTEXT (0x0010) // winnt
  58. // begin_ntddk begin_wdm begin_ntifs
  59. #define THREAD_SET_INFORMATION (0x0020) // winnt
  60. // end_ntddk end_wdm end_ntifs
  61. #define THREAD_QUERY_INFORMATION (0x0040) // winnt
  62. // begin_winnt
  63. #define THREAD_SET_THREAD_TOKEN (0x0080)
  64. #define THREAD_IMPERSONATE (0x0100)
  65. #define THREAD_DIRECT_IMPERSONATION (0x0200)
  66. // begin_ntddk begin_wdm begin_ntifs
  67. #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
  68. 0x3FF)
  69. // end_ntddk end_wdm end_ntifs
  70. // end_winnt
  71. //
  72. // Job Object Specific Access Rights
  73. //
  74. // begin_winnt
  75. #define JOB_OBJECT_ASSIGN_PROCESS (0x0001)
  76. #define JOB_OBJECT_SET_ATTRIBUTES (0x0002)
  77. #define JOB_OBJECT_QUERY (0x0004)
  78. #define JOB_OBJECT_TERMINATE (0x0008)
  79. #define JOB_OBJECT_SET_SECURITY_ATTRIBUTES (0x0010)
  80. #define JOB_OBJECT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
  81. 0x1F )
  82. typedef struct _JOB_SET_ARRAY {
  83. HANDLE JobHandle; // Handle to job object to insert
  84. ULONG MemberLevel; // Level of this job in the set. Must be > 0. Can be sparse.
  85. ULONG Flags; // Unused. Must be zero
  86. } JOB_SET_ARRAY, *PJOB_SET_ARRAY;
  87. // end_winnt
  88. //
  89. // Process Environment Block
  90. //
  91. #ifdef _MAC
  92. #pragma warning( disable : 4121)
  93. #endif
  94. typedef struct _PEB_LDR_DATA {
  95. ULONG Length;
  96. BOOLEAN Initialized;
  97. HANDLE SsHandle;
  98. LIST_ENTRY InLoadOrderModuleList;
  99. LIST_ENTRY InMemoryOrderModuleList;
  100. LIST_ENTRY InInitializationOrderModuleList;
  101. PVOID EntryInProgress;
  102. } PEB_LDR_DATA, *PPEB_LDR_DATA;
  103. #ifdef _MAC
  104. #pragma warning( default : 4121 )
  105. #endif
  106. //
  107. // Handle tag bits for Peb Stdio File Handles
  108. //
  109. #define PEB_STDIO_HANDLE_NATIVE 0
  110. #define PEB_STDIO_HANDLE_SUBSYS 1
  111. #define PEB_STDIO_HANDLE_PM 2
  112. #define PEB_STDIO_HANDLE_RESERVED 3
  113. #define GDI_HANDLE_BUFFER_SIZE32 34
  114. #define GDI_HANDLE_BUFFER_SIZE64 60
  115. #if !defined(_IA64_) && !defined(_AMD64_)
  116. #define GDI_HANDLE_BUFFER_SIZE GDI_HANDLE_BUFFER_SIZE32
  117. #else
  118. #define GDI_HANDLE_BUFFER_SIZE GDI_HANDLE_BUFFER_SIZE64
  119. #endif
  120. typedef ULONG GDI_HANDLE_BUFFER32[GDI_HANDLE_BUFFER_SIZE32];
  121. typedef ULONG GDI_HANDLE_BUFFER64[GDI_HANDLE_BUFFER_SIZE64];
  122. typedef ULONG GDI_HANDLE_BUFFER [GDI_HANDLE_BUFFER_SIZE ];
  123. #define FOREGROUND_BASE_PRIORITY 9
  124. #define NORMAL_BASE_PRIORITY 8
  125. typedef struct _PEB_FREE_BLOCK {
  126. struct _PEB_FREE_BLOCK *Next;
  127. ULONG Size;
  128. } PEB_FREE_BLOCK, *PPEB_FREE_BLOCK;
  129. // begin_ntddk begin_wdm begin_nthal begin_ntifs
  130. //
  131. // ClientId
  132. //
  133. typedef struct _CLIENT_ID {
  134. HANDLE UniqueProcess;
  135. HANDLE UniqueThread;
  136. } CLIENT_ID;
  137. typedef CLIENT_ID *PCLIENT_ID;
  138. // end_ntddk end_wdm end_nthal end_ntifs
  139. #if !defined(CLIENT_ID64_DEFINED)
  140. typedef struct _CLIENT_ID64 {
  141. ULONGLONG UniqueProcess;
  142. ULONGLONG UniqueThread;
  143. } CLIENT_ID64;
  144. typedef CLIENT_ID64 *PCLIENT_ID64;
  145. #define CLIENT_ID64_DEFINED
  146. #endif
  147. #define TLS_MINIMUM_AVAILABLE 64 // winnt
  148. #define TLS_EXPANSION_SLOTS 1024
  149. typedef
  150. VOID
  151. (*PPS_POST_PROCESS_INIT_ROUTINE) (
  152. VOID
  153. );
  154. // begin_nthal begin_ntddk begin_ntifs
  155. //
  156. // Thread Environment Block (and portable part of Thread Information Block)
  157. //
  158. //
  159. // NT_TIB - Thread Information Block - Portable part.
  160. //
  161. // This is the subsystem portable part of the Thread Information Block.
  162. // It appears as the first part of the TEB for all threads which have
  163. // a user mode component.
  164. //
  165. // end_nthal end_ntddk end_ntifs
  166. // This structure MUST MATCH OS/2 V2.0!
  167. //
  168. // There is another, non-portable part of the TIB which is used
  169. // for by subsystems, i.e. Os2Tib for OS/2 threads. SubSystemTib
  170. // points there.
  171. // begin_nthal begin_ntddk begin_ntifs
  172. //
  173. // begin_winnt
  174. typedef struct _NT_TIB {
  175. struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
  176. PVOID StackBase;
  177. PVOID StackLimit;
  178. PVOID SubSystemTib;
  179. union {
  180. PVOID FiberData;
  181. ULONG Version;
  182. };
  183. PVOID ArbitraryUserPointer;
  184. struct _NT_TIB *Self;
  185. } NT_TIB;
  186. typedef NT_TIB *PNT_TIB;
  187. //
  188. // 32 and 64 bit specific version for wow64 and the debugger
  189. //
  190. typedef struct _NT_TIB32 {
  191. ULONG ExceptionList;
  192. ULONG StackBase;
  193. ULONG StackLimit;
  194. ULONG SubSystemTib;
  195. union {
  196. ULONG FiberData;
  197. ULONG Version;
  198. };
  199. ULONG ArbitraryUserPointer;
  200. ULONG Self;
  201. } NT_TIB32, *PNT_TIB32;
  202. typedef struct _NT_TIB64 {
  203. ULONG64 ExceptionList;
  204. ULONG64 StackBase;
  205. ULONG64 StackLimit;
  206. ULONG64 SubSystemTib;
  207. union {
  208. ULONG64 FiberData;
  209. ULONG Version;
  210. };
  211. ULONG64 ArbitraryUserPointer;
  212. ULONG64 Self;
  213. } NT_TIB64, *PNT_TIB64;
  214. // end_nthal end_ntddk end_ntifs end_winnt
  215. //
  216. // Gdi command batching
  217. //
  218. #define GDI_BATCH_BUFFER_SIZE 310
  219. typedef struct _GDI_TEB_BATCH {
  220. ULONG Offset;
  221. ULONG_PTR HDC;
  222. ULONG Buffer[GDI_BATCH_BUFFER_SIZE];
  223. } GDI_TEB_BATCH,*PGDI_TEB_BATCH;
  224. //
  225. // Wx86 thread state information
  226. //
  227. typedef struct _Wx86ThreadState {
  228. PULONG CallBx86Eip;
  229. PVOID DeallocationCpu;
  230. BOOLEAN UseKnownWx86Dll;
  231. char OleStubInvoked;
  232. } WX86THREAD, *PWX86THREAD;
  233. //
  234. // TEB - The thread environment block
  235. //
  236. #define STATIC_UNICODE_BUFFER_LENGTH 261
  237. #define WIN32_CLIENT_INFO_LENGTH 62
  238. #define WIN32_CLIENT_INFO_SPIN_COUNT 1
  239. typedef PVOID* PPVOID;
  240. #include "pebteb.h"
  241. // begin_winnt
  242. #if !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_)
  243. #define WX86
  244. #endif
  245. // end_winnt
  246. #if defined(WX86)
  247. #define Wx86CurrentTib() ((PWX86TIB)NtCurrentTeb()->Vdm)
  248. #else
  249. #define Wx86CurrentTib() (NULL)
  250. #endif
  251. #if !defined(_X86_) && !defined(_IA64_)
  252. //
  253. // Exception Registration structure
  254. //
  255. // X86 Call frame record definition, normally defined in nti386.h
  256. // which is not included on risc.
  257. //
  258. typedef struct _EXCEPTION_REGISTRATION_RECORD {
  259. struct _EXCEPTION_REGISTRATION_RECORD *Next;
  260. PEXCEPTION_ROUTINE Handler;
  261. } EXCEPTION_REGISTRATION_RECORD;
  262. typedef EXCEPTION_REGISTRATION_RECORD *PEXCEPTION_REGISTRATION_RECORD;
  263. #endif
  264. typedef struct _Wx86TIB {
  265. ULONG Size;
  266. ULONG InitialPc;
  267. VOID * POINTER_32 StackBase;
  268. VOID * POINTER_32 StackLimit;
  269. VOID * POINTER_32 DeallocationStack;
  270. ULONG LogFlags;
  271. ULONG InitialSp;
  272. UCHAR SimulationCount;
  273. BOOLEAN InCpuSimulation;
  274. BOOLEAN EmulateInitialPc;
  275. BOOLEAN Initialized;
  276. EXCEPTION_REGISTRATION_RECORD * POINTER_32 ExceptionList;
  277. VOID * POINTER_32 CpuContext;
  278. CONTEXT * POINTER_32 InitialExceptionContext;
  279. VOID * POINTER_32 pCallersRIID;
  280. VOID * POINTER_32 pCallersUnknown;
  281. ULONG Flags;
  282. VOID * POINTER_32 SelfRegDllName;
  283. VOID * POINTER_32 SelfRegDllHandle;
  284. } WX86TIB, *PWX86TIB;
  285. #define EXCEPTION_CHAIN_END ((struct _EXCEPTION_REGISTRATION_RECORD * POINTER_32)-1)
  286. //
  287. // The version number of OS2
  288. //
  289. #define MAJOR_VERSION 30 // Cruiser uses 20 (not 20H)
  290. #define MINOR_VERSION 00
  291. #define OS2_VERSION (MAJOR_VERSION << 8 | MINOR_VERSION )
  292. #if DBG
  293. //
  294. // Reserve the last 9 SystemReserved pointers for debugging
  295. //
  296. #define DBG_TEB_THREADNAME 16
  297. #define DBG_TEB_RESERVED_1 15
  298. #define DBG_TEB_RESERVED_2 14
  299. #define DBG_TEB_RESERVED_3 13
  300. #define DBG_TEB_RESERVED_4 12
  301. #define DBG_TEB_RESERVED_5 11
  302. #define DBG_TEB_RESERVED_6 10
  303. #define DBG_TEB_RESERVED_7 9
  304. #define DBG_TEB_RESERVED_8 8
  305. #endif // DBG
  306. typedef struct _INITIAL_TEB {
  307. struct {
  308. PVOID OldStackBase;
  309. PVOID OldStackLimit;
  310. #if defined(_IA64_)
  311. PVOID OldBStoreLimit;
  312. #endif // defined(_IA64_)
  313. } OldInitialTeb;
  314. PVOID StackBase;
  315. PVOID StackLimit;
  316. #if defined(_IA64_)
  317. PVOID BStoreLimit;
  318. #endif // defined(_IA64_)
  319. PVOID StackAllocationBase;
  320. } INITIAL_TEB, *PINITIAL_TEB;
  321. #define PROCESS_PRIORITY_CLASS_UNKNOWN 0
  322. #define PROCESS_PRIORITY_CLASS_IDLE 1
  323. #define PROCESS_PRIORITY_CLASS_NORMAL 2
  324. #define PROCESS_PRIORITY_CLASS_HIGH 3
  325. #define PROCESS_PRIORITY_CLASS_REALTIME 4
  326. #define PROCESS_PRIORITY_CLASS_BELOW_NORMAL 5
  327. #define PROCESS_PRIORITY_CLASS_ABOVE_NORMAL 6
  328. typedef struct _PROCESS_PRIORITY_CLASS {
  329. BOOLEAN Foreground;
  330. UCHAR PriorityClass;
  331. } PROCESS_PRIORITY_CLASS, *PPROCESS_PRIORITY_CLASS;
  332. typedef struct _PROCESS_FOREGROUND_BACKGROUND {
  333. BOOLEAN Foreground;
  334. } PROCESS_FOREGROUND_BACKGROUND, *PPROCESS_FOREGROUND_BACKGROUND;
  335. //
  336. // Define process debug flags
  337. //
  338. #define PROCESS_DEBUG_INHERIT 0x00000001
  339. // begin_ntddk begin_ntifs
  340. //
  341. // Process Information Classes
  342. //
  343. typedef enum _PROCESSINFOCLASS {
  344. ProcessBasicInformation,
  345. ProcessQuotaLimits,
  346. ProcessIoCounters,
  347. ProcessVmCounters,
  348. ProcessTimes,
  349. ProcessBasePriority,
  350. ProcessRaisePriority,
  351. ProcessDebugPort,
  352. ProcessExceptionPort,
  353. ProcessAccessToken,
  354. ProcessLdtInformation,
  355. ProcessLdtSize,
  356. ProcessDefaultHardErrorMode,
  357. ProcessIoPortHandlers, // Note: this is kernel mode only
  358. ProcessPooledUsageAndLimits,
  359. ProcessWorkingSetWatch,
  360. ProcessUserModeIOPL,
  361. ProcessEnableAlignmentFaultFixup,
  362. ProcessPriorityClass,
  363. ProcessWx86Information,
  364. ProcessHandleCount,
  365. ProcessAffinityMask,
  366. ProcessPriorityBoost,
  367. ProcessDeviceMap,
  368. ProcessSessionInformation,
  369. ProcessForegroundInformation,
  370. ProcessWow64Information,
  371. ProcessImageFileName,
  372. ProcessLUIDDeviceMapsEnabled,
  373. ProcessBreakOnTermination,
  374. ProcessDebugObjectHandle,
  375. ProcessDebugFlags,
  376. ProcessHandleTracing,
  377. MaxProcessInfoClass // MaxProcessInfoClass should always be the last enum
  378. } PROCESSINFOCLASS;
  379. //
  380. // Thread Information Classes
  381. //
  382. typedef enum _THREADINFOCLASS {
  383. ThreadBasicInformation,
  384. ThreadTimes,
  385. ThreadPriority,
  386. ThreadBasePriority,
  387. ThreadAffinityMask,
  388. ThreadImpersonationToken,
  389. ThreadDescriptorTableEntry,
  390. ThreadEnableAlignmentFaultFixup,
  391. ThreadEventPair_Reusable,
  392. ThreadQuerySetWin32StartAddress,
  393. ThreadZeroTlsCell,
  394. ThreadPerformanceCount,
  395. ThreadAmILastThread,
  396. ThreadIdealProcessor,
  397. ThreadPriorityBoost,
  398. ThreadSetTlsArrayAddress,
  399. ThreadIsIoPending,
  400. ThreadHideFromDebugger,
  401. ThreadBreakOnTermination,
  402. MaxThreadInfoClass
  403. } THREADINFOCLASS;
  404. // end_ntddk end_ntifs
  405. #define PROCESS_PRIORITY_SEPARATION_MASK 0x00000003
  406. #define PROCESS_PRIORITY_SEPARATION_MAX 0x00000002
  407. #define PROCESS_QUANTUM_VARIABLE_MASK 0x0000000c
  408. #define PROCESS_QUANTUM_VARIABLE_DEF 0x00000000
  409. #define PROCESS_QUANTUM_VARIABLE_VALUE 0x00000004
  410. #define PROCESS_QUANTUM_FIXED_VALUE 0x00000008
  411. #define PROCESS_QUANTUM_LONG_MASK 0x00000030
  412. #define PROCESS_QUANTUM_LONG_DEF 0x00000000
  413. #define PROCESS_QUANTUM_LONG_VALUE 0x00000010
  414. #define PROCESS_QUANTUM_SHORT_VALUE 0x00000020
  415. #define PROCESS_HARDERROR_ALIGNMENT_BIT 0x0004 // from winbase.h, but not tagged
  416. //
  417. // thread base priority ranges
  418. //
  419. // begin_winnt
  420. #define THREAD_BASE_PRIORITY_LOWRT 15 // value that gets a thread to LowRealtime-1
  421. #define THREAD_BASE_PRIORITY_MAX 2 // maximum thread base priority boost
  422. #define THREAD_BASE_PRIORITY_MIN (-2) // minimum thread base priority boost
  423. #define THREAD_BASE_PRIORITY_IDLE (-15) // value that gets a thread to idle
  424. // end_winnt
  425. // begin_ntddk begin_ntifs
  426. //
  427. // Process Information Structures
  428. //
  429. //
  430. // PageFaultHistory Information
  431. // NtQueryInformationProcess using ProcessWorkingSetWatch
  432. //
  433. typedef struct _PROCESS_WS_WATCH_INFORMATION {
  434. PVOID FaultingPc;
  435. PVOID FaultingVa;
  436. } PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION;
  437. //
  438. // Basic Process Information
  439. // NtQueryInformationProcess using ProcessBasicInfo
  440. //
  441. typedef struct _PROCESS_BASIC_INFORMATION {
  442. NTSTATUS ExitStatus;
  443. PPEB PebBaseAddress;
  444. ULONG_PTR AffinityMask;
  445. KPRIORITY BasePriority;
  446. ULONG_PTR UniqueProcessId;
  447. ULONG_PTR InheritedFromUniqueProcessId;
  448. } PROCESS_BASIC_INFORMATION;
  449. typedef PROCESS_BASIC_INFORMATION *PPROCESS_BASIC_INFORMATION;
  450. //
  451. // Process Device Map information
  452. // NtQueryInformationProcess using ProcessDeviceMap
  453. // NtSetInformationProcess using ProcessDeviceMap
  454. //
  455. typedef struct _PROCESS_DEVICEMAP_INFORMATION {
  456. union {
  457. struct {
  458. HANDLE DirectoryHandle;
  459. } Set;
  460. struct {
  461. ULONG DriveMap;
  462. UCHAR DriveType[ 32 ];
  463. } Query;
  464. };
  465. } PROCESS_DEVICEMAP_INFORMATION, *PPROCESS_DEVICEMAP_INFORMATION;
  466. typedef struct _PROCESS_DEVICEMAP_INFORMATION_EX {
  467. union {
  468. struct {
  469. HANDLE DirectoryHandle;
  470. } Set;
  471. struct {
  472. ULONG DriveMap;
  473. UCHAR DriveType[ 32 ];
  474. } Query;
  475. };
  476. ULONG Flags; // specifies that the query type
  477. } PROCESS_DEVICEMAP_INFORMATION_EX, *PPROCESS_DEVICEMAP_INFORMATION_EX;
  478. //
  479. // PROCESS_DEVICEMAP_INFORMATION_EX flags
  480. //
  481. #define PROCESS_LUID_DOSDEVICES_ONLY 0x00000001
  482. //
  483. // Multi-User Session specific Process Information
  484. // NtQueryInformationProcess using ProcessSessionInformation
  485. //
  486. typedef struct _PROCESS_SESSION_INFORMATION {
  487. ULONG SessionId;
  488. } PROCESS_SESSION_INFORMATION, *PPROCESS_SESSION_INFORMATION;
  489. typedef struct _PROCESS_HANDLE_TRACING_ENABLE {
  490. ULONG Flags;
  491. } PROCESS_HANDLE_TRACING_ENABLE, *PPROCESS_HANDLE_TRACING_ENABLE;
  492. #define PROCESS_HANDLE_TRACING_MAX_STACKS 16
  493. typedef struct _PROCESS_HANDLE_TRACING_ENTRY {
  494. HANDLE Handle;
  495. CLIENT_ID ClientId;
  496. ULONG Type;
  497. PVOID Stacks[PROCESS_HANDLE_TRACING_MAX_STACKS];
  498. } PROCESS_HANDLE_TRACING_ENTRY, *PPROCESS_HANDLE_TRACING_ENTRY;
  499. typedef struct _PROCESS_HANDLE_TRACING_QUERY {
  500. HANDLE Handle;
  501. ULONG TotalTraces;
  502. PROCESS_HANDLE_TRACING_ENTRY HandleTrace[1];
  503. } PROCESS_HANDLE_TRACING_QUERY, *PPROCESS_HANDLE_TRACING_QUERY;
  504. //
  505. // Process Quotas
  506. // NtQueryInformationProcess using ProcessQuotaLimits
  507. // NtQueryInformationProcess using ProcessPooledQuotaLimits
  508. // NtSetInformationProcess using ProcessQuotaLimits
  509. //
  510. // begin_winnt
  511. typedef struct _QUOTA_LIMITS {
  512. SIZE_T PagedPoolLimit;
  513. SIZE_T NonPagedPoolLimit;
  514. SIZE_T MinimumWorkingSetSize;
  515. SIZE_T MaximumWorkingSetSize;
  516. SIZE_T PagefileLimit;
  517. LARGE_INTEGER TimeLimit;
  518. } QUOTA_LIMITS;
  519. typedef QUOTA_LIMITS *PQUOTA_LIMITS;
  520. // end_winnt
  521. //
  522. // Process I/O Counters
  523. // NtQueryInformationProcess using ProcessIoCounters
  524. //
  525. // begin_winnt
  526. typedef struct _IO_COUNTERS {
  527. ULONGLONG ReadOperationCount;
  528. ULONGLONG WriteOperationCount;
  529. ULONGLONG OtherOperationCount;
  530. ULONGLONG ReadTransferCount;
  531. ULONGLONG WriteTransferCount;
  532. ULONGLONG OtherTransferCount;
  533. } IO_COUNTERS;
  534. typedef IO_COUNTERS *PIO_COUNTERS;
  535. // end_winnt
  536. //
  537. // Process Virtual Memory Counters
  538. // NtQueryInformationProcess using ProcessVmCounters
  539. //
  540. typedef struct _VM_COUNTERS {
  541. SIZE_T PeakVirtualSize;
  542. SIZE_T VirtualSize;
  543. ULONG PageFaultCount;
  544. SIZE_T PeakWorkingSetSize;
  545. SIZE_T WorkingSetSize;
  546. SIZE_T QuotaPeakPagedPoolUsage;
  547. SIZE_T QuotaPagedPoolUsage;
  548. SIZE_T QuotaPeakNonPagedPoolUsage;
  549. SIZE_T QuotaNonPagedPoolUsage;
  550. SIZE_T PagefileUsage;
  551. SIZE_T PeakPagefileUsage;
  552. } VM_COUNTERS;
  553. typedef VM_COUNTERS *PVM_COUNTERS;
  554. typedef struct _VM_COUNTERS_EX {
  555. SIZE_T PeakVirtualSize;
  556. SIZE_T VirtualSize;
  557. ULONG PageFaultCount;
  558. SIZE_T PeakWorkingSetSize;
  559. SIZE_T WorkingSetSize;
  560. SIZE_T QuotaPeakPagedPoolUsage;
  561. SIZE_T QuotaPagedPoolUsage;
  562. SIZE_T QuotaPeakNonPagedPoolUsage;
  563. SIZE_T QuotaNonPagedPoolUsage;
  564. SIZE_T PagefileUsage;
  565. SIZE_T PeakPagefileUsage;
  566. SIZE_T PrivateUsage;
  567. } VM_COUNTERS_EX;
  568. typedef VM_COUNTERS_EX *PVM_COUNTERS_EX;
  569. //
  570. // Process Pooled Quota Usage and Limits
  571. // NtQueryInformationProcess using ProcessPooledUsageAndLimits
  572. //
  573. typedef struct _POOLED_USAGE_AND_LIMITS {
  574. SIZE_T PeakPagedPoolUsage;
  575. SIZE_T PagedPoolUsage;
  576. SIZE_T PagedPoolLimit;
  577. SIZE_T PeakNonPagedPoolUsage;
  578. SIZE_T NonPagedPoolUsage;
  579. SIZE_T NonPagedPoolLimit;
  580. SIZE_T PeakPagefileUsage;
  581. SIZE_T PagefileUsage;
  582. SIZE_T PagefileLimit;
  583. } POOLED_USAGE_AND_LIMITS;
  584. typedef POOLED_USAGE_AND_LIMITS *PPOOLED_USAGE_AND_LIMITS;
  585. //
  586. // Process Security Context Information
  587. // NtSetInformationProcess using ProcessAccessToken
  588. // PROCESS_SET_ACCESS_TOKEN access to the process is needed
  589. // to use this info level.
  590. //
  591. typedef struct _PROCESS_ACCESS_TOKEN {
  592. //
  593. // Handle to Primary token to assign to the process.
  594. // TOKEN_ASSIGN_PRIMARY access to this token is needed.
  595. //
  596. HANDLE Token;
  597. //
  598. // Handle to the initial thread of the process.
  599. // A process's access token can only be changed if the process has
  600. // no threads or one thread. If the process has no threads, this
  601. // field must be set to NULL. Otherwise, it must contain a handle
  602. // open to the process's only thread. THREAD_QUERY_INFORMATION access
  603. // is needed via this handle.
  604. HANDLE Thread;
  605. } PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN;
  606. //
  607. // Process/Thread System and User Time
  608. // NtQueryInformationProcess using ProcessTimes
  609. // NtQueryInformationThread using ThreadTimes
  610. //
  611. typedef struct _KERNEL_USER_TIMES {
  612. LARGE_INTEGER CreateTime;
  613. LARGE_INTEGER ExitTime;
  614. LARGE_INTEGER KernelTime;
  615. LARGE_INTEGER UserTime;
  616. } KERNEL_USER_TIMES;
  617. typedef KERNEL_USER_TIMES *PKERNEL_USER_TIMES;
  618. // end_ntddk end_ntifs
  619. //
  620. // Thread Information Structures
  621. //
  622. //
  623. // Basic Thread Information
  624. // NtQueryInformationThread using ThreadBasicInfo
  625. //
  626. typedef struct _THREAD_BASIC_INFORMATION {
  627. NTSTATUS ExitStatus;
  628. PTEB TebBaseAddress;
  629. CLIENT_ID ClientId;
  630. ULONG_PTR AffinityMask;
  631. KPRIORITY Priority;
  632. LONG BasePriority;
  633. } THREAD_BASIC_INFORMATION;
  634. typedef THREAD_BASIC_INFORMATION *PTHREAD_BASIC_INFORMATION;
  635. #if defined(_AMD64_) || defined(_IA64_)
  636. #include <pshpck16.h>
  637. #endif
  638. typedef struct _FIBER {
  639. PVOID FiberData;
  640. //
  641. // Matches first three DWORDs of TEB
  642. //
  643. struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
  644. PVOID StackBase;
  645. PVOID StackLimit;
  646. //
  647. // Used by base to free a thread's stack
  648. //
  649. PVOID DeallocationStack;
  650. CONTEXT FiberContext;
  651. PWX86TIB Wx86Tib;
  652. #ifdef _IA64_
  653. PVOID DeallocationBStore;
  654. PVOID BStoreLimit;
  655. #endif
  656. } FIBER, *PFIBER;
  657. #if defined(_AMD64_) || defined(_IA64_)
  658. #include <poppack.h>
  659. #endif
  660. //
  661. //
  662. // Process Object APIs
  663. //
  664. NTSYSCALLAPI
  665. NTSTATUS
  666. NTAPI
  667. NtCreateProcess(
  668. OUT PHANDLE ProcessHandle,
  669. IN ACCESS_MASK DesiredAccess,
  670. IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
  671. IN HANDLE ParentProcess,
  672. IN BOOLEAN InheritObjectTable,
  673. IN HANDLE SectionHandle OPTIONAL,
  674. IN HANDLE DebugPort OPTIONAL,
  675. IN HANDLE ExceptionPort OPTIONAL
  676. );
  677. #define PROCESS_CREATE_FLAGS_BREAKAWAY 0x00000001
  678. #define PROCESS_CREATE_FLAGS_NO_DEBUG_INHERIT 0x00000002
  679. #define PROCESS_CREATE_FLAGS_INHERIT_HANDLES 0x00000004
  680. #define PROCESS_CREATE_FLAGS_OVERRIDE_ADDRESS_SPACE 0x00000008
  681. #define PROCESS_CREATE_FLAGS_LEGAL_MASK 0x0000000f
  682. NTSYSCALLAPI
  683. NTSTATUS
  684. NTAPI
  685. NtCreateProcessEx(
  686. OUT PHANDLE ProcessHandle,
  687. IN ACCESS_MASK DesiredAccess,
  688. IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
  689. IN HANDLE ParentProcess,
  690. IN ULONG Flags,
  691. IN HANDLE SectionHandle OPTIONAL,
  692. IN HANDLE DebugPort OPTIONAL,
  693. IN HANDLE ExceptionPort OPTIONAL,
  694. IN ULONG JobMemberLevel
  695. );
  696. // begin_ntddk begin_ntifs
  697. NTSYSCALLAPI
  698. NTSTATUS
  699. NTAPI
  700. NtOpenProcess (
  701. OUT PHANDLE ProcessHandle,
  702. IN ACCESS_MASK DesiredAccess,
  703. IN POBJECT_ATTRIBUTES ObjectAttributes,
  704. IN PCLIENT_ID ClientId OPTIONAL
  705. );
  706. // end_ntddk end_ntifs
  707. NTSYSCALLAPI
  708. NTSTATUS
  709. NTAPI
  710. NtTerminateProcess(
  711. IN HANDLE ProcessHandle OPTIONAL,
  712. IN NTSTATUS ExitStatus
  713. );
  714. #define NtCurrentProcess() ( (HANDLE)(LONG_PTR) -1 ) // ntddk wdm ntifs
  715. #if defined(RTL_USE_KERNEL_PEB_RTN) || defined(NTOS_KERNEL_RUNTIME)
  716. #define NtCurrentPeb() (PsGetCurrentProcess ()->Peb)
  717. #else
  718. #define NtCurrentPeb() (NtCurrentTeb()->ProcessEnvironmentBlock)
  719. #endif
  720. // begin_ntddk begin_ntifs
  721. NTSYSCALLAPI
  722. NTSTATUS
  723. NTAPI
  724. NtQueryInformationProcess(
  725. IN HANDLE ProcessHandle,
  726. IN PROCESSINFOCLASS ProcessInformationClass,
  727. OUT PVOID ProcessInformation,
  728. IN ULONG ProcessInformationLength,
  729. OUT PULONG ReturnLength OPTIONAL
  730. );
  731. // end_ntddk end_ntifs
  732. NTSYSCALLAPI
  733. NTSTATUS
  734. NTAPI
  735. NtQueryPortInformationProcess(
  736. VOID
  737. );
  738. NTSYSCALLAPI
  739. NTSTATUS
  740. NTAPI
  741. NtSetInformationProcess(
  742. IN HANDLE ProcessHandle,
  743. IN PROCESSINFOCLASS ProcessInformationClass,
  744. IN PVOID ProcessInformation,
  745. IN ULONG ProcessInformationLength
  746. );
  747. //
  748. // Thread Object APIs
  749. //
  750. NTSYSCALLAPI
  751. NTSTATUS
  752. NTAPI
  753. NtCreateThread(
  754. OUT PHANDLE ThreadHandle,
  755. IN ACCESS_MASK DesiredAccess,
  756. IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
  757. IN HANDLE ProcessHandle,
  758. OUT PCLIENT_ID ClientId,
  759. IN PCONTEXT ThreadContext,
  760. IN PINITIAL_TEB InitialTeb,
  761. IN BOOLEAN CreateSuspended
  762. );
  763. NTSYSCALLAPI
  764. NTSTATUS
  765. NTAPI
  766. NtOpenThread (
  767. OUT PHANDLE ThreadHandle,
  768. IN ACCESS_MASK DesiredAccess,
  769. IN POBJECT_ATTRIBUTES ObjectAttributes,
  770. IN PCLIENT_ID ClientId OPTIONAL
  771. );
  772. NTSYSCALLAPI
  773. NTSTATUS
  774. NTAPI
  775. NtTerminateThread(
  776. IN HANDLE ThreadHandle OPTIONAL,
  777. IN NTSTATUS ExitStatus
  778. );
  779. #define NtCurrentThread() ( (HANDLE)(LONG_PTR) -2 ) // ntddk wdm ntifs
  780. NTSYSCALLAPI
  781. NTSTATUS
  782. NTAPI
  783. NtSuspendThread(
  784. IN HANDLE ThreadHandle,
  785. OUT PULONG PreviousSuspendCount OPTIONAL
  786. );
  787. NTSYSCALLAPI
  788. NTSTATUS
  789. NTAPI
  790. NtResumeThread(
  791. IN HANDLE ThreadHandle,
  792. OUT PULONG PreviousSuspendCount OPTIONAL
  793. );
  794. NTSYSCALLAPI
  795. NTSTATUS
  796. NTAPI
  797. NtSuspendProcess (
  798. IN HANDLE ProcessHandle
  799. );
  800. NTSYSCALLAPI
  801. NTSTATUS
  802. NTAPI
  803. NtResumeProcess (
  804. IN HANDLE ProcessHandle
  805. );
  806. NTSYSCALLAPI
  807. NTSTATUS
  808. NTAPI
  809. NtGetContextThread(
  810. IN HANDLE ThreadHandle,
  811. IN OUT PCONTEXT ThreadContext
  812. );
  813. NTSYSCALLAPI
  814. NTSTATUS
  815. NTAPI
  816. NtSetContextThread(
  817. IN HANDLE ThreadHandle,
  818. IN PCONTEXT ThreadContext
  819. );
  820. NTSYSCALLAPI
  821. NTSTATUS
  822. NTAPI
  823. NtQueryInformationThread(
  824. IN HANDLE ThreadHandle,
  825. IN THREADINFOCLASS ThreadInformationClass,
  826. OUT PVOID ThreadInformation,
  827. IN ULONG ThreadInformationLength,
  828. OUT PULONG ReturnLength OPTIONAL
  829. );
  830. // begin_ntifs
  831. NTSYSCALLAPI
  832. NTSTATUS
  833. NTAPI
  834. NtSetInformationThread(
  835. IN HANDLE ThreadHandle,
  836. IN THREADINFOCLASS ThreadInformationClass,
  837. IN PVOID ThreadInformation,
  838. IN ULONG ThreadInformationLength
  839. );
  840. // end_ntifs
  841. NTSYSCALLAPI
  842. NTSTATUS
  843. NTAPI
  844. NtAlertThread(
  845. IN HANDLE ThreadHandle
  846. );
  847. NTSYSCALLAPI
  848. NTSTATUS
  849. NTAPI
  850. NtAlertResumeThread(
  851. IN HANDLE ThreadHandle,
  852. OUT PULONG PreviousSuspendCount OPTIONAL
  853. );
  854. NTSYSCALLAPI
  855. NTSTATUS
  856. NTAPI
  857. NtImpersonateThread(
  858. IN HANDLE ServerThreadHandle,
  859. IN HANDLE ClientThreadHandle,
  860. IN PSECURITY_QUALITY_OF_SERVICE SecurityQos
  861. );
  862. NTSYSCALLAPI
  863. NTSTATUS
  864. NTAPI
  865. NtTestAlert(
  866. VOID
  867. );
  868. NTSYSCALLAPI
  869. NTSTATUS
  870. NTAPI
  871. NtRegisterThreadTerminatePort(
  872. IN HANDLE PortHandle
  873. );
  874. NTSYSCALLAPI
  875. NTSTATUS
  876. NTAPI
  877. NtSetLdtEntries(
  878. IN ULONG Selector0,
  879. IN ULONG Entry0Low,
  880. IN ULONG Entry0Hi,
  881. IN ULONG Selector1,
  882. IN ULONG Entry1Low,
  883. IN ULONG Entry1High
  884. );
  885. typedef
  886. VOID
  887. (*PPS_APC_ROUTINE) (
  888. IN PVOID ApcArgument1,
  889. IN PVOID ApcArgument2,
  890. IN PVOID ApcArgument3
  891. );
  892. NTSYSCALLAPI
  893. NTSTATUS
  894. NTAPI
  895. NtQueueApcThread(
  896. IN HANDLE ThreadHandle,
  897. IN PPS_APC_ROUTINE ApcRoutine,
  898. IN PVOID ApcArgument1,
  899. IN PVOID ApcArgument2,
  900. IN PVOID ApcArgument3
  901. );
  902. //
  903. // Job Object APIs
  904. //
  905. NTSYSCALLAPI
  906. NTSTATUS
  907. NTAPI
  908. NtCreateJobObject (
  909. OUT PHANDLE JobHandle,
  910. IN ACCESS_MASK DesiredAccess,
  911. IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL
  912. );
  913. NTSYSCALLAPI
  914. NTSTATUS
  915. NTAPI
  916. NtOpenJobObject(
  917. OUT PHANDLE JobHandle,
  918. IN ACCESS_MASK DesiredAccess,
  919. IN POBJECT_ATTRIBUTES ObjectAttributes
  920. );
  921. NTSYSCALLAPI
  922. NTSTATUS
  923. NTAPI
  924. NtAssignProcessToJobObject(
  925. IN HANDLE JobHandle,
  926. IN HANDLE ProcessHandle
  927. );
  928. NTSYSCALLAPI
  929. NTSTATUS
  930. NTAPI
  931. NtTerminateJobObject(
  932. IN HANDLE JobHandle,
  933. IN NTSTATUS ExitStatus
  934. );
  935. NTSYSCALLAPI
  936. NTSTATUS
  937. NTAPI
  938. NtIsProcessInJob (
  939. IN HANDLE ProcessHandle,
  940. IN HANDLE JobHandle
  941. );
  942. NTSYSCALLAPI
  943. NTSTATUS
  944. NTAPI
  945. NtCreateJobSet (
  946. IN ULONG NumJob,
  947. IN PJOB_SET_ARRAY UserJobSet,
  948. IN ULONG Flags);
  949. // begin_winnt
  950. typedef struct _JOBOBJECT_BASIC_ACCOUNTING_INFORMATION {
  951. LARGE_INTEGER TotalUserTime;
  952. LARGE_INTEGER TotalKernelTime;
  953. LARGE_INTEGER ThisPeriodTotalUserTime;
  954. LARGE_INTEGER ThisPeriodTotalKernelTime;
  955. ULONG TotalPageFaultCount;
  956. ULONG TotalProcesses;
  957. ULONG ActiveProcesses;
  958. ULONG TotalTerminatedProcesses;
  959. } JOBOBJECT_BASIC_ACCOUNTING_INFORMATION, *PJOBOBJECT_BASIC_ACCOUNTING_INFORMATION;
  960. typedef struct _JOBOBJECT_BASIC_LIMIT_INFORMATION {
  961. LARGE_INTEGER PerProcessUserTimeLimit;
  962. LARGE_INTEGER PerJobUserTimeLimit;
  963. ULONG LimitFlags;
  964. SIZE_T MinimumWorkingSetSize;
  965. SIZE_T MaximumWorkingSetSize;
  966. ULONG ActiveProcessLimit;
  967. ULONG_PTR Affinity;
  968. ULONG PriorityClass;
  969. ULONG SchedulingClass;
  970. } JOBOBJECT_BASIC_LIMIT_INFORMATION, *PJOBOBJECT_BASIC_LIMIT_INFORMATION;
  971. typedef struct _JOBOBJECT_EXTENDED_LIMIT_INFORMATION {
  972. JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation;
  973. IO_COUNTERS IoInfo;
  974. SIZE_T ProcessMemoryLimit;
  975. SIZE_T JobMemoryLimit;
  976. SIZE_T PeakProcessMemoryUsed;
  977. SIZE_T PeakJobMemoryUsed;
  978. } JOBOBJECT_EXTENDED_LIMIT_INFORMATION, *PJOBOBJECT_EXTENDED_LIMIT_INFORMATION;
  979. typedef struct _JOBOBJECT_BASIC_PROCESS_ID_LIST {
  980. ULONG NumberOfAssignedProcesses;
  981. ULONG NumberOfProcessIdsInList;
  982. ULONG_PTR ProcessIdList[1];
  983. } JOBOBJECT_BASIC_PROCESS_ID_LIST, *PJOBOBJECT_BASIC_PROCESS_ID_LIST;
  984. typedef struct _JOBOBJECT_BASIC_UI_RESTRICTIONS {
  985. ULONG UIRestrictionsClass;
  986. } JOBOBJECT_BASIC_UI_RESTRICTIONS, *PJOBOBJECT_BASIC_UI_RESTRICTIONS;
  987. typedef struct _JOBOBJECT_SECURITY_LIMIT_INFORMATION {
  988. ULONG SecurityLimitFlags ;
  989. HANDLE JobToken ;
  990. PTOKEN_GROUPS SidsToDisable ;
  991. PTOKEN_PRIVILEGES PrivilegesToDelete ;
  992. PTOKEN_GROUPS RestrictedSids ;
  993. } JOBOBJECT_SECURITY_LIMIT_INFORMATION, *PJOBOBJECT_SECURITY_LIMIT_INFORMATION ;
  994. typedef struct _JOBOBJECT_END_OF_JOB_TIME_INFORMATION {
  995. ULONG EndOfJobTimeAction;
  996. } JOBOBJECT_END_OF_JOB_TIME_INFORMATION, *PJOBOBJECT_END_OF_JOB_TIME_INFORMATION;
  997. typedef struct _JOBOBJECT_ASSOCIATE_COMPLETION_PORT {
  998. PVOID CompletionKey;
  999. HANDLE CompletionPort;
  1000. } JOBOBJECT_ASSOCIATE_COMPLETION_PORT, *PJOBOBJECT_ASSOCIATE_COMPLETION_PORT;
  1001. typedef struct _JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION {
  1002. JOBOBJECT_BASIC_ACCOUNTING_INFORMATION BasicInfo;
  1003. IO_COUNTERS IoInfo;
  1004. } JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION, *PJOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION;
  1005. typedef struct _JOBOBJECT_JOBSET_INFORMATION {
  1006. ULONG MemberLevel;
  1007. } JOBOBJECT_JOBSET_INFORMATION, *PJOBOBJECT_JOBSET_INFORMATION;
  1008. #define JOB_OBJECT_TERMINATE_AT_END_OF_JOB 0
  1009. #define JOB_OBJECT_POST_AT_END_OF_JOB 1
  1010. //
  1011. // Completion Port Messages for job objects
  1012. //
  1013. // These values are returned via the lpNumberOfBytesTransferred parameter
  1014. //
  1015. #define JOB_OBJECT_MSG_END_OF_JOB_TIME 1
  1016. #define JOB_OBJECT_MSG_END_OF_PROCESS_TIME 2
  1017. #define JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT 3
  1018. #define JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO 4
  1019. #define JOB_OBJECT_MSG_NEW_PROCESS 6
  1020. #define JOB_OBJECT_MSG_EXIT_PROCESS 7
  1021. #define JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS 8
  1022. #define JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT 9
  1023. #define JOB_OBJECT_MSG_JOB_MEMORY_LIMIT 10
  1024. //
  1025. // Basic Limits
  1026. //
  1027. #define JOB_OBJECT_LIMIT_WORKINGSET 0x00000001
  1028. #define JOB_OBJECT_LIMIT_PROCESS_TIME 0x00000002
  1029. #define JOB_OBJECT_LIMIT_JOB_TIME 0x00000004
  1030. #define JOB_OBJECT_LIMIT_ACTIVE_PROCESS 0x00000008
  1031. #define JOB_OBJECT_LIMIT_AFFINITY 0x00000010
  1032. #define JOB_OBJECT_LIMIT_PRIORITY_CLASS 0x00000020
  1033. #define JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME 0x00000040
  1034. #define JOB_OBJECT_LIMIT_SCHEDULING_CLASS 0x00000080
  1035. //
  1036. // Extended Limits
  1037. //
  1038. #define JOB_OBJECT_LIMIT_PROCESS_MEMORY 0x00000100
  1039. #define JOB_OBJECT_LIMIT_JOB_MEMORY 0x00000200
  1040. #define JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION 0x00000400
  1041. #define JOB_OBJECT_LIMIT_BREAKAWAY_OK 0x00000800
  1042. #define JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK 0x00001000
  1043. #define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE 0x00002000
  1044. #define JOB_OBJECT_LIMIT_RESERVED2 0x00004000
  1045. #define JOB_OBJECT_LIMIT_RESERVED3 0x00008000
  1046. #define JOB_OBJECT_LIMIT_RESERVED4 0x00010000
  1047. #define JOB_OBJECT_LIMIT_RESERVED5 0x00020000
  1048. #define JOB_OBJECT_LIMIT_RESERVED6 0x00040000
  1049. #define JOB_OBJECT_LIMIT_VALID_FLAGS 0x0007ffff
  1050. #define JOB_OBJECT_BASIC_LIMIT_VALID_FLAGS 0x000000ff
  1051. #define JOB_OBJECT_EXTENDED_LIMIT_VALID_FLAGS 0x00003fff
  1052. #define JOB_OBJECT_RESERVED_LIMIT_VALID_FLAGS 0x0007ffff
  1053. //
  1054. // UI restrictions for jobs
  1055. //
  1056. #define JOB_OBJECT_UILIMIT_NONE 0x00000000
  1057. #define JOB_OBJECT_UILIMIT_HANDLES 0x00000001
  1058. #define JOB_OBJECT_UILIMIT_READCLIPBOARD 0x00000002
  1059. #define JOB_OBJECT_UILIMIT_WRITECLIPBOARD 0x00000004
  1060. #define JOB_OBJECT_UILIMIT_SYSTEMPARAMETERS 0x00000008
  1061. #define JOB_OBJECT_UILIMIT_DISPLAYSETTINGS 0x00000010
  1062. #define JOB_OBJECT_UILIMIT_GLOBALATOMS 0x00000020
  1063. #define JOB_OBJECT_UILIMIT_DESKTOP 0x00000040
  1064. #define JOB_OBJECT_UILIMIT_EXITWINDOWS 0x00000080
  1065. #define JOB_OBJECT_UILIMIT_ALL 0x000000FF
  1066. #define JOB_OBJECT_UI_VALID_FLAGS 0x000000FF
  1067. #define JOB_OBJECT_SECURITY_NO_ADMIN 0x00000001
  1068. #define JOB_OBJECT_SECURITY_RESTRICTED_TOKEN 0x00000002
  1069. #define JOB_OBJECT_SECURITY_ONLY_TOKEN 0x00000004
  1070. #define JOB_OBJECT_SECURITY_FILTER_TOKENS 0x00000008
  1071. #define JOB_OBJECT_SECURITY_VALID_FLAGS 0x0000000f
  1072. typedef enum _JOBOBJECTINFOCLASS {
  1073. JobObjectBasicAccountingInformation = 1,
  1074. JobObjectBasicLimitInformation,
  1075. JobObjectBasicProcessIdList,
  1076. JobObjectBasicUIRestrictions,
  1077. JobObjectSecurityLimitInformation,
  1078. JobObjectEndOfJobTimeInformation,
  1079. JobObjectAssociateCompletionPortInformation,
  1080. JobObjectBasicAndIoAccountingInformation,
  1081. JobObjectExtendedLimitInformation,
  1082. JobObjectJobSetInformation,
  1083. MaxJobObjectInfoClass
  1084. } JOBOBJECTINFOCLASS;
  1085. //
  1086. // end_winnt
  1087. //
  1088. NTSYSCALLAPI
  1089. NTSTATUS
  1090. NTAPI
  1091. NtQueryInformationJobObject(
  1092. IN HANDLE JobHandle,
  1093. IN JOBOBJECTINFOCLASS JobObjectInformationClass,
  1094. OUT PVOID JobObjectInformation,
  1095. IN ULONG JobObjectInformationLength,
  1096. OUT PULONG ReturnLength OPTIONAL
  1097. );
  1098. NTSYSCALLAPI
  1099. NTSTATUS
  1100. NTAPI
  1101. NtSetInformationJobObject(
  1102. IN HANDLE JobHandle,
  1103. IN JOBOBJECTINFOCLASS JobObjectInformationClass,
  1104. IN PVOID JobObjectInformation,
  1105. IN ULONG JobObjectInformationLength
  1106. );
  1107. #ifdef __cplusplus
  1108. }
  1109. #endif
  1110. #endif // _NTPSAPI_