1c2c66affSColin Finck /*++ NDK Version: 0095 2c2c66affSColin Finck 3c2c66affSColin Finck Copyright (c) Alex Ionescu. All rights reserved. 4c2c66affSColin Finck 5c2c66affSColin Finck Header Name: 6c2c66affSColin Finck 7c2c66affSColin Finck umtypes.h 8c2c66affSColin Finck 9c2c66affSColin Finck Abstract: 10c2c66affSColin Finck 11c2c66affSColin Finck Type definitions for the basic native types. 12c2c66affSColin Finck 13c2c66affSColin Finck Author: 14c2c66affSColin Finck 15c2c66affSColin Finck Alex Ionescu (alex.ionescu@reactos.com) 06-Oct-2004 16c2c66affSColin Finck 17c2c66affSColin Finck --*/ 18c2c66affSColin Finck 19c2c66affSColin Finck #if !defined(_NTDEF_) && !defined(_NTDEF_H) 20c2c66affSColin Finck #define _NTDEF_ 21c2c66affSColin Finck #define _NTDEF_H 22c2c66affSColin Finck 23c2c66affSColin Finck // 24c2c66affSColin Finck // Use dummy macros, if SAL 2 is not available 25c2c66affSColin Finck // 26c2c66affSColin Finck #include <sal.h> 27c2c66affSColin Finck #if (_SAL_VERSION < 20) 28c2c66affSColin Finck #include <no_sal2.h> 29c2c66affSColin Finck #endif 30c2c66affSColin Finck 31c2c66affSColin Finck // 32c2c66affSColin Finck // Don't use the SDK status values 33c2c66affSColin Finck // 34c2c66affSColin Finck #ifndef WIN32_NO_STATUS 35c2c66affSColin Finck #define WIN32_NO_STATUS 36c2c66affSColin Finck #endif 37c2c66affSColin Finck 38c2c66affSColin Finck // 39c2c66affSColin Finck // Let the NDK know we're in Application Mode 40c2c66affSColin Finck // 41c2c66affSColin Finck #define NTOS_MODE_USER 42c2c66affSColin Finck 43c2c66affSColin Finck // 44c2c66affSColin Finck // Dependencies 45c2c66affSColin Finck // 46c2c66affSColin Finck #include <windef.h> 47c2c66affSColin Finck #undef WIN32_NO_STATUS 48c2c66affSColin Finck #include <ntstatus.h> 49c2c66affSColin Finck #include <winioctl.h> 50c2c66affSColin Finck #include <ntnls.h> 51c2c66affSColin Finck 52c2c66affSColin Finck // 53c2c66affSColin Finck // Compiler Definitions 54c2c66affSColin Finck // 55c2c66affSColin Finck #ifndef _MANAGED 56c2c66affSColin Finck #if defined(_M_IX86) 57c2c66affSColin Finck #ifndef FASTCALL 58c2c66affSColin Finck #define FASTCALL __fastcall 59c2c66affSColin Finck #endif 60c2c66affSColin Finck #else 61c2c66affSColin Finck #define FASTCALL 62c2c66affSColin Finck #endif 63c2c66affSColin Finck #else 64c2c66affSColin Finck #define FASTCALL NTAPI 65c2c66affSColin Finck #endif 66c2c66affSColin Finck 67c2c66affSColin Finck #if !defined(_M_CEE_PURE) 68c2c66affSColin Finck #define NTAPI_INLINE NTAPI 69c2c66affSColin Finck #else 70c2c66affSColin Finck #define NTAPI_INLINE 71c2c66affSColin Finck #endif 72c2c66affSColin Finck 73c2c66affSColin Finck // 74c2c66affSColin Finck // Alignment Macros 75c2c66affSColin Finck // 763b78272dSTimo Kreuzer #define ALIGN_DOWN_BY(size, align) \ 773b78272dSTimo Kreuzer ((ULONG_PTR)(size) & ~((ULONG_PTR)(align) - 1)) 78c2c66affSColin Finck 793b78272dSTimo Kreuzer #define ALIGN_UP_BY(size, align) \ 803b78272dSTimo Kreuzer (ALIGN_DOWN_BY(((ULONG_PTR)(size) + align - 1), align)) 81c2c66affSColin Finck 823b78272dSTimo Kreuzer #define ALIGN_DOWN_POINTER_BY(ptr, align) \ 833b78272dSTimo Kreuzer ((PVOID)ALIGN_DOWN_BY(ptr, align)) 84c2c66affSColin Finck 853b78272dSTimo Kreuzer #define ALIGN_UP_POINTER_BY(ptr, align) \ 863b78272dSTimo Kreuzer ((PVOID)ALIGN_UP_BY(ptr, align)) 873b78272dSTimo Kreuzer 883b78272dSTimo Kreuzer #define ALIGN_DOWN(size, type) \ 893b78272dSTimo Kreuzer ALIGN_DOWN_BY(size, sizeof(type)) 903b78272dSTimo Kreuzer 913b78272dSTimo Kreuzer #define ALIGN_UP(size, type) \ 923b78272dSTimo Kreuzer ALIGN_UP_BY(size, sizeof(type)) 933b78272dSTimo Kreuzer 943b78272dSTimo Kreuzer #define ALIGN_DOWN_POINTER(ptr, type) \ 953b78272dSTimo Kreuzer ALIGN_DOWN_POINTER_BY(ptr, sizeof(type)) 963b78272dSTimo Kreuzer 973b78272dSTimo Kreuzer #define ALIGN_UP_POINTER(ptr, type) \ 983b78272dSTimo Kreuzer ALIGN_UP_POINTER_BY(ptr, sizeof(type)) 99c2c66affSColin Finck 100c2c66affSColin Finck // 101c2c66affSColin Finck // Native API Return Value Macros 102c2c66affSColin Finck // 103c2c66affSColin Finck #define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0) 104c2c66affSColin Finck #define NT_INFORMATION(Status) ((((ULONG)(Status)) >> 30) == 1) 105c2c66affSColin Finck #define NT_WARNING(Status) ((((ULONG)(Status)) >> 30) == 2) 106c2c66affSColin Finck #define NT_ERROR(Status) ((((ULONG)(Status)) >> 30) == 3) 107c2c66affSColin Finck 108c2c66affSColin Finck // 109c2c66affSColin Finck // Limits 110c2c66affSColin Finck // 111*a3763c61STimo Kreuzer #define MINCHAR 0x80 112*a3763c61STimo Kreuzer #define MAXCHAR 0x7f 113*a3763c61STimo Kreuzer #define MINSHORT 0x8000 114*a3763c61STimo Kreuzer #define MAXSHORT 0x7fff 115*a3763c61STimo Kreuzer #define MINLONG 0x80000000 116*a3763c61STimo Kreuzer #define MAXLONG 0x7fffffff 117c2c66affSColin Finck #define MAXUCHAR 0xff 118c2c66affSColin Finck #define MAXUSHORT 0xffff 119c2c66affSColin Finck #define MAXULONG 0xffffffff 120c2c66affSColin Finck 121c2c66affSColin Finck // 122c2c66affSColin Finck // Basic Types that aren't defined in User-Mode Headers 123c2c66affSColin Finck // 124c2c66affSColin Finck typedef CONST int CINT; 125c2c66affSColin Finck typedef CONST char *PCSZ; 126c2c66affSColin Finck typedef ULONG CLONG; 127c2c66affSColin Finck typedef short CSHORT; 128c2c66affSColin Finck typedef CSHORT *PCSHORT; 129c2c66affSColin Finck typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS; 130c2c66affSColin Finck typedef LONG KPRIORITY; 131c2c66affSColin Finck 132c2c66affSColin Finck // 133c2c66affSColin Finck // Basic NT Types 134c2c66affSColin Finck // 135c2c66affSColin Finck #if !defined(_NTSECAPI_H) && !defined(_SUBAUTH_H) && !defined(_NTSECAPI_) 136c2c66affSColin Finck 137c2c66affSColin Finck #if !defined(__BCRYPT_H__) && !defined(__WINE_BCRYPT_H) 138c2c66affSColin Finck typedef _Return_type_success_(return >= 0) long NTSTATUS, *PNTSTATUS; 139c2c66affSColin Finck #endif 140c2c66affSColin Finck 141c2c66affSColin Finck typedef struct _UNICODE_STRING 142c2c66affSColin Finck { 143c2c66affSColin Finck USHORT Length; 144c2c66affSColin Finck USHORT MaximumLength; 145c2c66affSColin Finck PWSTR Buffer; 146c2c66affSColin Finck } UNICODE_STRING, *PUNICODE_STRING; 147c2c66affSColin Finck 148c2c66affSColin Finck typedef struct _STRING 149c2c66affSColin Finck { 150c2c66affSColin Finck USHORT Length; 151c2c66affSColin Finck USHORT MaximumLength; 152c2c66affSColin Finck PCHAR Buffer; 153c2c66affSColin Finck } STRING, *PSTRING; 154c2c66affSColin Finck 155c2c66affSColin Finck typedef struct _CSTRING 156c2c66affSColin Finck { 157c2c66affSColin Finck USHORT Length; 158c2c66affSColin Finck USHORT MaximumLength; 159c2c66affSColin Finck CONST CHAR *Buffer; 160c2c66affSColin Finck } CSTRING, *PCSTRING; 161c2c66affSColin Finck 162c2c66affSColin Finck #endif 163c2c66affSColin Finck 164c2c66affSColin Finck typedef struct _STRING32 { 165c2c66affSColin Finck USHORT Length; 166c2c66affSColin Finck USHORT MaximumLength; 167c2c66affSColin Finck ULONG Buffer; 168c2c66affSColin Finck } STRING32, *PSTRING32, 169c2c66affSColin Finck UNICODE_STRING32, *PUNICODE_STRING32, 170c2c66affSColin Finck ANSI_STRING32, *PANSI_STRING32; 171c2c66affSColin Finck 172c2c66affSColin Finck typedef struct _STRING64 { 173c2c66affSColin Finck USHORT Length; 174c2c66affSColin Finck USHORT MaximumLength; 175c2c66affSColin Finck ULONGLONG Buffer; 176c2c66affSColin Finck } STRING64, *PSTRING64, 177c2c66affSColin Finck UNICODE_STRING64, *PUNICODE_STRING64, 178c2c66affSColin Finck ANSI_STRING64, *PANSI_STRING64; 179c2c66affSColin Finck 180c2c66affSColin Finck 181c2c66affSColin Finck typedef struct _OBJECT_ATTRIBUTES 182c2c66affSColin Finck { 183c2c66affSColin Finck ULONG Length; 184c2c66affSColin Finck HANDLE RootDirectory; 185c2c66affSColin Finck PUNICODE_STRING ObjectName; 186c2c66affSColin Finck ULONG Attributes; 187c2c66affSColin Finck PVOID SecurityDescriptor; 188c2c66affSColin Finck PVOID SecurityQualityOfService; 189c2c66affSColin Finck } OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES; 190c2c66affSColin Finck 191c2c66affSColin Finck // 192c2c66affSColin Finck // ClientID Structure 193c2c66affSColin Finck // 194c2c66affSColin Finck typedef struct _CLIENT_ID 195c2c66affSColin Finck { 196c2c66affSColin Finck HANDLE UniqueProcess; 197c2c66affSColin Finck HANDLE UniqueThread; 198c2c66affSColin Finck } CLIENT_ID, *PCLIENT_ID; 199c2c66affSColin Finck 200c2c66affSColin Finck typedef const UNICODE_STRING* PCUNICODE_STRING; 201c2c66affSColin Finck typedef STRING ANSI_STRING; 202c2c66affSColin Finck typedef PSTRING PANSI_STRING; 203c2c66affSColin Finck typedef STRING OEM_STRING; 204c2c66affSColin Finck typedef PSTRING POEM_STRING; 205c2c66affSColin Finck typedef CONST STRING* PCOEM_STRING; 206c2c66affSColin Finck typedef STRING CANSI_STRING; 207c2c66affSColin Finck typedef PSTRING PCANSI_STRING; 208c2c66affSColin Finck 209c2c66affSColin Finck #endif 210