147 lines
2.4 KiB
C
147 lines
2.4 KiB
C
/*++
|
|
|
|
Copyright (c) 2024, the LibreXP developers.
|
|
Provided under the BSD 3-Clause license.
|
|
|
|
Module Name:
|
|
|
|
ntdef.h
|
|
|
|
Abstract:
|
|
|
|
Provides basic NT definitions.
|
|
|
|
--*/
|
|
|
|
#ifndef _NTDEF_H
|
|
#define _NTDEF_H
|
|
|
|
#ifndef VOID
|
|
#define VOID void
|
|
#endif
|
|
|
|
#ifndef CONST
|
|
#define CONST const
|
|
#endif
|
|
|
|
#ifndef IN
|
|
#define IN
|
|
#define OUT
|
|
#define OPTIONAL
|
|
#endif
|
|
|
|
#ifndef ANYSIZE_ARRAY
|
|
#define ANYSIZE_ARRAY 1
|
|
#endif
|
|
|
|
#ifndef FORCEINLINE
|
|
#if defined(_MSC_EXTENSIONS)
|
|
#define FORCEINLINE __inline
|
|
#else
|
|
#define FORCEINLINE static inline
|
|
#endif
|
|
#endif
|
|
|
|
#ifndef FASTCALL
|
|
#define FASTCALL
|
|
#endif
|
|
|
|
#ifndef NTAPI
|
|
#define NTAPI
|
|
#endif
|
|
|
|
//
|
|
// Basic types.
|
|
//
|
|
typedef char CHAR;
|
|
typedef short SHORT;
|
|
typedef long LONG;
|
|
typedef unsigned char UCHAR;
|
|
typedef unsigned short USHORT;
|
|
typedef unsigned long ULONG;
|
|
|
|
//
|
|
// Basic type pointers.
|
|
//
|
|
typedef void *PVOID;
|
|
typedef CHAR *PCHAR;
|
|
typedef SHORT *PSHORT;
|
|
typedef UCHAR *PUCHAR;
|
|
typedef USHORT *PUSHORT;
|
|
typedef ULONG *PULONG;
|
|
|
|
//
|
|
// Wide characters.
|
|
//
|
|
typedef USHORT WCHAR;
|
|
typedef WCHAR *PWCHAR;
|
|
|
|
//
|
|
// Logical values.
|
|
//
|
|
typedef ULONG LOGICAL;
|
|
typedef ULONG *PLOGICAL;
|
|
|
|
//
|
|
// Status codes.
|
|
//
|
|
typedef LONG NTSTATUS;
|
|
typedef NTSTATUS *PNTSTATUS;
|
|
|
|
//
|
|
// Status code utilities.
|
|
//
|
|
#define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0)
|
|
#define NT_INFORMATION(Status) ((ULONG)(Status) >> 30 == 1)
|
|
#define NT_WARNING(Status) ((ULONG)(Status) >> 30 == 2)
|
|
#define NT_ERROR(Status) ((ULONG)(Status) >> 30 == 3)
|
|
|
|
//
|
|
// Long long type definitions.
|
|
//
|
|
#if defined(_MSC_EXTENSIONS)
|
|
typedef unsigned __int64 ULONGLONG;
|
|
typedef __int64 LONGLONG;
|
|
#elif defined(UNIX_LP64)
|
|
typedef unsigned long ULONGLONG;
|
|
typedef long LONGLONG;
|
|
#else
|
|
typedef unsigned long long ULONGLONG;
|
|
typedef long long LONGLONG;
|
|
#endif
|
|
|
|
//
|
|
// Large (64-bit) integer value.
|
|
//
|
|
typedef union LARGE_INTEGER {
|
|
struct {
|
|
ULONG LowPart;
|
|
LONG HighPart;
|
|
};
|
|
|
|
LONGLONG QuadPart;
|
|
} LARGE_INTEGER, *PLARGE_INTEGER;
|
|
|
|
//
|
|
// Large (64-bit) unsigned integer value.
|
|
//
|
|
typedef union ULARGE_INTEGER {
|
|
struct {
|
|
ULONG LowPart;
|
|
ULONG HighPart;
|
|
};
|
|
|
|
ULONGLONG QuadPart;
|
|
} ULARGE_INTEGER, *PULARGE_INTEGER;
|
|
|
|
//
|
|
// Struct field offset helper.
|
|
//
|
|
#if !defined(__GNUC__) && !defined(__clang__)
|
|
#define FIELD_OFFSET(type, field) ((ULONG)&(((type *)0)->field))
|
|
#else
|
|
#define FIELD_OFFSET(type, field) ((ULONG)__builtin_offsetof(type, field))
|
|
#endif
|
|
|
|
#endif
|