VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/i8042prt/include/ntdef.h@ 3539

Last change on this file since 3539 was 1, checked in by vboxsync, 55 years ago

import

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette