4 #if (PHNT_MODE == PHNT_MODE_KERNEL)
5 #define PROCESS_TERMINATE 0x0001
6 #define PROCESS_CREATE_THREAD 0x0002
7 #define PROCESS_SET_SESSIONID 0x0004
8 #define PROCESS_VM_OPERATION 0x0008
9 #define PROCESS_VM_READ 0x0010
10 #define PROCESS_VM_WRITE 0x0020
11 #define PROCESS_CREATE_PROCESS 0x0080
12 #define PROCESS_SET_QUOTA 0x0100
13 #define PROCESS_SET_INFORMATION 0x0200
14 #define PROCESS_QUERY_INFORMATION 0x0400
15 #define PROCESS_SET_PORT 0x0800
16 #define PROCESS_SUSPEND_RESUME 0x0800
17 #define PROCESS_QUERY_LIMITED_INFORMATION 0x1000
19 #ifndef PROCESS_SET_PORT
20 #define PROCESS_SET_PORT 0x0800
24 #if (PHNT_MODE == PHNT_MODE_KERNEL)
25 #define THREAD_QUERY_INFORMATION 0x0040
26 #define THREAD_SET_THREAD_TOKEN 0x0080
27 #define THREAD_IMPERSONATE 0x0100
28 #define THREAD_DIRECT_IMPERSONATION 0x0200
31 #define THREAD_ALERT 0x0004
35 #if (PHNT_MODE == PHNT_MODE_KERNEL)
36 #define JOB_OBJECT_ASSIGN_PROCESS 0x0001
37 #define JOB_OBJECT_SET_ATTRIBUTES 0x0002
38 #define JOB_OBJECT_QUERY 0x0004
39 #define JOB_OBJECT_TERMINATE 0x0008
40 #define JOB_OBJECT_SET_SECURITY_ATTRIBUTES 0x0010
41 #define JOB_OBJECT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1f)
44 #define GDI_HANDLE_BUFFER_SIZE32 34
45 #define GDI_HANDLE_BUFFER_SIZE64 60
48 #define GDI_HANDLE_BUFFER_SIZE GDI_HANDLE_BUFFER_SIZE32
50 #define GDI_HANDLE_BUFFER_SIZE GDI_HANDLE_BUFFER_SIZE64
58 #define FLS_MAXIMUM_AVAILABLE 128
59 #define TLS_MINIMUM_AVAILABLE 64
60 #define TLS_EXPANSION_SLOTS 1024
97 #if (PHNT_MODE != PHNT_MODE_KERNEL)
98 typedef enum _PROCESSINFOCLASS
100 ProcessBasicInformation,
106 ProcessRaisePriority,
108 ProcessExceptionPort,
110 ProcessLdtInformation,
112 ProcessDefaultHardErrorMode,
113 ProcessIoPortHandlers,
114 ProcessPooledUsageAndLimits,
115 ProcessWorkingSetWatch,
117 ProcessEnableAlignmentFaultFixup,
118 ProcessPriorityClass,
119 ProcessWx86Information,
122 ProcessPriorityBoost,
124 ProcessSessionInformation,
125 ProcessForegroundInformation,
126 ProcessWow64Information,
127 ProcessImageFileName,
128 ProcessLUIDDeviceMapsEnabled,
129 ProcessBreakOnTermination,
130 ProcessDebugObjectHandle,
132 ProcessHandleTracing,
135 ProcessResourceManagement,
137 ProcessImageInformation,
140 ProcessInstrumentationCallback,
141 ProcessThreadStackAllocation,
142 ProcessWorkingSetWatchEx,
143 ProcessImageFileNameWin32,
144 ProcessImageFileMapping,
145 ProcessAffinityUpdateMode,
146 ProcessMemoryAllocationMode,
147 ProcessGroupInformation,
148 ProcessTokenVirtualizationEnabled,
149 ProcessConsoleHostProcess,
150 ProcessWindowInformation,
151 ProcessHandleInformation,
152 ProcessMitigationPolicy,
153 ProcessDynamicFunctionTableInformation,
154 ProcessHandleCheckingMode,
155 ProcessKeepAliveCount,
156 ProcessRevokeFileHandles,
157 ProcessWorkingSetControl,
159 ProcessCheckStackExtentsMode,
160 ProcessCommandLineInformation,
161 ProcessProtectionInformation,
162 ProcessMemoryExhaustion,
163 ProcessFaultInformation,
164 ProcessTelemetryIdInformation,
165 ProcessCommitReleaseInformation,
166 ProcessDefaultCpuSetsInformation,
167 ProcessAllowedCpuSetsInformation,
168 ProcessReserved1Information,
169 ProcessReserved2Information,
170 ProcessSubsystemProcess,
171 ProcessJobMemoryInformation,
176 #if (PHNT_MODE != PHNT_MODE_KERNEL)
177 typedef enum _THREADINFOCLASS
179 ThreadBasicInformation,
184 ThreadImpersonationToken,
185 ThreadDescriptorTableEntry,
186 ThreadEnableAlignmentFaultFixup,
188 ThreadQuerySetWin32StartAddress,
190 ThreadPerformanceCount,
192 ThreadIdealProcessor,
194 ThreadSetTlsArrayAddress,
196 ThreadHideFromDebugger,
197 ThreadBreakOnTermination,
198 ThreadSwitchLegacyState,
200 ThreadLastSystemCall,
204 ThreadActualBasePriority,
205 ThreadTebInformation,
209 ThreadGroupInformation,
210 ThreadUmsInformation,
211 ThreadCounterProfiling,
212 ThreadIdealProcessorEx,
213 ThreadCpuAccountingInformation,
215 ThreadHeterogeneousCpuPolicy,
217 ThreadNameInformation,
219 ThreadSelectedCpuSets,
220 ThreadSystemThreadInformation,
225 #if (PHNT_MODE != PHNT_MODE_KERNEL)
227 typedef struct _PAGE_PRIORITY_INFORMATION
230 } PAGE_PRIORITY_INFORMATION, *PPAGE_PRIORITY_INFORMATION;
235 #if (PHNT_MODE != PHNT_MODE_KERNEL)
237 typedef struct _PROCESS_BASIC_INFORMATION
241 ULONG_PTR AffinityMask;
243 HANDLE UniqueProcessId;
244 HANDLE InheritedFromUniqueProcessId;
245 } PROCESS_BASIC_INFORMATION, *PPROCESS_BASIC_INFORMATION;
247 typedef struct _PROCESS_EXTENDED_BASIC_INFORMATION
250 PROCESS_BASIC_INFORMATION BasicInfo;
256 ULONG IsProtectedProcess : 1;
257 ULONG IsWow64Process : 1;
258 ULONG IsProcessDeleting : 1;
259 ULONG IsCrossSessionCreate : 1;
261 ULONG IsBackground : 1;
262 ULONG IsStronglyNamed : 1;
263 ULONG IsSecureProcess : 1;
264 ULONG SpareBits : 24;
267 } PROCESS_EXTENDED_BASIC_INFORMATION, *PPROCESS_EXTENDED_BASIC_INFORMATION;
269 typedef struct _VM_COUNTERS
271 SIZE_T PeakVirtualSize;
273 ULONG PageFaultCount;
274 SIZE_T PeakWorkingSetSize;
275 SIZE_T WorkingSetSize;
276 SIZE_T QuotaPeakPagedPoolUsage;
277 SIZE_T QuotaPagedPoolUsage;
278 SIZE_T QuotaPeakNonPagedPoolUsage;
279 SIZE_T QuotaNonPagedPoolUsage;
280 SIZE_T PagefileUsage;
281 SIZE_T PeakPagefileUsage;
282 } VM_COUNTERS, *PVM_COUNTERS;
284 typedef struct _VM_COUNTERS_EX
286 SIZE_T PeakVirtualSize;
288 ULONG PageFaultCount;
289 SIZE_T PeakWorkingSetSize;
290 SIZE_T WorkingSetSize;
291 SIZE_T QuotaPeakPagedPoolUsage;
292 SIZE_T QuotaPagedPoolUsage;
293 SIZE_T QuotaPeakNonPagedPoolUsage;
294 SIZE_T QuotaNonPagedPoolUsage;
295 SIZE_T PagefileUsage;
296 SIZE_T PeakPagefileUsage;
298 } VM_COUNTERS_EX, *PVM_COUNTERS_EX;
301 typedef struct _VM_COUNTERS_EX2
303 VM_COUNTERS_EX CountersEx;
304 SIZE_T PrivateWorkingSetSize;
305 SIZE_T SharedCommitUsage;
306 } VM_COUNTERS_EX2, *PVM_COUNTERS_EX2;
308 typedef struct _KERNEL_USER_TIMES
310 LARGE_INTEGER CreateTime;
311 LARGE_INTEGER ExitTime;
312 LARGE_INTEGER KernelTime;
313 LARGE_INTEGER UserTime;
314 } KERNEL_USER_TIMES, *PKERNEL_USER_TIMES;
316 typedef struct _POOLED_USAGE_AND_LIMITS
318 SIZE_T PeakPagedPoolUsage;
319 SIZE_T PagedPoolUsage;
320 SIZE_T PagedPoolLimit;
321 SIZE_T PeakNonPagedPoolUsage;
322 SIZE_T NonPagedPoolUsage;
323 SIZE_T NonPagedPoolLimit;
324 SIZE_T PeakPagefileUsage;
325 SIZE_T PagefileUsage;
326 SIZE_T PagefileLimit;
327 } POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS;
329 typedef struct _PROCESS_ACCESS_TOKEN
333 } PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN;
335 typedef struct _PROCESS_LDT_INFORMATION
339 LDT_ENTRY LdtEntries[1];
340 } PROCESS_LDT_INFORMATION, *PPROCESS_LDT_INFORMATION;
342 typedef struct _PROCESS_LDT_SIZE
345 } PROCESS_LDT_SIZE, *PPROCESS_LDT_SIZE;
347 typedef struct _PROCESS_WS_WATCH_INFORMATION
351 } PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION;
363 #define PROCESS_PRIORITY_CLASS_UNKNOWN 0
364 #define PROCESS_PRIORITY_CLASS_IDLE 1
365 #define PROCESS_PRIORITY_CLASS_NORMAL 2
366 #define PROCESS_PRIORITY_CLASS_HIGH 3
367 #define PROCESS_PRIORITY_CLASS_REALTIME 4
368 #define PROCESS_PRIORITY_CLASS_BELOW_NORMAL 5
369 #define PROCESS_PRIORITY_CLASS_ABOVE_NORMAL 6
382 #if (PHNT_MODE != PHNT_MODE_KERNEL)
384 typedef struct _PROCESS_DEVICEMAP_INFORMATION
390 HANDLE DirectoryHandle;
398 } PROCESS_DEVICEMAP_INFORMATION, *PPROCESS_DEVICEMAP_INFORMATION;
400 #define PROCESS_LUID_DOSDEVICES_ONLY 0x00000001
402 typedef struct _PROCESS_DEVICEMAP_INFORMATION_EX
408 HANDLE DirectoryHandle;
417 } PROCESS_DEVICEMAP_INFORMATION_EX, *PPROCESS_DEVICEMAP_INFORMATION_EX;
419 typedef struct _PROCESS_SESSION_INFORMATION
422 } PROCESS_SESSION_INFORMATION, *PPROCESS_SESSION_INFORMATION;
424 typedef struct _PROCESS_HANDLE_TRACING_ENABLE
427 } PROCESS_HANDLE_TRACING_ENABLE, *PPROCESS_HANDLE_TRACING_ENABLE;
429 typedef struct _PROCESS_HANDLE_TRACING_ENABLE_EX
433 } PROCESS_HANDLE_TRACING_ENABLE_EX, *PPROCESS_HANDLE_TRACING_ENABLE_EX;
435 #define PROCESS_HANDLE_TRACING_MAX_STACKS 16
436 #define HANDLE_TRACE_DB_OPEN 1
437 #define HANDLE_TRACE_DB_CLOSE 2
438 #define HANDLE_TRACE_DB_BADREF 3
440 typedef struct _PROCESS_HANDLE_TRACING_ENTRY
445 PVOID Stacks[PROCESS_HANDLE_TRACING_MAX_STACKS];
446 } PROCESS_HANDLE_TRACING_ENTRY, *PPROCESS_HANDLE_TRACING_ENTRY;
448 typedef struct _PROCESS_HANDLE_TRACING_QUERY
452 PROCESS_HANDLE_TRACING_ENTRY HandleTrace[1];
453 } PROCESS_HANDLE_TRACING_QUERY, *PPROCESS_HANDLE_TRACING_QUERY;
540 #if (PHNT_MODE != PHNT_MODE_KERNEL)
543 typedef struct _PROCESS_MITIGATION_CONTROL_FLOW_GUARD_POLICY
550 ULONG EnableControlFlowGuard : 1;
551 ULONG ReservedFlags : 31;
554 } PROCESS_MITIGATION_CONTROL_FLOW_GUARD_POLICY, *PPROCESS_MITIGATION_CONTROL_FLOW_GUARD_POLICY;
557 typedef struct _PROCESS_MITIGATION_POLICY_INFORMATION
559 PROCESS_MITIGATION_POLICY Policy;
562 PROCESS_MITIGATION_ASLR_POLICY ASLRPolicy;
563 PROCESS_MITIGATION_STRICT_HANDLE_CHECK_POLICY StrictHandleCheckPolicy;
564 PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY SystemCallDisablePolicy;
565 PROCESS_MITIGATION_EXTENSION_POINT_DISABLE_POLICY ExtensionPointDisablePolicy;
566 PROCESS_MITIGATION_DYNAMIC_CODE_POLICY DynamicCodePolicy;
567 PROCESS_MITIGATION_CONTROL_FLOW_GUARD_POLICY ControlFlowGuardPolicy;
568 PROCESS_MITIGATION_BINARY_SIGNATURE_POLICY SignaturePolicy;
570 } PROCESS_MITIGATION_POLICY_INFORMATION, *PPROCESS_MITIGATION_POLICY_INFORMATION;
572 typedef struct _PROCESS_KEEPALIVE_COUNT_INFORMATION
576 } PROCESS_KEEPALIVE_COUNT_INFORMATION, *PPROCESS_KEEPALIVE_COUNT_INFORMATION;
578 typedef struct _PROCESS_REVOKE_FILE_HANDLES_INFORMATION
581 } PROCESS_REVOKE_FILE_HANDLES_INFORMATION, *PPROCESS_REVOKE_FILE_HANDLES_INFORMATION;
585 typedef enum _PROCESS_WORKING_SET_OPERATION
587 ProcessWorkingSetSwap,
588 ProcessWorkingSetEmpty,
589 ProcessWorkingSetOperationMax
590 } PROCESS_WORKING_SET_OPERATION;
592 typedef struct _PROCESS_WORKING_SET_CONTROL
595 PROCESS_WORKING_SET_OPERATION Operation;
597 } PROCESS_WORKING_SET_CONTROL, *PPROCESS_WORKING_SET_CONTROL;
599 typedef enum _PS_PROTECTED_TYPE
602 PsProtectedTypeProtectedLight,
603 PsProtectedTypeProtected,
607 typedef enum _PS_PROTECTED_SIGNER
609 PsProtectedSignerNone,
610 PsProtectedSignerAuthenticode,
611 PsProtectedSignerCodeGen,
612 PsProtectedSignerAntimalware,
613 PsProtectedSignerLsa,
614 PsProtectedSignerWindows,
615 PsProtectedSignerWinTcb,
617 } PS_PROTECTED_SIGNER;
619 typedef struct _PS_PROTECTION
631 } PS_PROTECTION, *PPS_PROTECTION;
633 typedef enum _PROCESS_MEMORY_EXHAUSTION_TYPE
635 PMETypeFailFastOnCommitFailure,
637 } PROCESS_MEMORY_EXHAUSTION_TYPE;
639 typedef struct _PROCESS_MEMORY_EXHAUSTION_INFO
643 PROCESS_MEMORY_EXHAUSTION_TYPE Type;
645 } PROCESS_MEMORY_EXHAUSTION_INFO, *PPROCESS_MEMORY_EXHAUSTION_INFO;
647 typedef struct _PROCESS_FAULT_INFORMATION
650 ULONG AdditionalInfo;
651 } PROCESS_FAULT_INFORMATION, *PPROCESS_FAULT_INFORMATION;
653 typedef struct _PROCESS_TELEMETRY_ID_INFORMATION
657 ULONGLONG ProcessStartKey;
658 ULONGLONG CreateTime;
659 ULONGLONG CreateInterruptTime;
660 ULONGLONG CreateUnbiasedInterruptTime;
661 ULONGLONG ProcessSequenceNumber;
662 ULONGLONG SessionCreateTime;
666 ULONG ImageTimeDateStamp;
668 ULONG ImagePathOffset;
669 ULONG PackageNameOffset;
670 ULONG RelativeAppNameOffset;
671 ULONG CommandLineOffset;
672 } PROCESS_TELEMETRY_ID_INFORMATION, *PPROCESS_TELEMETRY_ID_INFORMATION;
674 typedef struct _PROCESS_COMMIT_RELEASE_INFORMATION
683 } PROCESS_COMMIT_RELEASE_INFORMATION, *PPROCESS_COMMIT_RELEASE_INFORMATION;
685 typedef struct _PROCESS_JOB_MEMORY_INFO
687 ULONGLONG SharedCommitUsage;
688 ULONGLONG PrivateCommitUsage;
689 ULONGLONG PeakPrivateCommitUsage;
690 ULONGLONG PrivateCommitLimit;
691 ULONGLONG TotalCommitLimit;
692 } PROCESS_JOB_MEMORY_INFO, *PPROCESS_JOB_MEMORY_INFO;
767 #if (PHNT_MODE != PHNT_MODE_KERNEL)
773 _Out_ PHANDLE ProcessHandle,
774 _In_ ACCESS_MASK DesiredAccess,
776 _In_ HANDLE ParentProcess,
777 _In_ BOOLEAN InheritObjectTable,
778 _In_opt_ HANDLE SectionHandle,
779 _In_opt_ HANDLE DebugPort,
780 _In_opt_ HANDLE ExceptionPort
783 #define PROCESS_CREATE_FLAGS_BREAKAWAY 0x00000001
784 #define PROCESS_CREATE_FLAGS_NO_DEBUG_INHERIT 0x00000002
785 #define PROCESS_CREATE_FLAGS_INHERIT_HANDLES 0x00000004
786 #define PROCESS_CREATE_FLAGS_OVERRIDE_ADDRESS_SPACE 0x00000008
787 #define PROCESS_CREATE_FLAGS_LARGE_PAGES 0x00000010
793 _Out_ PHANDLE ProcessHandle,
794 _In_ ACCESS_MASK DesiredAccess,
796 _In_ HANDLE ParentProcess,
798 _In_opt_ HANDLE SectionHandle,
799 _In_opt_ HANDLE DebugPort,
800 _In_opt_ HANDLE ExceptionPort,
801 _In_ ULONG JobMemberLevel
808 _Out_ PHANDLE ProcessHandle,
809 _In_ ACCESS_MASK DesiredAccess,
818 _In_opt_ HANDLE ProcessHandle,
819 _In_ NTSTATUS ExitStatus
826 _In_ HANDLE ProcessHandle
833 _In_ HANDLE ProcessHandle
836 #define NtCurrentProcess() ((HANDLE)(LONG_PTR)-1)
837 #define ZwCurrentProcess() NtCurrentProcess()
838 #define NtCurrentThread() ((HANDLE)(LONG_PTR)-2)
839 #define ZwCurrentThread() NtCurrentThread()
840 #define NtCurrentSession() ((HANDLE)(LONG_PTR)-3)
841 #define ZwCurrentSession() NtCurrentSession()
842 #define NtCurrentPeb() (NtCurrentTeb()->ProcessEnvironmentBlock)
845 #define NtCurrentProcessId() (NtCurrentTeb()->ClientId.UniqueProcess)
846 #define NtCurrentThreadId() (NtCurrentTeb()->ClientId.UniqueThread)
851 NtQueryInformationProcess(
852 _In_ HANDLE ProcessHandle,
853 _In_ PROCESSINFOCLASS ProcessInformationClass,
854 _Out_writes_bytes_(ProcessInformationLength) PVOID ProcessInformation,
855 _In_ ULONG ProcessInformationLength,
856 _Out_opt_ PULONG ReturnLength
859 #if (PHNT_VERSION >= PHNT_WS03)
864 _In_ HANDLE ProcessHandle,
865 _In_ ACCESS_MASK DesiredAccess,
866 _In_ ULONG HandleAttributes,
868 _Out_ PHANDLE NewProcessHandle
872 #if (PHNT_VERSION >= PHNT_WS03)
877 _In_ HANDLE ProcessHandle,
878 _In_ HANDLE ThreadHandle,
879 _In_ ACCESS_MASK DesiredAccess,
880 _In_ ULONG HandleAttributes,
882 _Out_ PHANDLE NewThreadHandle
889 NtSetInformationProcess(
890 _In_ HANDLE ProcessHandle,
891 _In_ PROCESSINFOCLASS ProcessInformationClass,
892 _In_reads_bytes_(ProcessInformationLength) PVOID ProcessInformation,
893 _In_ ULONG ProcessInformationLength
899 NtQueryPortInformationProcess(
907 #if (PHNT_MODE != PHNT_MODE_KERNEL)
913 _Out_ PHANDLE ThreadHandle,
914 _In_ ACCESS_MASK DesiredAccess,
916 _In_ HANDLE ProcessHandle,
918 _In_ PCONTEXT ThreadContext,
919 _In_ PINITIAL_TEB InitialTeb,
920 _In_ BOOLEAN CreateSuspended
927 _Out_ PHANDLE ThreadHandle,
928 _In_ ACCESS_MASK DesiredAccess,
937 _In_opt_ HANDLE ThreadHandle,
938 _In_ NTSTATUS ExitStatus
945 _In_ HANDLE ThreadHandle,
946 _Out_opt_ PULONG PreviousSuspendCount
953 _In_ HANDLE ThreadHandle,
954 _Out_opt_ PULONG PreviousSuspendCount
960 NtGetCurrentProcessorNumber(
968 _In_ HANDLE ThreadHandle,
969 _Inout_ PCONTEXT ThreadContext
976 _In_ HANDLE ThreadHandle,
977 _In_ PCONTEXT ThreadContext
983 NtQueryInformationThread(
984 _In_ HANDLE ThreadHandle,
985 _In_ THREADINFOCLASS ThreadInformationClass,
986 _Out_writes_bytes_(ThreadInformationLength) PVOID ThreadInformation,
987 _In_ ULONG ThreadInformationLength,
988 _Out_opt_ PULONG ReturnLength
994 NtSetInformationThread(
995 _In_ HANDLE ThreadHandle,
996 _In_ THREADINFOCLASS ThreadInformationClass,
997 _In_reads_bytes_(ThreadInformationLength) PVOID ThreadInformation,
998 _In_ ULONG ThreadInformationLength
1005 _In_ HANDLE ThreadHandle
1011 NtAlertResumeThread(
1012 _In_ HANDLE ThreadHandle,
1013 _Out_opt_ PULONG PreviousSuspendCount
1026 NtImpersonateThread(
1027 _In_ HANDLE ServerThreadHandle,
1028 _In_ HANDLE ClientThreadHandle,
1029 _In_ PSECURITY_QUALITY_OF_SERVICE SecurityQos
1035 NtRegisterThreadTerminatePort(
1036 _In_ HANDLE PortHandle
1043 _In_ ULONG Selector0,
1044 _In_ ULONG Entry0Low,
1045 _In_ ULONG Entry0Hi,
1046 _In_ ULONG Selector1,
1047 _In_ ULONG Entry1Low,
1051 typedef VOID (*PPS_APC_ROUTINE)(
1052 _In_opt_ PVOID ApcArgument1,
1053 _In_opt_ PVOID ApcArgument2,
1054 _In_opt_ PVOID ApcArgument3
1061 _In_ HANDLE ThreadHandle,
1062 _In_ PPS_APC_ROUTINE ApcRoutine,
1063 _In_opt_ PVOID ApcArgument1,
1064 _In_opt_ PVOID ApcArgument2,
1065 _In_opt_ PVOID ApcArgument3
1068 #if (PHNT_VERSION >= PHNT_WIN7)
1073 _In_ HANDLE ThreadHandle,
1074 _In_opt_ HANDLE UserApcReserveHandle,
1075 _In_ PPS_APC_ROUTINE ApcRoutine,
1076 _In_opt_ PVOID ApcArgument1,
1077 _In_opt_ PVOID ApcArgument2,
1078 _In_opt_ PVOID ApcArgument3
1086 #if (PHNT_MODE != PHNT_MODE_KERNEL)
1091 #define PS_ATTRIBUTE_NUMBER_MASK 0x0000ffff
1092 #define PS_ATTRIBUTE_THREAD 0x00010000 // can be used with threads
1093 #define PS_ATTRIBUTE_INPUT 0x00020000 // input only
1094 #define PS_ATTRIBUTE_UNKNOWN 0x00040000
1098 typedef enum _PS_ATTRIBUTE_NUM
1100 PsAttributeParentProcess,
1101 PsAttributeDebugPort,
1103 PsAttributeClientId,
1104 PsAttributeTebAddress,
1105 PsAttributeImageName,
1106 PsAttributeImageInfo,
1107 PsAttributeMemoryReserve,
1108 PsAttributePriorityClass,
1109 PsAttributeErrorMode,
1110 PsAttributeStdHandleInfo,
1111 PsAttributeHandleList,
1112 PsAttributeGroupAffinity,
1113 PsAttributePreferredNode,
1114 PsAttributeIdealProcessor,
1115 PsAttributeUmsThread,
1116 PsAttributeMitigationOptions,
1117 PsAttributeProtectionLevel,
1118 PsAttributeSecureProcess,
1125 #define PsAttributeValue(Number, Thread, Input, Unknown) \
1126 (((Number) & PS_ATTRIBUTE_NUMBER_MASK) | \
1127 ((Thread) ? PS_ATTRIBUTE_THREAD : 0) | \
1128 ((Input) ? PS_ATTRIBUTE_INPUT : 0) | \
1129 ((Unknown) ? PS_ATTRIBUTE_UNKNOWN : 0))
1131 #define PS_ATTRIBUTE_PARENT_PROCESS \
1132 PsAttributeValue(PsAttributeParentProcess, FALSE, TRUE, TRUE)
1133 #define PS_ATTRIBUTE_DEBUG_PORT \
1134 PsAttributeValue(PsAttributeDebugPort, FALSE, TRUE, TRUE)
1135 #define PS_ATTRIBUTE_TOKEN \
1136 PsAttributeValue(PsAttributeToken, FALSE, TRUE, TRUE)
1137 #define PS_ATTRIBUTE_CLIENT_ID \
1138 PsAttributeValue(PsAttributeClientId, TRUE, FALSE, FALSE)
1139 #define PS_ATTRIBUTE_TEB_ADDRESS \
1140 PsAttributeValue(PsAttributeTebAddress, TRUE, FALSE, FALSE)
1141 #define PS_ATTRIBUTE_IMAGE_NAME \
1142 PsAttributeValue(PsAttributeImageName, FALSE, TRUE, FALSE)
1143 #define PS_ATTRIBUTE_IMAGE_INFO \
1144 PsAttributeValue(PsAttributeImageInfo, FALSE, FALSE, FALSE)
1145 #define PS_ATTRIBUTE_MEMORY_RESERVE \
1146 PsAttributeValue(PsAttributeMemoryReserve, FALSE, TRUE, FALSE)
1147 #define PS_ATTRIBUTE_PRIORITY_CLASS \
1148 PsAttributeValue(PsAttributePriorityClass, FALSE, TRUE, FALSE)
1149 #define PS_ATTRIBUTE_ERROR_MODE \
1150 PsAttributeValue(PsAttributeErrorMode, FALSE, TRUE, FALSE)
1151 #define PS_ATTRIBUTE_STD_HANDLE_INFO \
1152 PsAttributeValue(PsAttributeStdHandleInfo, FALSE, TRUE, FALSE)
1153 #define PS_ATTRIBUTE_HANDLE_LIST \
1154 PsAttributeValue(PsAttributeHandleList, FALSE, TRUE, FALSE)
1155 #define PS_ATTRIBUTE_GROUP_AFFINITY \
1156 PsAttributeValue(PsAttributeGroupAffinity, TRUE, TRUE, FALSE)
1157 #define PS_ATTRIBUTE_PREFERRED_NODE \
1158 PsAttributeValue(PsAttributePreferredNode, FALSE, TRUE, FALSE)
1159 #define PS_ATTRIBUTE_IDEAL_PROCESSOR \
1160 PsAttributeValue(PsAttributeIdealProcessor, TRUE, TRUE, FALSE)
1161 #define PS_ATTRIBUTE_MITIGATION_OPTIONS \
1162 PsAttributeValue(PsAttributeMitigationOptions, FALSE, TRUE, TRUE)
1168 typedef struct _PS_ATTRIBUTE
1177 PSIZE_T ReturnLength;
1178 } PS_ATTRIBUTE, *PPS_ATTRIBUTE;
1180 typedef struct _PS_ATTRIBUTE_LIST
1183 PS_ATTRIBUTE Attributes[1];
1184 } PS_ATTRIBUTE_LIST, *PPS_ATTRIBUTE_LIST;
1186 typedef struct _PS_MEMORY_RESERVE
1188 PVOID ReserveAddress;
1190 } PS_MEMORY_RESERVE, *PPS_MEMORY_RESERVE;
1192 typedef enum _PS_STD_HANDLE_STATE
1197 PsMaxStdHandleStates
1198 } PS_STD_HANDLE_STATE;
1201 #define PS_STD_INPUT_HANDLE 0x1
1202 #define PS_STD_OUTPUT_HANDLE 0x2
1203 #define PS_STD_ERROR_HANDLE 0x4
1206 typedef struct _PS_STD_HANDLE_INFO
1213 ULONG StdHandleState : 2;
1214 ULONG PseudoHandleMask : 3;
1217 ULONG StdHandleSubsystemType;
1218 } PS_STD_HANDLE_INFO, *PPS_STD_HANDLE_INFO;
1221 typedef enum _PS_CREATE_STATE
1223 PsCreateInitialState,
1224 PsCreateFailOnFileOpen,
1225 PsCreateFailOnSectionCreate,
1226 PsCreateFailExeFormat,
1227 PsCreateFailMachineMismatch,
1228 PsCreateFailExeName,
1230 PsCreateMaximumStates
1233 typedef struct _PS_CREATE_INFO
1236 PS_CREATE_STATE State;
1247 UCHAR WriteOutputOnExit : 1;
1248 UCHAR DetectManifest : 1;
1249 UCHAR IFEOSkipDebugger : 1;
1250 UCHAR IFEODoNotPropagateKeyState : 1;
1251 UCHAR SpareBits1 : 4;
1252 UCHAR SpareBits2 : 8;
1253 USHORT ProhibitedImageCharacteristics : 16;
1256 ACCESS_MASK AdditionalFileAccess;
1268 USHORT DllCharacteristics;
1285 UCHAR ProtectedProcess : 1;
1286 UCHAR AddressSpaceOverride : 1;
1287 UCHAR DevOverrideEnabled : 1;
1288 UCHAR ManifestDetected : 1;
1289 UCHAR ProtectedProcessLight : 1;
1290 UCHAR SpareBits1 : 3;
1291 UCHAR SpareBits2 : 8;
1292 USHORT SpareBits3 : 16;
1296 HANDLE SectionHandle;
1297 ULONGLONG UserProcessParametersNative;
1298 ULONG UserProcessParametersWow64;
1299 ULONG CurrentParameterFlags;
1300 ULONGLONG PebAddressNative;
1301 ULONG PebAddressWow64;
1302 ULONGLONG ManifestAddress;
1306 } PS_CREATE_INFO, *PPS_CREATE_INFO;
1312 #define PROCESS_CREATE_FLAGS_LARGE_PAGE_SYSTEM_DLL 0x00000020
1313 #define PROCESS_CREATE_FLAGS_PROTECTED_PROCESS 0x00000040
1314 #define PROCESS_CREATE_FLAGS_CREATE_SESSION 0x00000080 // ?
1315 #define PROCESS_CREATE_FLAGS_INHERIT_FROM_PARENT 0x00000100
1318 #if (PHNT_VERSION >= PHNT_VISTA)
1322 NtCreateUserProcess(
1323 _Out_ PHANDLE ProcessHandle,
1324 _Out_ PHANDLE ThreadHandle,
1325 _In_ ACCESS_MASK ProcessDesiredAccess,
1326 _In_ ACCESS_MASK ThreadDesiredAccess,
1329 _In_ ULONG ProcessFlags,
1330 _In_ ULONG ThreadFlags,
1331 _In_opt_ PVOID ProcessParameters,
1332 _Inout_ PPS_CREATE_INFO CreateInfo,
1333 _In_opt_ PPS_ATTRIBUTE_LIST AttributeList
1338 #define THREAD_CREATE_FLAGS_CREATE_SUSPENDED 0x00000001
1339 #define THREAD_CREATE_FLAGS_SKIP_THREAD_ATTACH 0x00000002 // ?
1340 #define THREAD_CREATE_FLAGS_HIDE_FROM_DEBUGGER 0x00000004
1341 #define THREAD_CREATE_FLAGS_HAS_SECURITY_DESCRIPTOR 0x00000010 // ?
1342 #define THREAD_CREATE_FLAGS_ACCESS_CHECK_IN_TARGET 0x00000020 // ?
1343 #define THREAD_CREATE_FLAGS_INITIAL_THREAD 0x00000080
1346 #if (PHNT_VERSION >= PHNT_VISTA)
1351 _Out_ PHANDLE ThreadHandle,
1352 _In_ ACCESS_MASK DesiredAccess,
1354 _In_ HANDLE ProcessHandle,
1355 _In_ PVOID StartRoutine,
1356 _In_opt_ PVOID Argument,
1357 _In_ ULONG CreateFlags,
1358 _In_ SIZE_T ZeroBits,
1359 _In_ SIZE_T StackSize,
1360 _In_ SIZE_T MaximumStackSize,
1361 _In_opt_ PPS_ATTRIBUTE_LIST AttributeList
1369 #if (PHNT_MODE != PHNT_MODE_KERNEL)
1375 _Out_ PHANDLE JobHandle,
1376 _In_ ACCESS_MASK DesiredAccess,
1384 _Out_ PHANDLE JobHandle,
1385 _In_ ACCESS_MASK DesiredAccess,
1392 NtAssignProcessToJobObject(
1393 _In_ HANDLE JobHandle,
1394 _In_ HANDLE ProcessHandle
1400 NtTerminateJobObject(
1401 _In_ HANDLE JobHandle,
1402 _In_ NTSTATUS ExitStatus
1409 _In_ HANDLE ProcessHandle,
1410 _In_opt_ HANDLE JobHandle
1416 NtQueryInformationJobObject(
1417 _In_opt_ HANDLE JobHandle,
1418 _In_ JOBOBJECTINFOCLASS JobObjectInformationClass,
1419 _Out_writes_bytes_(JobObjectInformationLength) PVOID JobObjectInformation,
1420 _In_ ULONG JobObjectInformationLength,
1421 _Out_opt_ PULONG ReturnLength
1427 NtSetInformationJobObject(
1428 _In_ HANDLE JobHandle,
1429 _In_ JOBOBJECTINFOCLASS JobObjectInformationClass,
1430 _In_reads_bytes_(JobObjectInformationLength) PVOID JobObjectInformation,
1431 _In_ ULONG JobObjectInformationLength
1439 _In_reads_(NumJob) PJOB_SET_ARRAY UserJobSet,
1443 #if (PHNT_VERSION >= PHNT_THRESHOLD)
1447 NtRevertContainerImpersonation(
1456 #if (PHNT_MODE != PHNT_MODE_KERNEL)
1459 typedef enum _MEMORY_RESERVE_TYPE
1461 MemoryReserveUserApc,
1462 MemoryReserveIoCompletion,
1463 MemoryReserveTypeMax
1464 } MEMORY_RESERVE_TYPE;
1466 #if (PHNT_VERSION >= PHNT_WIN7)
1470 NtAllocateReserveObject(
1471 _Out_ PHANDLE MemoryReserveHandle,
1473 _In_ MEMORY_RESERVE_TYPE Type
1481 #if (PHNT_MODE != PHNT_MODE_KERNEL)
1485 typedef enum _SERVERSILO_STATE
1489 SERVERSILO_TERMINATING,
1490 SERVERSILO_TERMINATED
1493 typedef enum _SILOOBJECTINFOCLASS
1495 SiloObjectBasicInformation,
1496 SiloObjectBasicProcessIdList,
1497 SiloObjectChildSiloIdList,
1498 SiloObjectRootDirectory,
1499 ServerSiloBasicInformation,
1500 ServerSiloServiceSessionId,
1501 ServerSiloInitialize,
1502 ServerSiloDefaultCompartmentId,
1503 MaxSiloObjectInfoClass
1504 } SILOOBJECTINFOCLASS;
1506 typedef struct _SILOOBJECT_BASIC_INFORMATION
1508 HANDLE SiloIdNumber;
1509 HANDLE SiloParentIdNumber;
1510 ULONG NumberOfProcesses;
1511 ULONG NumberOfChildSilos;
1512 BOOLEAN IsInServerSilo;
1513 } SILOOBJECT_BASIC_INFORMATION, *PSILOOBJECT_BASIC_INFORMATION;
1515 typedef struct _SILOOBJECT_ROOT_DIRECTORY
1517 HANDLE DirectoryHandle;
1518 } SILOOBJECT_ROOT_DIRECTORY, *PSILOOBJECT_ROOT_DIRECTORY;
1520 typedef struct _SERVERSILO_BASIC_INFORMATION
1522 HANDLE SiloIdNumber;
1523 ULONG ServiceSessionId;
1524 ULONG DefaultCompartmentId;
1525 SERVERSILO_STATE State;
1526 } SERVERSILO_BASIC_INFORMATION, *PSERVERSILO_BASIC_INFORMATION;
1530 #if (PHNT_VERSION >= PHNT_THRESHOLD)
1536 _Out_ PHANDLE SiloHandle,
1537 _In_ ACCESS_MASK DesiredAccess,
1545 _Out_ PHANDLE SiloHandle,
1546 _In_ ACCESS_MASK DesiredAccess,
1548 _In_opt_ HANDLE SiloId
1554 NtAssignProcessToSiloObject(
1555 _In_ HANDLE SiloHandle,
1556 _In_ HANDLE ProcessHandle
1562 NtTerminateSiloObject(
1563 _In_ HANDLE SiloHandle,
1564 _In_ NTSTATUS ExitStatus
1570 NtQueryInformationSiloObject(
1571 _In_opt_ HANDLE SiloHandle,
1572 _In_ SILOOBJECTINFOCLASS SiloObjectInformationClass,
1573 _Out_writes_bytes_(SiloObjectInformationLength) PVOID SiloObjectInformation,
1574 _In_ ULONG SiloObjectInformationLength,
1575 _Out_opt_ PULONG ReturnLength
1581 NtSetInformationSiloObject(
1582 _In_opt_ HANDLE SiloHandle,
1583 _In_ SILOOBJECTINFOCLASS SiloObjectInformationClass,
1584 _In_reads_bytes_(SiloObjectInformationLength) PVOID SiloObjectInformation,
1585 _In_ ULONG SiloObjectInformationLength
1591 NtAttachThreadSiloToCurrentThread(
1592 _In_ HANDLE ThreadHandle,
1593 _Out_ PHANDLE PreviousSiloHandle,
1594 _Out_opt_ PBOOLEAN bChangedSilo
1600 NtAttachThreadIdSiloToCurrentThread(
1601 _In_ HANDLE ThreadId,
1602 _Out_ PHANDLE PreviousSiloHandle,
1603 _Out_opt_ PBOOLEAN bChangedSilo
1609 NtDetachSiloFromCurrentThread(
1610 _In_ HANDLE SiloHandle