[SDK] Reorganize header files

This commit is contained in:
2024-08-08 15:27:44 -04:00
parent e48262d4d7
commit 120277161c
9 changed files with 90 additions and 58 deletions

23
SDK/INC/NT/nt.h Normal file
View File

@@ -0,0 +1,23 @@
/*++
Copyright (c) 2024, Quinn Stephens.
Provided under the BSD 3-Clause license.
Module Name:
nt.h
Abstract:
Provides NT header files.
--*/
#ifndef _NT_H
#define _NT_H
#include <ntdef.h>
#include <ntstatus.h>
#include <ntimage.h>
#endif /* !_NT_H */

183
SDK/INC/NT/ntdef.h Normal file
View File

@@ -0,0 +1,183 @@
/*++
Copyright (c) 2024, Quinn Stephens.
Provided under the BSD 3-Clause license.
Module Name:
ntdef.h
Abstract:
Provides basic NT definitions.
--*/
#ifndef _NTDEF_H
#define _NTDEF_H
#include <string.h>
#ifndef IN
#define IN
#endif
#ifndef OUT
#define OUT
#endif
#ifndef OPTIONAL
#define OPTIONAL
#endif
#ifndef FASTCALL
#define FASTCALL
#endif
#ifndef NTAPI
#define NTAPI
#endif
#ifndef VOID
#define VOID void
#endif
#ifndef CONST
#define CONST const
#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 NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((VOID *)0)
#endif
#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 pointer types.
//
typedef VOID *PVOID;
typedef CHAR *PCHAR;
typedef SHORT *PSHORT;
typedef UCHAR *PUCHAR;
typedef USHORT *PUSHORT;
typedef ULONG *PULONG;
//
// Logical value types.
//
typedef ULONG LOGICAL;
typedef ULONG *PLOGICAL;
//
// String types.
//
typedef CHAR *LPSTR;
typedef CONST CHAR *LPCSTR;
//
// Wide character/string types.
//
typedef USHORT WCHAR;
typedef WCHAR *PWCHAR, *LPWSTR;
typedef CONST WCHAR *LPCWSTR;
//
// 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
//
// Alignment helpers.
//
#define ALIGN_DOWN(x, a) ((x) & ~((a) - 1))
#define ALIGN_UP(x, a) ALIGN_DOWN((x) + (a) - 1, a)
//
// Doubly-linked list entry.
//
typedef struct _LIST_ENTRY {
struct _LIST_ENTRY *ForwardLink;
struct _LIST_ENTRY *BackLink;
} LIST_ENTRY, *PLIST_ENTRY;
#endif /* !_NTDEF_H */

26
SDK/INC/NT/ntimage.h Normal file
View File

@@ -0,0 +1,26 @@
/*++
Copyright (c) 2024, Quinn Stephens.
Provided under the BSD 3-Clause license.
Module Name:
ntimage.h
Abstract:
Provides NT image file definitions.
--*/
#ifndef _NTIMAGE_H
#define _NTIMAGE_H
//
// Machine type values.
//
#define IMAGE_FILE_MACHINE_UNKNOWN 0
#define IMAGE_FILE_MACHINE_I386 0x014c
#define IMAGE_FILE_MACHINE_AMD64 0x8664
#endif /* !_NTIMAGE_H */

29
SDK/INC/NT/ntrtl.h Normal file
View File

@@ -0,0 +1,29 @@
/*++
Copyright (c) 2024, Quinn Stephens.
Provided under the BSD 3-Clause license.
Module Name:
ntrtl.h
Abstract:
Provides NT RTL (Run-Time Library) definitions.
--*/
#ifndef _NTRTL_H
#define _NTRTL_H
#include <string.h>
//
// Memory operations.
//
#define RtlMoveMemory(Destination, Source, Length) memmove((Destination), (Source), (Length))
#define RtlCopyMemory(Destination, Source, Length) memcpy((Destination), (Source), (Length))
#define RtlFillMemory(Destination, Length, Fill) memset((Destination), (Fill), (Length))
#define RtlZeroMemory(Destination, Length) memset((Destination), 0, (Length))
#endif /* !_NTRTL_H */

44
SDK/INC/NT/ntstatus.h Normal file
View File

@@ -0,0 +1,44 @@
/*++
Copyright (c) 2024, Quinn Stephens.
Provided under the BSD 3-Clause license.
Module Name:
ntstatus.h
Abstract:
Provides NT status code values.
--*/
#ifndef _NTSTATUS_H
#define _NTSTATUS_H
#define STATUS_SUCCESS ((NTSTATUS) 0x00000000L)
//
// TODO: There are an insane amount of status values.
//
#define STATUS_MEDIA_CHANGED ((NTSTATUS) 0x8000001CL)
#define STATUS_INVALID_PARAMETER ((NTSTATUS) 0xC000000DL)
#define STATUS_ACCESS_DENIED ((NTSTATUS) 0xC0000022L)
#define STATUS_BUFFER_TOO_SMALL ((NTSTATUS) 0xC0000023L)
#define STATUS_DISK_CORRUPT_ERROR ((NTSTATUS) 0xC0000032L)
#define STATUS_DEVICE_ALREADY_ATTACHED ((NTSTATUS) 0xC0000038L)
#define STATUS_DISK_FULL ((NTSTATUS) 0xC000007FL)
#define STATUS_INSUFFICIENT_RESOURCES ((NTSTATUS) 0xC000009AL)
#define STATUS_MEDIA_WRITE_PROTECTED ((NTSTATUS) 0xC00000A2L)
#define STATUS_DEVICE_NOT_READY ((NTSTATUS) 0xC00000A3L)
#define STATUS_NOT_SUPPORTED ((NTSTATUS) 0xC00000BBL)
#define STATUS_TIMEOUT ((NTSTATUS) 0x00000102L)
#define STATUS_NO_MEDIA ((NTSTATUS) 0xC0000178L)
#define STATUS_IO_DEVICE_ERROR ((NTSTATUS) 0xC0000185L)
#define STATUS_INVALID_BUFFER_SIZE ((NTSTATUS) 0xC0000206L)
#define STATUS_NOT_FOUND ((NTSTATUS) 0xC0000225L)
#define STATUS_REQUEST_ABORTED ((NTSTATUS) 0xC0000240L)
#define STATUS_DRIVER_UNABLE_TO_LOAD ((NTSTATUS) 0xC000026CL)
#define STATUS_NO_MATCH ((NTSTATUS) 0xC0000272L)
#endif /* !_NTSTATUS_H */