Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / sandbox / win / src / nt_internals.h
blob010f7cb031e63254ec3a6cba7f57d0c13416ee4a
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // This file holds definitions related to the ntdll API.
7 #ifndef SANDBOX_WIN_SRC_NT_INTERNALS_H__
8 #define SANDBOX_WIN_SRC_NT_INTERNALS_H__
10 #include <windows.h>
12 typedef LONG NTSTATUS;
13 #define NT_SUCCESS(st) (st >= 0)
15 #define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
16 #define STATUS_BUFFER_OVERFLOW ((NTSTATUS)0x80000005L)
17 #define STATUS_UNSUCCESSFUL ((NTSTATUS)0xC0000001L)
18 #define STATUS_NOT_IMPLEMENTED ((NTSTATUS)0xC0000002L)
19 #define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS)0xC0000004L)
20 #ifndef STATUS_INVALID_PARAMETER
21 // It is now defined in Windows 2008 SDK.
22 #define STATUS_INVALID_PARAMETER ((NTSTATUS)0xC000000DL)
23 #endif
24 #define STATUS_CONFLICTING_ADDRESSES ((NTSTATUS)0xC0000018L)
25 #define STATUS_ACCESS_DENIED ((NTSTATUS)0xC0000022L)
26 #define STATUS_BUFFER_TOO_SMALL ((NTSTATUS)0xC0000023L)
27 #define STATUS_OBJECT_NAME_NOT_FOUND ((NTSTATUS)0xC0000034L)
28 #define STATUS_OBJECT_NAME_COLLISION ((NTSTATUS)0xC0000035L)
29 #define STATUS_PROCEDURE_NOT_FOUND ((NTSTATUS)0xC000007AL)
30 #define STATUS_INVALID_IMAGE_FORMAT ((NTSTATUS)0xC000007BL)
31 #define STATUS_NO_TOKEN ((NTSTATUS)0xC000007CL)
33 #define CURRENT_PROCESS ((HANDLE) -1)
34 #define CURRENT_THREAD ((HANDLE) -2)
35 #define NtCurrentProcess CURRENT_PROCESS
37 typedef struct _UNICODE_STRING {
38 USHORT Length;
39 USHORT MaximumLength;
40 PWSTR Buffer;
41 } UNICODE_STRING;
42 typedef UNICODE_STRING *PUNICODE_STRING;
43 typedef const UNICODE_STRING *PCUNICODE_STRING;
45 typedef struct _STRING {
46 USHORT Length;
47 USHORT MaximumLength;
48 PCHAR Buffer;
49 } STRING;
50 typedef STRING *PSTRING;
52 typedef STRING ANSI_STRING;
53 typedef PSTRING PANSI_STRING;
54 typedef CONST PSTRING PCANSI_STRING;
56 typedef STRING OEM_STRING;
57 typedef PSTRING POEM_STRING;
58 typedef CONST STRING* PCOEM_STRING;
60 #define OBJ_CASE_INSENSITIVE 0x00000040L
61 #define OBJ_OPENIF 0x00000080L
63 typedef struct _OBJECT_ATTRIBUTES {
64 ULONG Length;
65 HANDLE RootDirectory;
66 PUNICODE_STRING ObjectName;
67 ULONG Attributes;
68 PVOID SecurityDescriptor;
69 PVOID SecurityQualityOfService;
70 } OBJECT_ATTRIBUTES;
71 typedef OBJECT_ATTRIBUTES *POBJECT_ATTRIBUTES;
73 #define InitializeObjectAttributes(p, n, a, r, s) { \
74 (p)->Length = sizeof(OBJECT_ATTRIBUTES);\
75 (p)->RootDirectory = r;\
76 (p)->Attributes = a;\
77 (p)->ObjectName = n;\
78 (p)->SecurityDescriptor = s;\
79 (p)->SecurityQualityOfService = NULL;\
82 typedef struct _IO_STATUS_BLOCK {
83 union {
84 NTSTATUS Status;
85 PVOID Pointer;
87 ULONG_PTR Information;
88 } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
90 // -----------------------------------------------------------------------
91 // File IO
93 // Create disposition values.
95 #define FILE_SUPERSEDE 0x00000000
96 #define FILE_OPEN 0x00000001
97 #define FILE_CREATE 0x00000002
98 #define FILE_OPEN_IF 0x00000003
99 #define FILE_OVERWRITE 0x00000004
100 #define FILE_OVERWRITE_IF 0x00000005
101 #define FILE_MAXIMUM_DISPOSITION 0x00000005
103 // Create/open option flags.
105 #define FILE_DIRECTORY_FILE 0x00000001
106 #define FILE_WRITE_THROUGH 0x00000002
107 #define FILE_SEQUENTIAL_ONLY 0x00000004
108 #define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008
110 #define FILE_SYNCHRONOUS_IO_ALERT 0x00000010
111 #define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020
112 #define FILE_NON_DIRECTORY_FILE 0x00000040
113 #define FILE_CREATE_TREE_CONNECTION 0x00000080
115 #define FILE_COMPLETE_IF_OPLOCKED 0x00000100
116 #define FILE_NO_EA_KNOWLEDGE 0x00000200
117 #define FILE_OPEN_REMOTE_INSTANCE 0x00000400
118 #define FILE_RANDOM_ACCESS 0x00000800
120 #define FILE_DELETE_ON_CLOSE 0x00001000
121 #define FILE_OPEN_BY_FILE_ID 0x00002000
122 #define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000
123 #define FILE_NO_COMPRESSION 0x00008000
125 #define FILE_RESERVE_OPFILTER 0x00100000
126 #define FILE_OPEN_REPARSE_POINT 0x00200000
127 #define FILE_OPEN_NO_RECALL 0x00400000
128 #define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000
130 // Create/open result values. These are the disposition values returned on the
131 // io status information.
132 #define FILE_SUPERSEDED 0x00000000
133 #define FILE_OPENED 0x00000001
134 #define FILE_CREATED 0x00000002
135 #define FILE_OVERWRITTEN 0x00000003
136 #define FILE_EXISTS 0x00000004
137 #define FILE_DOES_NOT_EXIST 0x00000005
139 typedef NTSTATUS (WINAPI *NtCreateFileFunction)(
140 OUT PHANDLE FileHandle,
141 IN ACCESS_MASK DesiredAccess,
142 IN POBJECT_ATTRIBUTES ObjectAttributes,
143 OUT PIO_STATUS_BLOCK IoStatusBlock,
144 IN PLARGE_INTEGER AllocationSize OPTIONAL,
145 IN ULONG FileAttributes,
146 IN ULONG ShareAccess,
147 IN ULONG CreateDisposition,
148 IN ULONG CreateOptions,
149 IN PVOID EaBuffer OPTIONAL,
150 IN ULONG EaLength);
152 typedef NTSTATUS (WINAPI *NtOpenFileFunction)(
153 OUT PHANDLE FileHandle,
154 IN ACCESS_MASK DesiredAccess,
155 IN POBJECT_ATTRIBUTES ObjectAttributes,
156 OUT PIO_STATUS_BLOCK IoStatusBlock,
157 IN ULONG ShareAccess,
158 IN ULONG OpenOptions);
160 typedef NTSTATUS (WINAPI *NtCloseFunction)(
161 IN HANDLE Handle);
163 typedef enum _FILE_INFORMATION_CLASS {
164 FileRenameInformation = 10
165 } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
167 typedef struct _FILE_RENAME_INFORMATION {
168 BOOLEAN ReplaceIfExists;
169 HANDLE RootDirectory;
170 ULONG FileNameLength;
171 WCHAR FileName[1];
172 } FILE_RENAME_INFORMATION, *PFILE_RENAME_INFORMATION;
174 typedef NTSTATUS (WINAPI *NtSetInformationFileFunction)(
175 IN HANDLE FileHandle,
176 OUT PIO_STATUS_BLOCK IoStatusBlock,
177 IN PVOID FileInformation,
178 IN ULONG Length,
179 IN FILE_INFORMATION_CLASS FileInformationClass);
181 typedef struct FILE_BASIC_INFORMATION {
182 LARGE_INTEGER CreationTime;
183 LARGE_INTEGER LastAccessTime;
184 LARGE_INTEGER LastWriteTime;
185 LARGE_INTEGER ChangeTime;
186 ULONG FileAttributes;
187 } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
189 typedef NTSTATUS (WINAPI *NtQueryAttributesFileFunction)(
190 IN POBJECT_ATTRIBUTES ObjectAttributes,
191 OUT PFILE_BASIC_INFORMATION FileAttributes);
193 typedef struct _FILE_NETWORK_OPEN_INFORMATION {
194 LARGE_INTEGER CreationTime;
195 LARGE_INTEGER LastAccessTime;
196 LARGE_INTEGER LastWriteTime;
197 LARGE_INTEGER ChangeTime;
198 LARGE_INTEGER AllocationSize;
199 LARGE_INTEGER EndOfFile;
200 ULONG FileAttributes;
201 } FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION;
203 typedef NTSTATUS (WINAPI *NtQueryFullAttributesFileFunction)(
204 IN POBJECT_ATTRIBUTES ObjectAttributes,
205 OUT PFILE_NETWORK_OPEN_INFORMATION FileAttributes);
207 // -----------------------------------------------------------------------
208 // Sections
210 typedef NTSTATUS (WINAPI *NtCreateSectionFunction)(
211 OUT PHANDLE SectionHandle,
212 IN ACCESS_MASK DesiredAccess,
213 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
214 IN PLARGE_INTEGER MaximumSize OPTIONAL,
215 IN ULONG SectionPageProtection,
216 IN ULONG AllocationAttributes,
217 IN HANDLE FileHandle OPTIONAL);
219 typedef ULONG SECTION_INHERIT;
220 #define ViewShare 1
221 #define ViewUnmap 2
223 typedef NTSTATUS (WINAPI *NtMapViewOfSectionFunction)(
224 IN HANDLE SectionHandle,
225 IN HANDLE ProcessHandle,
226 IN OUT PVOID *BaseAddress,
227 IN ULONG_PTR ZeroBits,
228 IN SIZE_T CommitSize,
229 IN OUT PLARGE_INTEGER SectionOffset OPTIONAL,
230 IN OUT PSIZE_T ViewSize,
231 IN SECTION_INHERIT InheritDisposition,
232 IN ULONG AllocationType,
233 IN ULONG Win32Protect);
235 typedef NTSTATUS (WINAPI *NtUnmapViewOfSectionFunction)(
236 IN HANDLE ProcessHandle,
237 IN PVOID BaseAddress);
239 typedef enum _SECTION_INFORMATION_CLASS {
240 SectionBasicInformation = 0,
241 SectionImageInformation
242 } SECTION_INFORMATION_CLASS;
244 typedef struct _SECTION_BASIC_INFORMATION {
245 PVOID BaseAddress;
246 ULONG Attributes;
247 LARGE_INTEGER Size;
248 } SECTION_BASIC_INFORMATION, *PSECTION_BASIC_INFORMATION;
250 typedef NTSTATUS (WINAPI *NtQuerySectionFunction)(
251 IN HANDLE SectionHandle,
252 IN SECTION_INFORMATION_CLASS SectionInformationClass,
253 OUT PVOID SectionInformation,
254 IN SIZE_T SectionInformationLength,
255 OUT PSIZE_T ReturnLength OPTIONAL);
257 // -----------------------------------------------------------------------
258 // Process and Thread
260 typedef struct _CLIENT_ID {
261 PVOID UniqueProcess;
262 PVOID UniqueThread;
263 } CLIENT_ID, *PCLIENT_ID;
265 typedef NTSTATUS (WINAPI *NtOpenThreadFunction) (
266 OUT PHANDLE ThreadHandle,
267 IN ACCESS_MASK DesiredAccess,
268 IN POBJECT_ATTRIBUTES ObjectAttributes,
269 IN PCLIENT_ID ClientId);
271 typedef NTSTATUS (WINAPI *NtOpenProcessFunction) (
272 OUT PHANDLE ProcessHandle,
273 IN ACCESS_MASK DesiredAccess,
274 IN POBJECT_ATTRIBUTES ObjectAttributes,
275 IN PCLIENT_ID ClientId);
277 typedef enum _NT_THREAD_INFORMATION_CLASS {
278 ThreadBasicInformation,
279 ThreadTimes,
280 ThreadPriority,
281 ThreadBasePriority,
282 ThreadAffinityMask,
283 ThreadImpersonationToken,
284 ThreadDescriptorTableEntry,
285 ThreadEnableAlignmentFaultFixup,
286 ThreadEventPair,
287 ThreadQuerySetWin32StartAddress,
288 ThreadZeroTlsCell,
289 ThreadPerformanceCount,
290 ThreadAmILastThread,
291 ThreadIdealProcessor,
292 ThreadPriorityBoost,
293 ThreadSetTlsArrayAddress,
294 ThreadIsIoPending,
295 ThreadHideFromDebugger
296 } NT_THREAD_INFORMATION_CLASS, *PNT_THREAD_INFORMATION_CLASS;
298 typedef NTSTATUS (WINAPI *NtSetInformationThreadFunction) (
299 IN HANDLE ThreadHandle,
300 IN NT_THREAD_INFORMATION_CLASS ThreadInformationClass,
301 IN PVOID ThreadInformation,
302 IN ULONG ThreadInformationLength);
304 // Partial definition only:
305 typedef enum _PROCESSINFOCLASS {
306 ProcessBasicInformation = 0,
307 ProcessExecuteFlags = 0x22
308 } PROCESSINFOCLASS;
310 typedef PVOID PPEB;
311 typedef LONG KPRIORITY;
313 typedef struct _PROCESS_BASIC_INFORMATION {
314 union {
315 NTSTATUS ExitStatus;
316 PVOID padding_for_x64_0;
318 PPEB PebBaseAddress;
319 KAFFINITY AffinityMask;
320 union {
321 KPRIORITY BasePriority;
322 PVOID padding_for_x64_1;
324 union {
325 DWORD UniqueProcessId;
326 PVOID padding_for_x64_2;
328 union {
329 DWORD InheritedFromUniqueProcessId;
330 PVOID padding_for_x64_3;
332 } PROCESS_BASIC_INFORMATION, *PPROCESS_BASIC_INFORMATION;
334 typedef NTSTATUS (WINAPI *NtQueryInformationProcessFunction)(
335 IN HANDLE ProcessHandle,
336 IN PROCESSINFOCLASS ProcessInformationClass,
337 OUT PVOID ProcessInformation,
338 IN ULONG ProcessInformationLength,
339 OUT PULONG ReturnLength OPTIONAL);
341 typedef NTSTATUS (WINAPI *NtSetInformationProcessFunction)(
342 HANDLE ProcessHandle,
343 IN PROCESSINFOCLASS ProcessInformationClass,
344 IN PVOID ProcessInformation,
345 IN ULONG ProcessInformationLength);
347 typedef NTSTATUS (WINAPI *NtOpenThreadTokenFunction) (
348 IN HANDLE ThreadHandle,
349 IN ACCESS_MASK DesiredAccess,
350 IN BOOLEAN OpenAsSelf,
351 OUT PHANDLE TokenHandle);
353 typedef NTSTATUS (WINAPI *NtOpenThreadTokenExFunction) (
354 IN HANDLE ThreadHandle,
355 IN ACCESS_MASK DesiredAccess,
356 IN BOOLEAN OpenAsSelf,
357 IN ULONG HandleAttributes,
358 OUT PHANDLE TokenHandle);
360 typedef NTSTATUS (WINAPI *NtOpenProcessTokenFunction) (
361 IN HANDLE ProcessHandle,
362 IN ACCESS_MASK DesiredAccess,
363 OUT PHANDLE TokenHandle);
365 typedef NTSTATUS (WINAPI *NtOpenProcessTokenExFunction) (
366 IN HANDLE ProcessHandle,
367 IN ACCESS_MASK DesiredAccess,
368 IN ULONG HandleAttributes,
369 OUT PHANDLE TokenHandle);
371 typedef NTSTATUS (WINAPI * RtlCreateUserThreadFunction)(
372 IN HANDLE Process,
373 IN PSECURITY_DESCRIPTOR ThreadSecurityDescriptor,
374 IN BOOLEAN CreateSuspended,
375 IN ULONG ZeroBits,
376 IN SIZE_T MaximumStackSize,
377 IN SIZE_T CommittedStackSize,
378 IN LPTHREAD_START_ROUTINE StartAddress,
379 IN PVOID Parameter,
380 OUT PHANDLE Thread,
381 OUT PCLIENT_ID ClientId);
383 // -----------------------------------------------------------------------
384 // Registry
386 typedef NTSTATUS (WINAPI *NtCreateKeyFunction)(
387 OUT PHANDLE KeyHandle,
388 IN ACCESS_MASK DesiredAccess,
389 IN POBJECT_ATTRIBUTES ObjectAttributes,
390 IN ULONG TitleIndex,
391 IN PUNICODE_STRING Class OPTIONAL,
392 IN ULONG CreateOptions,
393 OUT PULONG Disposition OPTIONAL);
395 typedef NTSTATUS (WINAPI *NtOpenKeyFunction)(
396 OUT PHANDLE KeyHandle,
397 IN ACCESS_MASK DesiredAccess,
398 IN POBJECT_ATTRIBUTES ObjectAttributes);
400 typedef NTSTATUS (WINAPI *NtOpenKeyExFunction)(
401 OUT PHANDLE KeyHandle,
402 IN ACCESS_MASK DesiredAccess,
403 IN POBJECT_ATTRIBUTES ObjectAttributes,
404 IN DWORD open_options);
406 typedef NTSTATUS (WINAPI *NtDeleteKeyFunction)(
407 IN HANDLE KeyHandle);
409 // -----------------------------------------------------------------------
410 // Memory
412 // Don't really need this structure right now.
413 typedef PVOID PRTL_HEAP_PARAMETERS;
415 typedef PVOID (WINAPI *RtlCreateHeapFunction)(
416 IN ULONG Flags,
417 IN PVOID HeapBase OPTIONAL,
418 IN SIZE_T ReserveSize OPTIONAL,
419 IN SIZE_T CommitSize OPTIONAL,
420 IN PVOID Lock OPTIONAL,
421 IN PRTL_HEAP_PARAMETERS Parameters OPTIONAL);
423 typedef PVOID (WINAPI *RtlDestroyHeapFunction)(
424 IN PVOID HeapHandle);
426 typedef PVOID (WINAPI *RtlAllocateHeapFunction)(
427 IN PVOID HeapHandle,
428 IN ULONG Flags,
429 IN SIZE_T Size);
431 typedef BOOLEAN (WINAPI *RtlFreeHeapFunction)(
432 IN PVOID HeapHandle,
433 IN ULONG Flags,
434 IN PVOID HeapBase);
436 typedef NTSTATUS (WINAPI *NtAllocateVirtualMemoryFunction) (
437 IN HANDLE ProcessHandle,
438 IN OUT PVOID *BaseAddress,
439 IN ULONG_PTR ZeroBits,
440 IN OUT PSIZE_T RegionSize,
441 IN ULONG AllocationType,
442 IN ULONG Protect);
444 typedef NTSTATUS (WINAPI *NtFreeVirtualMemoryFunction) (
445 IN HANDLE ProcessHandle,
446 IN OUT PVOID *BaseAddress,
447 IN OUT PSIZE_T RegionSize,
448 IN ULONG FreeType);
450 typedef enum _MEMORY_INFORMATION_CLASS {
451 MemoryBasicInformation = 0,
452 MemoryWorkingSetList,
453 MemorySectionName,
454 MemoryBasicVlmInformation
455 } MEMORY_INFORMATION_CLASS;
457 typedef struct _MEMORY_SECTION_NAME { // Information Class 2
458 UNICODE_STRING SectionFileName;
459 } MEMORY_SECTION_NAME, *PMEMORY_SECTION_NAME;
461 typedef NTSTATUS (WINAPI *NtQueryVirtualMemoryFunction)(
462 IN HANDLE ProcessHandle,
463 IN PVOID BaseAddress,
464 IN MEMORY_INFORMATION_CLASS MemoryInformationClass,
465 OUT PVOID MemoryInformation,
466 IN SIZE_T MemoryInformationLength,
467 OUT PSIZE_T ReturnLength OPTIONAL);
469 typedef NTSTATUS (WINAPI *NtProtectVirtualMemoryFunction)(
470 IN HANDLE ProcessHandle,
471 IN OUT PVOID* BaseAddress,
472 IN OUT PSIZE_T ProtectSize,
473 IN ULONG NewProtect,
474 OUT PULONG OldProtect);
476 // -----------------------------------------------------------------------
477 // Objects
479 typedef enum _OBJECT_INFORMATION_CLASS {
480 ObjectBasicInformation,
481 ObjectNameInformation,
482 ObjectTypeInformation,
483 ObjectAllInformation,
484 ObjectDataInformation
485 } OBJECT_INFORMATION_CLASS, *POBJECT_INFORMATION_CLASS;
487 typedef struct _OBJDIR_INFORMATION {
488 UNICODE_STRING ObjectName;
489 UNICODE_STRING ObjectTypeName;
490 BYTE Data[1];
491 } OBJDIR_INFORMATION;
493 typedef struct _PUBLIC_OBJECT_BASIC_INFORMATION {
494 ULONG Attributes;
495 ACCESS_MASK GrantedAccess;
496 ULONG HandleCount;
497 ULONG PointerCount;
498 ULONG Reserved[10]; // reserved for internal use
499 } PUBLIC_OBJECT_BASIC_INFORMATION, *PPUBLIC_OBJECT_BASIC_INFORMATION;
501 typedef struct __PUBLIC_OBJECT_TYPE_INFORMATION {
502 UNICODE_STRING TypeName;
503 ULONG Reserved[22]; // reserved for internal use
504 } PUBLIC_OBJECT_TYPE_INFORMATION, *PPUBLIC_OBJECT_TYPE_INFORMATION;
506 typedef enum _POOL_TYPE {
507 NonPagedPool,
508 PagedPool,
509 NonPagedPoolMustSucceed,
510 ReservedType,
511 NonPagedPoolCacheAligned,
512 PagedPoolCacheAligned,
513 NonPagedPoolCacheAlignedMustS
514 } POOL_TYPE;
516 typedef struct _OBJECT_BASIC_INFORMATION {
517 ULONG Attributes;
518 ACCESS_MASK GrantedAccess;
519 ULONG HandleCount;
520 ULONG PointerCount;
521 ULONG PagedPoolUsage;
522 ULONG NonPagedPoolUsage;
523 ULONG Reserved[3];
524 ULONG NameInformationLength;
525 ULONG TypeInformationLength;
526 ULONG SecurityDescriptorLength;
527 LARGE_INTEGER CreateTime;
528 } OBJECT_BASIC_INFORMATION, *POBJECT_BASIC_INFORMATION;
530 typedef struct _OBJECT_TYPE_INFORMATION {
531 UNICODE_STRING Name;
532 ULONG TotalNumberOfObjects;
533 ULONG TotalNumberOfHandles;
534 ULONG TotalPagedPoolUsage;
535 ULONG TotalNonPagedPoolUsage;
536 ULONG TotalNamePoolUsage;
537 ULONG TotalHandleTableUsage;
538 ULONG HighWaterNumberOfObjects;
539 ULONG HighWaterNumberOfHandles;
540 ULONG HighWaterPagedPoolUsage;
541 ULONG HighWaterNonPagedPoolUsage;
542 ULONG HighWaterNamePoolUsage;
543 ULONG HighWaterHandleTableUsage;
544 ULONG InvalidAttributes;
545 GENERIC_MAPPING GenericMapping;
546 ULONG ValidAccess;
547 BOOLEAN SecurityRequired;
548 BOOLEAN MaintainHandleCount;
549 USHORT MaintainTypeList;
550 POOL_TYPE PoolType;
551 ULONG PagedPoolUsage;
552 ULONG NonPagedPoolUsage;
553 } OBJECT_TYPE_INFORMATION, *POBJECT_TYPE_INFORMATION;
555 typedef enum _SYSTEM_INFORMATION_CLASS {
556 SystemHandleInformation = 16
557 } SYSTEM_INFORMATION_CLASS;
559 typedef struct _SYSTEM_HANDLE_INFORMATION {
560 USHORT ProcessId;
561 USHORT CreatorBackTraceIndex;
562 UCHAR ObjectTypeNumber;
563 UCHAR Flags;
564 USHORT Handle;
565 PVOID Object;
566 ACCESS_MASK GrantedAccess;
567 } SYSTEM_HANDLE_INFORMATION, *PSYSTEM_HANDLE_INFORMATION;
569 typedef struct _SYSTEM_HANDLE_INFORMATION_EX {
570 ULONG NumberOfHandles;
571 SYSTEM_HANDLE_INFORMATION Information[1];
572 } SYSTEM_HANDLE_INFORMATION_EX, *PSYSTEM_HANDLE_INFORMATION_EX;
574 typedef struct _OBJECT_NAME_INFORMATION {
575 UNICODE_STRING ObjectName;
576 } OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION;
578 typedef NTSTATUS (WINAPI *NtQueryObjectFunction)(
579 IN HANDLE Handle,
580 IN OBJECT_INFORMATION_CLASS ObjectInformationClass,
581 OUT PVOID ObjectInformation OPTIONAL,
582 IN ULONG ObjectInformationLength,
583 OUT PULONG ReturnLength OPTIONAL);
585 typedef NTSTATUS (WINAPI *NtDuplicateObjectFunction)(
586 IN HANDLE SourceProcess,
587 IN HANDLE SourceHandle,
588 IN HANDLE TargetProcess,
589 OUT PHANDLE TargetHandle,
590 IN ACCESS_MASK DesiredAccess,
591 IN ULONG Attributes,
592 IN ULONG Options);
594 typedef NTSTATUS (WINAPI *NtSignalAndWaitForSingleObjectFunction)(
595 IN HANDLE HandleToSignal,
596 IN HANDLE HandleToWait,
597 IN BOOLEAN Alertable,
598 IN PLARGE_INTEGER Timeout OPTIONAL);
600 typedef NTSTATUS (WINAPI *NtQuerySystemInformation)(
601 IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
602 OUT PVOID SystemInformation,
603 IN ULONG SystemInformationLength,
604 OUT PULONG ReturnLength);
606 typedef NTSTATUS (WINAPI *NtQueryObject)(
607 IN HANDLE Handle,
608 IN OBJECT_INFORMATION_CLASS ObjectInformationClass,
609 OUT PVOID ObjectInformation,
610 IN ULONG ObjectInformationLength,
611 OUT PULONG ReturnLength);
613 // -----------------------------------------------------------------------
614 // Strings
616 typedef int (__cdecl *_strnicmpFunction)(
617 IN const char* _Str1,
618 IN const char* _Str2,
619 IN size_t _MaxCount);
621 typedef size_t (__cdecl *strlenFunction)(
622 IN const char * _Str);
624 typedef size_t (__cdecl *wcslenFunction)(
625 IN const wchar_t* _Str);
627 typedef void* (__cdecl *memcpyFunction)(
628 IN void* dest,
629 IN const void* src,
630 IN size_t count);
632 typedef NTSTATUS (WINAPI *RtlAnsiStringToUnicodeStringFunction)(
633 IN OUT PUNICODE_STRING DestinationString,
634 IN PANSI_STRING SourceString,
635 IN BOOLEAN AllocateDestinationString);
637 typedef LONG (WINAPI *RtlCompareUnicodeStringFunction)(
638 IN PCUNICODE_STRING String1,
639 IN PCUNICODE_STRING String2,
640 IN BOOLEAN CaseInSensitive);
642 typedef VOID (WINAPI *RtlInitUnicodeStringFunction) (
643 IN OUT PUNICODE_STRING DestinationString,
644 IN PCWSTR SourceString);
646 typedef enum _EVENT_TYPE {
647 NotificationEvent,
648 SynchronizationEvent
649 } EVENT_TYPE, *PEVENT_TYPE;
651 typedef NTSTATUS (WINAPI* NtCreateDirectoryObjectFunction) (
652 PHANDLE DirectoryHandle,
653 ACCESS_MASK DesiredAccess,
654 POBJECT_ATTRIBUTES ObjectAttributes);
656 typedef NTSTATUS (WINAPI* NtOpenDirectoryObjectFunction) (
657 PHANDLE DirectoryHandle,
658 ACCESS_MASK DesiredAccess,
659 POBJECT_ATTRIBUTES ObjectAttributes);
661 typedef NTSTATUS (WINAPI* NtQuerySymbolicLinkObjectFunction) (
662 HANDLE LinkHandle,
663 PUNICODE_STRING LinkTarget,
664 PULONG ReturnedLength);
666 typedef NTSTATUS (WINAPI* NtOpenSymbolicLinkObjectFunction) (
667 PHANDLE LinkHandle,
668 ACCESS_MASK DesiredAccess,
669 POBJECT_ATTRIBUTES ObjectAttributes);
671 #define DIRECTORY_QUERY 0x0001
672 #define DIRECTORY_TRAVERSE 0x0002
673 #define DIRECTORY_CREATE_OBJECT 0x0004
674 #define DIRECTORY_CREATE_SUBDIRECTORY 0x0008
675 #define DIRECTORY_ALL_ACCESS 0x000F
677 typedef NTSTATUS (WINAPI* NtCreateLowBoxToken)(
678 OUT PHANDLE token,
679 IN HANDLE original_handle,
680 IN ACCESS_MASK access,
681 IN POBJECT_ATTRIBUTES object_attribute,
682 IN PSID appcontainer_sid,
683 IN DWORD capabilityCount,
684 IN PSID_AND_ATTRIBUTES capabilities,
685 IN DWORD handle_count,
686 IN PHANDLE handles);
688 typedef NTSTATUS(WINAPI *NtSetInformationProcess)(
689 IN HANDLE process_handle,
690 IN ULONG info_class,
691 IN PVOID process_information,
692 IN ULONG information_length);
694 struct PROCESS_ACCESS_TOKEN {
695 HANDLE token;
696 HANDLE thread;
699 const unsigned int NtProcessInformationAccessToken = 9;
701 #endif // SANDBOX_WIN_SRC_NT_INTERNALS_H__