Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1905 lines
51 KiB

  1. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. ntdef.h
  5. Abstract:
  6. Type definitions for the basic types.
  7. Author:
  8. Mark Lucovsky (markl) 02-Feb-1989
  9. Revision History:
  10. --*/
  11. #ifndef _NTDEF_
  12. #define _NTDEF_
  13. #if _MSC_VER > 1000
  14. #pragma once
  15. #endif
  16. #include <ctype.h> // winnt ntndis
  17. // begin_ntminiport begin_ntndis begin_ntminitape
  18. #ifndef IN
  19. #define IN
  20. #endif
  21. #ifndef OUT
  22. #define OUT
  23. #endif
  24. #ifndef OPTIONAL
  25. #define OPTIONAL
  26. #endif
  27. #ifndef NOTHING
  28. #define NOTHING
  29. #endif
  30. #ifndef CRITICAL
  31. #define CRITICAL
  32. #endif
  33. #ifndef ANYSIZE_ARRAY
  34. #define ANYSIZE_ARRAY 1 // winnt
  35. #endif
  36. // begin_winnt
  37. #if defined(_M_MRX000) && !(defined(MIDL_PASS) || defined(RC_INVOKED)) && defined(ENABLE_RESTRICTED)
  38. #define RESTRICTED_POINTER __restrict
  39. #else
  40. #define RESTRICTED_POINTER
  41. #endif
  42. #if defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC) || defined(_M_IA64) || defined(_M_AMD64)
  43. #define UNALIGNED __unaligned
  44. #if defined(_WIN64)
  45. #define UNALIGNED64 __unaligned
  46. #else
  47. #define UNALIGNED64
  48. #endif
  49. #else
  50. #define UNALIGNED
  51. #define UNALIGNED64
  52. #endif
  53. #if defined(_WIN64) || defined(_M_ALPHA)
  54. #define MAX_NATURAL_ALIGNMENT sizeof(ULONGLONG)
  55. #define MEMORY_ALLOCATION_ALIGNMENT 16
  56. #else
  57. #define MAX_NATURAL_ALIGNMENT sizeof(ULONG)
  58. #define MEMORY_ALLOCATION_ALIGNMENT 8
  59. #endif
  60. //
  61. // TYPE_ALIGNMENT will return the alignment requirements of a given type for
  62. // the current platform.
  63. //
  64. #ifdef __cplusplus
  65. #if _MSC_VER >= 1300
  66. #define TYPE_ALIGNMENT( t ) __alignof(t)
  67. #endif
  68. #else
  69. #define TYPE_ALIGNMENT( t ) \
  70. FIELD_OFFSET( struct { char x; t test; }, test )
  71. #endif
  72. #if defined(_WIN64)
  73. #define PROBE_ALIGNMENT( _s ) (TYPE_ALIGNMENT( _s ) > TYPE_ALIGNMENT( ULONG ) ? \
  74. TYPE_ALIGNMENT( _s ) : TYPE_ALIGNMENT( ULONG ))
  75. #define PROBE_ALIGNMENT32( _s ) TYPE_ALIGNMENT( ULONG )
  76. #else
  77. #define PROBE_ALIGNMENT( _s ) TYPE_ALIGNMENT( ULONG )
  78. #endif
  79. //
  80. // C_ASSERT() can be used to perform many compile-time assertions:
  81. // type sizes, field offsets, etc.
  82. //
  83. // An assertion failure results in error C2118: negative subscript.
  84. //
  85. #define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
  86. #if !defined(_MAC) && (defined(_M_MRX000) || defined(_M_AMD64) || defined(_M_IA64)) && (_MSC_VER >= 1100) && !(defined(MIDL_PASS) || defined(RC_INVOKED))
  87. #define POINTER_64 __ptr64
  88. typedef unsigned __int64 POINTER_64_INT;
  89. #if defined(_WIN64)
  90. #define POINTER_32 __ptr32
  91. #else
  92. #define POINTER_32
  93. #endif
  94. #else
  95. #if defined(_MAC) && defined(_MAC_INT_64)
  96. #define POINTER_64 __ptr64
  97. typedef unsigned __int64 POINTER_64_INT;
  98. #else
  99. #define POINTER_64
  100. typedef unsigned long POINTER_64_INT;
  101. #endif
  102. #define POINTER_32
  103. #endif
  104. #if defined(_IA64_) || defined(_AMD64_)
  105. #define FIRMWARE_PTR
  106. #else
  107. #define FIRMWARE_PTR POINTER_32
  108. #endif
  109. #include <basetsd.h>
  110. // end_winnt
  111. #ifndef CONST
  112. #define CONST const
  113. #endif
  114. // begin_winnt
  115. #if (defined(_M_IX86) || defined(_M_IA64) || defined(_M_AMD64)) && !defined(MIDL_PASS)
  116. #define DECLSPEC_IMPORT __declspec(dllimport)
  117. #else
  118. #define DECLSPEC_IMPORT
  119. #endif
  120. #ifndef DECLSPEC_NORETURN
  121. #if (_MSC_VER >= 1200) && !defined(MIDL_PASS)
  122. #define DECLSPEC_NORETURN __declspec(noreturn)
  123. #else
  124. #define DECLSPEC_NORETURN
  125. #endif
  126. #endif
  127. #ifndef DECLSPEC_ALIGN
  128. #if (_MSC_VER >= 1300) && !defined(MIDL_PASS)
  129. #define DECLSPEC_ALIGN(x) __declspec(align(x))
  130. #else
  131. #define DECLSPEC_ALIGN(x)
  132. #endif
  133. #endif
  134. #ifndef DECLSPEC_CACHEALIGN
  135. #define DECLSPEC_CACHEALIGN DECLSPEC_ALIGN(128)
  136. #endif
  137. #ifndef DECLSPEC_UUID
  138. #if (_MSC_VER >= 1100) && defined (__cplusplus)
  139. #define DECLSPEC_UUID(x) __declspec(uuid(x))
  140. #else
  141. #define DECLSPEC_UUID(x)
  142. #endif
  143. #endif
  144. #ifndef DECLSPEC_NOVTABLE
  145. #if (_MSC_VER >= 1100) && defined(__cplusplus)
  146. #define DECLSPEC_NOVTABLE __declspec(novtable)
  147. #else
  148. #define DECLSPEC_NOVTABLE
  149. #endif
  150. #endif
  151. #ifndef DECLSPEC_SELECTANY
  152. #if (_MSC_VER >= 1100)
  153. #define DECLSPEC_SELECTANY __declspec(selectany)
  154. #else
  155. #define DECLSPEC_SELECTANY
  156. #endif
  157. #endif
  158. #ifndef NOP_FUNCTION
  159. #if (_MSC_VER >= 1210)
  160. #define NOP_FUNCTION __noop
  161. #else
  162. #define NOP_FUNCTION (void)0
  163. #endif
  164. #endif
  165. #ifndef DECLSPEC_ADDRSAFE
  166. #if (_MSC_VER >= 1200) && (defined(_M_ALPHA) || defined(_M_AXP64))
  167. #define DECLSPEC_ADDRSAFE __declspec(address_safe)
  168. #else
  169. #define DECLSPEC_ADDRSAFE
  170. #endif
  171. #endif
  172. #ifndef DECLSPEC_NOINLINE
  173. #if (_MSC_VER >= 1300)
  174. #define DECLSPEC_NOINLINE __declspec(noinline)
  175. #else
  176. #define DECLSPEC_NOINLINE
  177. #endif
  178. #endif
  179. #ifndef FORCEINLINE
  180. #if (_MSC_VER >= 1200)
  181. #define FORCEINLINE __forceinline
  182. #else
  183. #define FORCEINLINE __inline
  184. #endif
  185. #endif
  186. #ifndef DECLSPEC_DEPRECATED
  187. #if (_MSC_VER >= 1300) && !defined(MIDL_PASS)
  188. #define DECLSPEC_DEPRECATED __declspec(deprecated)
  189. #define DEPRECATE_SUPPORTED
  190. #else
  191. #define DECLSPEC_DEPRECATED
  192. #undef DEPRECATE_SUPPORTED
  193. #endif
  194. #endif
  195. #ifdef DEPRECATE_DDK_FUNCTIONS
  196. #ifdef _NTDDK_
  197. #define DECLSPEC_DEPRECATED_DDK DECLSPEC_DEPRECATED
  198. #ifdef DEPRECATE_SUPPORTED
  199. #define PRAGMA_DEPRECATED_DDK 1
  200. #endif
  201. #else
  202. #define DECLSPEC_DEPRECATED_DDK
  203. #define PRAGMA_DEPRECATED_DDK 1
  204. #endif
  205. #else
  206. #define DECLSPEC_DEPRECATED_DDK
  207. #define PRAGMA_DEPRECATED_DDK 0
  208. #endif
  209. //
  210. // Void
  211. //
  212. typedef void *PVOID;
  213. typedef void * POINTER_64 PVOID64;
  214. // end_winnt
  215. #if defined(_M_IX86)
  216. #define FASTCALL _fastcall
  217. #else
  218. #define FASTCALL
  219. #endif
  220. // end_ntminiport end_ntndis end_ntminitape
  221. // begin_winnt begin_ntndis
  222. #if ((_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)) && !defined(_M_AMD64)
  223. #define NTAPI __stdcall
  224. #else
  225. #define _cdecl
  226. #define NTAPI
  227. #endif
  228. //
  229. // Define API decoration for direct importing system DLL references.
  230. //
  231. #if !defined(_NTSYSTEM_)
  232. #define NTSYSAPI DECLSPEC_IMPORT
  233. #define NTSYSCALLAPI DECLSPEC_IMPORT
  234. #else
  235. #define NTSYSAPI
  236. #if defined(_NTDLLBUILD_)
  237. #define NTSYSCALLAPI
  238. #else
  239. #define NTSYSCALLAPI DECLSPEC_ADDRSAFE
  240. #endif
  241. #endif
  242. // end_winnt end_ntndis
  243. // begin_winnt begin_ntminiport begin_ntndis begin_ntminitape
  244. //
  245. // Basics
  246. //
  247. #ifndef VOID
  248. #define VOID void
  249. typedef char CHAR;
  250. typedef short SHORT;
  251. typedef long LONG;
  252. #endif
  253. //
  254. // UNICODE (Wide Character) types
  255. //
  256. #ifndef _MAC
  257. typedef wchar_t WCHAR; // wc, 16-bit UNICODE character
  258. #else
  259. // some Macintosh compilers don't define wchar_t in a convenient location, or define it as a char
  260. typedef unsigned short WCHAR; // wc, 16-bit UNICODE character
  261. #endif
  262. typedef WCHAR *PWCHAR;
  263. typedef WCHAR *LPWCH, *PWCH;
  264. typedef CONST WCHAR *LPCWCH, *PCWCH;
  265. typedef WCHAR *NWPSTR;
  266. typedef WCHAR *LPWSTR, *PWSTR;
  267. typedef WCHAR UNALIGNED *LPUWSTR, *PUWSTR;
  268. typedef CONST WCHAR *LPCWSTR, *PCWSTR;
  269. typedef CONST WCHAR UNALIGNED *LPCUWSTR, *PCUWSTR;
  270. //
  271. // ANSI (Multi-byte Character) types
  272. //
  273. typedef CHAR *PCHAR;
  274. typedef CHAR *LPCH, *PCH;
  275. typedef CONST CHAR *LPCCH, *PCCH;
  276. typedef CHAR *NPSTR;
  277. typedef CHAR *LPSTR, *PSTR;
  278. typedef CONST CHAR *LPCSTR, *PCSTR;
  279. //
  280. // Neutral ANSI/UNICODE types and macros
  281. //
  282. #ifdef UNICODE // r_winnt
  283. #ifndef _TCHAR_DEFINED
  284. typedef WCHAR TCHAR, *PTCHAR;
  285. typedef WCHAR TUCHAR, *PTUCHAR;
  286. #define _TCHAR_DEFINED
  287. #endif /* !_TCHAR_DEFINED */
  288. typedef LPWSTR LPTCH, PTCH;
  289. typedef LPWSTR PTSTR, LPTSTR;
  290. typedef LPCWSTR PCTSTR, LPCTSTR;
  291. typedef LPUWSTR PUTSTR, LPUTSTR;
  292. typedef LPCUWSTR PCUTSTR, LPCUTSTR;
  293. typedef LPWSTR LP;
  294. #define __TEXT(quote) L##quote // r_winnt
  295. #else /* UNICODE */ // r_winnt
  296. #ifndef _TCHAR_DEFINED
  297. typedef char TCHAR, *PTCHAR;
  298. typedef unsigned char TUCHAR, *PTUCHAR;
  299. #define _TCHAR_DEFINED
  300. #endif /* !_TCHAR_DEFINED */
  301. typedef LPSTR LPTCH, PTCH;
  302. typedef LPSTR PTSTR, LPTSTR, PUTSTR, LPUTSTR;
  303. typedef LPCSTR PCTSTR, LPCTSTR, PCUTSTR, LPCUTSTR;
  304. #define __TEXT(quote) quote // r_winnt
  305. #endif /* UNICODE */ // r_winnt
  306. #define TEXT(quote) __TEXT(quote) // r_winnt
  307. // end_winnt
  308. typedef double DOUBLE;
  309. typedef struct _QUAD { // QUAD is for those times we want
  310. double DoNotUseThisField; // an 8 byte aligned 8 byte long structure
  311. } QUAD; // which is NOT really a floating point
  312. // number. Use DOUBLE if you want an FP
  313. // number.
  314. //
  315. // Pointer to Basics
  316. //
  317. typedef SHORT *PSHORT; // winnt
  318. typedef LONG *PLONG; // winnt
  319. typedef QUAD *PQUAD;
  320. //
  321. // Unsigned Basics
  322. //
  323. // Tell windef.h that some types are already defined.
  324. #define BASETYPES
  325. typedef unsigned char UCHAR;
  326. typedef unsigned short USHORT;
  327. typedef unsigned long ULONG;
  328. typedef QUAD UQUAD;
  329. //
  330. // Pointer to Unsigned Basics
  331. //
  332. typedef UCHAR *PUCHAR;
  333. typedef USHORT *PUSHORT;
  334. typedef ULONG *PULONG;
  335. typedef UQUAD *PUQUAD;
  336. //
  337. // Signed characters
  338. //
  339. typedef signed char SCHAR;
  340. typedef SCHAR *PSCHAR;
  341. #ifndef NO_STRICT
  342. #ifndef STRICT
  343. #define STRICT 1
  344. #endif
  345. #endif
  346. //
  347. // Handle to an Object
  348. //
  349. // begin_winnt
  350. #ifdef STRICT
  351. typedef void *HANDLE;
  352. #define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
  353. #else
  354. typedef PVOID HANDLE;
  355. #define DECLARE_HANDLE(name) typedef HANDLE name
  356. #endif
  357. typedef HANDLE *PHANDLE;
  358. //
  359. // Flag (bit) fields
  360. //
  361. typedef UCHAR FCHAR;
  362. typedef USHORT FSHORT;
  363. typedef ULONG FLONG;
  364. // Component Object Model defines, and macros
  365. #ifndef _HRESULT_DEFINED
  366. #define _HRESULT_DEFINED
  367. typedef LONG HRESULT;
  368. #endif // !_HRESULT_DEFINED
  369. #ifdef __cplusplus
  370. #define EXTERN_C extern "C"
  371. #else
  372. #define EXTERN_C extern
  373. #endif
  374. #if defined(_WIN32) || defined(_MPPC_)
  375. // Win32 doesn't support __export
  376. #ifdef _68K_
  377. #define STDMETHODCALLTYPE __cdecl
  378. #else
  379. #define STDMETHODCALLTYPE __stdcall
  380. #endif
  381. #define STDMETHODVCALLTYPE __cdecl
  382. #define STDAPICALLTYPE __stdcall
  383. #define STDAPIVCALLTYPE __cdecl
  384. #else
  385. #define STDMETHODCALLTYPE __export __stdcall
  386. #define STDMETHODVCALLTYPE __export __cdecl
  387. #define STDAPICALLTYPE __export __stdcall
  388. #define STDAPIVCALLTYPE __export __cdecl
  389. #endif
  390. #define STDAPI EXTERN_C HRESULT STDAPICALLTYPE
  391. #define STDAPI_(type) EXTERN_C type STDAPICALLTYPE
  392. #define STDMETHODIMP HRESULT STDMETHODCALLTYPE
  393. #define STDMETHODIMP_(type) type STDMETHODCALLTYPE
  394. // The 'V' versions allow Variable Argument lists.
  395. #define STDAPIV EXTERN_C HRESULT STDAPIVCALLTYPE
  396. #define STDAPIV_(type) EXTERN_C type STDAPIVCALLTYPE
  397. #define STDMETHODIMPV HRESULT STDMETHODVCALLTYPE
  398. #define STDMETHODIMPV_(type) type STDMETHODVCALLTYPE
  399. // end_winnt
  400. //
  401. // Low order two bits of a handle are ignored by the system and available
  402. // for use by application code as tag bits. The remaining bits are opaque
  403. // and used to store a serial number and table index.
  404. //
  405. #define OBJ_HANDLE_TAGBITS 0x00000003L
  406. //
  407. // Cardinal Data Types [0 - 2**N-2)
  408. //
  409. typedef char CCHAR; // winnt
  410. typedef short CSHORT;
  411. typedef ULONG CLONG;
  412. typedef CCHAR *PCCHAR;
  413. typedef CSHORT *PCSHORT;
  414. typedef CLONG *PCLONG;
  415. // end_ntminiport end_ntndis end_ntminitape
  416. //
  417. // NLS basics (Locale and Language Ids)
  418. //
  419. typedef ULONG LCID; // winnt
  420. typedef PULONG PLCID; // winnt
  421. typedef USHORT LANGID; // winnt
  422. //
  423. // Logical Data Type - These are 32-bit logical values.
  424. //
  425. typedef ULONG LOGICAL;
  426. typedef ULONG *PLOGICAL;
  427. // begin_ntndis begin_windbgkd
  428. //
  429. // NTSTATUS
  430. //
  431. typedef LONG NTSTATUS;
  432. /*lint -save -e624 */ // Don't complain about different typedefs.
  433. typedef NTSTATUS *PNTSTATUS;
  434. /*lint -restore */ // Resume checking for different typedefs.
  435. //
  436. // Status values are 32 bit values layed out as follows:
  437. //
  438. // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  439. // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  440. // +---+-+-------------------------+-------------------------------+
  441. // |Sev|C| Facility | Code |
  442. // +---+-+-------------------------+-------------------------------+
  443. //
  444. // where
  445. //
  446. // Sev - is the severity code
  447. //
  448. // 00 - Success
  449. // 01 - Informational
  450. // 10 - Warning
  451. // 11 - Error
  452. //
  453. // C - is the Customer code flag
  454. //
  455. // Facility - is the facility code
  456. //
  457. // Code - is the facility's status code
  458. //
  459. //
  460. // Generic test for success on any status value (non-negative numbers
  461. // indicate success).
  462. //
  463. #define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0)
  464. //
  465. // Generic test for information on any status value.
  466. //
  467. #define NT_INFORMATION(Status) ((ULONG)(Status) >> 30 == 1)
  468. //
  469. // Generic test for warning on any status value.
  470. //
  471. #define NT_WARNING(Status) ((ULONG)(Status) >> 30 == 2)
  472. //
  473. // Generic test for error on any status value.
  474. //
  475. #define NT_ERROR(Status) ((ULONG)(Status) >> 30 == 3)
  476. // end_windbgkd
  477. // begin_winnt
  478. #define APPLICATION_ERROR_MASK 0x20000000
  479. #define ERROR_SEVERITY_SUCCESS 0x00000000
  480. #define ERROR_SEVERITY_INFORMATIONAL 0x40000000
  481. #define ERROR_SEVERITY_WARNING 0x80000000
  482. #define ERROR_SEVERITY_ERROR 0xC0000000
  483. // end_winnt
  484. #ifndef __SECSTATUS_DEFINED__
  485. typedef long SECURITY_STATUS;
  486. #define __SECSTATUS_DEFINED__
  487. #endif
  488. // end_ntndis
  489. //
  490. // Large (64-bit) integer types and operations
  491. //
  492. #define TIME LARGE_INTEGER
  493. #define _TIME _LARGE_INTEGER
  494. #define PTIME PLARGE_INTEGER
  495. #define LowTime LowPart
  496. #define HighTime HighPart
  497. // begin_winnt
  498. //
  499. // _M_IX86 included so that EM CONTEXT structure compiles with
  500. // x86 programs. *** TBD should this be for all architectures?
  501. //
  502. //
  503. // 16 byte aligned type for 128 bit floats
  504. //
  505. //
  506. // For we define a 128 bit structure and use __declspec(align(16)) pragma to
  507. // align to 128 bits.
  508. //
  509. #if defined(_M_IA64) && !defined(MIDL_PASS)
  510. __declspec(align(16))
  511. #endif
  512. typedef struct _FLOAT128 {
  513. __int64 LowPart;
  514. __int64 HighPart;
  515. } FLOAT128;
  516. typedef FLOAT128 *PFLOAT128;
  517. // end_winnt
  518. // begin_winnt begin_ntminiport begin_ntndis begin_ntminitape
  519. //
  520. // __int64 is only supported by 2.0 and later midl.
  521. // __midl is set by the 2.0 midl and not by 1.0 midl.
  522. //
  523. #define _ULONGLONG_
  524. #if (!defined (_MAC) && (!defined(MIDL_PASS) || defined(__midl)) && (!defined(_M_IX86) || (defined(_INTEGRAL_MAX_BITS) && _INTEGRAL_MAX_BITS >= 64)))
  525. typedef __int64 LONGLONG;
  526. typedef unsigned __int64 ULONGLONG;
  527. #define MAXLONGLONG (0x7fffffffffffffff)
  528. #else
  529. #if defined(_MAC) && defined(_MAC_INT_64)
  530. typedef __int64 LONGLONG;
  531. typedef unsigned __int64 ULONGLONG;
  532. #define MAXLONGLONG (0x7fffffffffffffff)
  533. #else
  534. typedef double LONGLONG;
  535. typedef double ULONGLONG;
  536. #endif //_MAC and int64
  537. #endif
  538. typedef LONGLONG *PLONGLONG;
  539. typedef ULONGLONG *PULONGLONG;
  540. // Update Sequence Number
  541. typedef LONGLONG USN;
  542. #if defined(MIDL_PASS)
  543. typedef struct _LARGE_INTEGER {
  544. #else // MIDL_PASS
  545. typedef union _LARGE_INTEGER {
  546. struct {
  547. ULONG LowPart;
  548. LONG HighPart;
  549. };
  550. struct {
  551. ULONG LowPart;
  552. LONG HighPart;
  553. } u;
  554. #endif //MIDL_PASS
  555. LONGLONG QuadPart;
  556. } LARGE_INTEGER;
  557. typedef LARGE_INTEGER *PLARGE_INTEGER;
  558. #if defined(MIDL_PASS)
  559. typedef struct _ULARGE_INTEGER {
  560. #else // MIDL_PASS
  561. typedef union _ULARGE_INTEGER {
  562. struct {
  563. ULONG LowPart;
  564. ULONG HighPart;
  565. };
  566. struct {
  567. ULONG LowPart;
  568. ULONG HighPart;
  569. } u;
  570. #endif //MIDL_PASS
  571. ULONGLONG QuadPart;
  572. } ULARGE_INTEGER;
  573. typedef ULARGE_INTEGER *PULARGE_INTEGER;
  574. // end_ntminiport end_ntndis end_ntminitape
  575. //
  576. // Locally Unique Identifier
  577. //
  578. typedef struct _LUID {
  579. ULONG LowPart;
  580. LONG HighPart;
  581. } LUID, *PLUID;
  582. #define _DWORDLONG_
  583. typedef ULONGLONG DWORDLONG;
  584. typedef DWORDLONG *PDWORDLONG;
  585. // end_winnt
  586. // begin_ntminiport begin_ntndis
  587. //
  588. // Physical address.
  589. //
  590. typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS;
  591. // end_ntminiport end_ntndis
  592. // begin_winnt
  593. //
  594. // Define operations to logically shift an int64 by 0..31 bits and to multiply
  595. // 32-bits by 32-bits to form a 64-bit product.
  596. //
  597. #if defined(MIDL_PASS) || defined(RC_INVOKED)
  598. //
  599. // Midl does not understand inline assembler. Therefore, the Rtl functions
  600. // are used for shifts by 0.31 and multiplies of 32-bits times 32-bits to
  601. // form a 64-bit product.
  602. //
  603. #define Int32x32To64(a, b) ((LONGLONG)((LONG)(a)) * (LONGLONG)((LONG)(b)))
  604. #define UInt32x32To64(a, b) ((ULONGLONG)((ULONG)(a)) * (ULONGLONG)((ULONG)(b)))
  605. #define Int64ShllMod32(a, b) ((ULONGLONG)(a) << (b))
  606. #define Int64ShraMod32(a, b) ((LONGLONG)(a) >> (b))
  607. #define Int64ShrlMod32(a, b) ((ULONGLONG)(a) >> (b))
  608. #elif defined(_M_IX86)
  609. //
  610. // The x86 C compiler understands inline assembler. Therefore, inline functions
  611. // that employ inline assembler are used for shifts of 0..31. The multiplies
  612. // rely on the compiler recognizing the cast of the multiplicand to int64 to
  613. // generate the optimal code inline.
  614. //
  615. #define Int32x32To64( a, b ) (LONGLONG)((LONGLONG)(LONG)(a) * (LONG)(b))
  616. #define UInt32x32To64( a, b ) (ULONGLONG)((ULONGLONG)(ULONG)(a) * (ULONG)(b))
  617. ULONGLONG
  618. NTAPI
  619. Int64ShllMod32 (
  620. ULONGLONG Value,
  621. ULONG ShiftCount
  622. );
  623. LONGLONG
  624. NTAPI
  625. Int64ShraMod32 (
  626. LONGLONG Value,
  627. ULONG ShiftCount
  628. );
  629. ULONGLONG
  630. NTAPI
  631. Int64ShrlMod32 (
  632. ULONGLONG Value,
  633. ULONG ShiftCount
  634. );
  635. #if _MSC_VER >= 1200
  636. #pragma warning(push)
  637. #endif
  638. #pragma warning(disable:4035) // re-enable below
  639. __inline ULONGLONG
  640. NTAPI
  641. Int64ShllMod32 (
  642. ULONGLONG Value,
  643. ULONG ShiftCount
  644. )
  645. {
  646. __asm {
  647. mov ecx, ShiftCount
  648. mov eax, dword ptr [Value]
  649. mov edx, dword ptr [Value+4]
  650. shld edx, eax, cl
  651. shl eax, cl
  652. }
  653. }
  654. __inline LONGLONG
  655. NTAPI
  656. Int64ShraMod32 (
  657. LONGLONG Value,
  658. ULONG ShiftCount
  659. )
  660. {
  661. __asm {
  662. mov ecx, ShiftCount
  663. mov eax, dword ptr [Value]
  664. mov edx, dword ptr [Value+4]
  665. shrd eax, edx, cl
  666. sar edx, cl
  667. }
  668. }
  669. __inline ULONGLONG
  670. NTAPI
  671. Int64ShrlMod32 (
  672. ULONGLONG Value,
  673. ULONG ShiftCount
  674. )
  675. {
  676. __asm {
  677. mov ecx, ShiftCount
  678. mov eax, dword ptr [Value]
  679. mov edx, dword ptr [Value+4]
  680. shrd eax, edx, cl
  681. shr edx, cl
  682. }
  683. }
  684. #if _MSC_VER >= 1200
  685. #pragma warning(pop)
  686. #else
  687. #pragma warning(default:4035)
  688. #endif
  689. #elif defined(_68K_) || defined(_MPPC_)
  690. //
  691. // The Macintosh 68K and PowerPC compilers do not currently support int64.
  692. //
  693. #define Int32x32To64(a, b) ((LONGLONG)((LONG)(a)) * (LONGLONG)((LONG)(b)))
  694. #define UInt32x32To64(a, b) ((DWORDLONG)((DWORD)(a)) * (DWORDLONG)((DWORD)(b)))
  695. #define Int64ShllMod32(a, b) ((DWORDLONG)(a) << (b))
  696. #define Int64ShraMod32(a, b) ((LONGLONG)(a) >> (b))
  697. #define Int64ShrlMod32(a, b) ((DWORDLONG)(a) >> (b))
  698. #elif defined(_M_IA64) || defined(_M_AMD64)
  699. //
  700. // IA64 and AMD64 have native 64-bit operations that are just as fast as their
  701. // 32-bit counter parts. Therefore, the int64 data type is used directly to form
  702. // shifts of 0..31 and multiplies of 32-bits times 32-bits to form a 64-bit
  703. // product.
  704. //
  705. #define Int32x32To64(a, b) ((LONGLONG)((LONG)(a)) * (LONGLONG)((LONG)(b)))
  706. #define UInt32x32To64(a, b) ((ULONGLONG)((ULONG)(a)) * (ULONGLONG)((ULONG)(b)))
  707. #define Int64ShllMod32(a, b) ((ULONGLONG)(a) << (b))
  708. #define Int64ShraMod32(a, b) ((LONGLONG)(a) >> (b))
  709. #define Int64ShrlMod32(a, b) ((ULONGLONG)(a) >> (b))
  710. #else
  711. #error Must define a target architecture.
  712. #endif
  713. // end_winnt
  714. //
  715. // Define rotate intrinsics.
  716. //
  717. #ifdef __cplusplus
  718. extern "C" {
  719. #endif
  720. #define RotateLeft32 _rotl
  721. #define RotateLeft64 _rotl64
  722. #define RotateRight32 _rotr
  723. #define RotateRight64 _rotr64
  724. unsigned int
  725. __cdecl
  726. _rotl (
  727. IN unsigned int Value,
  728. IN int Shift
  729. );
  730. unsigned __int64
  731. __cdecl
  732. _rotl64 (
  733. IN unsigned __int64 Value,
  734. IN int Shift
  735. );
  736. unsigned int
  737. __cdecl
  738. _rotr (
  739. IN unsigned int Value,
  740. IN int Shift
  741. );
  742. unsigned __int64
  743. __cdecl
  744. _rotr64 (
  745. IN unsigned __int64 Value,
  746. IN int Shift
  747. );
  748. #pragma intrinsic(_rotl)
  749. #pragma intrinsic(_rotl64)
  750. #pragma intrinsic(_rotr)
  751. #pragma intrinsic(_rotr64)
  752. #ifdef __cplusplus
  753. }
  754. #endif
  755. //
  756. // Event type
  757. //
  758. typedef enum _EVENT_TYPE {
  759. NotificationEvent,
  760. SynchronizationEvent
  761. } EVENT_TYPE;
  762. //
  763. // Timer type
  764. //
  765. typedef enum _TIMER_TYPE {
  766. NotificationTimer,
  767. SynchronizationTimer
  768. } TIMER_TYPE;
  769. //
  770. // Wait type
  771. //
  772. typedef enum _WAIT_TYPE {
  773. WaitAll,
  774. WaitAny
  775. } WAIT_TYPE;
  776. //
  777. // Pointer to an Asciiz string
  778. //
  779. typedef CHAR *PSZ;
  780. typedef CONST char *PCSZ;
  781. // begin_ntndis
  782. //
  783. // Counted String
  784. //
  785. typedef USHORT RTL_STRING_LENGTH_TYPE;
  786. typedef struct _STRING {
  787. USHORT Length;
  788. USHORT MaximumLength;
  789. #ifdef MIDL_PASS
  790. [size_is(MaximumLength), length_is(Length) ]
  791. #endif // MIDL_PASS
  792. PCHAR Buffer;
  793. } STRING;
  794. typedef STRING *PSTRING;
  795. typedef STRING ANSI_STRING;
  796. typedef PSTRING PANSI_STRING;
  797. typedef STRING OEM_STRING;
  798. typedef PSTRING POEM_STRING;
  799. typedef CONST STRING* PCOEM_STRING;
  800. //
  801. // CONSTCounted String
  802. //
  803. typedef struct _CSTRING {
  804. USHORT Length;
  805. USHORT MaximumLength;
  806. CONST char *Buffer;
  807. } CSTRING;
  808. typedef CSTRING *PCSTRING;
  809. #define ANSI_NULL ((CHAR)0) // winnt
  810. typedef STRING CANSI_STRING;
  811. typedef PSTRING PCANSI_STRING;
  812. //
  813. // Unicode strings are counted 16-bit character strings. If they are
  814. // NULL terminated, Length does not include trailing NULL.
  815. //
  816. typedef struct _UNICODE_STRING {
  817. USHORT Length;
  818. USHORT MaximumLength;
  819. #ifdef MIDL_PASS
  820. [size_is(MaximumLength / 2), length_is((Length) / 2) ] USHORT * Buffer;
  821. #else // MIDL_PASS
  822. PWSTR Buffer;
  823. #endif // MIDL_PASS
  824. } UNICODE_STRING;
  825. typedef UNICODE_STRING *PUNICODE_STRING;
  826. typedef const UNICODE_STRING *PCUNICODE_STRING;
  827. #define UNICODE_NULL ((WCHAR)0) // winnt
  828. #if _WIN32_WINNT >= 0x0501
  829. #define UNICODE_STRING_MAX_BYTES ((USHORT) 65534) // winnt
  830. #define UNICODE_STRING_MAX_CHARS (32767) // winnt
  831. #define DECLARE_CONST_UNICODE_STRING(_variablename, _string) \
  832. const WCHAR _variablename ## _buffer[] = _string; \
  833. const UNICODE_STRING _variablename = { sizeof(_string) - sizeof(WCHAR), sizeof(_string), (PWSTR) _variablename ## _buffer };
  834. #endif // _WIN32_WINNT >= 0x0501
  835. // begin_ntminiport begin_ntminitape
  836. //
  837. // Boolean
  838. //
  839. typedef UCHAR BOOLEAN; // winnt
  840. typedef BOOLEAN *PBOOLEAN; // winnt
  841. // end_ntminiport end_ntminitape
  842. // begin_winnt
  843. //
  844. // Doubly linked list structure. Can be used as either a list head, or
  845. // as link words.
  846. //
  847. typedef struct _LIST_ENTRY {
  848. struct _LIST_ENTRY *Flink;
  849. struct _LIST_ENTRY *Blink;
  850. } LIST_ENTRY, *PLIST_ENTRY, *RESTRICTED_POINTER PRLIST_ENTRY;
  851. //
  852. // Singly linked list structure. Can be used as either a list head, or
  853. // as link words.
  854. //
  855. typedef struct _SINGLE_LIST_ENTRY {
  856. struct _SINGLE_LIST_ENTRY *Next;
  857. } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY;
  858. // end_winnt end_ntndis
  859. // begin_winnt
  860. //
  861. // These are needed for portable debugger support.
  862. //
  863. typedef struct LIST_ENTRY32 {
  864. ULONG Flink;
  865. ULONG Blink;
  866. } LIST_ENTRY32;
  867. typedef LIST_ENTRY32 *PLIST_ENTRY32;
  868. typedef struct LIST_ENTRY64 {
  869. ULONGLONG Flink;
  870. ULONGLONG Blink;
  871. } LIST_ENTRY64;
  872. typedef LIST_ENTRY64 *PLIST_ENTRY64;
  873. // end_winnt
  874. #if !defined(MIDL_PASS)
  875. __inline
  876. void
  877. ListEntry32To64(
  878. IN PLIST_ENTRY32 l32,
  879. OUT PLIST_ENTRY64 l64
  880. )
  881. {
  882. l64->Flink = (ULONGLONG)(LONGLONG)(LONG)l32->Flink;
  883. l64->Blink = (ULONGLONG)(LONGLONG)(LONG)l32->Blink;
  884. }
  885. __inline
  886. void
  887. ListEntry64To32(
  888. IN PLIST_ENTRY64 l64,
  889. OUT PLIST_ENTRY32 l32
  890. )
  891. {
  892. l32->Flink = (ULONG)l64->Flink;
  893. l32->Blink = (ULONG)l64->Blink;
  894. }
  895. #endif
  896. typedef struct _STRING32 {
  897. USHORT Length;
  898. USHORT MaximumLength;
  899. ULONG Buffer;
  900. } STRING32;
  901. typedef STRING32 *PSTRING32;
  902. typedef STRING32 UNICODE_STRING32;
  903. typedef UNICODE_STRING32 *PUNICODE_STRING32;
  904. typedef STRING32 ANSI_STRING32;
  905. typedef ANSI_STRING32 *PANSI_STRING32;
  906. typedef struct _STRING64 {
  907. USHORT Length;
  908. USHORT MaximumLength;
  909. ULONGLONG Buffer;
  910. } STRING64;
  911. typedef STRING64 *PSTRING64;
  912. typedef STRING64 UNICODE_STRING64;
  913. typedef UNICODE_STRING64 *PUNICODE_STRING64;
  914. typedef STRING64 ANSI_STRING64;
  915. typedef ANSI_STRING64 *PANSI_STRING64;
  916. //
  917. // Valid values for the Attributes field
  918. //
  919. #define OBJ_INHERIT 0x00000002L
  920. #define OBJ_PERMANENT 0x00000010L
  921. #define OBJ_EXCLUSIVE 0x00000020L
  922. #define OBJ_CASE_INSENSITIVE 0x00000040L
  923. #define OBJ_OPENIF 0x00000080L
  924. #define OBJ_OPENLINK 0x00000100L
  925. #define OBJ_KERNEL_HANDLE 0x00000200L
  926. #define OBJ_FORCE_ACCESS_CHECK 0x00000400L
  927. #define OBJ_VALID_ATTRIBUTES 0x000007F2L
  928. //
  929. // Object Attributes structure
  930. //
  931. typedef struct _OBJECT_ATTRIBUTES64 {
  932. ULONG Length;
  933. ULONG64 RootDirectory;
  934. ULONG64 ObjectName;
  935. ULONG Attributes;
  936. ULONG64 SecurityDescriptor;
  937. ULONG64 SecurityQualityOfService;
  938. } OBJECT_ATTRIBUTES64;
  939. typedef OBJECT_ATTRIBUTES64 *POBJECT_ATTRIBUTES64;
  940. typedef CONST OBJECT_ATTRIBUTES64 *PCOBJECT_ATTRIBUTES64;
  941. typedef struct _OBJECT_ATTRIBUTES32 {
  942. ULONG Length;
  943. ULONG RootDirectory;
  944. ULONG ObjectName;
  945. ULONG Attributes;
  946. ULONG SecurityDescriptor;
  947. ULONG SecurityQualityOfService;
  948. } OBJECT_ATTRIBUTES32;
  949. typedef OBJECT_ATTRIBUTES32 *POBJECT_ATTRIBUTES32;
  950. typedef CONST OBJECT_ATTRIBUTES32 *PCOBJECT_ATTRIBUTES32;
  951. typedef struct _OBJECT_ATTRIBUTES {
  952. ULONG Length;
  953. HANDLE RootDirectory;
  954. PUNICODE_STRING ObjectName;
  955. ULONG Attributes;
  956. PVOID SecurityDescriptor; // Points to type SECURITY_DESCRIPTOR
  957. PVOID SecurityQualityOfService; // Points to type SECURITY_QUALITY_OF_SERVICE
  958. } OBJECT_ATTRIBUTES;
  959. typedef OBJECT_ATTRIBUTES *POBJECT_ATTRIBUTES;
  960. typedef CONST OBJECT_ATTRIBUTES *PCOBJECT_ATTRIBUTES;
  961. //++
  962. //
  963. // VOID
  964. // InitializeObjectAttributes(
  965. // OUT POBJECT_ATTRIBUTES p,
  966. // IN PUNICODE_STRING n,
  967. // IN ULONG a,
  968. // IN HANDLE r,
  969. // IN PSECURITY_DESCRIPTOR s
  970. // )
  971. //
  972. //--
  973. #define InitializeObjectAttributes( p, n, a, r, s ) { \
  974. (p)->Length = sizeof( OBJECT_ATTRIBUTES ); \
  975. (p)->RootDirectory = r; \
  976. (p)->Attributes = a; \
  977. (p)->ObjectName = n; \
  978. (p)->SecurityDescriptor = s; \
  979. (p)->SecurityQualityOfService = NULL; \
  980. }
  981. // RTL_ to avoid collisions in the global namespace.
  982. // I don't believe there are possible/likely constant RootDirectory
  983. // or SecurityDescriptor values other than NULL, so they are hardcoded.
  984. // As well, the string will generally be const, so we cast that away.
  985. #define RTL_CONSTANT_OBJECT_ATTRIBUTES(n, a) \
  986. { sizeof(OBJECT_ATTRIBUTES), NULL, RTL_CONST_CAST(PUNICODE_STRING)(n), a, NULL, NULL }
  987. // This synonym is more appropriate for initializing what isn't actually const.
  988. #define RTL_INIT_OBJECT_ATTRIBUTES(n, a) RTL_CONSTANT_OBJECT_ATTRIBUTES(n, a)
  989. // begin_ntminiport begin_ntndis begin_ntminitape
  990. //
  991. // Constants
  992. //
  993. #define FALSE 0
  994. #define TRUE 1
  995. #ifndef NULL
  996. #ifdef __cplusplus
  997. #define NULL 0
  998. #define NULL64 0
  999. #else
  1000. #define NULL ((void *)0)
  1001. #define NULL64 ((void * POINTER_64)0)
  1002. #endif
  1003. #endif // NULL
  1004. // end_ntminiport end_ntndis end_ntminitape
  1005. // begin_winnt begin_ntndis
  1006. #include <guiddef.h>
  1007. #ifndef __OBJECTID_DEFINED
  1008. #define __OBJECTID_DEFINED
  1009. typedef struct _OBJECTID { // size is 20
  1010. GUID Lineage;
  1011. ULONG Uniquifier;
  1012. } OBJECTID;
  1013. #endif // !_OBJECTID_DEFINED
  1014. // end_winnt end_ntndis
  1015. #define MINCHAR 0x80 // winnt
  1016. #define MAXCHAR 0x7f // winnt
  1017. #define MINSHORT 0x8000 // winnt
  1018. #define MAXSHORT 0x7fff // winnt
  1019. #define MINLONG 0x80000000 // winnt
  1020. #define MAXLONG 0x7fffffff // winnt
  1021. #define MAXUCHAR 0xff // winnt
  1022. #define MAXUSHORT 0xffff // winnt
  1023. #define MAXULONG 0xffffffff // winnt
  1024. //
  1025. // Useful Helper Macros
  1026. //
  1027. // begin_ntndis
  1028. //
  1029. // Determine if an argument is present by testing the value of the pointer
  1030. // to the argument value.
  1031. //
  1032. #define ARGUMENT_PRESENT(ArgumentPointer) (\
  1033. (CHAR *)((ULONG_PTR)(ArgumentPointer)) != (CHAR *)(NULL) )
  1034. // begin_winnt begin_ntminiport
  1035. //
  1036. // Calculate the byte offset of a field in a structure of type type.
  1037. //
  1038. #define FIELD_OFFSET(type, field) ((LONG)(LONG_PTR)&(((type *)0)->field))
  1039. //
  1040. // Calculate the size of a field in a structure of type type, without
  1041. // knowing or stating the type of the field.
  1042. //
  1043. #define RTL_FIELD_SIZE(type, field) (sizeof(((type *)0)->field))
  1044. //
  1045. // Calculate the size of a structure of type type up through and
  1046. // including a field.
  1047. //
  1048. #define RTL_SIZEOF_THROUGH_FIELD(type, field) \
  1049. (FIELD_OFFSET(type, field) + RTL_FIELD_SIZE(type, field))
  1050. //
  1051. // RTL_CONTAINS_FIELD usage:
  1052. //
  1053. // if (RTL_CONTAINS_FIELD(pBlock, pBlock->cbSize, dwMumble)) { // safe to use pBlock->dwMumble
  1054. //
  1055. #define RTL_CONTAINS_FIELD(Struct, Size, Field) \
  1056. ( (((PCHAR)(&(Struct)->Field)) + sizeof((Struct)->Field)) <= (((PCHAR)(Struct))+(Size)) )
  1057. //
  1058. // Return the number of elements in a statically sized array.
  1059. // ULONG Buffer[100];
  1060. // RTL_NUMBER_OF(Buffer) == 100
  1061. // This is also popularly known as: NUMBER_OF, ARRSIZE, _countof, NELEM, etc.
  1062. //
  1063. #define RTL_NUMBER_OF(A) (sizeof(A)/sizeof((A)[0]))
  1064. //
  1065. // An expression that yields the type of a field in a struct.
  1066. //
  1067. #define RTL_FIELD_TYPE(type, field) (((type*)0)->field)
  1068. // RTL_ to avoid collisions in the global namespace.
  1069. //
  1070. // Given typedef struct _FOO { BYTE Bar[123]; } FOO;
  1071. // RTL_NUMBER_OF_FIELD(FOO, Bar) == 123
  1072. //
  1073. #define RTL_NUMBER_OF_FIELD(type, field) (RTL_NUMBER_OF(RTL_FIELD_TYPE(type, field)))
  1074. //
  1075. // eg:
  1076. // typedef struct FOO {
  1077. // ULONG Integer;
  1078. // PVOID Pointer;
  1079. // } FOO;
  1080. //
  1081. // RTL_PADDING_BETWEEN_FIELDS(FOO, Integer, Pointer) == 0 for Win32, 4 for Win64
  1082. //
  1083. #define RTL_PADDING_BETWEEN_FIELDS(T, F1, F2) \
  1084. ((FIELD_OFFSET(T, F2) > FIELD_OFFSET(T, F1)) \
  1085. ? (FIELD_OFFSET(T, F2) - FIELD_OFFSET(T, F1) - RTL_FIELD_SIZE(T, F1)) \
  1086. : (FIELD_OFFSET(T, F1) - FIELD_OFFSET(T, F2) - RTL_FIELD_SIZE(T, F2)))
  1087. // RTL_ to avoid collisions in the global namespace.
  1088. #if defined(__cplusplus)
  1089. #define RTL_CONST_CAST(type) const_cast<type>
  1090. #else
  1091. #define RTL_CONST_CAST(type) (type)
  1092. #endif
  1093. // end_winnt
  1094. //
  1095. // This works "generically" for Unicode and Ansi/Oem strings.
  1096. // Usage:
  1097. // const static UNICODE_STRING FooU = RTL_CONSTANT_STRING(L"Foo");
  1098. // const static STRING Foo = RTL_CONSTANT_STRING( "Foo");
  1099. // instead of the slower:
  1100. // UNICODE_STRING FooU;
  1101. // STRING Foo;
  1102. // RtlInitUnicodeString(&FooU, L"Foo");
  1103. // RtlInitString(&Foo , "Foo");
  1104. //
  1105. #define RTL_CONSTANT_STRING(s) { sizeof( s ) - sizeof( (s)[0] ), sizeof( s ), s }
  1106. // begin_winnt
  1107. // like sizeof
  1108. // usually this would be * CHAR_BIT, but we don't necessarily have #include <limits.h>
  1109. #define RTL_BITS_OF(sizeOfArg) (sizeof(sizeOfArg) * 8)
  1110. #define RTL_BITS_OF_FIELD(type, field) (RTL_BITS_OF(RTL_FIELD_TYPE(type, field)))
  1111. //
  1112. // Calculate the address of the base of the structure given its type, and an
  1113. // address of a field within the structure.
  1114. //
  1115. #define CONTAINING_RECORD(address, type, field) ((type *)( \
  1116. (PCHAR)(address) - \
  1117. (ULONG_PTR)(&((type *)0)->field)))
  1118. // end_winnt end_ntminiport end_ntndis
  1119. //
  1120. // Exception handler routine definition.
  1121. //
  1122. struct _CONTEXT;
  1123. struct _EXCEPTION_RECORD;
  1124. typedef
  1125. EXCEPTION_DISPOSITION
  1126. (*PEXCEPTION_ROUTINE) (
  1127. IN struct _EXCEPTION_RECORD *ExceptionRecord,
  1128. IN PVOID EstablisherFrame,
  1129. IN OUT struct _CONTEXT *ContextRecord,
  1130. IN OUT PVOID DispatcherContext
  1131. );
  1132. // begin_ntminiport begin_ntndis
  1133. //
  1134. // Interrupt Request Level (IRQL)
  1135. //
  1136. typedef UCHAR KIRQL;
  1137. typedef KIRQL *PKIRQL;
  1138. // end_ntminiport end_ntndis
  1139. //
  1140. // Product types
  1141. //
  1142. typedef enum _NT_PRODUCT_TYPE {
  1143. NtProductWinNt = 1,
  1144. NtProductLanManNt,
  1145. NtProductServer
  1146. } NT_PRODUCT_TYPE, *PNT_PRODUCT_TYPE;
  1147. //
  1148. // the bit mask, SharedUserData->SuiteMask, is a ULONG
  1149. // so there can be a maximum of 32 entries
  1150. // in this enum.
  1151. //
  1152. typedef enum _SUITE_TYPE {
  1153. SmallBusiness,
  1154. Enterprise,
  1155. BackOffice,
  1156. CommunicationServer,
  1157. TerminalServer,
  1158. SmallBusinessRestricted,
  1159. EmbeddedNT,
  1160. DataCenter,
  1161. SingleUserTS,
  1162. Personal,
  1163. Blade,
  1164. EmbeddedRestricted,
  1165. SecurityAppliance,
  1166. MaxSuiteType
  1167. } SUITE_TYPE;
  1168. // begin_winnt
  1169. #define VER_SERVER_NT 0x80000000
  1170. #define VER_WORKSTATION_NT 0x40000000
  1171. #define VER_SUITE_SMALLBUSINESS 0x00000001
  1172. #define VER_SUITE_ENTERPRISE 0x00000002
  1173. #define VER_SUITE_BACKOFFICE 0x00000004
  1174. #define VER_SUITE_COMMUNICATIONS 0x00000008
  1175. #define VER_SUITE_TERMINAL 0x00000010
  1176. #define VER_SUITE_SMALLBUSINESS_RESTRICTED 0x00000020
  1177. #define VER_SUITE_EMBEDDEDNT 0x00000040
  1178. #define VER_SUITE_DATACENTER 0x00000080
  1179. #define VER_SUITE_SINGLEUSERTS 0x00000100
  1180. #define VER_SUITE_PERSONAL 0x00000200
  1181. #define VER_SUITE_BLADE 0x00000400
  1182. #define VER_SUITE_EMBEDDED_RESTRICTED 0x00000800
  1183. #define VER_SUITE_SECURITY_APPLIANCE 0x00001000
  1184. // end_winnt
  1185. // begin_winnt begin_r_winnt
  1186. //
  1187. // Language IDs.
  1188. //
  1189. // The following two combinations of primary language ID and
  1190. // sublanguage ID have special semantics:
  1191. //
  1192. // Primary Language ID Sublanguage ID Result
  1193. // ------------------- --------------- ------------------------
  1194. // LANG_NEUTRAL SUBLANG_NEUTRAL Language neutral
  1195. // LANG_NEUTRAL SUBLANG_DEFAULT User default language
  1196. // LANG_NEUTRAL SUBLANG_SYS_DEFAULT System default language
  1197. // LANG_INVARIANT SUBLANG_NEUTRAL Invariant locale
  1198. //
  1199. //
  1200. // Primary language IDs.
  1201. //
  1202. #define LANG_NEUTRAL 0x00
  1203. #define LANG_INVARIANT 0x7f
  1204. #define LANG_AFRIKAANS 0x36
  1205. #define LANG_ALBANIAN 0x1c
  1206. #define LANG_ARABIC 0x01
  1207. #define LANG_ARMENIAN 0x2b
  1208. #define LANG_ASSAMESE 0x4d
  1209. #define LANG_AZERI 0x2c
  1210. #define LANG_BASQUE 0x2d
  1211. #define LANG_BELARUSIAN 0x23
  1212. #define LANG_BENGALI 0x45
  1213. #define LANG_BULGARIAN 0x02
  1214. #define LANG_CATALAN 0x03
  1215. #define LANG_CHINESE 0x04
  1216. #define LANG_CROATIAN 0x1a
  1217. #define LANG_CZECH 0x05
  1218. #define LANG_DANISH 0x06
  1219. #define LANG_DIVEHI 0x65
  1220. #define LANG_DUTCH 0x13
  1221. #define LANG_ENGLISH 0x09
  1222. #define LANG_ESTONIAN 0x25
  1223. #define LANG_FAEROESE 0x38
  1224. #define LANG_FARSI 0x29
  1225. #define LANG_FINNISH 0x0b
  1226. #define LANG_FRENCH 0x0c
  1227. #define LANG_GALICIAN 0x56
  1228. #define LANG_GEORGIAN 0x37
  1229. #define LANG_GERMAN 0x07
  1230. #define LANG_GREEK 0x08
  1231. #define LANG_GUJARATI 0x47
  1232. #define LANG_HEBREW 0x0d
  1233. #define LANG_HINDI 0x39
  1234. #define LANG_HUNGARIAN 0x0e
  1235. #define LANG_ICELANDIC 0x0f
  1236. #define LANG_INDONESIAN 0x21
  1237. #define LANG_ITALIAN 0x10
  1238. #define LANG_JAPANESE 0x11
  1239. #define LANG_KANNADA 0x4b
  1240. #define LANG_KASHMIRI 0x60
  1241. #define LANG_KAZAK 0x3f
  1242. #define LANG_KONKANI 0x57
  1243. #define LANG_KOREAN 0x12
  1244. #define LANG_KYRGYZ 0x40
  1245. #define LANG_LATVIAN 0x26
  1246. #define LANG_LITHUANIAN 0x27
  1247. #define LANG_MACEDONIAN 0x2f // the Former Yugoslav Republic of Macedonia
  1248. #define LANG_MALAY 0x3e
  1249. #define LANG_MALAYALAM 0x4c
  1250. #define LANG_MANIPURI 0x58
  1251. #define LANG_MARATHI 0x4e
  1252. #define LANG_MONGOLIAN 0x50
  1253. #define LANG_NEPALI 0x61
  1254. #define LANG_NORWEGIAN 0x14
  1255. #define LANG_ORIYA 0x48
  1256. #define LANG_POLISH 0x15
  1257. #define LANG_PORTUGUESE 0x16
  1258. #define LANG_PUNJABI 0x46
  1259. #define LANG_ROMANIAN 0x18
  1260. #define LANG_RUSSIAN 0x19
  1261. #define LANG_SANSKRIT 0x4f
  1262. #define LANG_SERBIAN 0x1a
  1263. #define LANG_SINDHI 0x59
  1264. #define LANG_SLOVAK 0x1b
  1265. #define LANG_SLOVENIAN 0x24
  1266. #define LANG_SPANISH 0x0a
  1267. #define LANG_SWAHILI 0x41
  1268. #define LANG_SWEDISH 0x1d
  1269. #define LANG_SYRIAC 0x5a
  1270. #define LANG_TAMIL 0x49
  1271. #define LANG_TATAR 0x44
  1272. #define LANG_TELUGU 0x4a
  1273. #define LANG_THAI 0x1e
  1274. #define LANG_TURKISH 0x1f
  1275. #define LANG_UKRAINIAN 0x22
  1276. #define LANG_URDU 0x20
  1277. #define LANG_UZBEK 0x43
  1278. #define LANG_VIETNAMESE 0x2a
  1279. //
  1280. // Sublanguage IDs.
  1281. //
  1282. // The name immediately following SUBLANG_ dictates which primary
  1283. // language ID that sublanguage ID can be combined with to form a
  1284. // valid language ID.
  1285. //
  1286. #define SUBLANG_NEUTRAL 0x00 // language neutral
  1287. #define SUBLANG_DEFAULT 0x01 // user default
  1288. #define SUBLANG_SYS_DEFAULT 0x02 // system default
  1289. #define SUBLANG_ARABIC_SAUDI_ARABIA 0x01 // Arabic (Saudi Arabia)
  1290. #define SUBLANG_ARABIC_IRAQ 0x02 // Arabic (Iraq)
  1291. #define SUBLANG_ARABIC_EGYPT 0x03 // Arabic (Egypt)
  1292. #define SUBLANG_ARABIC_LIBYA 0x04 // Arabic (Libya)
  1293. #define SUBLANG_ARABIC_ALGERIA 0x05 // Arabic (Algeria)
  1294. #define SUBLANG_ARABIC_MOROCCO 0x06 // Arabic (Morocco)
  1295. #define SUBLANG_ARABIC_TUNISIA 0x07 // Arabic (Tunisia)
  1296. #define SUBLANG_ARABIC_OMAN 0x08 // Arabic (Oman)
  1297. #define SUBLANG_ARABIC_YEMEN 0x09 // Arabic (Yemen)
  1298. #define SUBLANG_ARABIC_SYRIA 0x0a // Arabic (Syria)
  1299. #define SUBLANG_ARABIC_JORDAN 0x0b // Arabic (Jordan)
  1300. #define SUBLANG_ARABIC_LEBANON 0x0c // Arabic (Lebanon)
  1301. #define SUBLANG_ARABIC_KUWAIT 0x0d // Arabic (Kuwait)
  1302. #define SUBLANG_ARABIC_UAE 0x0e // Arabic (U.A.E)
  1303. #define SUBLANG_ARABIC_BAHRAIN 0x0f // Arabic (Bahrain)
  1304. #define SUBLANG_ARABIC_QATAR 0x10 // Arabic (Qatar)
  1305. #define SUBLANG_AZERI_LATIN 0x01 // Azeri (Latin)
  1306. #define SUBLANG_AZERI_CYRILLIC 0x02 // Azeri (Cyrillic)
  1307. #define SUBLANG_CHINESE_TRADITIONAL 0x01 // Chinese (Taiwan)
  1308. #define SUBLANG_CHINESE_SIMPLIFIED 0x02 // Chinese (PR China)
  1309. #define SUBLANG_CHINESE_HONGKONG 0x03 // Chinese (Hong Kong S.A.R., P.R.C.)
  1310. #define SUBLANG_CHINESE_SINGAPORE 0x04 // Chinese (Singapore)
  1311. #define SUBLANG_CHINESE_MACAU 0x05 // Chinese (Macau S.A.R.)
  1312. #define SUBLANG_DUTCH 0x01 // Dutch
  1313. #define SUBLANG_DUTCH_BELGIAN 0x02 // Dutch (Belgian)
  1314. #define SUBLANG_ENGLISH_US 0x01 // English (USA)
  1315. #define SUBLANG_ENGLISH_UK 0x02 // English (UK)
  1316. #define SUBLANG_ENGLISH_AUS 0x03 // English (Australian)
  1317. #define SUBLANG_ENGLISH_CAN 0x04 // English (Canadian)
  1318. #define SUBLANG_ENGLISH_NZ 0x05 // English (New Zealand)
  1319. #define SUBLANG_ENGLISH_EIRE 0x06 // English (Irish)
  1320. #define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07 // English (South Africa)
  1321. #define SUBLANG_ENGLISH_JAMAICA 0x08 // English (Jamaica)
  1322. #define SUBLANG_ENGLISH_CARIBBEAN 0x09 // English (Caribbean)
  1323. #define SUBLANG_ENGLISH_BELIZE 0x0a // English (Belize)
  1324. #define SUBLANG_ENGLISH_TRINIDAD 0x0b // English (Trinidad)
  1325. #define SUBLANG_ENGLISH_ZIMBABWE 0x0c // English (Zimbabwe)
  1326. #define SUBLANG_ENGLISH_PHILIPPINES 0x0d // English (Philippines)
  1327. #define SUBLANG_FRENCH 0x01 // French
  1328. #define SUBLANG_FRENCH_BELGIAN 0x02 // French (Belgian)
  1329. #define SUBLANG_FRENCH_CANADIAN 0x03 // French (Canadian)
  1330. #define SUBLANG_FRENCH_SWISS 0x04 // French (Swiss)
  1331. #define SUBLANG_FRENCH_LUXEMBOURG 0x05 // French (Luxembourg)
  1332. #define SUBLANG_FRENCH_MONACO 0x06 // French (Monaco)
  1333. #define SUBLANG_GERMAN 0x01 // German
  1334. #define SUBLANG_GERMAN_SWISS 0x02 // German (Swiss)
  1335. #define SUBLANG_GERMAN_AUSTRIAN 0x03 // German (Austrian)
  1336. #define SUBLANG_GERMAN_LUXEMBOURG 0x04 // German (Luxembourg)
  1337. #define SUBLANG_GERMAN_LIECHTENSTEIN 0x05 // German (Liechtenstein)
  1338. #define SUBLANG_ITALIAN 0x01 // Italian
  1339. #define SUBLANG_ITALIAN_SWISS 0x02 // Italian (Swiss)
  1340. #if _WIN32_WINNT >= 0x0501
  1341. #define SUBLANG_KASHMIRI_SASIA 0x02 // Kashmiri (South Asia)
  1342. #endif
  1343. #define SUBLANG_KASHMIRI_INDIA 0x02 // For app compatibility only
  1344. #define SUBLANG_KOREAN 0x01 // Korean (Extended Wansung)
  1345. #define SUBLANG_LITHUANIAN 0x01 // Lithuanian
  1346. #define SUBLANG_MALAY_MALAYSIA 0x01 // Malay (Malaysia)
  1347. #define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02 // Malay (Brunei Darussalam)
  1348. #define SUBLANG_NEPALI_INDIA 0x02 // Nepali (India)
  1349. #define SUBLANG_NORWEGIAN_BOKMAL 0x01 // Norwegian (Bokmal)
  1350. #define SUBLANG_NORWEGIAN_NYNORSK 0x02 // Norwegian (Nynorsk)
  1351. #define SUBLANG_PORTUGUESE 0x02 // Portuguese
  1352. #define SUBLANG_PORTUGUESE_BRAZILIAN 0x01 // Portuguese (Brazilian)
  1353. #define SUBLANG_SERBIAN_LATIN 0x02 // Serbian (Latin)
  1354. #define SUBLANG_SERBIAN_CYRILLIC 0x03 // Serbian (Cyrillic)
  1355. #define SUBLANG_SPANISH 0x01 // Spanish (Castilian)
  1356. #define SUBLANG_SPANISH_MEXICAN 0x02 // Spanish (Mexican)
  1357. #define SUBLANG_SPANISH_MODERN 0x03 // Spanish (Spain)
  1358. #define SUBLANG_SPANISH_GUATEMALA 0x04 // Spanish (Guatemala)
  1359. #define SUBLANG_SPANISH_COSTA_RICA 0x05 // Spanish (Costa Rica)
  1360. #define SUBLANG_SPANISH_PANAMA 0x06 // Spanish (Panama)
  1361. #define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07 // Spanish (Dominican Republic)
  1362. #define SUBLANG_SPANISH_VENEZUELA 0x08 // Spanish (Venezuela)
  1363. #define SUBLANG_SPANISH_COLOMBIA 0x09 // Spanish (Colombia)
  1364. #define SUBLANG_SPANISH_PERU 0x0a // Spanish (Peru)
  1365. #define SUBLANG_SPANISH_ARGENTINA 0x0b // Spanish (Argentina)
  1366. #define SUBLANG_SPANISH_ECUADOR 0x0c // Spanish (Ecuador)
  1367. #define SUBLANG_SPANISH_CHILE 0x0d // Spanish (Chile)
  1368. #define SUBLANG_SPANISH_URUGUAY 0x0e // Spanish (Uruguay)
  1369. #define SUBLANG_SPANISH_PARAGUAY 0x0f // Spanish (Paraguay)
  1370. #define SUBLANG_SPANISH_BOLIVIA 0x10 // Spanish (Bolivia)
  1371. #define SUBLANG_SPANISH_EL_SALVADOR 0x11 // Spanish (El Salvador)
  1372. #define SUBLANG_SPANISH_HONDURAS 0x12 // Spanish (Honduras)
  1373. #define SUBLANG_SPANISH_NICARAGUA 0x13 // Spanish (Nicaragua)
  1374. #define SUBLANG_SPANISH_PUERTO_RICO 0x14 // Spanish (Puerto Rico)
  1375. #define SUBLANG_SWEDISH 0x01 // Swedish
  1376. #define SUBLANG_SWEDISH_FINLAND 0x02 // Swedish (Finland)
  1377. #define SUBLANG_URDU_PAKISTAN 0x01 // Urdu (Pakistan)
  1378. #define SUBLANG_URDU_INDIA 0x02 // Urdu (India)
  1379. #define SUBLANG_UZBEK_LATIN 0x01 // Uzbek (Latin)
  1380. #define SUBLANG_UZBEK_CYRILLIC 0x02 // Uzbek (Cyrillic)
  1381. //
  1382. // Sorting IDs.
  1383. //
  1384. #define SORT_DEFAULT 0x0 // sorting default
  1385. #define SORT_JAPANESE_XJIS 0x0 // Japanese XJIS order
  1386. #define SORT_JAPANESE_UNICODE 0x1 // Japanese Unicode order
  1387. #define SORT_CHINESE_BIG5 0x0 // Chinese BIG5 order
  1388. #define SORT_CHINESE_PRCP 0x0 // PRC Chinese Phonetic order
  1389. #define SORT_CHINESE_UNICODE 0x1 // Chinese Unicode order
  1390. #define SORT_CHINESE_PRC 0x2 // PRC Chinese Stroke Count order
  1391. #define SORT_CHINESE_BOPOMOFO 0x3 // Traditional Chinese Bopomofo order
  1392. #define SORT_KOREAN_KSC 0x0 // Korean KSC order
  1393. #define SORT_KOREAN_UNICODE 0x1 // Korean Unicode order
  1394. #define SORT_GERMAN_PHONE_BOOK 0x1 // German Phone Book order
  1395. #define SORT_HUNGARIAN_DEFAULT 0x0 // Hungarian Default order
  1396. #define SORT_HUNGARIAN_TECHNICAL 0x1 // Hungarian Technical order
  1397. #define SORT_GEORGIAN_TRADITIONAL 0x0 // Georgian Traditional order
  1398. #define SORT_GEORGIAN_MODERN 0x1 // Georgian Modern order
  1399. // end_r_winnt
  1400. //
  1401. // A language ID is a 16 bit value which is the combination of a
  1402. // primary language ID and a secondary language ID. The bits are
  1403. // allocated as follows:
  1404. //
  1405. // +-----------------------+-------------------------+
  1406. // | Sublanguage ID | Primary Language ID |
  1407. // +-----------------------+-------------------------+
  1408. // 15 10 9 0 bit
  1409. //
  1410. //
  1411. // Language ID creation/extraction macros:
  1412. //
  1413. // MAKELANGID - construct language id from a primary language id and
  1414. // a sublanguage id.
  1415. // PRIMARYLANGID - extract primary language id from a language id.
  1416. // SUBLANGID - extract sublanguage id from a language id.
  1417. //
  1418. #define MAKELANGID(p, s) ((((USHORT)(s)) << 10) | (USHORT)(p))
  1419. #define PRIMARYLANGID(lgid) ((USHORT)(lgid) & 0x3ff)
  1420. #define SUBLANGID(lgid) ((USHORT)(lgid) >> 10)
  1421. //
  1422. // A locale ID is a 32 bit value which is the combination of a
  1423. // language ID, a sort ID, and a reserved area. The bits are
  1424. // allocated as follows:
  1425. //
  1426. // +-------------+---------+-------------------------+
  1427. // | Reserved | Sort ID | Language ID |
  1428. // +-------------+---------+-------------------------+
  1429. // 31 20 19 16 15 0 bit
  1430. //
  1431. //
  1432. // Locale ID creation/extraction macros:
  1433. //
  1434. // MAKELCID - construct the locale id from a language id and a sort id.
  1435. // MAKESORTLCID - construct the locale id from a language id, sort id, and sort version.
  1436. // LANGIDFROMLCID - extract the language id from a locale id.
  1437. // SORTIDFROMLCID - extract the sort id from a locale id.
  1438. // SORTVERSIONFROMLCID - extract the sort version from a locale id.
  1439. //
  1440. #define NLS_VALID_LOCALE_MASK 0x000fffff
  1441. #define MAKELCID(lgid, srtid) ((ULONG)((((ULONG)((USHORT)(srtid))) << 16) | \
  1442. ((ULONG)((USHORT)(lgid)))))
  1443. #define MAKESORTLCID(lgid, srtid, ver) \
  1444. ((ULONG)((MAKELCID(lgid, srtid)) | \
  1445. (((ULONG)((USHORT)(ver))) << 20)))
  1446. #define LANGIDFROMLCID(lcid) ((USHORT)(lcid))
  1447. #define SORTIDFROMLCID(lcid) ((USHORT)((((ULONG)(lcid)) >> 16) & 0xf))
  1448. #define SORTVERSIONFROMLCID(lcid) ((USHORT)((((ULONG)(lcid)) >> 20) & 0xf))
  1449. //
  1450. // Default System and User IDs for language and locale.
  1451. //
  1452. #define LANG_SYSTEM_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
  1453. #define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
  1454. #define LOCALE_SYSTEM_DEFAULT (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
  1455. #define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
  1456. #define LOCALE_NEUTRAL \
  1457. (MAKELCID(MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), SORT_DEFAULT))
  1458. #define LOCALE_INVARIANT \
  1459. (MAKELCID(MAKELANGID(LANG_INVARIANT, SUBLANG_NEUTRAL), SORT_DEFAULT))
  1460. // begin_ntminiport begin_ntndis begin_ntminitape
  1461. //
  1462. // Macros used to eliminate compiler warning generated when formal
  1463. // parameters or local variables are not declared.
  1464. //
  1465. // Use DBG_UNREFERENCED_PARAMETER() when a parameter is not yet
  1466. // referenced but will be once the module is completely developed.
  1467. //
  1468. // Use DBG_UNREFERENCED_LOCAL_VARIABLE() when a local variable is not yet
  1469. // referenced but will be once the module is completely developed.
  1470. //
  1471. // Use UNREFERENCED_PARAMETER() if a parameter will never be referenced.
  1472. //
  1473. // DBG_UNREFERENCED_PARAMETER and DBG_UNREFERENCED_LOCAL_VARIABLE will
  1474. // eventually be made into a null macro to help determine whether there
  1475. // is unfinished work.
  1476. //
  1477. #if ! defined(lint)
  1478. #define UNREFERENCED_PARAMETER(P) (P)
  1479. #define DBG_UNREFERENCED_PARAMETER(P) (P)
  1480. #define DBG_UNREFERENCED_LOCAL_VARIABLE(V) (V)
  1481. #else // lint
  1482. // Note: lint -e530 says don't complain about uninitialized variables for
  1483. // this varible. Error 527 has to do with unreachable code.
  1484. // -restore restores checking to the -save state
  1485. #define UNREFERENCED_PARAMETER(P) \
  1486. /*lint -save -e527 -e530 */ \
  1487. { \
  1488. (P) = (P); \
  1489. } \
  1490. /*lint -restore */
  1491. #define DBG_UNREFERENCED_PARAMETER(P) \
  1492. /*lint -save -e527 -e530 */ \
  1493. { \
  1494. (P) = (P); \
  1495. } \
  1496. /*lint -restore */
  1497. #define DBG_UNREFERENCED_LOCAL_VARIABLE(V) \
  1498. /*lint -save -e527 -e530 */ \
  1499. { \
  1500. (V) = (V); \
  1501. } \
  1502. /*lint -restore */
  1503. #endif // lint
  1504. //
  1505. // Macro used to eliminate compiler warning 4715 within a switch statement
  1506. // when all possible cases have already been accounted for.
  1507. //
  1508. // switch (a & 3) {
  1509. // case 0: return 1;
  1510. // case 1: return Foo();
  1511. // case 2: return Bar();
  1512. // case 3: return 1;
  1513. // DEFAULT_UNREACHABLE;
  1514. //
  1515. #if (_MSC_VER > 1200)
  1516. #define DEFAULT_UNREACHABLE default: __assume(0)
  1517. #else
  1518. //
  1519. // Older compilers do not support __assume(), and there is no other free
  1520. // method of eliminating the warning.
  1521. //
  1522. #define DEFAULT_UNREACHABLE
  1523. #endif
  1524. // end_winnt
  1525. //
  1526. // Define standard min and max macros
  1527. //
  1528. #ifndef NOMINMAX
  1529. #ifndef min
  1530. #define min(a,b) (((a) < (b)) ? (a) : (b))
  1531. #endif
  1532. #ifndef max
  1533. #define max(a,b) (((a) > (b)) ? (a) : (b))
  1534. #endif
  1535. #endif // NOMINMAX
  1536. // end_ntminiport end_ntndis end_ntminitape
  1537. #endif // _NTDEF_