Home | History | Annotate | Download | only in include
      1 /**
      2  * This file has no copyright assigned and is placed in the Public Domain.
      3  * This file is part of the mingw-w64 runtime package.
      4  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
      5  */
      6 #ifndef _WINTERNL_
      7 #define _WINTERNL_
      8 
      9 #include <windef.h>
     10 
     11 #ifndef NT_SUCCESS
     12 #define NT_SUCCESS(status)	((NTSTATUS) (status) >= 0)
     13 #endif
     14 
     15 #ifndef DEVICE_TYPE
     16 #define DEVICE_TYPE ULONG
     17 #endif
     18 
     19 #ifdef __cplusplus
     20 extern "C" {
     21 #endif
     22 
     23 #ifndef __UNICODE_STRING_DEFINED
     24 #define __UNICODE_STRING_DEFINED
     25   typedef struct _UNICODE_STRING {
     26     USHORT Length;
     27     USHORT MaximumLength;
     28     PWSTR Buffer;
     29   } UNICODE_STRING;
     30 #endif
     31 
     32   typedef struct _PEB_LDR_DATA {
     33     BYTE Reserved1[8];
     34     PVOID Reserved2[3];
     35     LIST_ENTRY InMemoryOrderModuleList;
     36   } PEB_LDR_DATA,*PPEB_LDR_DATA;
     37 
     38   typedef struct _LDR_DATA_TABLE_ENTRY {
     39     PVOID Reserved1[2];
     40     LIST_ENTRY InMemoryOrderLinks;
     41     PVOID Reserved2[2];
     42     PVOID DllBase;
     43     PVOID Reserved3[2];
     44     UNICODE_STRING FullDllName;
     45     BYTE Reserved4[8];
     46     PVOID Reserved5[3];
     47     __C89_NAMELESS union {
     48       ULONG CheckSum;
     49       PVOID Reserved6;
     50     };
     51     ULONG TimeDateStamp;
     52   } LDR_DATA_TABLE_ENTRY,*PLDR_DATA_TABLE_ENTRY;
     53 
     54 typedef struct _RTL_USER_PROCESS_PARAMETERS {
     55     BYTE Reserved1[16];
     56     PVOID Reserved2[10];
     57     UNICODE_STRING ImagePathName;
     58     UNICODE_STRING CommandLine;
     59   } RTL_USER_PROCESS_PARAMETERS,*PRTL_USER_PROCESS_PARAMETERS;
     60 
     61   /* This function pointer is undocumented and just valid for windows 2000.
     62      Therefore I guess.  */
     63   typedef VOID (NTAPI *PPS_POST_PROCESS_INIT_ROUTINE)(VOID);
     64 
     65   typedef struct _PEB {
     66     BYTE Reserved1[2];
     67     BYTE BeingDebugged;
     68     BYTE Reserved2[1];
     69     PVOID Reserved3[2];
     70     PPEB_LDR_DATA Ldr;
     71     PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
     72     BYTE Reserved4[104];
     73     PVOID Reserved5[52];
     74     PPS_POST_PROCESS_INIT_ROUTINE PostProcessInitRoutine;
     75     BYTE Reserved6[128];
     76     PVOID Reserved7[1];
     77     ULONG SessionId;
     78   } PEB,*PPEB;
     79 
     80   typedef struct _TEB {
     81     BYTE Reserved1[1952];
     82     PVOID Reserved2[412];
     83     PVOID TlsSlots[64];
     84     BYTE Reserved3[8];
     85     PVOID Reserved4[26];
     86     PVOID ReservedForOle;
     87     PVOID Reserved5[4];
     88     PVOID TlsExpansionSlots;
     89   } TEB;
     90 
     91   typedef TEB *PTEB;
     92   #if !defined (_NTDEF_) && !defined (_NTSTATUS_PSDK)
     93   #define _NTSTATUS_PSDK
     94   typedef LONG NTSTATUS, *PNTSTATUS;
     95   #endif
     96   typedef CONST char *PCSZ;
     97 
     98 #ifndef __STRING_DEFINED
     99 #define __STRING_DEFINED
    100   typedef struct _STRING {
    101     USHORT Length;
    102     USHORT MaximumLength;
    103     PCHAR Buffer;
    104   } STRING;
    105 #endif
    106 
    107   typedef STRING *PSTRING;
    108   typedef STRING ANSI_STRING;
    109   typedef PSTRING PANSI_STRING;
    110   typedef PSTRING PCANSI_STRING;
    111   typedef STRING OEM_STRING;
    112   typedef PSTRING POEM_STRING;
    113   typedef CONST STRING *PCOEM_STRING;
    114 
    115   typedef UNICODE_STRING *PUNICODE_STRING;
    116   typedef const UNICODE_STRING *PCUNICODE_STRING;
    117 
    118 #ifndef __OBJECT_ATTRIBUTES_DEFINED
    119 #define __OBJECT_ATTRIBUTES_DEFINED
    120   typedef struct _OBJECT_ATTRIBUTES {
    121     ULONG Length;
    122 #ifdef _WIN64
    123     ULONG pad1;
    124 #endif
    125     HANDLE RootDirectory;
    126     PUNICODE_STRING ObjectName;
    127     ULONG Attributes;
    128 #ifdef _WIN64
    129     ULONG pad2;
    130 #endif
    131     PVOID SecurityDescriptor;
    132     PVOID SecurityQualityOfService;
    133   } OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;
    134 #endif
    135 
    136 /* Values for the Attributes member */
    137  #define OBJ_INHERIT             0x00000002
    138  #define OBJ_PERMANENT           0x00000010
    139  #define OBJ_EXCLUSIVE           0x00000020
    140  #define OBJ_CASE_INSENSITIVE    0x00000040
    141  #define OBJ_OPENIF              0x00000080
    142  #define OBJ_OPENLINK            0x00000100
    143  #define OBJ_KERNEL_HANDLE       0x00000200
    144  #define OBJ_FORCE_ACCESS_CHECK  0x00000400
    145  #define OBJ_VALID_ATTRIBUTES    0x000007F2
    146 
    147  /* Helper Macro */
    148  #define InitializeObjectAttributes(p,n,a,r,s) { \
    149    (p)->Length = sizeof(OBJECT_ATTRIBUTES); \
    150    (p)->RootDirectory = (r); \
    151    (p)->Attributes = (a); \
    152    (p)->ObjectName = (n); \
    153    (p)->SecurityDescriptor = (s); \
    154    (p)->SecurityQualityOfService = NULL; \
    155  }
    156 
    157   typedef struct _OBJECT_DATA_INFORMATION {
    158     BOOLEAN InheritHandle;
    159     BOOLEAN ProtectFromClose;
    160   } OBJECT_DATA_INFORMATION, *POBJECT_DATA_INFORMATION;
    161 
    162   typedef struct _OBJECT_BASIC_INFORMATION {
    163     ULONG  Attributes;
    164     ACCESS_MASK  GrantedAccess;
    165     ULONG  HandleCount;
    166     ULONG  PointerCount;
    167     ULONG  PagedPoolUsage;
    168     ULONG  NonPagedPoolUsage;
    169     ULONG  Reserved[3];
    170     ULONG  NameInformationLength;
    171     ULONG  TypeInformationLength;
    172     ULONG  SecurityDescriptorLength;
    173     LARGE_INTEGER  CreateTime;
    174   } OBJECT_BASIC_INFORMATION, *POBJECT_BASIC_INFORMATION;
    175 
    176   typedef struct _OBJECT_NAME_INFORMATION {
    177     UNICODE_STRING Name;
    178   } OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION;
    179 
    180   typedef struct _OBJECT_TYPE_INFORMATION {
    181     UNICODE_STRING TypeName;
    182     ULONG TotalNumberOfObjects;
    183     ULONG TotalNumberOfHandles;
    184     ULONG TotalPagedPoolUsage;
    185     ULONG TotalNonPagedPoolUsage;
    186     ULONG TotalNamePoolUsage;
    187     ULONG TotalHandleTableUsage;
    188     ULONG HighWaterNumberOfObjects;
    189     ULONG HighWaterNumberOfHandles;
    190     ULONG HighWaterPagedPoolUsage;
    191     ULONG HighWaterNonPagedPoolUsage;
    192     ULONG HighWaterNamePoolUsage;
    193     ULONG HighWaterHandleTableUsage;
    194     ULONG InvalidAttributes;
    195     GENERIC_MAPPING GenericMapping;
    196     ULONG ValidAccessMask;
    197     BOOLEAN SecurityRequired;
    198     BOOLEAN MaintainHandleCount;
    199     ULONG PoolType;
    200     ULONG DefaultPagedPoolCharge;
    201     ULONG DefaultNonPagedPoolCharge;
    202   } OBJECT_TYPE_INFORMATION, *POBJECT_TYPE_INFORMATION;
    203 
    204   typedef struct _OBJECT_ALL_INFORMATION {
    205     ULONG NumberOfObjects;
    206     OBJECT_TYPE_INFORMATION ObjectTypeInformation[1];
    207   }OBJECT_ALL_INFORMATION, *POBJECT_ALL_INFORMATION;
    208 
    209   typedef enum _FILE_INFORMATION_CLASS {
    210     FileDirectoryInformation = 1,
    211     FileFullDirectoryInformation,
    212     FileBothDirectoryInformation,
    213     FileBasicInformation,
    214     FileStandardInformation,
    215     FileInternalInformation,
    216     FileEaInformation,
    217     FileAccessInformation,
    218     FileNameInformation,
    219     FileRenameInformation,
    220     FileLinkInformation,
    221     FileNamesInformation,
    222     FileDispositionInformation,
    223     FilePositionInformation,
    224     FileFullEaInformation,
    225     FileModeInformation,
    226     FileAlignmentInformation,
    227     FileAllInformation,
    228     FileAllocationInformation,
    229     FileEndOfFileInformation,
    230     FileAlternateNameInformation,
    231     FileStreamInformation,
    232     FilePipeInformation,
    233     FilePipeLocalInformation,
    234     FilePipeRemoteInformation,
    235     FileMailslotQueryInformation,
    236     FileMailslotSetInformation,
    237     FileCompressionInformation,
    238     FileObjectIdInformation,
    239     FileCompletionInformation,
    240     FileMoveClusterInformation,
    241     FileQuotaInformation,
    242     FileReparsePointInformation,
    243     FileNetworkOpenInformation,
    244     FileAttributeTagInformation,
    245     FileTrackingInformation,
    246     FileIdBothDirectoryInformation,
    247     FileIdFullDirectoryInformation,
    248     FileValidDataLengthInformation,
    249     FileShortNameInformation = 40,
    250     FileSfioReserveInformation = 44,
    251     FileSfioVolumeInformation = 45,
    252     FileHardLinkInformation = 46,
    253     FileNormalizedNameInformation = 48,
    254     FileIdGlobalTxDirectoryInformation = 50,
    255     FileStandardLinkInformation = 54,
    256     FileMaximumInformation
    257   } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
    258 
    259   typedef struct _FILE_DIRECTORY_INFORMATION {
    260     ULONG NextEntryOffset;
    261     ULONG FileIndex;
    262     LARGE_INTEGER CreationTime;
    263     LARGE_INTEGER LastAccessTime;
    264     LARGE_INTEGER LastWriteTime;
    265     LARGE_INTEGER ChangeTime;
    266     LARGE_INTEGER EndOfFile;
    267     LARGE_INTEGER AllocationSize;
    268     ULONG FileAttributes;
    269     ULONG FileNameLength;
    270     WCHAR FileName[ANYSIZE_ARRAY];
    271   } FILE_DIRECTORY_INFORMATION, *PFILE_DIRECTORY_INFORMATION;
    272 
    273   typedef struct _FILE_FULL_DIR_INFORMATION {
    274     ULONG NextEntryOffset;
    275     ULONG FileIndex;
    276     LARGE_INTEGER CreationTime;
    277     LARGE_INTEGER LastAccessTime;
    278     LARGE_INTEGER LastWriteTime;
    279     LARGE_INTEGER ChangeTime;
    280     LARGE_INTEGER EndOfFile;
    281     LARGE_INTEGER AllocationSize;
    282     ULONG FileAttributes;
    283     ULONG FileNameLength;
    284     ULONG EaSize;
    285     WCHAR FileName[ANYSIZE_ARRAY];
    286   } FILE_FULL_DIR_INFORMATION, *PFILE_FULL_DIR_INFORMATION;
    287 
    288   typedef struct _FILE_ID_FULL_DIR_INFORMATION {
    289     ULONG NextEntryOffset;
    290     ULONG FileIndex;
    291     LARGE_INTEGER CreationTime;
    292     LARGE_INTEGER LastAccessTime;
    293     LARGE_INTEGER LastWriteTime;
    294     LARGE_INTEGER ChangeTime;
    295     LARGE_INTEGER EndOfFile;
    296     LARGE_INTEGER AllocationSize;
    297     ULONG FileAttributes;
    298     ULONG FileNameLength;
    299     ULONG EaSize;
    300     LARGE_INTEGER FileId;
    301     WCHAR FileName[ANYSIZE_ARRAY];
    302   } FILE_ID_FULL_DIR_INFORMATION, *PFILE_ID_FULL_DIR_INFORMATION;
    303 
    304   typedef struct _FILE_BOTH_DIR_INFORMATION {
    305     ULONG NextEntryOffset;
    306 	 ULONG FileIndex;
    307     LARGE_INTEGER CreationTime;
    308     LARGE_INTEGER LastAccessTime;
    309     LARGE_INTEGER LastWriteTime;
    310     LARGE_INTEGER ChangeTime;
    311     LARGE_INTEGER EndOfFile;
    312     LARGE_INTEGER AllocationSize;
    313     ULONG FileAttributes;
    314     ULONG FileNameLength;
    315     ULONG EaSize;
    316     CHAR ShortNameLength;
    317     WCHAR ShortName[12];
    318     WCHAR FileName[ANYSIZE_ARRAY];
    319   } FILE_BOTH_DIR_INFORMATION, *PFILE_BOTH_DIR_INFORMATION;
    320 
    321   typedef struct _FILE_ID_BOTH_DIR_INFORMATION {
    322     ULONG NextEntryOffset;
    323     ULONG FileIndex;
    324     LARGE_INTEGER CreationTime;
    325     LARGE_INTEGER LastAccessTime;
    326     LARGE_INTEGER LastWriteTime;
    327     LARGE_INTEGER ChangeTime;
    328     LARGE_INTEGER EndOfFile;
    329     LARGE_INTEGER AllocationSize;
    330     ULONG FileAttributes;
    331     ULONG FileNameLength;
    332     ULONG EaSize;
    333     CHAR ShortNameLength;
    334     WCHAR ShortName[12];
    335     LARGE_INTEGER FileId;
    336     WCHAR FileName[ANYSIZE_ARRAY];
    337   } FILE_ID_BOTH_DIR_INFORMATION, *PFILE_ID_BOTH_DIR_INFORMATION;
    338 
    339   /* Old names of dir info structures as (partially) used in Nebbitt's
    340      Native API Reference.  Keep for backward compatibility. */
    341   typedef struct _FILE_FULL_DIR_INFORMATION
    342     FILE_FULL_DIRECTORY_INFORMATION, *PFILE_FULL_DIRECTORY_INFORMATION;
    343   typedef struct _FILE_ID_FULL_DIR_INFORMATION
    344     FILE_ID_FULL_DIRECTORY_INFORMATION, *PFILE_ID_FULL_DIRECTORY_INFORMATION;
    345   typedef struct _FILE_BOTH_DIR_INFORMATION
    346     FILE_BOTH_DIRECTORY_INFORMATION, *PFILE_BOTH_DIRECTORY_INFORMATION;
    347   typedef struct _FILE_ID_BOTH_DIR_INFORMATION
    348     FILE_ID_BOTH_DIRECTORY_INFORMATION, *PFILE_ID_BOTH_DIRECTORY_INFORMATION;
    349 
    350   typedef struct _FILE_BASIC_INFORMATION {
    351     LARGE_INTEGER CreationTime;
    352     LARGE_INTEGER LastAccessTime;
    353     LARGE_INTEGER LastWriteTime;
    354     LARGE_INTEGER ChangeTime;
    355     ULONG FileAttributes;
    356   } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
    357 
    358   typedef struct _FILE_STANDARD_INFORMATION {
    359     LARGE_INTEGER AllocationSize;
    360     LARGE_INTEGER EndOfFile;
    361     ULONG NumberOfLinks;
    362     BOOLEAN DeletePending;
    363     BOOLEAN Directory;
    364   } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;
    365 
    366   typedef struct _FILE_INTERNAL_INFORMATION {
    367     LARGE_INTEGER IndexNumber;
    368   } FILE_INTERNAL_INFORMATION, *PFILE_INTERNAL_INFORMATION;
    369 
    370   typedef struct _FILE_EA_INFORMATION {
    371     ULONG EaSize;
    372   } FILE_EA_INFORMATION, *PFILE_EA_INFORMATION;
    373 
    374   typedef struct _FILE_ACCESS_INFORMATION {
    375     ACCESS_MASK AccessFlags;
    376   } FILE_ACCESS_INFORMATION, *PFILE_ACCESS_INFORMATION;
    377 
    378   typedef struct _FILE_LINK_INFORMATION {
    379     BOOLEAN ReplaceIfExists;
    380     HANDLE RootDirectory;
    381     ULONG FileNameLength;
    382     WCHAR FileName[1];
    383   } FILE_LINK_INFORMATION, *PFILE_LINK_INFORMATION;
    384 
    385   typedef struct _FILE_NAME_INFORMATION {
    386     ULONG FileNameLength;
    387     WCHAR FileName[1];
    388   } FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
    389 
    390   typedef struct _FILE_RENAME_INFORMATION {
    391     BOOLEAN ReplaceIfExists;
    392     HANDLE RootDirectory;
    393     ULONG FileNameLength;
    394     WCHAR FileName[1];
    395   } FILE_RENAME_INFORMATION, *PFILE_RENAME_INFORMATION;
    396 
    397   typedef struct _FILE_NAMES_INFORMATION {
    398     ULONG NextEntryOffset;
    399     ULONG FileIndex;
    400     ULONG FileNameLength;
    401     WCHAR FileName[1];
    402   } FILE_NAMES_INFORMATION, *PFILE_NAMES_INFORMATION;
    403 
    404   typedef struct _FILE_DISPOSITION_INFORMATION {
    405     BOOLEAN DoDeleteFile;
    406   } FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION;
    407 
    408   typedef struct _FILE_POSITION_INFORMATION {
    409     LARGE_INTEGER CurrentByteOffset;
    410   } FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION;
    411 
    412   typedef struct _FILE_ALIGNMENT_INFORMATION {
    413     ULONG AlignmentRequirement;
    414   } FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION;
    415 
    416   typedef struct _FILE_ALLOCATION_INFORMATION {
    417     LARGE_INTEGER AllocationSize;
    418   } FILE_ALLOCATION_INFORMATION, *PFILE_ALLOCATION_INFORMATION;
    419 
    420   typedef struct _FILE_END_OF_FILE_INFORMATION {
    421     LARGE_INTEGER EndOfFile;
    422   } FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION;
    423 
    424   typedef struct _FILE_NETWORK_OPEN_INFORMATION {
    425     LARGE_INTEGER CreationTime;
    426     LARGE_INTEGER LastAccessTime;
    427     LARGE_INTEGER LastWriteTime;
    428     LARGE_INTEGER ChangeTime;
    429     LARGE_INTEGER AllocationSize;
    430     LARGE_INTEGER EndOfFile;
    431     ULONG FileAttributes;
    432   } FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION;
    433 
    434   typedef struct _FILE_FULL_EA_INFORMATION {
    435     ULONG NextEntryOffset;
    436     UCHAR Flags;
    437     UCHAR EaNameLength;
    438     USHORT EaValueLength;
    439     CHAR EaName[1];
    440   } FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
    441 
    442   typedef struct _FILE_MODE_INFORMATION {
    443     ULONG Mode;
    444   } FILE_MODE_INFORMATION, *PFILE_MODE_INFORMATION;
    445 
    446   typedef struct _FILE_STREAM_INFORMATION {
    447     ULONG NextEntryOffset;
    448     ULONG StreamNameLength;
    449     LARGE_INTEGER StreamSize;
    450     LARGE_INTEGER StreamAllocationSize;
    451     WCHAR StreamName[1];
    452   } FILE_STREAM_INFORMATION, *PFILE_STREAM_INFORMATION;
    453 
    454   typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION {
    455     ULONG FileAttributes;
    456     ULONG ReparseTag;
    457   } FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION;
    458 
    459   typedef struct _FILE_MAILSLOT_QUERY_INFORMATION {
    460     ULONG MaximumMessageSize;
    461     ULONG MailslotQuota;
    462     ULONG NextMessageSize;
    463     ULONG MessagesAvailable;
    464     LARGE_INTEGER ReadTimeout;
    465   } FILE_MAILSLOT_QUERY_INFORMATION, *PFILE_MAILSLOT_QUERY_INFORMATION;
    466 
    467   typedef struct _FILE_MAILSLOT_SET_INFORMATION {
    468     LARGE_INTEGER ReadTimeout;
    469   } FILE_MAILSLOT_SET_INFORMATION, *PFILE_MAILSLOT_SET_INFORMATION;
    470 
    471   typedef struct _FILE_PIPE_LOCAL_INFORMATION {
    472     ULONG NamedPipeType;
    473     ULONG NamedPipeConfiguration;
    474     ULONG MaximumInstances;
    475     ULONG CurrentInstances;
    476     ULONG InboundQuota;
    477     ULONG ReadDataAvailable;
    478     ULONG OutboundQuota;
    479     ULONG WriteQuotaAvailable;
    480     ULONG NamedPipeState;
    481     ULONG NamedPipeEnd;
    482   } FILE_PIPE_LOCAL_INFORMATION, *PFILE_PIPE_LOCAL_INFORMATION;
    483 
    484   typedef struct _FILE_ALL_INFORMATION {
    485     FILE_BASIC_INFORMATION     BasicInformation;
    486     FILE_STANDARD_INFORMATION  StandardInformation;
    487     FILE_INTERNAL_INFORMATION  InternalInformation;
    488     FILE_EA_INFORMATION        EaInformation;
    489     FILE_ACCESS_INFORMATION    AccessInformation;
    490     FILE_POSITION_INFORMATION  PositionInformation;
    491     FILE_MODE_INFORMATION      ModeInformation;
    492     FILE_ALIGNMENT_INFORMATION AlignmentInformation;
    493     FILE_NAME_INFORMATION      NameInformation;
    494   } FILE_ALL_INFORMATION, *PFILE_ALL_INFORMATION;
    495 
    496   typedef enum _FSINFOCLASS {
    497     FileFsVolumeInformation = 1,
    498     FileFsLabelInformation,
    499     FileFsSizeInformation,
    500     FileFsDeviceInformation,
    501     FileFsAttributeInformation,
    502     FileFsControlInformation,
    503     FileFsFullSizeInformation,
    504     FileFsObjectIdInformation,
    505     FileFsDriverPathInformation,
    506     FileFsVolumeFlagsInformation,
    507     FileFsMaximumInformation
    508   } FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS;
    509 
    510   typedef struct _FILE_FS_VOLUME_INFORMATION {
    511     LARGE_INTEGER VolumeCreationTime;
    512     ULONG VolumeSerialNumber;
    513     ULONG VolumeLabelLength;
    514     BOOLEAN SupportsObjects;
    515     WCHAR VolumeLabel[1];
    516   } FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION;
    517 
    518   typedef struct _FILE_FS_LABEL_INFORMATION {
    519     ULONG VolumeLabelLength;
    520     WCHAR VolumeLabel[1];
    521   } FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION;
    522 
    523   typedef struct _FILE_FS_SIZE_INFORMATION {
    524     LARGE_INTEGER TotalAllocationUnits;
    525     LARGE_INTEGER AvailableAllocationUnits;
    526     ULONG SectorsPerAllocationUnit;
    527     ULONG BytesPerSector;
    528   } FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION;
    529 
    530   typedef struct _FILE_FS_DEVICE_INFORMATION {
    531     DEVICE_TYPE DeviceType;
    532     ULONG Characteristics;
    533   } FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION;
    534 
    535   typedef struct _FILE_FS_ATTRIBUTE_INFORMATION {
    536     ULONG FileSystemAttributes;
    537     ULONG MaximumComponentNameLength;
    538     ULONG FileSystemNameLength;
    539     WCHAR FileSystemName[1];
    540   } FILE_FS_ATTRIBUTE_INFORMATION, *PFILE_FS_ATTRIBUTE_INFORMATION;
    541 
    542   typedef struct _FILE_FS_FULL_SIZE_INFORMATION {
    543     LARGE_INTEGER TotalAllocationUnits;
    544     LARGE_INTEGER CallerAvailableAllocationUnits;
    545     LARGE_INTEGER ActualAvailableAllocationUnits;
    546     ULONG SectorsPerAllocationUnit;
    547     ULONG BytesPerSector;
    548   } FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION;
    549 
    550   typedef struct _FILE_FS_OBJECTID_INFORMATION {
    551     UCHAR ObjectId[16];
    552     UCHAR ExtendedInfo[48];
    553   } FILE_FS_OBJECTID_INFORMATION, *PFILE_FS_OBJECTID_INFORMATION;
    554 
    555   typedef struct _IO_STATUS_BLOCK {
    556     __C89_NAMELESS union {
    557       NTSTATUS Status;
    558       PVOID Pointer;
    559     };
    560     ULONG_PTR Information;
    561   } IO_STATUS_BLOCK,*PIO_STATUS_BLOCK;
    562 
    563   typedef VOID (NTAPI *PIO_APC_ROUTINE)(PVOID ApcContext,PIO_STATUS_BLOCK IoStatusBlock,ULONG Reserved);
    564 
    565 #ifdef __ia64__
    566   typedef struct _FRAME_POINTERS {
    567     ULONGLONG MemoryStackFp;
    568     ULONGLONG BackingStoreFp;
    569   } FRAME_POINTERS,*PFRAME_POINTERS;
    570 
    571 #define UNWIND_HISTORY_TABLE_SIZE 12
    572 
    573   typedef struct _RUNTIME_FUNCTION {
    574     ULONG BeginAddress;
    575     ULONG EndAddress;
    576     ULONG UnwindInfoAddress;
    577   } RUNTIME_FUNCTION,*PRUNTIME_FUNCTION;
    578 
    579   typedef struct _UNWIND_HISTORY_TABLE_ENTRY {
    580     ULONG64 ImageBase;
    581     ULONG64 Gp;
    582     PRUNTIME_FUNCTION FunctionEntry;
    583   } UNWIND_HISTORY_TABLE_ENTRY,*PUNWIND_HISTORY_TABLE_ENTRY;
    584 
    585   typedef struct _UNWIND_HISTORY_TABLE {
    586     ULONG Count;
    587     UCHAR Search;
    588     ULONG64 LowAddress;
    589     ULONG64 HighAddress;
    590     UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
    591   } UNWIND_HISTORY_TABLE,*PUNWIND_HISTORY_TABLE;
    592 #endif
    593 
    594   typedef struct _VM_COUNTERS {
    595     SIZE_T PeakVirtualSize;
    596     SIZE_T VirtualSize;
    597     ULONG PageFaultCount;
    598     SIZE_T PeakWorkingSetSize;
    599     SIZE_T WorkingSetSize;
    600     SIZE_T QuotaPeakPagedPoolUsage;
    601     SIZE_T QuotaPagedPoolUsage;
    602     SIZE_T QuotaPeakNonPagedPoolUsage;
    603     SIZE_T QuotaNonPagedPoolUsage;
    604     SIZE_T PagefileUsage;
    605     SIZE_T PeakPagefileUsage;
    606   } VM_COUNTERS, *PVM_COUNTERS;
    607 
    608   typedef enum _THREAD_STATE {
    609     StateInitialized = 0,
    610     StateReady, StateRunning, StateStandby, StateTerminated,
    611     StateWait, StateTransition,
    612     StateUnknown
    613   } THREAD_STATE;
    614 
    615   typedef struct _CLIENT_ID {
    616     HANDLE UniqueProcess;
    617     HANDLE UniqueThread;
    618   } CLIENT_ID, *PCLIENT_ID;
    619 
    620   typedef LONG KPRIORITY;
    621 
    622   typedef enum _KWAIT_REASON {
    623     Executive = 0,
    624     FreePage, PageIn, PoolAllocation, DelayExecution,
    625     Suspended, UserRequest, WrExecutive, WrFreePage, WrPageIn,
    626     WrPoolAllocation, WrDelayExecution, WrSuspended,
    627     WrUserRequest, WrEventPair, WrQueue, WrLpcReceive,
    628     WrLpcReply, WrVirtualMemory, WrPageOut, WrRendezvous,
    629     Spare2, Spare3, Spare4, Spare5, Spare6, WrKernel,
    630     MaximumWaitReason
    631   } KWAIT_REASON;
    632 
    633   typedef struct _SYSTEM_THREADS
    634   {
    635     LARGE_INTEGER KernelTime;
    636     LARGE_INTEGER UserTime;
    637     LARGE_INTEGER CreateTime;
    638     ULONG WaitTime;
    639     PVOID StartAddress;
    640     CLIENT_ID ClientId;
    641     KPRIORITY Priority;
    642     KPRIORITY BasePriority;
    643     ULONG ContextSwitchCount;
    644     THREAD_STATE State;
    645     KWAIT_REASON WaitReason;
    646   } SYSTEM_THREADS, *PSYSTEM_THREADS;
    647 
    648   typedef struct _PROCESS_BASIC_INFORMATION {
    649     NTSTATUS ExitStatus;
    650     PPEB PebBaseAddress;
    651     KAFFINITY AffinityMask;
    652     KPRIORITY BasePriority;
    653     ULONG_PTR UniqueProcessId;
    654     ULONG_PTR InheritedFromUniqueProcessId;
    655   } PROCESS_BASIC_INFORMATION, *PPROCESS_BASIC_INFORMATION;
    656 
    657   typedef struct _KERNEL_USER_TIMES {
    658     FILETIME CreateTime;
    659     FILETIME ExitTime;
    660     LARGE_INTEGER KernelTime;
    661     LARGE_INTEGER UserTime;
    662   } KERNEL_USER_TIMES, *PKERNEL_USER_TIMES;
    663 
    664   typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION {
    665     LARGE_INTEGER IdleTime;
    666     LARGE_INTEGER KernelTime;
    667     LARGE_INTEGER UserTime;
    668     LARGE_INTEGER Reserved1[2];
    669     ULONG Reserved2;
    670   } SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION,*PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION;
    671 
    672   typedef struct _SYSTEM_PROCESS_INFORMATION {
    673     ULONG NextEntryOffset;
    674     ULONG NumberOfThreads;
    675     LARGE_INTEGER Reserved[3];
    676     LARGE_INTEGER CreateTime;
    677     LARGE_INTEGER UserTime;
    678     LARGE_INTEGER KernelTime;
    679     UNICODE_STRING ImageName;
    680     KPRIORITY BasePriority;
    681     HANDLE UniqueProcessId;
    682     HANDLE InheritedFromUniqueProcessId;
    683     ULONG HandleCount;
    684     ULONG SessionId;
    685     ULONG PageDirectoryBase;
    686     VM_COUNTERS VirtualMemoryCounters;
    687     SIZE_T PrivatePageCount;
    688     IO_COUNTERS IoCounters;
    689   } SYSTEM_PROCESS_INFORMATION,*PSYSTEM_PROCESS_INFORMATION;
    690 
    691   typedef struct _SYSTEM_REGISTRY_QUOTA_INFORMATION {
    692     ULONG RegistryQuotaAllowed;
    693     ULONG RegistryQuotaUsed;
    694     PVOID Reserved1;
    695   } SYSTEM_REGISTRY_QUOTA_INFORMATION,*PSYSTEM_REGISTRY_QUOTA_INFORMATION;
    696 
    697   typedef struct _SYSTEM_BASIC_INFORMATION {
    698     BYTE Reserved1[4];
    699     ULONG MaximumIncrement;
    700     ULONG PhysicalPageSize;
    701     ULONG NumberOfPhysicalPages;
    702     ULONG LowestPhysicalPage;
    703     ULONG HighestPhysicalPage;
    704     ULONG AllocationGranularity;
    705     ULONG_PTR LowestUserAddress;
    706     ULONG_PTR HighestUserAddress;
    707     ULONG_PTR ActiveProcessors;
    708     CCHAR NumberOfProcessors;
    709   } SYSTEM_BASIC_INFORMATION,*PSYSTEM_BASIC_INFORMATION;
    710 
    711   typedef struct _SYSTEM_PROCESSOR_INFORMATION {
    712     USHORT ProcessorArchitecture;
    713     USHORT ProcessorLevel;
    714     USHORT ProcessorRevision;
    715     USHORT Unknown;
    716     ULONG FeatureBits;
    717   } SYSTEM_PROCESSOR_INFORMATION, *PSYSTEM_PROCESSOR_INFORMATION;
    718 
    719   typedef struct _SYSTEM_TIMEOFDAY_INFORMATION {
    720     LARGE_INTEGER BootTime;
    721     LARGE_INTEGER CurrentTime;
    722     LARGE_INTEGER TimeZoneBias;
    723     ULONG CurrentTimeZoneId;
    724     BYTE Reserved1[20];
    725   } SYSTEM_TIMEOFDAY_INFORMATION,*PSYSTEM_TIMEOFDAY_INFORMATION;
    726 
    727   typedef struct _SYSTEM_PERFORMANCE_INFORMATION {
    728     LARGE_INTEGER IdleTime;
    729     LARGE_INTEGER ReadTransferCount;
    730     LARGE_INTEGER WriteTransferCount;
    731     LARGE_INTEGER OtherTransferCount;
    732     ULONG ReadOperationCount;
    733     ULONG WriteOperationCount;
    734     ULONG OtherOperationCount;
    735     ULONG AvailablePages;
    736     ULONG TotalCommittedPages;
    737     ULONG TotalCommitLimit;
    738     ULONG PeakCommitment;
    739     ULONG PageFaults;
    740     ULONG WriteCopyFaults;
    741     ULONG TransitionFaults;
    742     ULONG CacheTransitionFaults;
    743     ULONG DemandZeroFaults;
    744     ULONG PagesRead;
    745     ULONG PageReadIos;
    746     ULONG CacheReads;
    747     ULONG CacheIos;
    748     ULONG PagefilePagesWritten;
    749     ULONG PagefilePageWriteIos;
    750     ULONG MappedFilePagesWritten;
    751     ULONG MappedFilePageWriteIos;
    752     ULONG PagedPoolUsage;
    753     ULONG NonPagedPoolUsage;
    754     ULONG PagedPoolAllocs;
    755     ULONG PagedPoolFrees;
    756     ULONG NonPagedPoolAllocs;
    757     ULONG NonPagedPoolFrees;
    758     ULONG TotalFreeSystemPtes;
    759     ULONG SystemCodePage;
    760     ULONG TotalSystemDriverPages;
    761     ULONG TotalSystemCodePages;
    762     ULONG SmallNonPagedLookasideListAllocateHits;
    763     ULONG SmallPagedLookasideListAllocateHits;
    764     ULONG Reserved3;
    765     ULONG MmSystemCachePage;
    766     ULONG PagedPoolPage;
    767     ULONG SystemDriverPage;
    768     ULONG FastReadNoWait;
    769     ULONG FastReadWait;
    770     ULONG FastReadResourceMiss;
    771     ULONG FastReadNotPossible;
    772     ULONG FastMdlReadNoWait;
    773     ULONG FastMdlReadWait;
    774     ULONG FastMdlReadResourceMiss;
    775     ULONG FastMdlReadNotPossible;
    776     ULONG MapDataNoWait;
    777     ULONG MapDataWait;
    778     ULONG MapDataNoWaitMiss;
    779     ULONG MapDataWaitMiss;
    780     ULONG PinMappedDataCount;
    781     ULONG PinReadNoWait;
    782     ULONG PinReadWait;
    783     ULONG PinReadNoWaitMiss;
    784     ULONG PinReadWaitMiss;
    785     ULONG CopyReadNoWait;
    786     ULONG CopyReadWait;
    787     ULONG CopyReadNoWaitMiss;
    788     ULONG CopyReadWaitMiss;
    789     ULONG MdlReadNoWait;
    790     ULONG MdlReadWait;
    791     ULONG MdlReadNoWaitMiss;
    792     ULONG MdlReadWaitMiss;
    793     ULONG ReadAheadIos;
    794     ULONG LazyWriteIos;
    795     ULONG LazyWritePages;
    796     ULONG DataFlushes;
    797     ULONG DataPages;
    798     ULONG ContextSwitches;
    799     ULONG FirstLevelTbFills;
    800     ULONG SecondLevelTbFills;
    801     ULONG SystemCalls;
    802   } SYSTEM_PERFORMANCE_INFORMATION, *PSYSTEM_PERFORMANCE_INFORMATION;
    803 
    804   typedef struct _SYSTEM_EXCEPTION_INFORMATION {
    805     BYTE Reserved1[16];
    806   } SYSTEM_EXCEPTION_INFORMATION,*PSYSTEM_EXCEPTION_INFORMATION;
    807 
    808   typedef struct _SYSTEM_LOOKASIDE_INFORMATION {
    809     BYTE Reserved1[32];
    810   } SYSTEM_LOOKASIDE_INFORMATION,*PSYSTEM_LOOKASIDE_INFORMATION;
    811 
    812   typedef struct _SYSTEM_INTERRUPT_INFORMATION {
    813     BYTE Reserved1[24];
    814   } SYSTEM_INTERRUPT_INFORMATION,*PSYSTEM_INTERRUPT_INFORMATION;
    815 
    816   typedef struct _SYSTEM_HANDLE_ENTRY {
    817     ULONG OwnerPid;
    818     BYTE ObjectType;
    819     BYTE HandleFlags;
    820     USHORT HandleValue;
    821     PVOID ObjectPointer;
    822     ULONG AccessMask;
    823   } SYSTEM_HANDLE_ENTRY, *PSYSTEM_HANDLE_ENTRY;
    824 
    825   typedef struct _SYSTEM_HANDLE_INFORMATION {
    826     ULONG Count;
    827     SYSTEM_HANDLE_ENTRY Handle[1];
    828   } SYSTEM_HANDLE_INFORMATION, *PSYSTEM_HANDLE_INFORMATION;
    829 
    830   typedef struct _SYSTEM_PAGEFILE_INFORMATION {
    831     ULONG NextEntryOffset;
    832     ULONG CurrentSize;
    833     ULONG TotalUsed;
    834     ULONG PeakUsed;
    835     UNICODE_STRING FileName;
    836   } SYSTEM_PAGEFILE_INFORMATION, *PSYSTEM_PAGEFILE_INFORMATION;
    837 
    838   typedef enum _PROCESSINFOCLASS {
    839     ProcessBasicInformation,
    840     ProcessQuotaLimits,
    841     ProcessIoCounters,
    842     ProcessVmCounters,
    843     ProcessTimes,
    844     ProcessBasePriority,
    845     ProcessRaisePriority,
    846     ProcessDebugPort,
    847     ProcessExceptionPort,
    848     ProcessAccessToken,
    849     ProcessLdtInformation,
    850     ProcessLdtSize,
    851     ProcessDefaultHardErrorMode,
    852     ProcessIoPortHandlers,
    853     ProcessPooledUsageAndLimits,
    854     ProcessWorkingSetWatch,
    855     ProcessUserModeIOPL,
    856     ProcessEnableAlignmentFaultFixup,
    857     ProcessPriorityClass,
    858     ProcessWx86Information,
    859     ProcessHandleCount,
    860     ProcessAffinityMask,
    861     ProcessPriorityBoost,
    862     ProcessDeviceMap,
    863     ProcessSessionInformation,
    864     ProcessForegroundInformation,
    865     ProcessWow64Information,
    866     ProcessImageFileName,
    867     ProcessLUIDDeviceMapsEnabled,
    868     ProcessBreakOnTermination,
    869     ProcessDebugObjectHandle,
    870     ProcessDebugFlags,
    871     ProcessHandleTracing,
    872     ProcessIoPriority,
    873     ProcessExecuteFlags,
    874     ProcessTlsInformation,
    875     ProcessCookie,
    876     ProcessImageInformation,
    877     ProcessCycleTime,
    878     ProcessPagePriority,
    879     ProcessInstrumentationCallback,
    880     ProcessThreadStackAllocation,
    881     ProcessWorkingSetWatchEx,
    882     ProcessImageFileNameWin32,
    883     ProcessImageFileMapping,
    884     ProcessAffinityUpdateMode,
    885     ProcessMemoryAllocationMode,
    886     ProcessGroupInformation,
    887     ProcessTokenVirtualizationEnabled,
    888     ProcessConsoleHostProcess,
    889     ProcessWindowInformation,
    890     MaxProcessInfoClass
    891   } PROCESSINFOCLASS;
    892 
    893   typedef enum _THREADINFOCLASS {
    894      ThreadBasicInformation,
    895      ThreadTimes,
    896      ThreadPriority,
    897      ThreadBasePriority,
    898      ThreadAffinityMask,
    899      ThreadImpersonationToken,
    900      ThreadDescriptorTableEntry,
    901      ThreadEnableAlignmentFaultFixup,
    902      ThreadEventPair,
    903      ThreadQuerySetWin32StartAddress,
    904      ThreadZeroTlsCell,
    905      ThreadPerformanceCount,
    906      ThreadAmILastThread,
    907      ThreadIdealProcessor,
    908      ThreadPriorityBoost,
    909      ThreadSetTlsArrayAddress,
    910      ThreadIsIoPending,
    911      ThreadHideFromDebugger
    912   } THREADINFOCLASS;
    913 
    914   typedef enum _SYSTEM_INFORMATION_CLASS {
    915     SystemBasicInformation = 0,
    916     SystemProcessorInformation = 1,
    917     SystemPerformanceInformation = 2,
    918     SystemTimeOfDayInformation = 3,
    919     SystemProcessInformation = 5,
    920     SystemProcessorPerformanceInformation = 8,
    921     SystemHandleInformation = 16,
    922     SystemPagefileInformation = 18,
    923     SystemInterruptInformation = 23,
    924     SystemExceptionInformation = 33,
    925     SystemRegistryQuotaInformation = 37,
    926     SystemLookasideInformation = 45
    927   } SYSTEM_INFORMATION_CLASS;
    928 
    929   typedef enum _OBJECT_INFORMATION_CLASS {
    930     ObjectBasicInformation,
    931     ObjectNameInformation,
    932     ObjectTypeInformation,
    933     ObjectAllInformation,
    934     ObjectDataInformation
    935  } OBJECT_INFORMATION_CLASS, *POBJECT_INFORMATION_CLASS;
    936 
    937 #define INTERNAL_TS_ACTIVE_CONSOLE_ID (*((volatile ULONG*)(0x7ffe02d8)))
    938 
    939 #define RtlMoveMemory(Destination,Source,Length) memmove((Destination),(Source),(Length))
    940 #define RtlFillMemory(Destination,Length,Fill) memset((Destination),(Fill),(Length))
    941 #define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length))
    942 
    943   NTSTATUS NTAPI NtClose(HANDLE Handle);
    944   NTSTATUS NTAPI NtCreateFile(PHANDLE FileHandle,ACCESS_MASK DesiredAccess,POBJECT_ATTRIBUTES ObjectAttributes,PIO_STATUS_BLOCK IoStatusBlock,PLARGE_INTEGER AllocationSize,ULONG FileAttributes,ULONG ShareAccess,ULONG CreateDisposition,ULONG CreateOptions,PVOID EaBuffer,ULONG EaLength);
    945   NTSTATUS NTAPI NtOpenFile(PHANDLE FileHandle,ACCESS_MASK DesiredAccess,POBJECT_ATTRIBUTES ObjectAttributes,PIO_STATUS_BLOCK IoStatusBlock,ULONG ShareAccess,ULONG OpenOptions);
    946   NTSTATUS NTAPI NtFsControlFile(HANDLE FileHandle,HANDLE Event,PIO_APC_ROUTINE ApcRoutine,PVOID ApcContext,PIO_STATUS_BLOCK IoStatusBlock,ULONG IoControlCode,PVOID InputBuffer,ULONG InputBufferLength,PVOID OutputBuffer,ULONG OutputBufferLength);
    947   NTSTATUS NTAPI NtDeviceIoControlFile(HANDLE FileHandle,HANDLE Event,PIO_APC_ROUTINE ApcRoutine,PVOID ApcContext,PIO_STATUS_BLOCK IoStatusBlock,ULONG IoControlCode,PVOID InputBuffer,ULONG InputBufferLength,PVOID OutputBuffer,ULONG OutputBufferLength);
    948   NTSTATUS NTAPI NtWaitForSingleObject(HANDLE Handle,BOOLEAN Alertable,PLARGE_INTEGER Timeout);
    949   BOOLEAN NTAPI RtlIsNameLegalDOS8Dot3(PUNICODE_STRING Name,POEM_STRING OemName,PBOOLEAN NameContainsSpaces);
    950   ULONG NTAPI RtlNtStatusToDosError (NTSTATUS Status);
    951   NTSTATUS NTAPI NtQueryInformationProcess(HANDLE ProcessHandle,PROCESSINFOCLASS ProcessInformationClass,PVOID ProcessInformation,ULONG ProcessInformationLength,PULONG ReturnLength);
    952   NTSTATUS NTAPI NtQueryInformationThread(HANDLE ThreadHandle,THREADINFOCLASS ThreadInformationClass,PVOID ThreadInformation,ULONG ThreadInformationLength,PULONG ReturnLength);
    953   NTSTATUS NTAPI NtQueryInformationFile(HANDLE hFile,PIO_STATUS_BLOCK io,PVOID ptr,ULONG len,FILE_INFORMATION_CLASS FileInformationClass);
    954   NTSTATUS NTAPI NtQueryObject(HANDLE Handle,OBJECT_INFORMATION_CLASS ObjectInformationClass,PVOID ObjectInformation,ULONG ObjectInformationLength,PULONG ReturnLength);
    955   NTSTATUS NTAPI NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass,PVOID SystemInformation,ULONG SystemInformationLength,PULONG ReturnLength);
    956   NTSTATUS NTAPI NtQuerySystemTime(PLARGE_INTEGER SystemTime);
    957   NTSTATUS NTAPI NtQueryVolumeInformationFile(HANDLE hFile,PIO_STATUS_BLOCK io,PVOID ptr,ULONG len,FS_INFORMATION_CLASS FsInformationClass);
    958   NTSTATUS NTAPI NtSetInformationFile(HANDLE hFile,PIO_STATUS_BLOCK io,PVOID ptr,ULONG len,FILE_INFORMATION_CLASS FileInformationClass);
    959   NTSTATUS NTAPI NtSetInformationProcess(HANDLE ProcessHandle, PROCESSINFOCLASS ProcessInformationClass, PVOID ProcessInformation, ULONG ProcessInformationLength);
    960   NTSTATUS NTAPI NtSetVolumeInformationFile(HANDLE hFile,PIO_STATUS_BLOCK io,PVOID ptr,ULONG len,FILE_INFORMATION_CLASS FileInformationClass);
    961   NTSTATUS NTAPI RtlLocalTimeToSystemTime(PLARGE_INTEGER LocalTime,PLARGE_INTEGER SystemTime);
    962   BOOLEAN NTAPI RtlTimeToSecondsSince1970(PLARGE_INTEGER Time,PULONG ElapsedSeconds);
    963   VOID NTAPI RtlFreeAnsiString(PANSI_STRING AnsiString);
    964   VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString);
    965   VOID NTAPI RtlFreeOemString(POEM_STRING OemString);
    966   VOID NTAPI RtlInitString (PSTRING DestinationString,PCSZ SourceString);
    967   VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString,PCSZ SourceString);
    968   VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString,PCWSTR SourceString);
    969   NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString,PCANSI_STRING SourceString,BOOLEAN AllocateDestinationString);
    970   NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString,PCUNICODE_STRING SourceString,BOOLEAN AllocateDestinationString);
    971   NTSTATUS NTAPI RtlUnicodeStringToOemString(POEM_STRING DestinationString,PCUNICODE_STRING SourceString,BOOLEAN AllocateDestinationString);
    972   NTSTATUS NTAPI RtlUnicodeToMultiByteSize(PULONG BytesInMultiByteString,PWCH UnicodeString,ULONG BytesInUnicodeString);
    973   NTSTATUS NTAPI RtlCharToInteger (PCSZ String,ULONG Base,PULONG Value);
    974   NTSTATUS NTAPI RtlConvertSidToUnicodeString(PUNICODE_STRING UnicodeString,PSID Sid,BOOLEAN AllocateDestinationString);
    975   ULONG NTAPI RtlUniform(PULONG Seed);
    976   VOID NTAPI RtlUnwind (PVOID TargetFrame,PVOID TargetIp,PEXCEPTION_RECORD ExceptionRecord,PVOID ReturnValue);
    977   BOOL NTAPI RtlDosPathNameToNtPathName_U(PCWSTR DosPathName, PUNICODE_STRING NtPathName, PCWSTR *NtFileNamePart, VOID *DirectoryInfo);
    978   BOOLEAN NTAPI RtlPrefixUnicodeString(PCUNICODE_STRING String1, PCUNICODE_STRING String2, BOOLEAN CaseInSensitive);
    979   BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(PUNICODE_STRING target, LPCSTR src);
    980 #ifdef __ia64__
    981   VOID RtlUnwind2(FRAME_POINTERS TargetFrame,PVOID TargetIp,PEXCEPTION_RECORD ExceptionRecord,PVOID ReturnValue,PCONTEXT ContextRecord);
    982   VOID RtlUnwindEx(FRAME_POINTERS TargetFrame,PVOID TargetIp,PEXCEPTION_RECORD ExceptionRecord,PVOID ReturnValue,PCONTEXT ContextRecord,PUNWIND_HISTORY_TABLE HistoryTable);
    983 #endif
    984 
    985   typedef NTSTATUS (NTAPI *PRTL_HEAP_COMMIT_ROUTINE) (PVOID Base, PVOID *CommitAddress, PSIZE_T CommitSize);
    986 
    987   typedef struct _RTL_HEAP_PARAMETERS {
    988     ULONG Length;
    989     SIZE_T SegmentReserve;
    990     SIZE_T SegmentCommit;
    991     SIZE_T DeCommitFreeBlockThreshold;
    992     SIZE_T DeCommitTotalFreeThreshold;
    993     SIZE_T MaximumAllocationSize;
    994     SIZE_T VirtualMemoryThreshold;
    995     SIZE_T InitialCommit;
    996     SIZE_T InitialReserve;
    997     PRTL_HEAP_COMMIT_ROUTINE CommitRoutine;
    998     SIZE_T Reserved[ 2 ];
    999   } RTL_HEAP_PARAMETERS, *PRTL_HEAP_PARAMETERS;
   1000 
   1001   BOOLEAN NTAPI RtlFreeHeap(PVOID HeapHandle, ULONG Flags, PVOID HeapBase);
   1002   PVOID NTAPI RtlAllocateHeap(PVOID HeapHandle, ULONG Flags, SIZE_T Size);
   1003   PVOID NTAPI RtlCreateHeap(ULONG Flags, PVOID HeapBase, SIZE_T ReserveSize, SIZE_T CommitSize, PVOID Lock, PRTL_HEAP_PARAMETERS Parameters);
   1004   PVOID NTAPI RtlDestroyHeap(PVOID HeapHandle);
   1005 
   1006 #define LOGONID_CURRENT ((ULONG)-1)
   1007 #define SERVERNAME_CURRENT ((HANDLE)NULL)
   1008 
   1009   typedef enum _WINSTATIONINFOCLASS {
   1010     WinStationInformation = 8
   1011   } WINSTATIONINFOCLASS;
   1012 
   1013   typedef struct _WINSTATIONINFORMATIONW {
   1014     BYTE Reserved2[70];
   1015     ULONG LogonId;
   1016     BYTE Reserved3[1140];
   1017   } WINSTATIONINFORMATIONW,*PWINSTATIONINFORMATIONW;
   1018 
   1019   typedef BOOLEAN (NTAPI *PWINSTATIONQUERYINFORMATIONW)(HANDLE,ULONG,WINSTATIONINFOCLASS,PVOID,ULONG,PULONG);
   1020 
   1021 #ifdef __cplusplus
   1022 }
   1023 #endif
   1024 
   1025 #endif
   1026 
   1027