diff --git a/SDK/CRT/INC/stddef.h b/SDK/INC/CRT/stddef.h similarity index 100% rename from SDK/CRT/INC/stddef.h rename to SDK/INC/CRT/stddef.h diff --git a/SDK/CRT/INC/string.h b/SDK/INC/CRT/string.h similarity index 100% rename from SDK/CRT/INC/string.h rename to SDK/INC/CRT/string.h diff --git a/SDK/CRT/INC/wchar.h b/SDK/INC/CRT/wchar.h similarity index 100% rename from SDK/CRT/INC/wchar.h rename to SDK/INC/CRT/wchar.h diff --git a/BOOT/ENVIRON/INC/nt.h b/SDK/INC/NT/nt.h similarity index 92% rename from BOOT/ENVIRON/INC/nt.h rename to SDK/INC/NT/nt.h index 123ac4a..fbdd8e4 100644 --- a/BOOT/ENVIRON/INC/nt.h +++ b/SDK/INC/NT/nt.h @@ -20,4 +20,4 @@ Abstract: #include #include -#endif +#endif /* !_NT_H */ diff --git a/BOOT/ENVIRON/INC/ntdef.h b/SDK/INC/NT/ntdef.h similarity index 74% rename from BOOT/ENVIRON/INC/ntdef.h rename to SDK/INC/NT/ntdef.h index 0c593d7..d0d1abe 100644 --- a/BOOT/ENVIRON/INC/ntdef.h +++ b/SDK/INC/NT/ntdef.h @@ -16,42 +16,55 @@ Abstract: #ifndef _NTDEF_H #define _NTDEF_H +#include + +#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 +#define VOID void #endif #ifndef CONST - #define CONST const -#endif - -#ifndef IN - #define IN - #define OUT - #define OPTIONAL +#define CONST const #endif #ifndef ANYSIZE_ARRAY - #define ANYSIZE_ARRAY 1 +#define ANYSIZE_ARRAY 1 #endif #ifndef FORCEINLINE #if defined(_MSC_EXTENSIONS) - #define FORCEINLINE __inline +#define FORCEINLINE __inline #else - #define FORCEINLINE static inline +#define FORCEINLINE static inline #endif #endif -#ifndef FASTCALL - #define FASTCALL -#endif - -#ifndef NTAPI - #define NTAPI -#endif - -#undef NULL +#ifndef NULL +#ifdef __cplusplus +#define NULL 0 +#else #define NULL ((VOID *)0) +#endif +#endif // // Basic types. @@ -64,9 +77,9 @@ typedef unsigned short USHORT; typedef unsigned long ULONG; // -// Basic type pointers. +// Basic pointer types. // -typedef void *PVOID; +typedef VOID *PVOID; typedef CHAR *PCHAR; typedef SHORT *PSHORT; typedef UCHAR *PUCHAR; @@ -74,17 +87,24 @@ typedef USHORT *PUSHORT; typedef ULONG *PULONG; // -// Wide characters. -// -typedef USHORT WCHAR; -typedef WCHAR *PWCHAR; - -// -// Logical values. +// 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. // @@ -103,14 +123,14 @@ typedef NTSTATUS *PNTSTATUS; // Long long type definitions. // #if defined(_MSC_EXTENSIONS) - typedef unsigned __int64 ULONGLONG; - typedef __int64 LONGLONG; +typedef unsigned __int64 ULONGLONG; +typedef __int64 LONGLONG; #elif defined(UNIX_LP64) - typedef unsigned long ULONGLONG; - typedef long LONGLONG; +typedef unsigned long ULONGLONG; +typedef long LONGLONG; #else - typedef unsigned long long ULONGLONG; - typedef long long LONGLONG; +typedef unsigned long long ULONGLONG; +typedef long long LONGLONG; #endif // @@ -160,21 +180,4 @@ typedef struct _LIST_ENTRY { struct _LIST_ENTRY *BackLink; } LIST_ENTRY, *PLIST_ENTRY; -// -// Runtime library definitions. -// - -PVOID -RtlCopyMemory ( - PVOID Destination, - CONST PVOID Source, - ULONG Length - ); - -PVOID -RtlZeroMemory ( - PVOID Destination, - ULONG Length - ); - -#endif +#endif /* !_NTDEF_H */ diff --git a/BOOT/ENVIRON/INC/ntimage.h b/SDK/INC/NT/ntimage.h similarity index 93% rename from BOOT/ENVIRON/INC/ntimage.h rename to SDK/INC/NT/ntimage.h index b983514..6100e0e 100644 --- a/BOOT/ENVIRON/INC/ntimage.h +++ b/SDK/INC/NT/ntimage.h @@ -23,4 +23,4 @@ Abstract: #define IMAGE_FILE_MACHINE_I386 0x014c #define IMAGE_FILE_MACHINE_AMD64 0x8664 -#endif +#endif /* !_NTIMAGE_H */ diff --git a/SDK/INC/NT/ntrtl.h b/SDK/INC/NT/ntrtl.h new file mode 100644 index 0000000..4e9f5ed --- /dev/null +++ b/SDK/INC/NT/ntrtl.h @@ -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 + +// +// 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 */ diff --git a/BOOT/ENVIRON/INC/ntstatus.h b/SDK/INC/NT/ntstatus.h similarity index 98% rename from BOOT/ENVIRON/INC/ntstatus.h rename to SDK/INC/NT/ntstatus.h index b490fad..3603078 100644 --- a/BOOT/ENVIRON/INC/ntstatus.h +++ b/SDK/INC/NT/ntstatus.h @@ -41,4 +41,4 @@ Abstract: #define STATUS_DRIVER_UNABLE_TO_LOAD ((NTSTATUS) 0xC000026CL) #define STATUS_NO_MATCH ((NTSTATUS) 0xC0000272L) -#endif +#endif /* !_NTSTATUS_H */ diff --git a/premake5.lua b/premake5.lua index f75122c..3e53787 100644 --- a/premake5.lua +++ b/premake5.lua @@ -25,11 +25,11 @@ project("CRT") kind("StaticLib") location("SDK/CRT") - includedirs({ "SDK/CRT/INC" }) + includedirs({ "SDK/INC/CRT" }) objdir("BUILD/SDK/CRT") targetdir("BUILD/SDK") targetname("crt") - files({ "SDK/CRT/INC/**.h", "SDK/CRT/**.c" }) + files({ "SDK/INC/CRT/**.h", "SDK/CRT/**.c" }) --[[ project("BOOT")