Use standard types in rpcrt4 headers so they can be used to build MIDL
[wine] / include / winternl.h
1 /*
2  * Internal NT APIs and data structures
3  *
4  * Copyright (C) the Wine project
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #ifndef __WINE_WINTERNL_H
22 #define __WINE_WINTERNL_H
23
24 #include <windef.h>
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif /* defined(__cplusplus) */
29
30
31 /**********************************************************************
32  * Fundamental types and data structures
33  */
34
35 typedef LONG NTSTATUS;
36
37 typedef CONST char *PCSZ;
38
39 typedef short CSHORT;
40 typedef CSHORT *PCSHORT;
41
42 typedef struct _STRING {
43   USHORT Length;
44   USHORT MaximumLength;
45   PCHAR Buffer;
46 } STRING, *PSTRING;
47
48 typedef STRING ANSI_STRING;
49 typedef PSTRING PANSI_STRING;
50 typedef const STRING *PCANSI_STRING;
51
52 typedef STRING OEM_STRING;
53 typedef PSTRING POEM_STRING;
54 typedef const STRING *PCOEM_STRING;
55
56 typedef struct _UNICODE_STRING {
57   USHORT Length;        /* bytes */
58   USHORT MaximumLength; /* bytes */
59   PWSTR  Buffer;
60 } UNICODE_STRING, *PUNICODE_STRING;
61
62 typedef const UNICODE_STRING *PCUNICODE_STRING;
63
64 typedef struct _CLIENT_ID
65 {
66    HANDLE UniqueProcess;
67    HANDLE UniqueThread;
68 } CLIENT_ID, *PCLIENT_ID;
69
70 typedef struct _CURDIR
71 {
72     UNICODE_STRING DosPath;
73     PVOID Handle;
74 } CURDIR, *PCURDIR;
75
76 typedef struct RTL_DRIVE_LETTER_CURDIR
77 {
78     USHORT              Flags;
79     USHORT              Length;
80     ULONG               TimeStamp;
81     UNICODE_STRING      DosPath;
82 } RTL_DRIVE_LETTER_CURDIR, *PRTL_DRIVE_LETTER_CURDIR;
83
84 typedef struct tagRTL_BITMAP {
85     ULONG  SizeOfBitMap; /* Number of bits in the bitmap */
86     PULONG Buffer; /* Bitmap data, assumed sized to a DWORD boundary */
87 } RTL_BITMAP, *PRTL_BITMAP;
88
89 typedef const RTL_BITMAP *PCRTL_BITMAP;
90
91 typedef struct tagRTL_BITMAP_RUN {
92     ULONG StartingIndex; /* Bit position at which run starts */
93     ULONG NumberOfBits;  /* Size of the run in bits */
94 } RTL_BITMAP_RUN, *PRTL_BITMAP_RUN;
95
96 typedef const RTL_BITMAP_RUN *PCRTL_BITMAP_RUN;
97
98 typedef struct _RTL_USER_PROCESS_PARAMETERS
99 {
100     ULONG               AllocationSize;
101     ULONG               Size;
102     ULONG               Flags;
103     ULONG               DebugFlags;
104     HANDLE              hConsole;
105     ULONG               ProcessGroup;
106     HANDLE              hStdInput;
107     HANDLE              hStdOutput;
108     HANDLE              hStdError;
109     CURDIR              CurrentDirectory;
110     UNICODE_STRING      DllPath;
111     UNICODE_STRING      ImagePathName;
112     UNICODE_STRING      CommandLine;
113     PWSTR               Environment;
114     ULONG               dwX;
115     ULONG               dwY;
116     ULONG               dwXSize;
117     ULONG               dwYSize;
118     ULONG               dwXCountChars;
119     ULONG               dwYCountChars;
120     ULONG               dwFillAttribute;
121     ULONG               dwFlags;
122     ULONG               wShowWindow;
123     UNICODE_STRING      WindowTitle;
124     UNICODE_STRING      Desktop;
125     UNICODE_STRING      ShellInfo;
126     UNICODE_STRING      RuntimeInfo;
127     RTL_DRIVE_LETTER_CURDIR DLCurrentDirectory[0x20];
128 } RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS;
129
130 /* value for Flags field (FIXME: not the correct name) */
131 #define PROCESS_PARAMS_FLAG_NORMALIZED 1
132
133 typedef struct _PEB_LDR_DATA
134 {
135     ULONG               Length;
136     BOOLEAN             Initialized;
137     PVOID               SsHandle;
138     LIST_ENTRY          InLoadOrderModuleList;
139     LIST_ENTRY          InMemoryOrderModuleList;
140     LIST_ENTRY          InInitializationOrderModuleList;
141 } PEB_LDR_DATA, *PPEB_LDR_DATA;
142
143 /***********************************************************************
144  * PEB data structure
145  */
146 typedef struct _PEB
147 {
148     BYTE                         Reserved1[2];       /*  00 */
149     BYTE                         BeingDebugged;      /*  02 */
150     BYTE                         Reserved2[5];       /*  03 */
151     HMODULE                      ImageBaseAddress;   /*  08 */
152     PPEB_LDR_DATA                LdrData;            /*  0c */
153     RTL_USER_PROCESS_PARAMETERS *ProcessParameters;  /*  10 */
154     PVOID                        __pad_14;           /*  14 */
155     HANDLE                       ProcessHeap;        /*  18 */
156     BYTE                         __pad_1c[36];       /*  1c */
157     PRTL_BITMAP                  TlsBitmap;          /*  40 */
158     ULONG                        TlsBitmapBits[2];   /*  44 */
159     BYTE                         __pad_4c[24];       /*  4c */
160     ULONG                        NumberOfProcessors; /*  64 */
161     BYTE                         __pad_68[128];      /*  68 */
162     PVOID                        Reserved3[59];      /*  e8 */
163     ULONG                        SessionId;          /* 1d4 */
164 } PEB, *PPEB;
165
166
167 /***********************************************************************
168  * TEB data structure
169  */
170 #if defined(_NTSYSTEM_) || defined(_KERNEL32_)  /* hack, should go away */
171 # define WINE_NO_TEB
172 #endif
173
174 #ifndef WINE_NO_TEB  /* don't define TEB if included from thread.h */
175 # ifndef WINE_TEB_DEFINED
176 # define WINE_TEB_DEFINED
177 typedef struct _TEB
178 {
179     NT_TIB          Tib;                        /* 000 */
180     PVOID           EnvironmentPointer;         /* 01c */
181     CLIENT_ID       ClientId;                   /* 020 */
182     PVOID           ActiveRpcHandle;            /* 028 */
183     PVOID           ThreadLocalStoragePointer;  /* 02c */
184     PPEB            Peb;                        /* 030 */
185     ULONG           LastErrorValue;             /* 034 */
186     BYTE            __pad038[140];              /* 038 */
187     ULONG           CurrentLocale;              /* 0c4 */
188     BYTE            __pad0c8[1752];             /* 0c8 */
189     PVOID           Reserved2[278];             /* 7a0 */
190     UNICODE_STRING  StaticUnicodeString;        /* bf8 used by advapi32 */
191     WCHAR           StaticUnicodeBuffer[261];   /* c00 used by advapi32 */
192     PVOID           DeallocationStack;          /* e0c */
193     PVOID           TlsSlots[64];               /* e10 */
194     LIST_ENTRY      TlsLinks;                   /* f10 */
195     PVOID           Reserved4[26];              /* f18 */
196     PVOID           ReservedForOle;             /* f80 Windows 2000 only */
197     PVOID           Reserved5[4];               /* f84 */
198     PVOID           TlsExpansionSlots;          /* f94 */
199 } TEB, *PTEB;
200 # endif /* WINE_TEB_DEFINED */
201 #endif  /* WINE_NO_TEB */
202
203 /***********************************************************************
204  * Enums
205  */
206
207 typedef enum _FILE_INFORMATION_CLASS {
208     FileDirectoryInformation = 1,
209     FileFullDirectoryInformation,
210     FileBothDirectoryInformation,
211     FileBasicInformation,
212     FileStandardInformation,
213     FileInternalInformation,
214     FileEaInformation,
215     FileAccessInformation,
216     FileNameInformation,
217     FileRenameInformation,
218     FileLinkInformation,
219     FileNamesInformation,
220     FileDispositionInformation,
221     FilePositionInformation,
222     FileFullEaInformation,
223     FileModeInformation,
224     FileAlignmentInformation,
225     FileAllInformation,
226     FileAllocationInformation,
227     FileEndOfFileInformation,
228     FileAlternateNameInformation,
229     FileStreamInformation,
230     FilePipeInformation,
231     FilePipeLocalInformation,
232     FilePipeRemoteInformation,
233     FileMailslotQueryInformation,
234     FileMailslotSetInformation,
235     FileCompressionInformation,
236     FileObjectIdInformation,
237     FileCompletionInformation,
238     FileMoveClusterInformation,
239     FileQuotaInformation,
240     FileReparsePointInformation,
241     FileNetworkOpenInformation,
242     FileAttributeTagInformation,
243     FileTrackingInformation,
244     FileMaximumInformation
245 } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
246
247 typedef struct _FILE_DIRECTORY_INFORMATION {
248     ULONG               NextEntryOffset;
249     ULONG               FileIndex;
250     LARGE_INTEGER       CreationTime;
251     LARGE_INTEGER       LastAccessTime;
252     LARGE_INTEGER       LastWriteTime;
253     LARGE_INTEGER       ChangeTime;
254     LARGE_INTEGER       EndOfFile;
255     LARGE_INTEGER       AllocationSize;
256     ULONG               FileAttributes;
257     ULONG               FileNameLength;
258     WCHAR               FileName[ANYSIZE_ARRAY];
259 } FILE_DIRECTORY_INFORMATION, *PFILE_DIRECTORY_INFORMATION;
260
261 typedef struct _FILE_FULL_DIRECTORY_INFORMATION {
262     ULONG               NextEntryOffset;
263     ULONG               FileIndex;
264     LARGE_INTEGER       CreationTime;
265     LARGE_INTEGER       LastAccessTime;
266     LARGE_INTEGER       LastWriteTime;
267     LARGE_INTEGER       ChangeTime;
268     LARGE_INTEGER       EndOfFile;
269     LARGE_INTEGER       AllocationSize;
270     ULONG               FileAttributes;
271     ULONG               FileNameLength;
272     ULONG               EaSize;
273     WCHAR               FileName[ANYSIZE_ARRAY];
274 } FILE_FULL_DIRECTORY_INFORMATION, *PFILE_FULL_DIRECTORY_INFORMATION,
275   FILE_FULL_DIR_INFORMATION, *PFILE_FULL_DIR_INFORMATION;
276
277 typedef struct _FILE_BOTH_DIRECTORY_INFORMATION {
278     ULONG               NextEntryOffset;
279     ULONG               FileIndex;
280     LARGE_INTEGER       CreationTime;
281     LARGE_INTEGER       LastAccessTime;
282     LARGE_INTEGER       LastWriteTime;
283     LARGE_INTEGER       ChangeTime;
284     LARGE_INTEGER       EndOfFile;
285     LARGE_INTEGER       AllocationSize;
286     ULONG               FileAttributes;
287     ULONG               FileNameLength;
288     ULONG               EaSize;
289     CHAR                ShortNameLength;
290     WCHAR               ShortName[12];
291     WCHAR               FileName[ANYSIZE_ARRAY];
292 } FILE_BOTH_DIRECTORY_INFORMATION, *PFILE_BOTH_DIRECTORY_INFORMATION,
293   FILE_BOTH_DIR_INFORMATION, *PFILE_BOTH_DIR_INFORMATION;
294
295 typedef struct _FILE_BASIC_INFORMATION {
296     LARGE_INTEGER CreationTime;
297     LARGE_INTEGER LastAccessTime;
298     LARGE_INTEGER LastWriteTime;
299     LARGE_INTEGER ChangeTime;
300     ULONG FileAttributes;
301 } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
302
303 typedef struct _FILE_STANDARD_INFORMATION {
304     LARGE_INTEGER AllocationSize;
305     LARGE_INTEGER EndOfFile;
306     ULONG NumberOfLinks;
307     BOOLEAN DeletePending;
308     BOOLEAN Directory;
309 } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;
310
311 typedef struct _FILE_INTERNAL_INFORMATION {
312     LARGE_INTEGER IndexNumber;
313 } FILE_INTERNAL_INFORMATION, *PFILE_INTERNAL_INFORMATION;
314
315 typedef struct _FILE_EA_INFORMATION {
316     ULONG EaSize;
317 } FILE_EA_INFORMATION, *PFILE_EA_INFORMATION;
318
319 typedef struct _FILE_ACCESS_INFORMATION {
320     ACCESS_MASK AccessFlags;
321 } FILE_ACCESS_INFORMATION, *PFILE_ACCESS_INFORMATION;
322
323 typedef struct _FILE_NAME_INFORMATION {
324     ULONG FileNameLength;
325     WCHAR FileName[1];
326 } FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
327
328 typedef struct _FILE_RENAME_INFORMATION {
329     BOOLEAN Replace;
330     HANDLE RootDir;
331     ULONG FileNameLength;
332     WCHAR FileName[1];
333 } FILE_RENAME_INFORMATION, *PFILE_RENAME_INFORMATION;
334
335 typedef struct _FILE_NAMES_INFORMATION {
336     ULONG NextEntryOffset;
337     ULONG FileIndex;
338     ULONG FileNameLength;
339     WCHAR FileName[1];
340 } FILE_NAMES_INFORMATION, *PFILE_NAMES_INFORMATION;
341
342 typedef struct _FILE_DISPOSITION_INFORMATION {
343     BOOLEAN DoDeleteFile;
344 } FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION;
345
346 typedef struct _FILE_POSITION_INFORMATION {
347     LARGE_INTEGER CurrentByteOffset;
348 } FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION;
349
350 typedef struct _FILE_ALIGNMENT_INFORMATION {
351     ULONG AlignmentRequirement;
352 } FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION;
353
354 typedef struct _FILE_ALLOCATION_INFORMATION {
355     LARGE_INTEGER AllocationSize;
356 } FILE_ALLOCATION_INFORMATION, *PFILE_ALLOCATION_INFORMATION;
357
358 typedef struct _FILE_END_OF_FILE_INFORMATION {
359     LARGE_INTEGER EndOfFile;
360 } FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION;
361
362 typedef struct _FILE_NETWORK_OPEN_INFORMATION {
363     LARGE_INTEGER CreationTime;
364     LARGE_INTEGER LastAccessTime;
365     LARGE_INTEGER LastWriteTime;
366     LARGE_INTEGER ChangeTime;
367     LARGE_INTEGER AllocationSize;
368     LARGE_INTEGER EndOfFile;
369     ULONG FileAttributes;
370 } FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION;
371
372 typedef struct _FILE_FULL_EA_INFORMATION {
373     ULONG NextEntryOffset;
374     UCHAR Flags;
375     UCHAR EaNameLength;
376     USHORT EaValueLength;
377     CHAR EaName[1];
378 } FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
379
380 typedef struct _FILE_MODE_INFORMATION {
381     ULONG Mode;
382 } FILE_MODE_INFORMATION, *PFILE_MODE_INFORMATION;
383
384 typedef struct _FILE_STREAM_INFORMATION
385 {
386     ULONG NextEntryOffset;
387     ULONG StreamNameLength;
388     LARGE_INTEGER StreamSize;
389     LARGE_INTEGER StreamAllocationSize;
390     WCHAR StreamName[1];
391 } FILE_STREAM_INFORMATION, *PFILE_STREAM_INFORMATION;
392
393 typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION
394 {
395     ULONG FileAttributes;
396     ULONG ReparseTag;
397 } FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION;
398
399 typedef struct _FILE_ALL_INFORMATION
400 {
401     FILE_BASIC_INFORMATION     BasicInformation;
402     FILE_STANDARD_INFORMATION  StandardInformation;
403     FILE_INTERNAL_INFORMATION  InternalInformation;
404     FILE_EA_INFORMATION        EaInformation;
405     FILE_ACCESS_INFORMATION    AccessInformation;
406     FILE_POSITION_INFORMATION  PositionInformation;
407     FILE_MODE_INFORMATION      ModeInformation;
408     FILE_ALIGNMENT_INFORMATION AlignmentInformation;
409     FILE_NAME_INFORMATION      NameInformation;
410 } FILE_ALL_INFORMATION, *PFILE_ALL_INFORMATION;
411
412 typedef enum _FSINFOCLASS {
413     FileFsVolumeInformation = 1,
414     FileFsLabelInformation,
415     FileFsSizeInformation,
416     FileFsDeviceInformation,
417     FileFsAttributeInformation,
418     FileFsControlInformation,
419     FileFsFullSizeInformation,
420     FileFsObjectIdInformation,
421     FileFsMaximumInformation
422 } FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS;
423
424 typedef enum _KEY_INFORMATION_CLASS {
425     KeyBasicInformation,
426     KeyNodeInformation,
427     KeyFullInformation
428 } KEY_INFORMATION_CLASS;
429
430 typedef enum _KEY_VALUE_INFORMATION_CLASS {
431     KeyValueBasicInformation,
432     KeyValueFullInformation,
433     KeyValuePartialInformation,
434     KeyValueFullInformationAlign64,
435     KeyValuePartialInformationAlign64
436 } KEY_VALUE_INFORMATION_CLASS;
437
438 typedef enum _OBJECT_INFORMATION_CLASS {
439     ObjectBasicInformation,
440     ObjectNameInformation,
441     ObjectTypeInformation,
442     ObjectAllInformation,
443     ObjectDataInformation
444 } OBJECT_INFORMATION_CLASS, *POBJECT_INFORMATION_CLASS;
445
446 typedef enum _PROCESSINFOCLASS {
447     ProcessBasicInformation = 0,
448     ProcessQuotaLimits = 1,
449     ProcessIoCounters = 2,
450     ProcessVmCounters = 3,
451     ProcessTimes = 4,
452     ProcessBasePriority = 5,
453     ProcessRaisePriority = 6,
454     ProcessDebugPort = 7,
455     ProcessExceptionPort = 8,
456     ProcessAccessToken = 9,
457     ProcessLdtInformation = 10,
458     ProcessLdtSize = 11,
459     ProcessDefaultHardErrorMode = 12,
460     ProcessIoPortHandlers = 13,
461     ProcessPooledUsageAndLimits = 14,
462     ProcessWorkingSetWatch = 15,
463     ProcessUserModeIOPL = 16,
464     ProcessEnableAlignmentFaultFixup = 17,
465     ProcessPriorityClass = 18,
466     ProcessWx86Information = 19,
467     ProcessHandleCount = 20,
468     ProcessAffinityMask = 21,
469     ProcessPriorityBoost = 22,
470     ProcessDeviceMap = 23,
471     ProcessSessionInformation = 24,
472     ProcessForegroundInformation = 25,
473     ProcessWow64Information = 26,
474     MaxProcessInfoClass
475 } PROCESSINFOCLASS;
476
477 typedef enum _SECTION_INHERIT {
478     ViewShare = 1,
479     ViewUnmap = 2
480 } SECTION_INHERIT;
481
482 typedef enum _SYSTEM_INFORMATION_CLASS {
483     SystemBasicInformation = 0,
484     Unknown1,
485     SystemPerformanceInformation = 2,
486     SystemTimeOfDayInformation = 3, /* was SystemTimeInformation */
487     Unknown4,
488     SystemProcessInformation = 5,
489     Unknown6,
490     Unknown7,
491     SystemProcessorPerformanceInformation = 8,
492     Unknown9,
493     Unknown10,
494     SystemDriverInformation,
495     Unknown12,
496     Unknown13,
497     Unknown14,
498     Unknown15,
499     SystemHandleList,
500     Unknown17,
501     Unknown18,
502     Unknown19,
503     Unknown20,
504     SystemCacheInformation,
505     Unknown22,
506     SystemInterruptInformation = 23,
507     SystemDpcBehaviourInformation = 24,
508     SystemFullMemoryInformation = 25,
509     SystemNotImplemented6 = 25,
510     SystemLoadImage = 26,
511     SystemUnloadImage = 27,
512     SystemTimeAdjustmentInformation = 28,
513     SystemTimeAdjustment = 28,
514     SystemSummaryMemoryInformation = 29,
515     SystemNotImplemented7 = 29,
516     SystemNextEventIdInformation = 30,
517     SystemNotImplemented8 = 30,
518     SystemEventIdsInformation = 31,
519     SystemCrashDumpInformation = 32,
520     SystemExceptionInformation = 33,
521     SystemCrashDumpStateInformation = 34,
522     SystemKernelDebuggerInformation = 35,
523     SystemContextSwitchInformation = 36,
524     SystemRegistryQuotaInformation = 37,
525     SystemCurrentTimeZoneInformation = 44,
526     SystemTimeZoneInformation = 44,
527     SystemLookasideInformation = 45,
528     SystemSetTimeSlipEvent = 46,
529     SystemCreateSession = 47,
530     SystemDeleteSession = 48,
531     SystemInvalidInfoClass4 = 49,
532     SystemRangeStartInformation = 50,
533     SystemVerifierInformation = 51,
534     SystemAddVerifier = 52,
535     SystemSessionProcessesInformation   = 53,
536     SystemInformationClassMax
537 } SYSTEM_INFORMATION_CLASS, *PSYSTEM_INFORMATION_CLASS;
538
539 typedef enum _TIMER_TYPE {
540     NotificationTimer,
541     SynchronizationTimer
542 } TIMER_TYPE;
543
544 typedef enum _THREADINFOCLASS {
545     ThreadBasicInformation,
546     ThreadTimes,
547     ThreadPriority,
548     ThreadBasePriority,
549     ThreadAffinityMask,
550     ThreadImpersonationToken,
551     ThreadDescriptorTableEntry,
552     ThreadEnableAlignmentFaultFixup,
553     ThreadEventPair_Reusable,
554     ThreadQuerySetWin32StartAddress,
555     ThreadZeroTlsCell,
556     ThreadPerformanceCount,
557     ThreadAmILastThread,
558     ThreadIdealProcessor,
559     ThreadPriorityBoost,
560     ThreadSetTlsArrayAddress,
561     ThreadIsIoPending,
562     MaxThreadInfoClass
563 } THREADINFOCLASS;
564
565 typedef struct _THREAD_BASIC_INFORMATION
566 {
567     NTSTATUS  ExitStatus;
568     PVOID     TebBaseAddress;
569     CLIENT_ID ClientId;
570     ULONG     AffinityMask;
571     LONG      Priority;
572     LONG      BasePriority;
573 } THREAD_BASIC_INFORMATION, *PTHREAD_BASIC_INFORMATION;
574
575
576 typedef enum _WINSTATIONINFOCLASS {
577     WinStationInformation = 8
578 } WINSTATIONINFOCLASS;
579
580 typedef enum
581 {
582     MemoryBasicInformation = 0
583 } MEMORY_INFORMATION_CLASS;
584
585 /* return type of RtlDetermineDosPathNameType_U (FIXME: not the correct names) */
586 typedef enum
587 {
588     INVALID_PATH = 0,
589     UNC_PATH,              /* "//foo" */
590     ABSOLUTE_DRIVE_PATH,   /* "c:/foo" */
591     RELATIVE_DRIVE_PATH,   /* "c:foo" */
592     ABSOLUTE_PATH,         /* "/foo" */
593     RELATIVE_PATH,         /* "foo" */
594     DEVICE_PATH,           /* "//./foo" */
595     UNC_DOT_PATH           /* "//." */
596 } DOS_PATHNAME_TYPE;
597
598 /***********************************************************************
599  * IA64 specific types and data structures
600  */
601
602 #ifdef __ia64__
603
604 typedef struct _FRAME_POINTERS {
605   ULONGLONG MemoryStackFp;
606   ULONGLONG BackingStoreFp;
607 } FRAME_POINTERS, *PFRAME_POINTERS;
608
609 #define UNWIND_HISTORY_TABLE_SIZE 12
610
611 typedef struct _RUNTIME_FUNCTION {
612   ULONG BeginAddress;
613   ULONG EndAddress;
614   ULONG UnwindInfoAddress;
615 } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
616
617 typedef struct _UNWIND_HISTORY_TABLE_ENTRY {
618   ULONG64 ImageBase;
619   ULONG64 Gp;
620   PRUNTIME_FUNCTION FunctionEntry;
621 } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
622
623 typedef struct _UNWIND_HISTORY_TABLE {
624   ULONG Count;
625   UCHAR Search;
626   ULONG64 LowAddress;
627   ULONG64 HighAddress;
628   UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
629 } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
630
631 #endif /* defined(__ia64__) */
632
633 /***********************************************************************
634  * Types and data structures
635  */
636
637 /* This is used by NtQuerySystemInformation */
638 /* FIXME: Isn't THREAD_INFO and THREADINFO the same structure? */
639 typedef struct {
640     FILETIME    ftKernelTime;
641     FILETIME    ftUserTime;
642     FILETIME    ftCreateTime;
643     DWORD       dwTickCount;
644     DWORD       dwStartAddress;
645     DWORD       dwOwningPID;
646     DWORD       dwThreadID;
647     DWORD       dwCurrentPriority;
648     DWORD       dwBasePriority;
649     DWORD       dwContextSwitches;
650     DWORD       dwThreadState;
651     DWORD       dwWaitReason;
652 } THREADINFO, *PTHREADINFO;
653
654 /* FIXME: Isn't THREAD_INFO and THREADINFO the same structure? */
655 typedef struct _THREAD_INFO{
656     DWORD Unknown1[6];
657     DWORD ThreadID;
658     DWORD Unknown2[3];
659     DWORD Status;
660     DWORD WaitReason;
661     DWORD Unknown3[4];
662 } THREAD_INFO, PTHREAD_INFO;
663
664 /***********************************************************************
665  * Types and data structures
666  */
667
668 typedef struct _IO_STATUS_BLOCK {
669   union {
670     NTSTATUS Status;
671     PVOID Pointer;
672   } DUMMYUNIONNAME;
673
674   ULONG_PTR Information;
675 } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
676
677 typedef void (WINAPI * PIO_APC_ROUTINE)(PVOID,PIO_STATUS_BLOCK,ULONG);
678
679 typedef struct _KEY_BASIC_INFORMATION {
680     LARGE_INTEGER LastWriteTime;
681     ULONG         TitleIndex;
682     ULONG         NameLength;
683     WCHAR         Name[1];
684 } KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION;
685
686 typedef struct _KEY_NODE_INFORMATION
687 {
688     LARGE_INTEGER LastWriteTime;
689     ULONG         TitleIndex;
690     ULONG         ClassOffset;
691     ULONG         ClassLength;
692     ULONG         NameLength;
693     WCHAR         Name[1];
694    /* Class[1]; */
695 } KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION;
696
697 typedef struct _KEY_FULL_INFORMATION
698 {
699     LARGE_INTEGER LastWriteTime;
700     ULONG         TitleIndex;
701     ULONG         ClassOffset;
702     ULONG         ClassLength;
703     ULONG         SubKeys;
704     ULONG         MaxNameLen;
705     ULONG         MaxClassLen;
706     ULONG         Values;
707     ULONG         MaxValueNameLen;
708     ULONG         MaxValueDataLen;
709     WCHAR         Class[1];
710 } KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION;
711
712 typedef struct _KEY_VALUE_ENTRY
713 {
714     PUNICODE_STRING ValueName;
715     ULONG           DataLength;
716     ULONG           DataOffset;
717     ULONG           Type;
718 } KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY;
719
720 typedef struct _KEY_VALUE_BASIC_INFORMATION {
721     ULONG TitleIndex;
722     ULONG Type;
723     ULONG NameLength;
724     WCHAR Name[1];
725 } KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION;
726
727 typedef struct _KEY_VALUE_FULL_INFORMATION {
728     ULONG TitleIndex;
729     ULONG Type;
730     ULONG DataOffset;
731     ULONG DataLength;
732     ULONG NameLength;
733     WCHAR Name[1];
734 } KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION;
735
736 typedef struct _KEY_VALUE_PARTIAL_INFORMATION {
737     ULONG TitleIndex;
738     ULONG Type;
739     ULONG DataLength;
740     UCHAR Data[1];
741 } KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION;
742
743 typedef struct _OBJECT_ATTRIBUTES {
744   ULONG Length;
745   HANDLE RootDirectory;
746   PUNICODE_STRING ObjectName;
747   ULONG Attributes;
748   PVOID SecurityDescriptor;       /* type SECURITY_DESCRIPTOR */
749   PVOID SecurityQualityOfService; /* type SECURITY_QUALITY_OF_SERVICE */
750 } OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;
751
752 typedef struct _OBJECT_DATA_INFORMATION {
753     BOOLEAN InheritHandle;
754     BOOLEAN ProtectFromClose;
755 } OBJECT_DATA_INFORMATION, *POBJECT_DATA_INFORMATION;
756
757 typedef struct _PROCESS_BASIC_INFORMATION {
758 #ifdef __WINESRC__
759     DWORD ExitStatus;
760     DWORD PebBaseAddress;
761     DWORD AffinityMask;
762     DWORD BasePriority;
763     ULONG UniqueProcessId;
764     ULONG InheritedFromUniqueProcessId;
765 #else
766     PVOID Reserved1;
767     PPEB PebBaseAddress;
768     PVOID Reserved2[2];
769     ULONG_PTR UniqueProcessId;
770     PVOID Reserved3;
771 #endif
772 } PROCESS_BASIC_INFORMATION, *PPROCESS_BASIC_INFORMATION;
773
774 typedef struct _PROCESS_INFO {
775     DWORD    Offset;             /* 00 offset to next PROCESS_INFO ok*/
776     DWORD    ThreadCount;        /* 04 number of ThreadInfo member ok */
777     DWORD    Unknown1[6];
778     FILETIME CreationTime;       /* 20 */
779     DWORD    Unknown2[5];
780     PWCHAR   ProcessName;        /* 3c ok */
781     DWORD    BasePriority;
782     DWORD    ProcessID;          /* 44 ok*/
783     DWORD    ParentProcessID;
784     DWORD    HandleCount;
785     DWORD    Unknown3[2];        /* 50 */
786     ULONG    PeakVirtualSize;
787     ULONG    VirtualSize;
788     ULONG    PageFaultCount;
789     ULONG    PeakWorkingSetSize;
790     ULONG    WorkingSetSize;
791     ULONG    QuotaPeakPagedPoolUsage;
792     ULONG    QuotaPagedPoolUsage;
793     ULONG    QuotaPeakNonPagedPoolUsage;
794     ULONG    QuotaNonPagedPoolUsage;
795     ULONG    PagefileUsage;
796     ULONG    PeakPagefileUsage;
797     DWORD    PrivateBytes;
798     DWORD    Unknown6[4];
799     THREAD_INFO ati[ANYSIZE_ARRAY]; /* 94 size=0x40*/
800 } PROCESS_INFO, PPROCESS_INFO;
801
802 typedef struct _RTL_HEAP_DEFINITION {
803     ULONG Length; /* = sizeof(RTL_HEAP_DEFINITION) */
804
805     ULONG Unknown[11];
806 } RTL_HEAP_DEFINITION, *PRTL_HEAP_DEFINITION;
807
808 typedef struct _RTL_RWLOCK {
809     RTL_CRITICAL_SECTION rtlCS;
810
811     HANDLE hSharedReleaseSemaphore;
812     UINT   uSharedWaiters;
813
814     HANDLE hExclusiveReleaseSemaphore;
815     UINT   uExclusiveWaiters;
816
817     INT    iNumberActive;
818     HANDLE hOwningThreadId;
819     DWORD  dwTimeoutBoost;
820     PVOID  pDebugInfo;
821 } RTL_RWLOCK, *LPRTL_RWLOCK;
822
823 /* System Information Class 0x00 */
824 typedef struct _SYSTEM_BASIC_INFORMATION {
825 #ifdef __WINESRC__
826     DWORD dwUnknown1;
827     ULONG uKeMaximumIncrement;
828     ULONG uPageSize;
829     ULONG uMmNumberOfPhysicalPages;
830     ULONG uMmLowestPhysicalPage;
831     ULONG uMmHighestPhysicalPage;
832     ULONG uAllocationGranularity;
833     PVOID pLowestUserAddress;
834     PVOID pMmHighestUserAddress;
835     ULONG uKeActiveProcessors;
836     BYTE bKeNumberProcessors;
837     BYTE bUnknown2;
838     WORD wUnknown3;
839 #else
840     BYTE Reserved1[24];
841     PVOID Reserved2[4];
842     CCHAR NumberOfProcessors;
843 #endif
844 } SYSTEM_BASIC_INFORMATION, *PSYSTEM_BASIC_INFORMATION;
845
846 /* System Information Class 0x15 */
847 typedef struct {
848     ULONG CurrentSize;
849     ULONG PeakSize;
850     ULONG PageFaultCount;
851     ULONG MinimumWorkingSet;
852     ULONG MaximumWorkingSet;
853     ULONG unused[4];
854 } SYSTEM_CACHE_INFORMATION;
855
856 typedef struct _SYSTEM_CONFIGURATION_INFO {
857     union {
858         ULONG   OemId;
859         struct {
860             WORD ProcessorArchitecture;
861             WORD Reserved;
862         } tag1;
863     } tag2;
864     ULONG PageSize;
865     PVOID MinimumApplicationAddress;
866     PVOID MaximumApplicationAddress;
867     ULONG ActiveProcessorMask;
868     ULONG NumberOfProcessors;
869     ULONG ProcessorType;
870     ULONG AllocationGranularity;
871     WORD  ProcessorLevel;
872     WORD  ProcessorRevision;
873 } SYSTEM_CONFIGURATION_INFO, *PSYSTEM_CONFIGURATION_INFO;
874
875 /* System Information Class 0x0b */
876 typedef struct {
877     PVOID pvAddress;
878     DWORD dwUnknown1;
879     DWORD dwUnknown2;
880     DWORD dwEntryIndex;
881     DWORD dwUnknown3;
882     char szName[MAX_PATH + 1];
883 } SYSTEM_DRIVER_INFORMATION;
884
885 typedef struct _SYSTEM_EXCEPTION_INFORMATION {
886     BYTE Reserved1[16];
887 } SYSTEM_EXCEPTION_INFORMATION, *PSYSTEM_EXCEPTION_INFORMATION;
888
889 typedef struct _SYSTEM_LOOKASIDE_INFORMATION {
890     BYTE Reserved1[32];
891 } SYSTEM_LOOKASIDE_INFORMATION, *PSYSTEM_LOOKASIDE_INFORMATION;
892
893 typedef struct _SYSTEM_INTERRUPT_INFORMATION {
894     BYTE Reserved1[24];
895 } SYSTEM_INTERRUPT_INFORMATION, *PSYSTEM_INTERRUPT_INFORMATION;
896
897 typedef struct _SYSTEM_KERNEL_DEBUGGER_INFORMATION {
898         BOOLEAN  DebuggerEnabled;
899         BOOLEAN  DebuggerNotPresent;
900 } SYSTEM_KERNEL_DEBUGGER_INFORMATION, *PSYSTEM_KERNEL_DEBUGGER_INFORMATION;
901
902 /* System Information Class 0x10 */
903 typedef struct {
904     USHORT dwPID;
905     USHORT dwCreatorBackTraceIndex;
906     BYTE bObjectType;
907     BYTE bHandleAttributes;
908     USHORT usHandleOffset;
909     DWORD dwKeObject;
910     ULONG ulGrantedAccess;
911 } HANDLEINFO, *PHANDLEINFO; /* FIXME: SYSTEM_HANDLE_INFORMATION? */
912
913 typedef struct _SYSTEM_PERFORMANCE_INFORMATION {
914     BYTE Reserved1[312];
915 } SYSTEM_PERFORMANCE_INFORMATION, *PSYSTEM_PERFORMANCE_INFORMATION;
916
917 /* System Information Class 0x02 */
918 typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION {
919 #ifdef __WINESRC__
920     LARGE_INTEGER liIdleTime;
921     DWORD dwSpare[10];
922 #else
923     LARGE_INTEGER IdleTime;
924     LARGE_INTEGER KernelTime;
925     LARGE_INTEGER UserTime;
926     LARGE_INTEGER Reserved1[2];
927     ULONG Reserved2;
928 #endif
929 } SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION, *PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION;
930
931 /* System Information Class 0x05 */
932 typedef struct _SYSTEM_PROCESS_INFORMATION {
933 #ifdef __WINESRC__
934     DWORD dwOffset;
935     DWORD dwThreadCount;
936     DWORD dwUnknown1[6];
937     FILETIME ftCreationTime;
938     DWORD dwUnknown2[5];
939     WCHAR *pszProcessName;
940     DWORD dwBasePriority;
941     DWORD dwProcessID;
942     DWORD dwParentProcessID;
943     DWORD dwHandleCount;
944     DWORD dwUnknown3;
945     DWORD dwUnknown4;
946     DWORD dwVirtualBytesPeak;
947     DWORD dwVirtualBytes;
948     DWORD dwPageFaults;
949     DWORD dwWorkingSetPeak;
950     DWORD dwWorkingSet;
951     DWORD dwUnknown5;
952     DWORD dwPagedPool;
953     DWORD dwUnknown6;
954     DWORD dwNonPagedPool;
955     DWORD dwPageFileBytesPeak;
956     DWORD dwPrivateBytes;
957     DWORD dwPageFileBytes;
958     DWORD dwUnknown7[4];
959     THREADINFO ti[1];
960 #else
961     ULONG NextEntryOffset;
962     BYTE Reserved1[52];
963     PVOID Reserved2[3];
964     HANDLE UniqueProcessId;
965     PVOID Reserved3;
966     ULONG HandleCount;
967     BYTE Reserved4[4];
968     PVOID Reserved5[11];
969     SIZE_T PeakPagefileUsage;
970     SIZE_T PrivatePageCount;
971     LARGE_INTEGER Reserved6[6];
972 #endif
973 } SYSTEM_PROCESS_INFORMATION, *PSYSTEM_PROCESS_INFORMATION;
974
975 typedef struct _SYSTEM_REGISTRY_QUOTA_INFORMATION {
976     ULONG RegistryQuotaAllowed;
977     ULONG RegistryQuotaUsed;
978     PVOID Reserved1;
979 } SYSTEM_REGISTRY_QUOTA_INFORMATION, *PSYSTEM_REGISTRY_QUOTA_INFORMATION;
980
981 typedef struct _SYSTEM_TIME_ADJUSTMENT {
982     ULONG   TimeAdjustment;
983     BOOLEAN TimeAdjustmentDisabled;
984 } SYSTEM_TIME_ADJUSTMENT, *PSYSTEM_TIME_ADJUSTMENT;
985
986 /* System Information Class 0x03 */
987 typedef struct _SYSTEM_TIMEOFDAY_INFORMATION {
988 #ifdef __WINESRC__
989     LARGE_INTEGER liKeBootTime;
990     LARGE_INTEGER liKeSystemTime;
991     LARGE_INTEGER liExpTimeZoneBias;
992     ULONG uCurrentTimeZoneId;
993     DWORD dwReserved;
994 #else
995     BYTE Reserved1[48];
996 #endif
997 } SYSTEM_TIMEOFDAY_INFORMATION, *PSYSTEM_TIMEOFDAY_INFORMATION; /* was SYSTEM_TIME_INFORMATION */
998
999 typedef struct _TIME_FIELDS
1000 {   CSHORT Year;
1001     CSHORT Month;
1002     CSHORT Day;
1003     CSHORT Hour;
1004     CSHORT Minute;
1005     CSHORT Second;
1006     CSHORT Milliseconds;
1007     CSHORT Weekday;
1008 } TIME_FIELDS, *PTIME_FIELDS;
1009
1010 typedef struct _WINSTATIONINFORMATIONW {
1011   BYTE Reserved2[70];
1012   ULONG LogonId;
1013   BYTE Reserved3[1140];
1014 } WINSTATIONINFORMATIONW, *PWINSTATIONINFORMATIONW;
1015
1016 typedef struct _VM_COUNTERS_ {
1017     SIZE_T PeakVirtualSize;
1018     SIZE_T VirtualSize;
1019     ULONG  PageFaultCount;
1020     SIZE_T PeakWorkingSetSize;
1021     SIZE_T WorkingSetSize;
1022     SIZE_T QuotaPeakPagedPoolUsage;
1023     SIZE_T QuotaPagedPoolUsage;
1024     SIZE_T QuotaPeakNonPagedPoolUsage;
1025     SIZE_T QuotaNonPagedPoolUsage;
1026     SIZE_T PagefileUsage;
1027     SIZE_T PeakPagefileUsage;
1028 } VM_COUNTERS, *PVM_COUNTERS;
1029
1030 typedef BOOLEAN (WINAPI * PWINSTATIONQUERYINFORMATIONW)(HANDLE,ULONG,WINSTATIONINFOCLASS,PVOID,ULONG,PULONG);
1031
1032 typedef struct _LDR_RESOURCE_INFO
1033 {
1034     ULONG Type;
1035     ULONG Name;
1036     ULONG Language;
1037 } LDR_RESOURCE_INFO, *PLDR_RESOURCE_INFO;
1038
1039
1040 /* debug buffer definitions */
1041
1042 typedef struct _DEBUG_BUFFER {
1043   HANDLE SectionHandle;
1044   PVOID  SectionBase;
1045   PVOID  RemoteSectionBase;
1046   ULONG  SectionBaseDelta;
1047   HANDLE EventPairHandle;
1048   ULONG  Unknown[2];
1049   HANDLE RemoteThreadHandle;
1050   ULONG  InfoClassMask;
1051   ULONG  SizeOfInfo;
1052   ULONG  AllocatedSize;
1053   ULONG  SectionSize;
1054   PVOID  ModuleInformation;
1055   PVOID  BackTraceInformation;
1056   PVOID  HeapInformation;
1057   PVOID  LockInformation;
1058   PVOID  Reserved[8];
1059 } DEBUG_BUFFER, *PDEBUG_BUFFER;
1060
1061 #define PDI_MODULES                       0x01
1062 #define PDI_BACKTRACE                     0x02
1063 #define PDI_HEAPS                         0x04
1064 #define PDI_HEAP_TAGS                     0x08
1065 #define PDI_HEAP_BLOCKS                   0x10
1066 #define PDI_LOCKS                         0x20
1067
1068 typedef struct _DEBUG_MODULE_INFORMATION {
1069   ULONG  Reserved[2];
1070   ULONG  Base;
1071   ULONG  Size;
1072   ULONG  Flags;
1073   USHORT Index;
1074   USHORT Unknown;
1075   USHORT LoadCount;
1076   USHORT ModuleNameOffset;
1077   CHAR   ImageName[256];
1078 } DEBUG_MODULE_INFORMATION, *PDEBUG_MODULE_INFORMATION;
1079
1080 typedef struct _DEBUG_HEAP_INFORMATION {
1081   ULONG  Base;
1082   ULONG  Flags;
1083   USHORT Granularity;
1084   USHORT Unknown;
1085   ULONG  Allocated;
1086   ULONG  Committed;
1087   ULONG  TagCount;
1088   ULONG  BlockCount;
1089   ULONG  Reserved[7];
1090   PVOID  Tags;
1091   PVOID  Blocks;
1092 } DEBUG_HEAP_INFORMATION, *PDEBUG_HEAP_INFORMATION;
1093
1094 typedef struct _DEBUG_LOCK_INFORMATION {
1095   PVOID  Address;
1096   USHORT Type;
1097   USHORT CreatorBackTraceIndex;
1098   ULONG  OwnerThreadId;
1099   ULONG  ActiveCount;
1100   ULONG  ContentionCount;
1101   ULONG  EntryCount;
1102   ULONG  RecursionCount;
1103   ULONG  NumberOfSharedWaiters;
1104   ULONG  NumberOfExclusiveWaiters;
1105 } DEBUG_LOCK_INFORMATION, *PDEBUG_LOCK_INFORMATION;
1106
1107 typedef struct _PORT_MESSAGE_HEADER {
1108   USHORT DataSize;
1109   USHORT MessageSize;
1110   USHORT MessageType;
1111   USHORT VirtualRangesOffset;
1112   CLIENT_ID ClientId;
1113   ULONG MessageId;
1114   ULONG SectionSize;
1115 } PORT_MESSAGE_HEADER, *PPORT_MESSAGE_HEADER, PORT_MESSAGE, *PPORT_MESSAGE;
1116
1117 /***********************************************************************
1118  * Defines
1119  */
1120
1121 /* flags for NtCreateFile and NtOpenFile */
1122 #define FILE_DIRECTORY_FILE             0x00000001
1123 #define FILE_WRITE_THROUGH              0x00000002
1124 #define FILE_SEQUENTIAL_ONLY            0x00000004
1125 #define FILE_NO_INTERMEDIATE_BUFFERING  0x00000008
1126 #define FILE_SYNCHRONOUS_IO_ALERT       0x00000010
1127 #define FILE_SYNCHRONOUS_IO_NONALERT    0x00000020
1128 #define FILE_NON_DIRECTORY_FILE         0x00000040
1129 #define FILE_CREATE_TREE_CONNECTION     0x00000080
1130 #define FILE_COMPLETE_IF_OPLOCKED       0x00000100
1131 #define FILE_NO_EA_KNOWLEDGE            0x00000200
1132 #define FILE_OPEN_FOR_RECOVERY          0x00000400
1133 #define FILE_RANDOM_ACCESS              0x00000800
1134 #define FILE_DELETE_ON_CLOSE            0x00001000
1135 #define FILE_OPEN_BY_FILE_ID            0x00002000
1136 #define FILE_OPEN_FOR_BACKUP_INTENT     0x00004000
1137 #define FILE_NO_COMPRESSION             0x00008000
1138 #define FILE_RESERVE_OPFILTER           0x00100000
1139 #define FILE_TRANSACTED_MODE            0x00200000
1140 #define FILE_OPEN_OFFLINE_FILE          0x00400000
1141 #define FILE_OPEN_FOR_FREE_SPACE_QUERY  0x00800000
1142
1143 #define FILE_ATTRIBUTE_VALID_FLAGS      0x00007fb7
1144 #define FILE_ATTRIBUTE_VALID_SET_FLAGS  0x000031a7
1145
1146 /* status for NtCreateFile or NtOpenFile */
1147 #define FILE_SUPERSEDED                 0
1148 #define FILE_OPENED                     1
1149 #define FILE_CREATED                    2
1150 #define FILE_OVERWRITTEN                3
1151 #define FILE_EXISTS                     4
1152 #define FILE_DOES_NOT_EXIST             5
1153
1154 /* disposition for NtCreateFile */
1155 #define FILE_SUPERSEDE                  0
1156 #define FILE_OPEN                       1
1157 #define FILE_CREATE                     2
1158 #define FILE_OPEN_IF                    3
1159 #define FILE_OVERWRITE                  4
1160 #define FILE_OVERWRITE_IF               5
1161 #define FILE_MAXIMUM_DISPOSITION        5
1162
1163 /* Characteristics of a File System */
1164 #define FILE_REMOVABLE_MEDIA            0x00000001
1165 #define FILE_READ_ONLY_DEVICE           0x00000002
1166 #define FILE_FLOPPY_DISKETTE            0x00000004
1167 #define FILE_WRITE_ONE_MEDIA            0x00000008
1168 #define FILE_REMOTE_DEVICE              0x00000010
1169 #define FILE_DEVICE_IS_MOUNTED          0x00000020
1170 #define FILE_VIRTUAL_VOLUME             0x00000040
1171 #define FILE_AUTOGENERATED_DEVICE_NAME  0x00000080
1172 #define FILE_DEVICE_SECURE_OPEN         0x00000100
1173
1174 #if (_WIN32_WINNT >= 0x0501)
1175 #define INTERNAL_TS_ACTIVE_CONSOLE_ID ( *((volatile ULONG*)(0x7ffe02d8)) )
1176 #endif /* (_WIN32_WINNT >= 0x0501) */
1177
1178 #define LOGONID_CURRENT    ((ULONG)-1)
1179
1180 #define OBJ_INHERIT          0x00000002L
1181 #define OBJ_PERMANENT        0x00000010L
1182 #define OBJ_EXCLUSIVE        0x00000020L
1183 #define OBJ_CASE_INSENSITIVE 0x00000040L
1184 #define OBJ_OPENIF           0x00000080L
1185 #define OBJ_OPENLINK         0x00000100L
1186 #define OBJ_KERNEL_HANDLE    0x00000200L
1187 #define OBJ_VALID_ATTRIBUTES 0x000003F2L
1188
1189 #define SERVERNAME_CURRENT ((HANDLE)NULL)
1190
1191 typedef void (CALLBACK *PNTAPCFUNC)(ULONG_PTR,ULONG_PTR,ULONG_PTR); /* FIXME: not the right name */
1192 typedef void (CALLBACK *PRTL_THREAD_START_ROUTINE)(LPVOID); /* FIXME: not the right name */
1193
1194
1195 /* DbgPrintEx default levels */
1196 #define DPFLTR_ERROR_LEVEL     0
1197 #define DPFLTR_WARNING_LEVEL   1
1198 #define DPFLTR_TRACE_LEVEL     2
1199 #define DPFLTR_INFO_LEVEL      3
1200 #define DPFLTR_MASK    0x8000000
1201
1202 /***********************************************************************
1203  * Function declarations
1204  */
1205
1206 extern LPSTR _strlwr(LPSTR str); /* FIXME: Doesn't belong here */
1207 extern LPSTR _strupr(LPSTR str); /* FIXME: Doesn't belong here */
1208
1209 #if defined(__i386__) && defined(__GNUC__)
1210 static inline void WINAPI DbgBreakPoint(void) { __asm__ __volatile__("int3"); }
1211 static inline void WINAPI DbgUserBreakPoint(void) { __asm__ __volatile__("int3"); }
1212 #else  /* __i386__ && __GNUC__ */
1213 void WINAPI DbgBreakPoint(void);
1214 void WINAPI DbgUserBreakPoint(void);
1215 #endif  /* __i386__ && __GNUC__ */
1216 NTSTATUS WINAPIV DbgPrint(LPCSTR fmt, ...);
1217 NTSTATUS WINAPIV DbgPrintEx(ULONG iComponentId, ULONG Level, LPCSTR fmt, ...);
1218
1219 NTSTATUS  WINAPI LdrAccessResource(HMODULE,const IMAGE_RESOURCE_DATA_ENTRY*,void**,PULONG);
1220 NTSTATUS  WINAPI LdrFindResourceDirectory_U(HMODULE,const LDR_RESOURCE_INFO*,ULONG,const IMAGE_RESOURCE_DIRECTORY**);
1221 NTSTATUS  WINAPI LdrFindResource_U(HMODULE,const LDR_RESOURCE_INFO*,ULONG,const IMAGE_RESOURCE_DATA_ENTRY**);
1222 NTSTATUS  WINAPI LdrGetDllHandle(ULONG, ULONG, const UNICODE_STRING*, HMODULE*);
1223 NTSTATUS  WINAPI LdrGetProcedureAddress(HMODULE, const ANSI_STRING*, ULONG, void**);
1224 void      WINAPI LdrInitializeThunk(HANDLE,ULONG,ULONG,ULONG);
1225 NTSTATUS  WINAPI LdrLoadDll(LPCWSTR, DWORD, const UNICODE_STRING*, HMODULE*);
1226 void      WINAPI LdrShutdownProcess(void);
1227 void      WINAPI LdrShutdownThread(void);
1228 NTSTATUS  WINAPI NtAccessCheck(PSECURITY_DESCRIPTOR,HANDLE,ACCESS_MASK,PGENERIC_MAPPING,PPRIVILEGE_SET,PULONG,PULONG,PBOOLEAN);
1229 NTSTATUS  WINAPI NtAdjustGroupsToken(HANDLE,BOOLEAN,PTOKEN_GROUPS,ULONG,PTOKEN_GROUPS,PULONG);
1230 NTSTATUS  WINAPI NtAdjustPrivilegesToken(HANDLE,BOOLEAN,PTOKEN_PRIVILEGES,DWORD,PTOKEN_PRIVILEGES,PDWORD);
1231 NTSTATUS  WINAPI NtAlertThread(HANDLE ThreadHandle);
1232 NTSTATUS  WINAPI NtAllocateVirtualMemory(HANDLE,PVOID*,PVOID,ULONG*,ULONG,ULONG);
1233 NTSTATUS  WINAPI NtCancelIoFile(HANDLE,PIO_STATUS_BLOCK);
1234 NTSTATUS  WINAPI NtCancelTimer(HANDLE, BOOLEAN*);
1235 NTSTATUS  WINAPI NtClearEvent(HANDLE);
1236 NTSTATUS  WINAPI NtClose(HANDLE);
1237 NTSTATUS  WINAPI NtCreateEvent(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *,BOOLEAN,BOOLEAN);
1238 NTSTATUS  WINAPI NtCreateFile(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,PIO_STATUS_BLOCK,PLARGE_INTEGER,ULONG,ULONG,ULONG,ULONG,PVOID,ULONG);
1239 NTSTATUS  WINAPI NtCreateIoCompletion(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,ULONG);
1240 NTSTATUS  WINAPI NtCreateKey(PHKEY,ACCESS_MASK,const OBJECT_ATTRIBUTES*,ULONG,const UNICODE_STRING*,ULONG,PULONG);
1241 NTSTATUS  WINAPI NtCreateNamedPipeFile(PHANDLE,ULONG,POBJECT_ATTRIBUTES,PIO_STATUS_BLOCK,ULONG,ULONG,ULONG,ULONG,ULONG,ULONG,ULONG,ULONG,ULONG,PLARGE_INTEGER);
1242 NTSTATUS  WINAPI NtCreateSection(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*,const LARGE_INTEGER*,ULONG,ULONG,HANDLE);
1243 NTSTATUS  WINAPI NtCreateSemaphore(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*,ULONG,ULONG);
1244 NTSTATUS  WINAPI NtCreateTimer(HANDLE*, ACCESS_MASK, const OBJECT_ATTRIBUTES*, TIMER_TYPE);
1245 NTSTATUS  WINAPI NtDelayExecution(BOOLEAN,const LARGE_INTEGER*);
1246 NTSTATUS  WINAPI NtDeleteFile(POBJECT_ATTRIBUTES);
1247 NTSTATUS  WINAPI NtDeleteKey(HKEY);
1248 NTSTATUS  WINAPI NtDeleteValueKey(HKEY,const UNICODE_STRING *);
1249 NTSTATUS  WINAPI NtDeviceIoControlFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,ULONG,PVOID,ULONG,PVOID,ULONG);
1250 NTSTATUS  WINAPI NtDuplicateObject(HANDLE,HANDLE,HANDLE,PHANDLE,ACCESS_MASK,ULONG,ULONG);
1251 NTSTATUS  WINAPI NtEnumerateKey(HKEY,ULONG,KEY_INFORMATION_CLASS,void *,DWORD,DWORD *);
1252 NTSTATUS  WINAPI NtEnumerateValueKey(HKEY,ULONG,KEY_VALUE_INFORMATION_CLASS,PVOID,ULONG,PULONG);
1253 NTSTATUS  WINAPI NtFlushBuffersFile(HANDLE,IO_STATUS_BLOCK*);
1254 NTSTATUS  WINAPI NtFlushInstructionCache(HANDLE,LPCVOID,ULONG);
1255 NTSTATUS  WINAPI NtFlushKey(HKEY);
1256 NTSTATUS  WINAPI NtFlushVirtualMemory(HANDLE,LPCVOID*,ULONG*,ULONG);
1257 NTSTATUS  WINAPI NtFreeVirtualMemory(HANDLE,PVOID*,ULONG*,ULONG);
1258 NTSTATUS  WINAPI NtGetContextThread(HANDLE,CONTEXT*);
1259 NTSTATUS  WINAPI NtImpersonateAnonymousToken(HANDLE);
1260 NTSTATUS  WINAPI NtImpersonateClientOfPort(HANDLE,PPORT_MESSAGE);
1261 NTSTATUS  WINAPI NtImpersonateThread(HANDLE,HANDLE,PSECURITY_QUALITY_OF_SERVICE);
1262 NTSTATUS  WINAPI NtLoadKey(const OBJECT_ATTRIBUTES *,const OBJECT_ATTRIBUTES *);
1263 NTSTATUS  WINAPI NtLockFile(HANDLE,HANDLE,PIO_APC_ROUTINE,void*,PIO_STATUS_BLOCK,PLARGE_INTEGER,PLARGE_INTEGER,ULONG*,BOOLEAN,BOOLEAN);
1264 NTSTATUS  WINAPI NtLockVirtualMemory(HANDLE,PVOID*,ULONG*,ULONG);
1265 NTSTATUS  WINAPI NtMapViewOfSection(HANDLE,HANDLE,PVOID*,ULONG,ULONG,const LARGE_INTEGER*,ULONG*,SECTION_INHERIT,ULONG,ULONG);
1266 NTSTATUS  WINAPI NtNotifyChangeKey(HKEY,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,ULONG,BOOLEAN,PVOID,ULONG,BOOLEAN);
1267 NTSTATUS  WINAPI NtOpenEvent(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *);
1268 NTSTATUS  WINAPI NtOpenFile(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,PIO_STATUS_BLOCK,ULONG,ULONG);
1269 NTSTATUS  WINAPI NtOpenIoCompletion(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES);
1270 NTSTATUS  WINAPI NtOpenKey(PHKEY,ACCESS_MASK,const OBJECT_ATTRIBUTES *);
1271 NTSTATUS  WINAPI NtOpenProcessToken(HANDLE,DWORD,HANDLE *);
1272 NTSTATUS  WINAPI NtOpenSection(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*);
1273 NTSTATUS  WINAPI NtOpenThread(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*,const CLIENT_ID*);
1274 NTSTATUS  WINAPI NtOpenThreadToken(HANDLE,DWORD,BOOLEAN,HANDLE *);
1275 NTSTATUS  WINAPI NtOpenTimer(HANDLE*, ACCESS_MASK, const OBJECT_ATTRIBUTES*);
1276 NTSTATUS  WINAPI NtProtectVirtualMemory(HANDLE,PVOID*,ULONG*,ULONG,ULONG*);
1277 NTSTATUS  WINAPI NtPulseEvent(HANDLE,PULONG);
1278 NTSTATUS  WINAPI NtQueueApcThread(HANDLE,PNTAPCFUNC,ULONG_PTR,ULONG_PTR,ULONG_PTR);
1279 NTSTATUS  WINAPI NtQueryAttributesFile(const OBJECT_ATTRIBUTES*,FILE_BASIC_INFORMATION*);
1280 NTSTATUS  WINAPI NtQueryDefaultLocale(BOOLEAN,LCID*);
1281 NTSTATUS  WINAPI NtQueryDefaultUILanguage(LANGID*);
1282 NTSTATUS  WINAPI NtQueryDirectoryFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,PVOID,ULONG,FILE_INFORMATION_CLASS,BOOLEAN,PUNICODE_STRING,BOOLEAN);
1283 NTSTATUS  WINAPI NtQueryEaFile(HANDLE,PIO_STATUS_BLOCK,PVOID,ULONG,BOOLEAN,PVOID,ULONG,PVOID,BOOLEAN);
1284 NTSTATUS  WINAPI NtQueryFullAttributesFile(const OBJECT_ATTRIBUTES*,FILE_NETWORK_OPEN_INFORMATION*);
1285 NTSTATUS  WINAPI NtQueryInformationFile(HANDLE,PIO_STATUS_BLOCK,PVOID,LONG,FILE_INFORMATION_CLASS);
1286 NTSTATUS  WINAPI NtQueryInformationProcess(HANDLE,PROCESSINFOCLASS,PVOID,ULONG,PULONG);
1287 NTSTATUS  WINAPI NtQueryInformationThread(HANDLE,THREADINFOCLASS,PVOID,ULONG,PULONG);
1288 NTSTATUS  WINAPI NtQueryInformationToken(HANDLE,DWORD,LPVOID,DWORD,LPDWORD);
1289 NTSTATUS  WINAPI NtQueryInstallUILanguage(LANGID*);
1290 NTSTATUS  WINAPI NtQueryKey(HKEY,KEY_INFORMATION_CLASS,void *,DWORD,DWORD *);
1291 NTSTATUS  WINAPI NtQueryMultipleValueKey(HKEY,PVALENTW,ULONG,PVOID,ULONG,PULONG);
1292 NTSTATUS  WINAPI NtQueryObject(HANDLE, OBJECT_INFORMATION_CLASS, PVOID, ULONG, PULONG);
1293 NTSTATUS  WINAPI NtQuerySecurityObject(HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR,ULONG,PULONG);
1294 NTSTATUS  WINAPI NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS,PVOID,ULONG,PULONG);
1295 NTSTATUS  WINAPI NtQuerySystemTime(PLARGE_INTEGER);
1296 NTSTATUS  WINAPI NtQueryValueKey(HKEY,const UNICODE_STRING *,KEY_VALUE_INFORMATION_CLASS,void *,DWORD,DWORD *);
1297 NTSTATUS  WINAPI NtQueryVirtualMemory(HANDLE,LPCVOID,MEMORY_INFORMATION_CLASS,PVOID,ULONG,ULONG*);
1298 NTSTATUS  WINAPI NtQueryVolumeInformationFile(HANDLE,PIO_STATUS_BLOCK,PVOID,ULONG,FS_INFORMATION_CLASS);
1299 void      WINAPI NtRaiseException(PEXCEPTION_RECORD,PCONTEXT,BOOL);
1300 NTSTATUS  WINAPI NtReadFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,PVOID,ULONG,PLARGE_INTEGER,PULONG);
1301 NTSTATUS  WINAPI NtReadVirtualMemory(HANDLE,const void*,void*,SIZE_T,SIZE_T*);
1302 NTSTATUS  WINAPI NtReleaseSemaphore(HANDLE,ULONG,PULONG);
1303 NTSTATUS  WINAPI NtRemoveIoCompletion(HANDLE,PULONG,PULONG,PIO_STATUS_BLOCK,PLARGE_INTEGER);
1304 NTSTATUS  WINAPI NtReplaceKey(POBJECT_ATTRIBUTES,HKEY,POBJECT_ATTRIBUTES);
1305 NTSTATUS  WINAPI NtResetEvent(HANDLE,PULONG);
1306 NTSTATUS  WINAPI NtRestoreKey(HKEY,HANDLE,ULONG);
1307 NTSTATUS  WINAPI NtResumeThread(HANDLE,PULONG);
1308 NTSTATUS  WINAPI NtSaveKey(HKEY,HANDLE);
1309 NTSTATUS  WINAPI NtSetContextThread(HANDLE,const CONTEXT*);
1310 NTSTATUS  WINAPI NtSetDefaultLocale(BOOLEAN,LCID);
1311 NTSTATUS  WINAPI NtSetDefaultUILanguage(LANGID);
1312 NTSTATUS  WINAPI NtSetEaFile(HANDLE,PIO_STATUS_BLOCK,PVOID,ULONG);
1313 NTSTATUS  WINAPI NtSetEvent(HANDLE,PULONG);
1314 NTSTATUS  WINAPI NtSetInformationFile(HANDLE,PIO_STATUS_BLOCK,PVOID,ULONG,FILE_INFORMATION_CLASS);
1315 NTSTATUS  WINAPI NtSetInformationKey(HKEY,const int,PVOID,ULONG);
1316 NTSTATUS  WINAPI NtSetInformationObject(HANDLE, OBJECT_INFORMATION_CLASS, PVOID, ULONG);
1317 NTSTATUS  WINAPI NtSetInformationThread(HANDLE,THREADINFOCLASS,LPCVOID,ULONG);
1318 NTSTATUS  WINAPI NtSetInformationToken(HANDLE,TOKEN_INFORMATION_CLASS,PVOID,ULONG);
1319 NTSTATUS  WINAPI NtSetIoCompletion(HANDLE,ULONG,ULONG,NTSTATUS,ULONG);
1320 NTSTATUS  WINAPI NtSetSecurityObject(HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR);
1321 NTSTATUS  WINAPI NtSetSystemTime(const LARGE_INTEGER*,LARGE_INTEGER*);
1322 NTSTATUS  WINAPI NtSetTimer(HANDLE, const LARGE_INTEGER*, PTIMERAPCROUTINE, PVOID, BOOLEAN, ULONG, BOOLEAN*);
1323 NTSTATUS  WINAPI NtSetValueKey(HKEY,const UNICODE_STRING *,ULONG,ULONG,const void *,ULONG);
1324 NTSTATUS  WINAPI NtSuspendThread(HANDLE,PULONG);
1325 NTSTATUS  WINAPI NtTerminateProcess(HANDLE,LONG);
1326 NTSTATUS  WINAPI NtTerminateThread(HANDLE,LONG);
1327 NTSTATUS  WINAPI NtUnloadKey(HKEY);
1328 NTSTATUS  WINAPI NtUnlockFile(HANDLE,PIO_STATUS_BLOCK,PLARGE_INTEGER,PLARGE_INTEGER,PULONG);
1329 NTSTATUS  WINAPI NtUnlockVirtualMemory(HANDLE,PVOID*,ULONG*,ULONG);
1330 NTSTATUS  WINAPI NtUnmapViewOfSection(HANDLE,PVOID);
1331 NTSTATUS  WINAPI NtWaitForSingleObject(HANDLE,BOOLEAN,const LARGE_INTEGER*);
1332 NTSTATUS  WINAPI NtWaitForMultipleObjects(ULONG,const HANDLE*,BOOLEAN,BOOLEAN,const LARGE_INTEGER*);
1333 NTSTATUS  WINAPI NtWriteFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,const void*,ULONG,PLARGE_INTEGER,PULONG);
1334 NTSTATUS  WINAPI NtWriteVirtualMemory(HANDLE,void*,const void*,SIZE_T,SIZE_T*);
1335
1336 void      WINAPI RtlAcquirePebLock(void);
1337 BYTE      WINAPI RtlAcquireResourceExclusive(LPRTL_RWLOCK,BYTE);
1338 BYTE      WINAPI RtlAcquireResourceShared(LPRTL_RWLOCK,BYTE);
1339 NTSTATUS  WINAPI RtlAddAce(PACL,DWORD,DWORD,PACE_HEADER,DWORD);
1340 NTSTATUS  WINAPI RtlAddAccessAllowedAce(PACL,DWORD,DWORD,PSID);
1341 NTSTATUS  WINAPI RtlAddAccessAllowedAceEx(PACL,DWORD,DWORD,DWORD,PSID);
1342 NTSTATUS  WINAPI RtlAddAccessDeniedAce(PACL,DWORD,DWORD,PSID);
1343 NTSTATUS  WINAPI RtlAddAccessDeniedAceEx(PACL,DWORD,DWORD,DWORD,PSID);
1344 PVOID     WINAPI RtlAddVectoredExceptionHandler(ULONG,PVECTORED_EXCEPTION_HANDLER);
1345 DWORD     WINAPI RtlAdjustPrivilege(DWORD,DWORD,DWORD,DWORD);
1346 BOOLEAN   WINAPI RtlAllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY,BYTE,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,PSID *);
1347 PVOID     WINAPI RtlAllocateHeap(HANDLE,ULONG,ULONG);
1348 DWORD     WINAPI RtlAnsiStringToUnicodeSize(const STRING *);
1349 NTSTATUS  WINAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING,PCANSI_STRING,BOOLEAN);
1350 NTSTATUS  WINAPI RtlAppendAsciizToString(STRING *,LPCSTR);
1351 NTSTATUS  WINAPI RtlAppendStringToString(STRING *,const STRING *);
1352 NTSTATUS  WINAPI RtlAppendUnicodeStringToString(UNICODE_STRING *,const UNICODE_STRING *);
1353 NTSTATUS  WINAPI RtlAppendUnicodeToString(UNICODE_STRING *,LPCWSTR);
1354 BOOLEAN   WINAPI RtlAreAllAccessesGranted(ACCESS_MASK,ACCESS_MASK);
1355 BOOLEAN   WINAPI RtlAreAnyAccessesGranted(ACCESS_MASK,ACCESS_MASK);
1356 BOOLEAN   WINAPI RtlAreBitsSet(PCRTL_BITMAP,ULONG,ULONG);
1357 BOOLEAN   WINAPI RtlAreBitsClear(PCRTL_BITMAP,ULONG,ULONG);
1358
1359 NTSTATUS  WINAPI RtlCharToInteger(PCSZ,ULONG,PULONG);
1360 void      WINAPI RtlClearAllBits(PRTL_BITMAP);
1361 void      WINAPI RtlClearBits(PRTL_BITMAP,ULONG,ULONG);
1362 ULONG     WINAPI RtlCompactHeap(HANDLE,ULONG);
1363 LONG      WINAPI RtlCompareString(const STRING*,const STRING*,BOOLEAN);
1364 LONG      WINAPI RtlCompareUnicodeString(const UNICODE_STRING*,const UNICODE_STRING*,BOOLEAN);
1365 DWORD     WINAPI RtlComputeCrc32(DWORD,PBYTE,INT);
1366 NTSTATUS  WINAPI RtlConvertSidToUnicodeString(PUNICODE_STRING,PSID,BOOLEAN);
1367 LONGLONG  WINAPI RtlConvertLongToLargeInteger(LONG);
1368 ULONGLONG WINAPI RtlConvertUlongToLargeInteger(ULONG);
1369 void      WINAPI RtlCopyLuid(PLUID,const LUID*);
1370 void      WINAPI RtlCopyLuidAndAttributesArray(ULONG,const LUID_AND_ATTRIBUTES*,PLUID_AND_ATTRIBUTES);
1371 DWORD     WINAPI RtlCopySid(DWORD,PSID,PSID);
1372 void      WINAPI RtlCopyString(STRING*,const STRING*);
1373 void      WINAPI RtlCopyUnicodeString(UNICODE_STRING*,const UNICODE_STRING*);
1374 NTSTATUS  WINAPI RtlCreateAcl(PACL,DWORD,DWORD);
1375 NTSTATUS  WINAPI RtlCreateEnvironment(BOOLEAN, PWSTR*);
1376 HANDLE    WINAPI RtlCreateHeap(ULONG,PVOID,ULONG,ULONG,PVOID,PRTL_HEAP_DEFINITION);
1377 NTSTATUS  WINAPI RtlCreateProcessParameters(RTL_USER_PROCESS_PARAMETERS**,const UNICODE_STRING*,
1378                                             const UNICODE_STRING*,const UNICODE_STRING*,
1379                                             const UNICODE_STRING*,PWSTR,const UNICODE_STRING*,
1380                                             const UNICODE_STRING*,const UNICODE_STRING*,
1381                                             const UNICODE_STRING*);
1382 NTSTATUS  WINAPI RtlCreateSecurityDescriptor(PSECURITY_DESCRIPTOR,DWORD);
1383 BOOLEAN   WINAPI RtlCreateUnicodeString(PUNICODE_STRING,LPCWSTR);
1384 BOOLEAN   WINAPI RtlCreateUnicodeStringFromAsciiz(PUNICODE_STRING,LPCSTR);
1385 NTSTATUS  WINAPI RtlCreateUserThread(HANDLE,const SECURITY_DESCRIPTOR*,BOOLEAN,PVOID,SIZE_T,SIZE_T,PRTL_THREAD_START_ROUTINE,void*,HANDLE*,CLIENT_ID*);
1386
1387 NTSTATUS  WINAPI RtlDeleteAce(PACL,DWORD);
1388 NTSTATUS  WINAPI RtlDeleteCriticalSection(RTL_CRITICAL_SECTION *);
1389 void      WINAPI RtlDeleteResource(LPRTL_RWLOCK);
1390 DWORD     WINAPI RtlDeleteSecurityObject(DWORD);
1391 PRTL_USER_PROCESS_PARAMETERS WINAPI RtlDeNormalizeProcessParams(RTL_USER_PROCESS_PARAMETERS*);
1392 NTSTATUS  WINAPI RtlDestroyEnvironment(PWSTR);
1393 HANDLE    WINAPI RtlDestroyHeap(HANDLE);
1394 void      WINAPI RtlDestroyProcessParameters(RTL_USER_PROCESS_PARAMETERS*);
1395 DOS_PATHNAME_TYPE WINAPI RtlDetermineDosPathNameType_U(PCWSTR);
1396 BOOLEAN   WINAPI RtlDoesFileExists_U(LPCWSTR);
1397 BOOLEAN   WINAPI RtlDosPathNameToNtPathName_U(PCWSTR,PUNICODE_STRING,PWSTR*,CURDIR*);
1398 ULONG     WINAPI RtlDosSearchPath_U(LPCWSTR, LPCWSTR, LPCWSTR, ULONG, LPWSTR, LPWSTR*);
1399 WCHAR     WINAPI RtlDowncaseUnicodeChar(WCHAR);
1400 NTSTATUS  WINAPI RtlDowncaseUnicodeString(UNICODE_STRING*,const UNICODE_STRING*,BOOLEAN);
1401 void      WINAPI RtlDumpResource(LPRTL_RWLOCK);
1402 NTSTATUS  WINAPI RtlDuplicateUnicodeString(int,const UNICODE_STRING*,UNICODE_STRING*);
1403
1404 LONGLONG  WINAPI RtlEnlargedIntegerMultiply(INT,INT);
1405 ULONGLONG WINAPI RtlEnlargedUnsignedMultiply(UINT,UINT);
1406 UINT      WINAPI RtlEnlargedUnsignedDivide(ULONGLONG,UINT,UINT *);
1407 NTSTATUS  WINAPI RtlEnterCriticalSection(RTL_CRITICAL_SECTION *);
1408 void      WINAPI RtlEraseUnicodeString(UNICODE_STRING*);
1409 NTSTATUS  WINAPI RtlEqualComputerName(const UNICODE_STRING*,const UNICODE_STRING*);
1410 NTSTATUS  WINAPI RtlEqualDomainName(const UNICODE_STRING*,const UNICODE_STRING*);
1411 BOOLEAN   WINAPI RtlEqualLuid(const LUID*,const LUID*);
1412 BOOL      WINAPI RtlEqualPrefixSid(PSID,PSID);
1413 BOOL      WINAPI RtlEqualSid(PSID,PSID);
1414 BOOLEAN   WINAPI RtlEqualString(const STRING*,const STRING*,BOOLEAN);
1415 BOOLEAN   WINAPI RtlEqualUnicodeString(const UNICODE_STRING*,const UNICODE_STRING*,BOOLEAN);
1416 NTSTATUS  WINAPI RtlExpandEnvironmentStrings_U(PWSTR, const UNICODE_STRING*, UNICODE_STRING*, ULONG*);
1417 LONGLONG  WINAPI RtlExtendedMagicDivide(LONGLONG,LONGLONG,INT);
1418 LONGLONG  WINAPI RtlExtendedIntegerMultiply(LONGLONG,INT);
1419 LONGLONG  WINAPI RtlExtendedLargeIntegerDivide(LONGLONG,INT,INT *);
1420
1421 NTSTATUS  WINAPI RtlFindCharInUnicodeString(int,const UNICODE_STRING*,const UNICODE_STRING*,USHORT*);
1422 ULONG     WINAPI RtlFindClearBits(PCRTL_BITMAP,ULONG,ULONG);
1423 ULONG     WINAPI RtlFindClearBitsAndSet(PRTL_BITMAP,ULONG,ULONG);
1424 ULONG     WINAPI RtlFindClearRuns(PCRTL_BITMAP,PRTL_BITMAP_RUN,ULONG,BOOLEAN);
1425 ULONG     WINAPI RtlFindLastBackwardRunSet(PCRTL_BITMAP,ULONG,PULONG);
1426 ULONG     WINAPI RtlFindLastBackwardRunClear(PCRTL_BITMAP,ULONG,PULONG);
1427 CCHAR     WINAPI RtlFindLeastSignificantBit(ULONGLONG);
1428 ULONG     WINAPI RtlFindLongestRunSet(PCRTL_BITMAP,PULONG);
1429 ULONG     WINAPI RtlFindLongestRunClear(PCRTL_BITMAP,PULONG);
1430 NTSTATUS  WINAPI RtlFindMessage(HMODULE,ULONG,ULONG,ULONG,const MESSAGE_RESOURCE_ENTRY**);
1431 CCHAR     WINAPI RtlFindMostSignificantBit(ULONGLONG);
1432 ULONG     WINAPI RtlFindNextForwardRunSet(PCRTL_BITMAP,ULONG,PULONG);
1433 ULONG     WINAPI RtlFindNextForwardRunClear(PCRTL_BITMAP,ULONG,PULONG);
1434 ULONG     WINAPI RtlFindSetBits(PCRTL_BITMAP,ULONG,ULONG);
1435 ULONG     WINAPI RtlFindSetBitsAndClear(PRTL_BITMAP,ULONG,ULONG);
1436 ULONG     WINAPI RtlFindSetRuns(PCRTL_BITMAP,PRTL_BITMAP_RUN,ULONG,BOOLEAN);
1437 BOOLEAN   WINAPI RtlFirstFreeAce(PACL,PACE_HEADER *);
1438 NTSTATUS  WINAPI RtlFormatCurrentUserKeyPath(PUNICODE_STRING);
1439 NTSTATUS  WINAPI RtlFormatMessage(LPWSTR,UCHAR,BOOLEAN,BOOLEAN,BOOLEAN,va_list *,LPWSTR,ULONG);
1440 void      WINAPI RtlFreeAnsiString(PANSI_STRING);
1441 BOOLEAN   WINAPI RtlFreeHeap(HANDLE,ULONG,PVOID);
1442 void      WINAPI RtlFreeOemString(POEM_STRING);
1443 DWORD     WINAPI RtlFreeSid(PSID);
1444 void      WINAPI RtlFreeUnicodeString(PUNICODE_STRING);
1445
1446 DWORD     WINAPI RtlGetAce(PACL,DWORD,LPVOID *);
1447 NTSTATUS  WINAPI RtlGetControlSecurityDescriptor(PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR_CONTROL,LPDWORD);
1448 NTSTATUS  WINAPI RtlGetCurrentDirectory_U(ULONG, LPWSTR);
1449 NTSTATUS  WINAPI RtlGetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR,PBOOLEAN,PACL *,PBOOLEAN);
1450 ULONG     WINAPI RtlGetFullPathName_U(PCWSTR,ULONG,PWSTR,PWSTR*);
1451 NTSTATUS  WINAPI RtlGetGroupSecurityDescriptor(PSECURITY_DESCRIPTOR,PSID *,PBOOLEAN);
1452 DWORD     WINAPI RtlGetLastWin32Error(void);
1453 DWORD     WINAPI RtlGetLongestNtPathLength(void);
1454 BOOLEAN   WINAPI RtlGetNtProductType(LPDWORD);
1455 NTSTATUS  WINAPI RtlGetOwnerSecurityDescriptor(PSECURITY_DESCRIPTOR,PSID *,PBOOLEAN);
1456 ULONG     WINAPI RtlGetProcessHeaps(ULONG,HANDLE*);
1457 NTSTATUS  WINAPI RtlGetSaclSecurityDescriptor(PSECURITY_DESCRIPTOR,PBOOLEAN,PACL *,PBOOLEAN);
1458 NTSTATUS  WINAPI RtlGetVersion(RTL_OSVERSIONINFOEXW*);
1459
1460 PSID_IDENTIFIER_AUTHORITY WINAPI RtlIdentifierAuthoritySid(PSID);
1461 PVOID     WINAPI RtlImageDirectoryEntryToData(HMODULE,BOOL,WORD,ULONG *);
1462 PIMAGE_NT_HEADERS WINAPI RtlImageNtHeader(HMODULE);
1463 PIMAGE_SECTION_HEADER WINAPI RtlImageRvaToSection(const IMAGE_NT_HEADERS *,HMODULE,DWORD);
1464 PVOID     WINAPI RtlImageRvaToVa(const IMAGE_NT_HEADERS *,HMODULE,DWORD,IMAGE_SECTION_HEADER **);
1465 BOOL      WINAPI RtlImpersonateSelf(SECURITY_IMPERSONATION_LEVEL);
1466 void      WINAPI RtlInitString(PSTRING,PCSZ);
1467 void      WINAPI RtlInitAnsiString(PANSI_STRING,PCSZ);
1468 void      WINAPI RtlInitUnicodeString(PUNICODE_STRING,PCWSTR);
1469 NTSTATUS  WINAPI RtlInitUnicodeStringEx(PUNICODE_STRING,PCWSTR);
1470 NTSTATUS  WINAPI RtlInitializeCriticalSection(RTL_CRITICAL_SECTION *);
1471 NTSTATUS  WINAPI RtlInitializeCriticalSectionAndSpinCount(RTL_CRITICAL_SECTION *,DWORD);
1472 void      WINAPI RtlInitializeBitMap(PRTL_BITMAP,PULONG,ULONG);
1473 void      WINAPI RtlInitializeResource(LPRTL_RWLOCK);
1474 BOOL      WINAPI RtlInitializeSid(PSID,PSID_IDENTIFIER_AUTHORITY,BYTE);
1475
1476 NTSTATUS  WINAPI RtlInt64ToUnicodeString(ULONGLONG,ULONG,UNICODE_STRING *);
1477 NTSTATUS  WINAPI RtlIntegerToChar(ULONG,ULONG,ULONG,PCHAR);
1478 NTSTATUS  WINAPI RtlIntegerToUnicodeString(ULONG,ULONG,UNICODE_STRING *);
1479 ULONG     WINAPI RtlIsDosDeviceName_U(PCWSTR);
1480 BOOLEAN   WINAPI RtlIsNameLegalDOS8Dot3(const UNICODE_STRING*,POEM_STRING,PBOOLEAN);
1481 DWORD     WINAPI RtlIsTextUnicode(LPVOID,DWORD,DWORD *);
1482
1483 LONGLONG  WINAPI RtlLargeIntegerAdd(LONGLONG,LONGLONG);
1484 LONGLONG  WINAPI RtlLargeIntegerArithmeticShift(LONGLONG,INT);
1485 ULONGLONG WINAPI RtlLargeIntegerDivide( ULONGLONG,ULONGLONG,ULONGLONG *);
1486 LONGLONG  WINAPI RtlLargeIntegerNegate(LONGLONG);
1487 LONGLONG  WINAPI RtlLargeIntegerShiftLeft(LONGLONG,INT);
1488 LONGLONG  WINAPI RtlLargeIntegerShiftRight(LONGLONG,INT);
1489 LONGLONG  WINAPI RtlLargeIntegerSubtract(LONGLONG,LONGLONG);
1490 NTSTATUS  WINAPI RtlLargeIntegerToChar(const ULONGLONG *,ULONG,ULONG,PCHAR);
1491 NTSTATUS  WINAPI RtlLeaveCriticalSection(RTL_CRITICAL_SECTION *);
1492 DWORD     WINAPI RtlLengthRequiredSid(DWORD);
1493 ULONG     WINAPI RtlLengthSecurityDescriptor(PSECURITY_DESCRIPTOR);
1494 DWORD     WINAPI RtlLengthSid(PSID);
1495 NTSTATUS  WINAPI RtlLocalTimeToSystemTime(const LARGE_INTEGER*,PLARGE_INTEGER);
1496 BOOLEAN   WINAPI RtlLockHeap(HANDLE);
1497
1498 NTSTATUS  WINAPI RtlMakeSelfRelativeSD(PSECURITY_DESCRIPTOR,PSECURITY_DESCRIPTOR,LPDWORD);
1499 void      WINAPI RtlMapGenericMask(PACCESS_MASK,const GENERIC_MAPPING*);
1500 NTSTATUS  WINAPI RtlMultiByteToUnicodeN(LPWSTR,DWORD,LPDWORD,LPCSTR,DWORD);
1501 NTSTATUS  WINAPI RtlMultiByteToUnicodeSize(DWORD*,LPCSTR,UINT);
1502
1503 DWORD     WINAPI RtlNewSecurityObject(DWORD,DWORD,DWORD,DWORD,DWORD,DWORD);
1504 PRTL_USER_PROCESS_PARAMETERS WINAPI RtlNormalizeProcessParams(RTL_USER_PROCESS_PARAMETERS*);
1505 ULONG     WINAPI RtlNtStatusToDosError(NTSTATUS);
1506 ULONG     WINAPI RtlNtStatusToDosErrorNoTeb(NTSTATUS);
1507 ULONG     WINAPI RtlNumberOfSetBits(PCRTL_BITMAP);
1508 ULONG     WINAPI RtlNumberOfClearBits(PCRTL_BITMAP);
1509
1510 UINT      WINAPI RtlOemStringToUnicodeSize(const STRING*);
1511 NTSTATUS  WINAPI RtlOemStringToUnicodeString(UNICODE_STRING*,const STRING*,BOOLEAN);
1512 NTSTATUS  WINAPI RtlOemToUnicodeN(LPWSTR,DWORD,LPDWORD,LPCSTR,DWORD);
1513 DWORD     WINAPI RtlOpenCurrentUser(ACCESS_MASK,PHKEY);
1514
1515 BOOLEAN   WINAPI RtlPrefixString(const STRING*,const STRING*,BOOLEAN);
1516 BOOLEAN   WINAPI RtlPrefixUnicodeString(const UNICODE_STRING*,const UNICODE_STRING*,BOOLEAN);
1517
1518 NTSTATUS  WINAPI RtlQueryEnvironmentVariable_U(PWSTR,PUNICODE_STRING,PUNICODE_STRING);
1519 NTSTATUS  WINAPI RtlQueryInformationAcl(PACL,LPVOID,DWORD,ACL_INFORMATION_CLASS);
1520 NTSTATUS  WINAPI RtlQueryTimeZoneInformation(LPTIME_ZONE_INFORMATION);
1521
1522 void      WINAPI RtlRaiseException(PEXCEPTION_RECORD);
1523 void      WINAPI RtlRaiseStatus(NTSTATUS);
1524 ULONG     WINAPI RtlRandom(PULONG);
1525 PVOID     WINAPI RtlReAllocateHeap(HANDLE,ULONG,PVOID,ULONG);
1526 void      WINAPI RtlReleasePebLock(void);
1527 void      WINAPI RtlReleaseResource(LPRTL_RWLOCK);
1528 ULONG     WINAPI RtlRemoveVectoredExceptionHandler(PVOID);
1529 void      WINAPI RtlRestoreLastWin32Error(DWORD);
1530
1531 void      WINAPI RtlSecondsSince1970ToTime(DWORD,LARGE_INTEGER *);
1532 void      WINAPI RtlSecondsSince1980ToTime(DWORD,LARGE_INTEGER *);
1533 NTSTATUS  WINAPI RtlSelfRelativeToAbsoluteSD(PSECURITY_DESCRIPTOR,PSECURITY_DESCRIPTOR,
1534                                              PDWORD,PACL,PDWORD,PACL,PDWORD,PSID,PDWORD,PSID,PDWORD);
1535 void      WINAPI RtlSetAllBits(PRTL_BITMAP);
1536 void      WINAPI RtlSetBits(PRTL_BITMAP,ULONG,ULONG);
1537 ULONG     WINAPI RtlSetCriticalSectionSpinCount(RTL_CRITICAL_SECTION*,ULONG);
1538 NTSTATUS  WINAPI RtlSetCurrentDirectory_U(const UNICODE_STRING*);
1539 void      WINAPI RtlSetCurrentEnvironment(PWSTR, PWSTR*);
1540 NTSTATUS  WINAPI RtlSetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR,BOOLEAN,PACL,BOOLEAN);
1541 NTSTATUS  WINAPI RtlSetEnvironmentVariable(PWSTR*,PUNICODE_STRING,PUNICODE_STRING);
1542 NTSTATUS  WINAPI RtlSetOwnerSecurityDescriptor(PSECURITY_DESCRIPTOR,PSID,BOOLEAN);
1543 NTSTATUS  WINAPI RtlSetGroupSecurityDescriptor(PSECURITY_DESCRIPTOR,PSID,BOOLEAN);
1544 void      WINAPI RtlSetLastWin32Error(DWORD);
1545 NTSTATUS  WINAPI RtlSetSaclSecurityDescriptor(PSECURITY_DESCRIPTOR,BOOLEAN,PACL,BOOLEAN);
1546 NTSTATUS  WINAPI RtlSetTimeZoneInformation(const TIME_ZONE_INFORMATION*);
1547 ULONG     WINAPI RtlSizeHeap(HANDLE,ULONG,PVOID);
1548 LPDWORD   WINAPI RtlSubAuthoritySid(PSID,DWORD);
1549 LPBYTE    WINAPI RtlSubAuthorityCountSid(PSID);
1550 NTSTATUS  WINAPI RtlSystemTimeToLocalTime(const LARGE_INTEGER*,PLARGE_INTEGER);
1551
1552 void      WINAPI RtlTimeToTimeFields(const LARGE_INTEGER*,PTIME_FIELDS);
1553 BOOLEAN   WINAPI RtlTimeFieldsToTime(PTIME_FIELDS,PLARGE_INTEGER);
1554 void      WINAPI RtlTimeToElapsedTimeFields(const LARGE_INTEGER *,PTIME_FIELDS);
1555 BOOLEAN   WINAPI RtlTimeToSecondsSince1970(const LARGE_INTEGER *,LPDWORD);
1556 BOOLEAN   WINAPI RtlTimeToSecondsSince1980(const LARGE_INTEGER *,LPDWORD);
1557 BOOL      WINAPI RtlTryEnterCriticalSection(RTL_CRITICAL_SECTION *);
1558
1559 ULONGLONG __cdecl RtlUlonglongByteSwap(ULONGLONG);
1560 DWORD     WINAPI RtlUnicodeStringToAnsiSize(const UNICODE_STRING*);
1561 NTSTATUS  WINAPI RtlUnicodeStringToAnsiString(PANSI_STRING,PCUNICODE_STRING,BOOLEAN);
1562 NTSTATUS  WINAPI RtlUnicodeStringToInteger(const UNICODE_STRING *,ULONG,ULONG *);
1563 DWORD     WINAPI RtlUnicodeStringToOemSize(const UNICODE_STRING*);
1564 NTSTATUS  WINAPI RtlUnicodeStringToOemString(POEM_STRING,PCUNICODE_STRING,BOOLEAN);
1565 NTSTATUS  WINAPI RtlUnicodeToMultiByteN(LPSTR,DWORD,LPDWORD,LPCWSTR,DWORD);
1566 NTSTATUS  WINAPI RtlUnicodeToMultiByteSize(PULONG,PCWSTR,ULONG);
1567 NTSTATUS  WINAPI RtlUnicodeToOemN(LPSTR,DWORD,LPDWORD,LPCWSTR,DWORD);
1568 ULONG     WINAPI RtlUniform(PULONG);
1569 BOOLEAN   WINAPI RtlUnlockHeap(HANDLE);
1570 void      WINAPI RtlUnwind(PVOID,PVOID,PEXCEPTION_RECORD,PVOID);
1571 #ifdef __ia64__
1572 void      WINAPI RtlUnwind2(FRAME_POINTERS,PVOID,PEXCEPTION_RECORD,PVOID,PCONTEXT);
1573 void      WINAPI RtlUnwindEx(FRAME_POINTERS,PVOID,PEXCEPTION_RECORD,PVOID,PCONTEXT,PUNWIND_HISTORY_TABLE);
1574 #endif
1575 WCHAR     WINAPI RtlUpcaseUnicodeChar(WCHAR);
1576 NTSTATUS  WINAPI RtlUpcaseUnicodeString(UNICODE_STRING*,const UNICODE_STRING *,BOOLEAN);
1577 NTSTATUS  WINAPI RtlUpcaseUnicodeStringToAnsiString(STRING*,const UNICODE_STRING*,BOOLEAN);
1578 NTSTATUS  WINAPI RtlUpcaseUnicodeStringToCountedOemString(STRING*,const UNICODE_STRING*,BOOLEAN);
1579 NTSTATUS  WINAPI RtlUpcaseUnicodeStringToOemString(STRING*,const UNICODE_STRING*,BOOLEAN);
1580 NTSTATUS  WINAPI RtlUpcaseUnicodeToMultiByteN(LPSTR,DWORD,LPDWORD,LPCWSTR,DWORD);
1581 NTSTATUS  WINAPI RtlUpcaseUnicodeToOemN(LPSTR,DWORD,LPDWORD,LPCWSTR,DWORD);
1582 CHAR      WINAPI RtlUpperChar(CHAR);
1583 void      WINAPI RtlUpperString(STRING *,const STRING *);
1584
1585 NTSTATUS  WINAPI RtlValidSecurityDescriptor(PSECURITY_DESCRIPTOR);
1586 BOOLEAN   WINAPI RtlValidAcl(PACL);
1587 BOOLEAN   WINAPI RtlValidSid(PSID);
1588 BOOLEAN   WINAPI RtlValidateHeap(HANDLE,ULONG,LPCVOID);
1589 NTSTATUS  WINAPI RtlVerifyVersionInfo(const RTL_OSVERSIONINFOEXW*,DWORD,DWORDLONG);
1590
1591 NTSTATUS  WINAPI RtlWalkHeap(HANDLE,PVOID);
1592
1593 NTSTATUS  WINAPI RtlpWaitForCriticalSection(RTL_CRITICAL_SECTION *);
1594 NTSTATUS  WINAPI RtlpUnWaitCriticalSection(RTL_CRITICAL_SECTION *);
1595
1596 /* Wine internal functions */
1597
1598 extern NTSTATUS wine_nt_to_unix_file_name( const UNICODE_STRING *nameW, ANSI_STRING *unix_name_ret,
1599                                            UINT disposition, BOOLEAN check_case );
1600
1601 /***********************************************************************
1602  * Inline functions
1603  */
1604
1605 #define InitializeObjectAttributes(p,n,a,r,s) \
1606     do { \
1607         (p)->Length = sizeof(OBJECT_ATTRIBUTES); \
1608         (p)->RootDirectory = r; \
1609         (p)->Attributes = a; \
1610         (p)->ObjectName = n; \
1611         (p)->SecurityDescriptor = s; \
1612         (p)->SecurityQualityOfService = NULL; \
1613     } while (0)
1614
1615 #define NtCurrentProcess() ((HANDLE)-1)
1616
1617 #define RtlFillMemory(Destination,Length,Fill) memset((Destination),(Fill),(Length))
1618 #define RtlMoveMemory(Destination,Source,Length) memmove((Destination),(Source),(Length))
1619 #define RtlStoreUlong(p,v)  do { ULONG _v = (v); memcpy((p), &_v, sizeof(_v)); } while (0)
1620 #define RtlStoreUlonglong(p,v) do { ULONGLONG _v = (v); memcpy((p), &_v, sizeof(_v)); } while (0)
1621 #define RtlRetrieveUlong(p,s) memcpy((p), (s), sizeof(ULONG))
1622 #define RtlRetrieveUlonglong(p,s) memcpy((p), (s), sizeof(ULONGLONG))
1623 #define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length))
1624
1625 inline static BOOLEAN RtlCheckBit(PCRTL_BITMAP lpBits, ULONG ulBit)
1626 {
1627     if (lpBits && ulBit < lpBits->SizeOfBitMap &&
1628         lpBits->Buffer[ulBit >> 5] & (1 << (ulBit & 31)))
1629         return TRUE;
1630     return FALSE;
1631 }
1632
1633 /* These are implemented as __fastcall, so we can't let Winelib apps link with them */
1634 inline static USHORT RtlUshortByteSwap(USHORT s)
1635 {
1636     return (s >> 8) | (s << 8);
1637 }
1638 inline static ULONG RtlUlongByteSwap(ULONG i)
1639 {
1640 #if defined(__i386__) && defined(__GNUC__)
1641     ULONG ret;
1642     __asm__("bswap %0" : "=r" (ret) : "0" (i) );
1643     return ret;
1644 #else
1645     return ((ULONG)RtlUshortByteSwap((USHORT)i) << 16) | RtlUshortByteSwap((USHORT)(i >> 16));
1646 #endif
1647 }
1648
1649 /*************************************************************************
1650  * Loader functions and structures.
1651  *
1652  * Those are not part of standard Winternl.h
1653  */
1654 typedef struct _LDR_MODULE
1655 {
1656     LIST_ENTRY          InLoadOrderModuleList;
1657     LIST_ENTRY          InMemoryOrderModuleList;
1658     LIST_ENTRY          InInitializationOrderModuleList;
1659     void*               BaseAddress;
1660     void*               EntryPoint;
1661     ULONG               SizeOfImage;
1662     UNICODE_STRING      FullDllName;
1663     UNICODE_STRING      BaseDllName;
1664     ULONG               Flags;
1665     SHORT               LoadCount;
1666     SHORT               TlsIndex;
1667     HANDLE              SectionHandle;
1668     ULONG               CheckSum;
1669     ULONG               TimeDateStamp;
1670 } LDR_MODULE, *PLDR_MODULE;
1671
1672 /* those defines are (some of the) regular LDR_MODULE.Flags values */
1673 #define LDR_IMAGE_IS_DLL                0x00000004
1674 #define LDR_LOAD_IN_PROGRESS            0x00001000
1675 #define LDR_UNLOAD_IN_PROGRESS          0x00002000
1676 #define LDR_NO_DLL_CALLS                0x00040000
1677 #define LDR_PROCESS_ATTACHED            0x00080000
1678 #define LDR_MODULE_REBASED              0x00200000
1679
1680 /* these ones is Wine specific */
1681 #define LDR_DONT_RESOLVE_REFS           0x40000000
1682 #define LDR_WINE_INTERNAL               0x80000000
1683
1684 /* FIXME: to be checked */
1685 #define MAXIMUM_FILENAME_LENGTH 256
1686
1687 typedef struct _SYSTEM_MODULE
1688 {
1689     ULONG               Reserved1;
1690     ULONG               Reserved2;
1691     PVOID               ImageBaseAddress;
1692     ULONG               ImageSize;
1693     ULONG               Flags;
1694     WORD                Id;
1695     WORD                Rank;
1696     WORD                Unknown;
1697     WORD                NameOffset;
1698     BYTE                Name[MAXIMUM_FILENAME_LENGTH];
1699 } SYSTEM_MODULE, *PSYSTEM_MODULE;
1700
1701 typedef struct _SYSTEM_MODULE_INFORMATION
1702 {
1703     ULONG               ModulesCount;
1704     SYSTEM_MODULE       Modules[1]; /* FIXME: should be Modules[0] */
1705 } SYSTEM_MODULE_INFORMATION, *PSYSTEM_MODULE_INFORMATION;
1706
1707 NTSTATUS WINAPI LdrDisableThreadCalloutsForDll(HMODULE);
1708 NTSTATUS WINAPI LdrFindEntryForAddress(const void*, PLDR_MODULE*);
1709 NTSTATUS WINAPI LdrLockLoaderLock(ULONG,ULONG*,ULONG*);
1710 NTSTATUS WINAPI LdrQueryProcessModuleInformation(SYSTEM_MODULE_INFORMATION*, ULONG, ULONG*);
1711 NTSTATUS WINAPI LdrUnloadDll(HMODULE);
1712 NTSTATUS WINAPI LdrUnlockLoaderLock(ULONG,ULONG);
1713
1714 /* list manipulation macros */
1715 #define InitializeListHead(le)  (void)((le)->Flink = (le)->Blink = (le))
1716 #define InsertHeadList(le,e)    do { PLIST_ENTRY f = (le)->Flink; (e)->Flink = f; (e)->Blink = (le); f->Blink = (e); (le)->Flink = (e); } while (0)
1717 #define InsertTailList(le,e)    do { PLIST_ENTRY b = (le)->Blink; (e)->Flink = (le); (e)->Blink = b; b->Flink = (e); (le)->Blink = (e); } while (0)
1718 #define IsListEmpty(le)         ((le)->Flink == (le))
1719 #define RemoveEntryList(e)      do { PLIST_ENTRY f = (e)->Flink, b = (e)->Blink; f->Blink = b; b->Flink = f; (e)->Flink = (e)->Blink = NULL; } while (0)
1720 static inline PLIST_ENTRY RemoveHeadList(PLIST_ENTRY le)
1721 {
1722     PLIST_ENTRY f, b, e;
1723
1724     e = le->Flink;
1725     f = le->Flink->Flink;
1726     b = le->Flink->Blink;
1727     f->Blink = b;
1728     b->Flink = f;
1729
1730     if (e != le) e->Flink = e->Blink = NULL;
1731     return e;
1732 }
1733 static inline PLIST_ENTRY RemoveTailList(PLIST_ENTRY le)
1734 {
1735     PLIST_ENTRY f, b, e;
1736
1737     e = le->Blink;
1738     f = le->Blink->Flink;
1739     b = le->Blink->Blink;
1740     f->Blink = b;
1741     b->Flink = f;
1742
1743     if (e != le) e->Flink = e->Blink = NULL;
1744     return e;
1745 }
1746
1747 #ifdef __cplusplus
1748 } /* extern "C" */
1749 #endif /* defined(__cplusplus) */
1750
1751 #endif  /* __WINE_WINTERNL_H */