Source code of Windows XP (NT5)
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.

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