#ifndef _WDMDDK_
#define _WDMDDK_
+/* Helper macro to enable gcc's extension. */
+#ifndef __GNU_EXTENSION
+#ifdef __GNUC__
+#define __GNU_EXTENSION __extension__
+#else
+#define __GNU_EXTENSION
+#endif
+#endif
+
//
// Dependencies
//
#endif
+/*
+ * Alignment Macros
+ */
+#define ALIGN_DOWN(s, t) \
+ ((ULONG)(s) & ~(sizeof(t) - 1))
+
+#define ALIGN_UP(s, t) \
+ (ALIGN_DOWN(((ULONG)(s) + sizeof(t) - 1), t))
+
+#define ALIGN_DOWN_POINTER(p, t) \
+ ((PVOID)((ULONG_PTR)(p) & ~((ULONG_PTR)sizeof(t) - 1)))
+
+#define ALIGN_UP_POINTER(p, t) \
+ (ALIGN_DOWN_POINTER(((ULONG_PTR)(p) + sizeof(t) - 1), t))
+
+/*
+ * GUID Comparison
+ */
+
+#ifndef __IID_ALIGNED__
+ #define __IID_ALIGNED__
+ #ifdef __cplusplus
+ inline int IsEqualGUIDAligned(REFGUID guid1, REFGUID guid2)
+ {
+ return ((*(PLONGLONG)(&guid1) == *(PLONGLONG)(&guid2)) && (*((PLONGLONG)(&guid1) + 1) == *((PLONGLONG)(&guid2) + 1)));
+ }
+ #else
+ #define IsEqualGUIDAligned(guid1, guid2) \
+ ((*(PLONGLONG)(guid1) == *(PLONGLONG)(guid2)) && (*((PLONGLONG)(guid1) + 1) == *((PLONGLONG)(guid2) + 1)))
+ #endif
+#endif
+
/* Simple types */
typedef UCHAR KPROCESSOR_MODE;
typedef LONG KPRIORITY;
} Interrupt;
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
struct {
- union {
+ __GNU_EXTENSION union {
struct {
USHORT Reserved;
USHORT MessageCount;
#ifndef _SLIST_HEADER_
#define _SLIST_HEADER_
-#define SLIST_ENTRY SINGLE_LIST_ENTRY
-#define _SLIST_ENTRY _SINGLE_LIST_ENTRY
-#define PSLIST_ENTRY PSINGLE_LIST_ENTRY
-
#if defined(_WIN64)
+typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY *PSLIST_ENTRY;
+typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY {
+ PSLIST_ENTRY Next;
+} SLIST_ENTRY;
typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER {
struct {
ULONGLONG Alignment;
} Header16;
} SLIST_HEADER, *PSLIST_HEADER;
#else
+#define SLIST_ENTRY SINGLE_LIST_ENTRY
+#define _SLIST_ENTRY _SINGLE_LIST_ENTRY
+#define PSLIST_ENTRY PSINGLE_LIST_ENTRY
typedef union _SLIST_HEADER {
ULONGLONG Alignment;
struct {
typedef struct _DISPATCHER_HEADER
{
- union
+ __GNU_EXTENSION union
{
- struct
+ __GNU_EXTENSION struct
{
UCHAR Type;
- union
+ __GNU_EXTENSION union
{
UCHAR Absolute;
UCHAR NpxIrql;
};
- union
+ __GNU_EXTENSION union
{
UCHAR Size;
UCHAR Hand;
};
- union
+ __GNU_EXTENSION union
{
UCHAR Inserted;
BOOLEAN DebugActive;
ULONG ContentionCount;
ULONG NumberOfSharedWaiters;
ULONG NumberOfExclusiveWaiters;
- union
+ __GNU_EXTENSION union
{
PVOID Address;
ULONG_PTR CreatorBackTraceIndex;
//} LOOKASIDE_LIST_EX, *PLOOKASIDE_LIST_EX;
typedef struct _EX_RUNDOWN_REF {
- union {
+ __GNU_EXTENSION union {
volatile ULONG_PTR Count;
volatile PVOID Ptr;
};