Use free Windows DDK and compile with latest MinGW releases.
[reactos.git] / reactos / include / ntos / types.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: include/types.h
5 * PURPOSE: Types used by all the parts of the system
6 * PROGRAMMER: David Welch <welch@cwcom.net>
7 * DEFINES: _WIN64: 64-bit architecture
8 * _WIN32: 32-bit architecture (default)
9 * UPDATE HISTORY:
10 * 27/06/00: Created
11 * 01/05/01: Portabillity changes
12 */
13
14 #ifndef __INCLUDE_TYPES_H
15 #define __INCLUDE_TYPES_H
16
17 #if __GNUC__ >=3
18 #pragma GCC system_header
19 #endif
20
21 #ifndef AS_INVOKED
22
23 #include <windef.h>
24 #include <winnt.h>
25 #include <windows.h>
26 #include <winreg.h>
27
28 #define PAGE_ROUND_UP(x) ( (((ULONG_PTR)x)%PAGE_SIZE) ? ((((ULONG_PTR)x)&(~(PAGE_SIZE-1)))+PAGE_SIZE) : ((ULONG_PTR)x) )
29 #define PAGE_ROUND_DOWN(x) (((ULONG_PTR)x)&(~(PAGE_SIZE-1)))
30
31 typedef DWORD (STDCALL *PTHREAD_START_ROUTINE)(PVOID);
32
33 #define FILE_ATTRIBUTE_VALID_FLAGS 0x00007fb7
34 #define FILE_ATTRIBUTE_VALID_SET_FLAGS 0x000031a7
35
36 #define IOCTL_CDROM_GET_DRIVE_GEOMETRY CTL_CODE(FILE_DEVICE_CD_ROM, 0x0013, METHOD_BUFFERED, FILE_READ_ACCESS)
37
38 #define THREAD_READ (0x020048L)
39 #define THREAD_WRITE (0x020037L)
40 #define THREAD_EXECUTE (0x120000L)
41
42 enum
43 {
44 DIRECTORY_QUERY,
45 DIRECTORY_TRAVERSE,
46 DIRECTORY_CREATE_OBJECT,
47 DIRECTORY_CREATE_SUBDIRECTORY,
48 DIRECTORY_ALL_ACCESS,
49 };
50
51 typedef enum _NT_PRODUCT_TYPE
52 {
53 NtProductWinNt = 1,
54 NtProductLanManNt,
55 NtProductServer
56 } NT_PRODUCT_TYPE, *PNT_PRODUCT_TYPE;
57
58 // ReactOS specific
59 #define HEAP_NO_VALLOC (0x800)
60
61 #define EVENT_QUERY_STATE (1)
62 #define EVENT_PAIR_ALL_ACCESS (0x1f0000L)
63 #define SEMAPHORE_QUERY_STATE (1)
64
65 typedef ULARGE_INTEGER TIME, *PTIME;
66
67 typedef struct
68 {
69 ACE_HEADER Header;
70 } ACE, *PACE;
71
72 /* our own invention */
73 #define FLAG_TRACE_BIT 0x100
74 #define CONTEXT_DEBUGGER (CONTEXT_FULL | CONTEXT_FLOATING_POINT)
75
76 // ReactOS specific
77 #define EX_MAXIMUM_WAIT_OBJECTS (64)
78
79 #define ROUNDUP(a,b) ((((a)+(b)-1)/(b))*(b))
80 #define ROUNDDOWN(a,b) (((a)/(b))*(b))
81
82 #define MAGIC(c1,c2,c3,c4) ((c1) + ((c2)<<8) + ((c3)<<16) + ((c4)<<24))
83
84 #define CONSOLE_OUTPUT_MODE_VALID 0x03
85 #define CONSOLE_INPUT_MODE_VALID 0x0f
86
87 typedef ULONG ACCESS_MODE, *PACCESS_MODE;
88
89 #include "except.h"
90
91
92
93 /* ReactOS specific */
94
95 #define MB_FLAGS_MEM_INFO (0x1)
96 #define MB_FLAGS_BOOT_DEVICE (0x2)
97 #define MB_FLAGS_COMMAND_LINE (0x4)
98 #define MB_FLAGS_MODULE_INFO (0x8)
99 #define MB_FLAGS_AOUT_SYMS (0x10)
100 #define MB_FLAGS_ELF_SYMS (0x20)
101 #define MB_FLAGS_MMAP_INFO (0x40)
102 #define MB_FLAGS_DRIVES_INFO (0x80)
103 #define MB_FLAGS_CONFIG_TABLE (0x100)
104 #define MB_FLAGS_BOOT_LOADER_NAME (0x200)
105 #define MB_FLAGS_APM_TABLE (0x400)
106 #define MB_FLAGS_GRAPHICS_TABLE (0x800)
107
108 typedef struct _LOADER_MODULE
109 {
110 ULONG ModStart;
111 ULONG ModEnd;
112 ULONG String;
113 ULONG Reserved;
114 } LOADER_MODULE, *PLOADER_MODULE;
115
116 typedef struct _ADDRESS_RANGE
117 {
118 ULONG BaseAddrLow;
119 ULONG BaseAddrHigh;
120 ULONG LengthLow;
121 ULONG LengthHigh;
122 ULONG Type;
123 } ADDRESS_RANGE, *PADDRESS_RANGE;
124
125 typedef struct _LOADER_PARAMETER_BLOCK {
126 ULONG Flags;
127 ULONG MemLower;
128 ULONG MemHigher;
129 ULONG BootDevice;
130 ULONG CommandLine;
131 ULONG ModsCount;
132 ULONG ModsAddr;
133 UCHAR Syms[12];
134 ULONG MmapLength;
135 ULONG MmapAddr;
136 ULONG DrivesCount;
137 ULONG DrivesAddr;
138 ULONG ConfigTable;
139 ULONG BootLoaderName;
140 } LOADER_PARAMETER_BLOCK, *PLOADER_PARAMETER_BLOCK;
141
142
143 typedef struct _KTSS
144 {
145 USHORT PreviousTask;
146 USHORT Reserved1;
147 ULONG Esp0;
148 USHORT Ss0;
149 USHORT Reserved2;
150 ULONG Esp1;
151 USHORT Ss1;
152 USHORT Reserved3;
153 ULONG Esp2;
154 USHORT Ss2;
155 USHORT Reserved4;
156 ULONG Cr3;
157 ULONG Eip;
158 ULONG Eflags;
159 ULONG Eax;
160 ULONG Ecx;
161 ULONG Edx;
162 ULONG Ebx;
163 ULONG Esp;
164 ULONG Ebp;
165 ULONG Esi;
166 ULONG Edi;
167 USHORT Es;
168 USHORT Reserved5;
169 USHORT Cs;
170 USHORT Reserved6;
171 USHORT Ss;
172 USHORT Reserved7;
173 USHORT Ds;
174 USHORT Reserved8;
175 USHORT Fs;
176 USHORT Reserved9;
177 USHORT Gs;
178 USHORT Reserved10;
179 USHORT Ldt;
180 USHORT Reserved11;
181 USHORT Trap;
182 USHORT IoMapBase;
183 UCHAR IoBitmap[1];
184 } KTSS __attribute__((packed));
185
186 typedef struct _IACCESS_TOKEN
187 {
188 TOKEN_SOURCE TokenSource; // 0x00
189 LUID TokenId; // 0x10
190 LUID AuthenticationId; // 0x18
191 LARGE_INTEGER ExpirationTime; // 0x20
192 LUID ModifiedId; // 0x28
193 ULONG UserAndGroupCount; // 0x30
194 ULONG PrivilegeCount; // 0x34
195 ULONG VariableLength; // 0x38
196 ULONG DynamicCharged; // 0x3C
197 ULONG DynamicAvailable; // 0x40
198 ULONG DefaultOwnerIndex; // 0x44
199 PSID_AND_ATTRIBUTES_ARRAY UserAndGroups; // 0x48
200 PSID PrimaryGroup; // 0x4C
201 PLUID_AND_ATTRIBUTES_ARRAY Privileges; // 0x50
202 ULONG Unknown1; // 0x54
203 PACL DefaultDacl; // 0x58
204 TOKEN_TYPE TokenType; // 0x5C
205 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; // 0x60
206 UCHAR TokenFlags; // 0x64
207 UCHAR TokenInUse; // 0x65
208 UCHAR Unused[2]; // 0x66
209 PVOID ProxyData; // 0x68
210 PVOID AuditData; // 0x6c
211 UCHAR VariablePart[0]; // 0x70
212 } IACCESS_TOKEN, *PIACCESS_TOKEN;
213
214 struct _DIRECTORY_OBJECT;
215 struct _OBJECT_ATTRIBUTES;
216
217 typedef struct _OBJECT_TYPE
218 {
219 /*
220 * PURPOSE: Tag to be used when allocating objects of this type
221 */
222 ULONG Tag;
223
224 /*
225 * PURPOSE: Name of the type
226 */
227 UNICODE_STRING TypeName;
228
229 /*
230 * PURPOSE: Total number of objects of this type
231 */
232 ULONG TotalObjects;
233
234 /*
235 * PURPOSE: Total number of handles of this type
236 */
237 ULONG TotalHandles;
238
239 /*
240 * PURPOSE: Maximum objects of this type
241 */
242 ULONG MaxObjects;
243
244 /*
245 * PURPOSE: Maximum handles of this type
246 */
247 ULONG MaxHandles;
248
249 /*
250 * PURPOSE: Paged pool charge
251 */
252 ULONG PagedPoolCharge;
253
254 /*
255 * PURPOSE: Nonpaged pool charge
256 */
257 ULONG NonpagedPoolCharge;
258
259 /*
260 * PURPOSE: Mapping of generic access rights
261 */
262 PGENERIC_MAPPING Mapping;
263
264 /*
265 * PURPOSE: Dumps the object
266 * NOTE: To be defined
267 */
268 VOID STDCALL (*Dump)(VOID);
269
270 /*
271 * PURPOSE: Opens the object
272 * NOTE: To be defined
273 */
274 VOID STDCALL (*Open)(VOID);
275
276 /*
277 * PURPOSE: Called to close an object if OkayToClose returns true
278 */
279 VOID STDCALL (*Close)(PVOID ObjectBody,
280 ULONG HandleCount);
281
282 /*
283 * PURPOSE: Called to delete an object when the last reference is removed
284 */
285 VOID STDCALL (*Delete)(PVOID ObjectBody);
286
287 /*
288 * PURPOSE: Called when an open attempts to open a file apparently
289 * residing within the object
290 * RETURNS
291 * STATUS_SUCCESS NextObject was found
292 * STATUS_UNSUCCESSFUL NextObject not found
293 * STATUS_REPARSE Path changed, restart parsing the path
294 */
295 NTSTATUS STDCALL (*Parse)(PVOID ParsedObject,
296 PVOID *NextObject,
297 PUNICODE_STRING FullPath,
298 PWSTR *Path,
299 ULONG Attributes);
300
301 /*
302 */
303 NTSTATUS STDCALL (*Security)(PVOID Object,
304 ULONG InfoClass,
305 PVOID Info,
306 PULONG InfoLength);
307
308 /*
309 */
310 VOID STDCALL (*QueryName)(VOID);
311
312 /*
313 * PURPOSE: Called when a process asks to close the object
314 */
315 VOID STDCALL (*OkayToClose)(VOID);
316
317 NTSTATUS STDCALL (*Create)(PVOID ObjectBody,
318 PVOID Parent,
319 PWSTR RemainingPath,
320 struct _OBJECT_ATTRIBUTES* ObjectAttributes);
321
322 VOID STDCALL (*DuplicationNotify)(PEPROCESS DuplicateTo,
323 PEPROCESS DuplicateFrom,
324 PVOID Object);
325 } OBJECT_TYPE, *POBJECT_TYPE;
326
327
328 typedef struct _OBJECT_HEADER
329 /*
330 * PURPOSE: Header for every object managed by the object manager
331 */
332 {
333 UNICODE_STRING Name;
334 LIST_ENTRY Entry;
335 LONG RefCount;
336 LONG HandleCount;
337 BOOLEAN CloseInProcess;
338 BOOLEAN Permanent;
339 struct _DIRECTORY_OBJECT* Parent;
340 POBJECT_TYPE ObjectType;
341
342 /*
343 * PURPOSE: Object type
344 * NOTE: This overlaps the first member of the object body
345 */
346 CSHORT Type;
347
348 /*
349 * PURPOSE: Object size
350 * NOTE: This overlaps the second member of the object body
351 */
352 CSHORT Size;
353
354
355 } OBJECT_HEADER, *POBJECT_HEADER;
356
357 typedef struct _ROS_HANDLE_TABLE
358 {
359 LIST_ENTRY ListHead;
360 KSPIN_LOCK ListLock;
361 } ROS_HANDLE_TABLE, *PROS_HANDLE_TABLE;
362
363 extern POBJECT_TYPE ObDirectoryType;
364
365 typedef struct _KINTERRUPT
366 {
367 ULONG Vector;
368 KAFFINITY ProcessorEnableMask;
369 PKSPIN_LOCK IrqLock;
370 BOOLEAN Shareable;
371 BOOLEAN FloatingSave;
372 PKSERVICE_ROUTINE ServiceRoutine;
373 PVOID ServiceContext;
374 LIST_ENTRY Entry;
375 KIRQL SynchLevel;
376 } KINTERRUPT, *PKINTERRUPT;
377
378 /* number of entries in the service descriptor tables */
379 #define SSDT_MAX_ENTRIES 4
380
381
382 #pragma pack(1)
383
384 typedef struct t_KeServiceDescriptorTableEntry {
385 PSSDT SSDT;
386 PULONG ServiceCounterTable;
387 unsigned int NumberOfServices;
388 PSSPT SSPT;
389
390 } KE_SERVICE_DESCRIPTOR_TABLE_ENTRY, *PKE_SERVICE_DESCRIPTOR_TABLE_ENTRY;
391
392 #pragma pack()
393
394
395 NTOSAPI KE_SERVICE_DESCRIPTOR_TABLE_ENTRY
396 KeServiceDescriptorTable[SSDT_MAX_ENTRIES];
397
398 extern
399 KE_SERVICE_DESCRIPTOR_TABLE_ENTRY
400 KeServiceDescriptorTableShadow[SSDT_MAX_ENTRIES];
401
402
403 BOOLEAN
404 STDCALL
405 KeAddSystemServiceTable (
406 PSSDT SSDT,
407 PULONG ServiceCounterTable,
408 ULONG NumberOfServices,
409 PSSPT SSPT,
410 ULONG TableIndex
411 );
412
413 extern struct _EPROCESS* PsInitialSystemProcess;
414 extern POBJECT_TYPE PsProcessType;
415 extern POBJECT_TYPE PsThreadType;
416
417 BOOLEAN STDCALL
418 KdPollBreakIn(VOID);
419
420
421 typedef struct _REACTOS_COMMON_FCB_HEADER
422 {
423 CSHORT NodeTypeCode;
424 CSHORT NodeByteSize;
425 struct _ROS_BCB* Bcb;
426 LARGE_INTEGER AllocationSize;
427 LARGE_INTEGER FileSize;
428 LARGE_INTEGER ValidDataLength;
429 } REACTOS_COMMON_FCB_HEADER, *PREACTOS_COMMON_FCB_HEADER;
430
431 NTSTATUS STDCALL
432 NtCreateKey(OUT PHANDLE KeyHandle,
433 IN ACCESS_MASK DesiredAccess,
434 IN POBJECT_ATTRIBUTES ObjectAttributes,
435 IN ULONG TitleIndex,
436 IN PUNICODE_STRING Class OPTIONAL,
437 IN ULONG CreateOptions,
438 IN PULONG Disposition OPTIONAL);
439
440 #define FILE_NON_DIRECTORY_FILE 0x40
441 #define FILE_CREATED 0x2
442
443
444 typedef enum _TRAVERSE_METHOD {
445 TraverseMethodPreorder,
446 TraverseMethodInorder,
447 TraverseMethodPostorder
448 } TRAVERSE_METHOD;
449
450 typedef LONG STDCALL
451 (*PKEY_COMPARATOR)(IN PVOID Key1,
452 IN PVOID Key2);
453
454 typedef BOOLEAN STDCALL
455 (*PTRAVERSE_ROUTINE)(IN PVOID Context,
456 IN PVOID Key,
457 IN PVOID Value);
458
459 struct _BINARY_TREE_NODE;
460
461 typedef struct _BINARY_TREE
462 {
463 struct _BINARY_TREE_NODE * RootNode;
464 PKEY_COMPARATOR Compare;
465 BOOLEAN UseNonPagedPool;
466 union {
467 NPAGED_LOOKASIDE_LIST NonPaged;
468 PAGED_LOOKASIDE_LIST Paged;
469 } List;
470 union {
471 KSPIN_LOCK NonPaged;
472 FAST_MUTEX Paged;
473 } Lock;
474 } BINARY_TREE, *PBINARY_TREE;
475
476
477 struct _SPLAY_TREE_NODE;
478
479 typedef struct _SPLAY_TREE
480 {
481 struct _SPLAY_TREE_NODE * RootNode;
482 PKEY_COMPARATOR Compare;
483 BOOLEAN Weighted;
484 BOOLEAN UseNonPagedPool;
485 union {
486 NPAGED_LOOKASIDE_LIST NonPaged;
487 PAGED_LOOKASIDE_LIST Paged;
488 } List;
489 union {
490 KSPIN_LOCK NonPaged;
491 FAST_MUTEX Paged;
492 } Lock;
493 PVOID Reserved[4];
494 } SPLAY_TREE, *PSPLAY_TREE;
495
496
497 typedef struct _HASH_TABLE
498 {
499 // Size of hash table in number of bits
500 ULONG HashTableSize;
501
502 // Use non-paged pool memory?
503 BOOLEAN UseNonPagedPool;
504
505 // Lock for this structure
506 union {
507 KSPIN_LOCK NonPaged;
508 FAST_MUTEX Paged;
509 } Lock;
510
511 // Pointer to array of hash buckets with splay trees
512 PSPLAY_TREE HashTrees;
513 } HASH_TABLE, *PHASH_TABLE;
514
515
516 BOOLEAN STDCALL
517 ExInitializeBinaryTree(IN PBINARY_TREE Tree,
518 IN PKEY_COMPARATOR Compare,
519 IN BOOLEAN UseNonPagedPool);
520
521 VOID STDCALL
522 ExDeleteBinaryTree(IN PBINARY_TREE Tree);
523
524 VOID STDCALL
525 ExInsertBinaryTree(IN PBINARY_TREE Tree,
526 IN PVOID Key,
527 IN PVOID Value);
528
529 BOOLEAN STDCALL
530 ExSearchBinaryTree(IN PBINARY_TREE Tree,
531 IN PVOID Key,
532 OUT PVOID * Value);
533
534 BOOLEAN STDCALL
535 ExRemoveBinaryTree(IN PBINARY_TREE Tree,
536 IN PVOID Key,
537 IN PVOID * Value);
538
539 BOOLEAN STDCALL
540 ExTraverseBinaryTree(IN PBINARY_TREE Tree,
541 IN TRAVERSE_METHOD Method,
542 IN PTRAVERSE_ROUTINE Routine,
543 IN PVOID Context);
544
545 BOOLEAN STDCALL
546 ExInitializeSplayTree(IN PSPLAY_TREE Tree,
547 IN PKEY_COMPARATOR Compare,
548 IN BOOLEAN Weighted,
549 IN BOOLEAN UseNonPagedPool);
550
551 VOID STDCALL
552 ExDeleteSplayTree(IN PSPLAY_TREE Tree);
553
554 VOID STDCALL
555 ExInsertSplayTree(IN PSPLAY_TREE Tree,
556 IN PVOID Key,
557 IN PVOID Value);
558
559 BOOLEAN STDCALL
560 ExSearchSplayTree(IN PSPLAY_TREE Tree,
561 IN PVOID Key,
562 OUT PVOID * Value);
563
564 BOOLEAN STDCALL
565 ExRemoveSplayTree(IN PSPLAY_TREE Tree,
566 IN PVOID Key,
567 IN PVOID * Value);
568
569 BOOLEAN STDCALL
570 ExWeightOfSplayTree(IN PSPLAY_TREE Tree,
571 OUT PULONG Weight);
572
573 BOOLEAN STDCALL
574 ExTraverseSplayTree(IN PSPLAY_TREE Tree,
575 IN TRAVERSE_METHOD Method,
576 IN PTRAVERSE_ROUTINE Routine,
577 IN PVOID Context);
578
579 BOOLEAN STDCALL
580 ExInitializeHashTable(IN PHASH_TABLE HashTable,
581 IN ULONG HashTableSize,
582 IN PKEY_COMPARATOR Compare OPTIONAL,
583 IN BOOLEAN UseNonPagedPool);
584
585 VOID STDCALL
586 ExDeleteHashTable(IN PHASH_TABLE HashTable);
587
588 VOID STDCALL
589 ExInsertHashTable(IN PHASH_TABLE HashTable,
590 IN PVOID Key,
591 IN ULONG KeyLength,
592 IN PVOID Value);
593
594 BOOLEAN STDCALL
595 ExSearchHashTable(IN PHASH_TABLE HashTable,
596 IN PVOID Key,
597 IN ULONG KeyLength,
598 OUT PVOID * Value);
599
600 BOOLEAN STDCALL
601 ExRemoveHashTable(IN PHASH_TABLE HashTable,
602 IN PVOID Key,
603 IN ULONG KeyLength,
604 IN PVOID * Value);
605
606
607
608 NTSTATUS STDCALL
609 NtAccessCheckAndAuditAlarm(IN PUNICODE_STRING SubsystemName,
610 IN PHANDLE ObjectHandle,
611 IN POBJECT_ATTRIBUTES ObjectAttributes,
612 IN ACCESS_MASK DesiredAccess,
613 IN PGENERIC_MAPPING GenericMapping,
614 IN BOOLEAN ObjectCreation,
615 OUT PULONG GrantedAccess,
616 OUT PBOOLEAN AccessStatus,
617 OUT PBOOLEAN GenerateOnClose
618 );
619
620 NTSTATUS
621 STDCALL
622 NtSetInformationObject (
623 IN HANDLE ObjectHandle,
624 IN CINT ObjectInformationClass,
625 IN PVOID ObjectInformation,
626 IN ULONG Length
627 );
628
629 #define LPC_CONNECTION_REFUSED (LPC_TYPE)(LPC_MAXIMUM + 1)
630
631 //#define DEVICE_TYPE_FROM_CTL_CODE(ctlCode) (((ULONG)(ctlCode&0xffff0000))>>16)
632 #define IO_METHOD_FROM_CTL_CODE(ctlCode) (ctlCode&0x00000003)
633
634 /*
635 * PURPOSE: Irp flags
636 */
637 enum
638 {
639 IRP_NOCACHE = 0x1,
640 IRP_PAGING_IO = 0x2,
641 IRP_MOUNT_COMPLETION = 0x2,
642 IRP_SYNCHRONOUS_API = 0x4,
643 IRP_ASSOCIATED_IRP = 0x8,
644 IRP_BUFFERED_IO = 0x10,
645 IRP_DEALLOCATE_BUFFER = 0x20,
646 IRP_INPUT_OPERATION = 0x40,
647 IRP_SYNCHRONOUS_PAGING_IO = 0x40,
648 IRP_CREATE_OPERATION = 0x80,
649 IRP_READ_OPERATION = 0x100,
650 IRP_WRITE_OPERATION = 0x200,
651 IRP_CLOSE_OPERATION = 0x400,
652 IRP_DEFER_IO_COMPLETION = 0x800,
653 IRP_OB_QUERY_NAME = 0x1000,
654 IRP_HOLD_DEVICE_QUEUE = 0x2000,
655 IRP_RETRY_IO_COMPLETION = 0x4000
656 };
657
658 /*
659 * PIO_STACK_LOCATION
660 * IoGetFirstIrpStackLocation(
661 * IN PIRP Irp)
662 */
663 #define IoGetFirstIrpStackLocation(_Irp) \
664 ((PIO_STACK_LOCATION)((_Irp) + 1))
665
666 /*
667 * PIO_STACK_LOCATION
668 * IoGetSpecificIrpStackLocation(
669 * IN PIRP Irp,
670 * IN ULONG Number)
671 */
672 #define IoGetSpecificIrpStackLocation(_Irp, _Number) \
673 (((PIO_STACK_LOCATION)((_Irp) + 1)) + (_Number))
674
675 /*
676 * file creation flags
677 */
678 #define FILE_DIRECTORY_FILE 0x00000001
679 #define FILE_WRITE_THROUGH 0x00000002
680 #define FILE_SEQUENTIAL_ONLY 0x00000004
681 #define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008
682
683 #define FILE_SYNCHRONOUS_IO_ALERT 0x00000010
684 #define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020
685 //#define FILE_NON_DIRECTORY_FILE 0x00000040
686 #define FILE_CREATE_TREE_CONNECTION 0x00000080
687
688 #define FILE_COMPLETE_IF_OPLOCKED 0x00000100
689 #define FILE_NO_EA_KNOWLEDGE 0x00000200
690
691 #define FILE_RANDOM_ACCESS 0x00000800
692
693 #define FILE_DELETE_ON_CLOSE 0x00001000
694 #define FILE_OPEN_BY_FILE_ID 0x00002000
695 #define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000
696 #define FILE_NO_COMPRESSION 0x00008000
697
698 #define FILE_RESERVE_OPFILTER 0x00100000
699 #define FILE_TRANSACTED_MODE 0x00200000
700 #define FILE_OPEN_OFFLINE_FILE 0x00400000
701
702 #define FILE_VALID_OPTION_FLAGS 0x007fffff
703 #define FILE_VALID_PIPE_OPTION_FLAGS 0x00000032
704 #define FILE_VALID_MAILSLOT_OPTION_FLAGS 0x00000032
705 #define FILE_VALID_SET_FLAGS 0x00001036
706
707 typedef struct _IO_PIPE_CREATE_BUFFER
708 {
709 BOOLEAN WriteModeMessage;
710 BOOLEAN ReadModeMessage;
711 BOOLEAN NonBlocking;
712 ULONG MaxInstances;
713 ULONG InBufferSize;
714 ULONG OutBufferSize;
715 LARGE_INTEGER TimeOut;
716 } IO_PIPE_CREATE_BUFFER, *PIO_PIPE_CREATE_BUFFER;
717
718 typedef struct _IO_MAILSLOT_CREATE_BUFFER {
719 ULONG Param; /* ?? */
720 ULONG MaxMessageSize;
721 LARGE_INTEGER TimeOut;
722 } IO_MAILSLOT_CREATE_BUFFER, *PIO_MAILSLOT_CREATE_BUFFER;
723
724 /*
725 * PURPOSE: Special timer associated with each device
726 * NOTES: This is a guess
727 */
728 typedef struct _IO_TIMER
729 {
730 KTIMER timer;
731 KDPC dpc;
732 } IO_TIMER, *PIO_TIMER;
733
734
735 #include "ntos/hal.h"
736
737 extern ULONG KdDebugState;
738 extern KD_PORT_INFORMATION GdbPortInfo;
739 extern KD_PORT_INFORMATION LogPortInfo;
740
741
742 typedef struct _LDR_RESOURCE_INFO
743 {
744 ULONG Type;
745 ULONG Name;
746 ULONG Language;
747 } LDR_RESOURCE_INFO, *PLDR_RESOURCE_INFO;
748
749 #define RESOURCE_TYPE_LEVEL 0
750 #define RESOURCE_NAME_LEVEL 1
751 #define RESOURCE_LANGUAGE_LEVEL 2
752 #define RESOURCE_DATA_LEVEL 3
753
754
755
756 #define FO_FILE_OPEN 0x00000001
757 #define FO_SYNCHRONOUS_IO 0x00000002
758 #define FO_ALERTABLE_IO 0x00000004
759 #define FO_NO_INTERMEDIATE_BUFFERING 0x00000008
760 #define FO_WRITE_THROUGH 0x00000010
761 #define FO_SEQUENTIAL_ONLY 0x00000020
762 #define FO_CACHE_SUPPORTED 0x00000040
763 #define FO_NAMED_PIPE 0x00000080
764 #define FO_STREAM_FILE 0x00000100
765 #define FO_MAILSLOT 0x00000200
766 #define FO_GENERATE_AUDIT_ON_CLOSE 0x00000400
767 #define FO_DIRECT_DEVICE_OPEN 0x00000800
768 #define FO_FILE_MODIFIED 0x00001000
769 #define FO_FILE_SIZE_CHANGED 0x00002000
770 #define FO_CLEANUP_COMPLETE 0x00004000
771 #define FO_TEMPORARY_FILE 0x00008000
772 #define FO_DELETE_ON_CLOSE 0x00010000
773 #define FO_OPENED_CASE_SENSITIVE 0x00020000
774 #define FO_HANDLE_CREATED 0x00040000
775 #define FO_FILE_FAST_IO_READ 0x00080000
776
777
778 /*
779 * ReactOS specific flags
780 */
781 #define FO_DIRECT_CACHE_READ 0x72000001
782 #define FO_DIRECT_CACHE_WRITE 0x72000002
783 #define FO_DIRECT_CACHE_PAGING_READ 0x72000004
784 #define FO_DIRECT_CACHE_PAGING_WRITE 0x72000008
785 #define FO_FCB_IS_VALID 0x72000010
786
787
788 extern LOADER_PARAMETER_BLOCK KeLoaderBlock;
789
790
791 #define MUTANT_INCREMENT 1
792
793 NTSTATUS STDCALL
794 NtCreateMutant(OUT PHANDLE MutantHandle,
795 IN ACCESS_MASK DesiredAccess,
796 IN POBJECT_ATTRIBUTES ObjectAttributes,
797 IN BOOLEAN InitialOwner);
798
799 NTSTATUS STDCALL
800 NtOpenMutant(OUT PHANDLE MutantHandle,
801 IN ACCESS_MASK DesiredAccess,
802 IN POBJECT_ATTRIBUTES ObjectAttributes);
803
804 NTSTATUS STDCALL
805 NtQueryMutant(IN HANDLE MutantHandle,
806 IN CINT MutantInformationClass,
807 OUT PVOID MutantInformation,
808 IN ULONG Length,
809 OUT PULONG ResultLength);
810
811 NTSTATUS STDCALL
812 NtReleaseMutant(IN HANDLE MutantHandle,
813 IN PULONG ReleaseCount OPTIONAL);
814
815 VOID STDCALL
816 KeInitializeMutant(IN PKMUTANT Mutant,
817 IN BOOLEAN InitialOwner);
818
819 LONG STDCALL
820 KeReadStateMutant(IN PKMUTANT Mutant);
821
822 LONG STDCALL
823 KeReleaseMutant(IN PKMUTANT Mutant,
824 IN KPRIORITY Increment,
825 IN BOOLEAN Abandon,
826 IN BOOLEAN Wait);
827
828
829 typedef struct _ROS_OBJECT_TYPE_INFORMATION
830 {
831 UNICODE_STRING Name;
832 UNICODE_STRING Type;
833 ULONG TotalHandles;
834 ULONG ReferenceCount;
835 } ROS_OBJECT_TYPE_INFORMATION, *PROS_OBJECT_TYPE_INFORMATION;
836
837
838 VOID STDCALL
839 PsImpersonateClient(PETHREAD Thread,
840 PACCESS_TOKEN Token,
841 UCHAR b,
842 UCHAR c,
843 SECURITY_IMPERSONATION_LEVEL Level);
844
845 NTSTATUS STDCALL
846 PsAssignImpersonationToken(PETHREAD Thread,
847 HANDLE TokenHandle);
848
849 VOID STDCALL
850 KiDispatchInterrupt(VOID);
851
852
853 NTSTATUS STDCALL
854 LdrAccessResource(IN PVOID BaseAddress,
855 IN PIMAGE_RESOURCE_DATA_ENTRY ResourceDataEntry,
856 OUT PVOID *Resource OPTIONAL,
857 OUT PULONG Size OPTIONAL);
858
859 NTSTATUS STDCALL
860 LdrFindResource_U(PVOID BaseAddress,
861 PLDR_RESOURCE_INFO ResourceInfo,
862 ULONG Level,
863 PIMAGE_RESOURCE_DATA_ENTRY *ResourceDataEntry);
864
865 typedef TIME_ZONE_INFORMATION *PTIME_ZONE_INFORMATION;
866
867 PVOID STDCALL
868 MmAllocateContiguousAlignedMemory(IN ULONG NumberOfBytes,
869 IN PHYSICAL_ADDRESS HighestAcceptableAddress,
870 IN ULONG Alignment);
871
872 /*
873 * PVOID
874 * MmGetSystemAddressForMdl (
875 * PMDL Mdl
876 * );
877 *
878 * FUNCTION:
879 * Maps the physical pages described by an MDL into system space
880 *
881 * ARGUMENTS:
882 * Mdl = mdl
883 *
884 * RETURNS:
885 * The base system address for the mapped buffer
886 */
887 #define MmGetSystemAddressForMdl(Mdl) \
888 (((Mdl)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA | MDL_SOURCE_IS_NONPAGED_POOL)) ? \
889 ((Mdl)->MappedSystemVa):(MmMapLockedPages((Mdl),KernelMode)))
890
891 VOID STDCALL
892 KeEnterKernelDebugger(VOID);
893
894 #ifdef _NTOSKRNL_
895 extern DECL_EXPORT ULONG DpcQueueSize;
896 #else
897 extern DECL_IMPORT ULONG DpcQueueSize;
898 #endif
899
900 VOID STDCALL
901 KiDeliverApc(ULONG Unknown1,
902 ULONG Unknown2,
903 ULONG Unknown3);
904
905 VOID STDCALL
906 KeFlushWriteBuffer(VOID);
907
908 #if 0
909 typedef struct _HANDLE_TABLE {
910 // Not used by ReactOS
911 } HANDLE_TABLE, *PHANDLE_TABLE;
912 #endif
913
914 typedef struct _ROS_BCB
915 {
916 LIST_ENTRY BcbSegmentListHead;
917 PFILE_OBJECT FileObject;
918 ULONG CacheSegmentSize;
919 LARGE_INTEGER AllocationSize;
920 LARGE_INTEGER FileSize;
921 KSPIN_LOCK BcbLock;
922 ULONG RefCount;
923 } ROS_BCB, *PROS_BCB;
924
925
926 NTSTATUS STDCALL
927 CcRosInitializeFileCache(PFILE_OBJECT FileObject,
928 PROS_BCB* Bcb,
929 ULONG CacheSegmentSize);
930
931 NTSTATUS STDCALL
932 CcRosReleaseFileCache(PFILE_OBJECT FileObject, PROS_BCB Bcb);
933
934 #define DebugDbgLoadSymbols (DEBUG_CONTROL_CODE)(DebugMaximum + 1)
935
936 #define WM_DROPOBJECT 544
937 #define WM_QUERYDROPOBJECT 555
938
939 typedef WINDOWPOS *PWINDOWPOS;
940
941 #define SECURITY_CREATOR_OWNER_SERVER_RID 0x2
942 #define SECURITY_CREATOR_GROUP_SERVER_RID 0x3
943 #define SECURITY_LOGON_IDS_RID_COUNT 0x3
944 #define SECURITY_ANONYMOUS_LOGON_RID 0x7
945 #define SECURITY_PROXY_RID 0x8
946 #define SECURITY_ENTERPRISE_CONTROLLERS_RID 0x9
947 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
948 #define SECURITY_AUTHENTICATED_USER_RID 0xB
949 #define SECURITY_RESTRICTED_CODE_RID 0xC
950 #define SECURITY_NT_NON_UNIQUE_RID 0x15
951 #define SE_MIN_WELL_KNOWN_PRIVILEGE 2
952 #define SE_CREATE_TOKEN_PRIVILEGE 2
953 #define SE_ASSIGNPRIMARYTOKEN_PRIVILEGE 3
954 #define SE_LOCK_MEMORY_PRIVILEGE 4
955 #define SE_INCREASE_QUOTA_PRIVILEGE 5
956 #define SE_UNSOLICITED_INPUT_PRIVILEGE 6
957 #define SE_MACHINE_ACCOUNT_PRIVILEGE 6
958 #define SE_TCB_PRIVILEGE 7
959 #define SE_SECURITY_PRIVILEGE 8
960 #define SE_TAKE_OWNERSHIP_PRIVILEGE 9
961 #define SE_LOAD_DRIVER_PRIVILEGE 10
962 #define SE_SYSTEM_PROFILE_PRIVILEGE 11
963 #define SE_SYSTEMTIME_PRIVILEGE 12
964 #define SE_PROF_SINGLE_PROCESS_PRIVILEGE 13
965 #define SE_INC_BASE_PRIORITY_PRIVILEGE 14
966 #define SE_CREATE_PAGEFILE_PRIVILEGE 15
967 #define SE_CREATE_PERMANENT_PRIVILEGE 16
968 #define SE_BACKUP_PRIVILEGE 17
969 #define SE_RESTORE_PRIVILEGE 18
970 #define SE_SHUTDOWN_PRIVILEGE 19
971 #define SE_DEBUG_PRIVILEGE 20
972 #define SE_AUDIT_PRIVILEGE 21
973 #define SE_SYSTEM_ENVIRONMENT_PRIVILEGE 22
974 #define SE_CHANGE_NOTIFY_PRIVILEGE 23
975 #define SE_REMOTE_SHUTDOWN_PRIVILEGE 24
976 #define SE_MAX_WELL_KNOWN_PRIVILEGE SE_REMOTE_SHUTDOWN_PRIVILEGE
977
978 typedef short INT16;
979
980 BOOL STDCALL GdiDllInitialize(HANDLE, DWORD, LPVOID);
981
982 #include <ddk/winddi.h>
983
984 typedef struct _ROS_PALOBJ
985 {
986 XLATEOBJ *logicalToSystem;
987 int *mapping;
988 PLOGPALETTE logpalette; // _MUST_ be the last field
989 } ROS_PALOBJ, *PROS_PALOBJ;
990
991 typedef struct _ROS_BRUSHOBJ
992 {
993 ULONG iSolidColor;
994 PVOID pvRbrush;
995
996 /* remainder of fields are for GDI internal use */
997 LOGBRUSH logbrush;
998 } ROS_BRUSHOBJ, *PROS_BRUSHOBJ;
999
1000 HBRUSH STDCALL W32kCreateDIBPatternBrushPt(CONST VOID *PackedDIB, UINT Usage);
1001
1002 #define GA_PARENT 1
1003
1004 #define DCX_USESTYLE 0x00010000L
1005
1006 #define HELP_SETWINPOS 0x0203L
1007
1008 typedef ENUMRECTS *PENUMRECTS;
1009
1010 #define FSRTL_TAG TAG('F','S','r','t')
1011
1012 NTSTATUS STDCALL
1013 ObRosCreateObject(OUT PHANDLE Handle,
1014 IN ACCESS_MASK DesiredAccess,
1015 IN POBJECT_ATTRIBUTES ObjectAttributes,
1016 IN POBJECT_TYPE Type,
1017 OUT PVOID *Object);
1018
1019 #endif /* !AS_INVOKED */
1020
1021 #endif /* __INCLUDE_TYPES_H */