diff --git a/BOOT/ENVIRON/APP/BOOTMGR/bootmgr.c b/BOOT/ENVIRON/APP/BOOTMGR/bootmgr.c index 0575fed..35b37df 100644 --- a/BOOT/ENVIRON/APP/BOOTMGR/bootmgr.c +++ b/BOOT/ENVIRON/APP/BOOTMGR/bootmgr.c @@ -14,6 +14,7 @@ Abstract: --*/ #include "bootmgr.h" +#include "bootlib.h" NTSTATUS BmMain ( @@ -38,9 +39,20 @@ Return Value: --*/ { - (VOID)InputParameters; + NTSTATUS Status; + BOOT_LIBRARY_PARAMETERS LibraryParameters; - /* TODO: Implement this */ + LibraryParameters.Flags = 0; - return STATUS_SUCCESS; + // + // Initialize the boot library. + // + Status = BlInitializeLibrary(InputParameters, &LibraryParameters); + if (!NT_SUCCESS(Status)) { + goto Exit; + } + +Exit: + BlDestroyLibrary(); + return Status; } diff --git a/BOOT/ENVIRON/INC/bootlib.h b/BOOT/ENVIRON/INC/bootlib.h new file mode 100644 index 0000000..ed3c543 --- /dev/null +++ b/BOOT/ENVIRON/INC/bootlib.h @@ -0,0 +1,37 @@ +/*++ + +Copyright (c) 2024, Quinn Stephens. +Provided under the BSD 3-Clause license. + +Module Name: + + bootlib.h + +Abstract: + + Boot library definitions. + +--*/ + +#ifndef _BOOTLIB_H +#define _BOOTLIB_H + +#include +#include "bootmgr.h" + +typedef struct { + ULONG Flags; +} BOOT_LIBRARY_PARAMETERS, *PBOOT_LIBRARY_PARAMETERS; + +NTSTATUS +BlInitializeLibrary ( + IN PBOOT_INPUT_PARAMETERS InputParameters, + IN PBOOT_LIBRARY_PARAMETERS LibraryParameters + ); + +NTSTATUS +BlDestroyLibrary ( + VOID + ); + +#endif diff --git a/BOOT/ENVIRON/INC/ntdef.h b/BOOT/ENVIRON/INC/ntdef.h index 08076b9..1d790d3 100644 --- a/BOOT/ENVIRON/INC/ntdef.h +++ b/BOOT/ENVIRON/INC/ntdef.h @@ -50,6 +50,9 @@ Abstract: #define NTAPI #endif +#undef NULL +#define NULL ((VOID *)0) + // // Basic types. // diff --git a/BOOT/ENVIRON/LIB/bootlib.c b/BOOT/ENVIRON/LIB/bootlib.c new file mode 100644 index 0000000..8048a7e --- /dev/null +++ b/BOOT/ENVIRON/LIB/bootlib.c @@ -0,0 +1,107 @@ +/*++ + +Copyright (c) 2024, Quinn Stephens. +Provided under the BSD 3-Clause license. + +Module Name: + + bootlib.c + +Abstract: + + Provides boot library utilities. + +--*/ + +#include "bootlib.h" + +NTSTATUS +InitializeLibrary ( + IN PBOOT_INPUT_PARAMETERS InputParameters, + IN PBOOT_LIBRARY_PARAMETERS LibraryParameters + ) + +/*++ + +Routine Description: + + Internal routine to initialize the boot library. + +Arguments: + + InputParameters - pointer to the input parameters structure. + + LibraryParameters - pointer to the library parameters structure. + +Return Value: + + STATUS_SUCCESS if successful. + +--*/ + +{ + (VOID)LibraryParameters; + + // + // Verify input parameters structure. + // + if (InputParameters == NULL || InputParameters->Signature != BOOT_INPUT_PARAMETERS_SIGNATURE) { + return STATUS_INVALID_PARAMETER; + } + + return STATUS_SUCCESS; +} + +NTSTATUS +BlInitializeLibrary ( + IN PBOOT_INPUT_PARAMETERS InputParameters, + IN PBOOT_LIBRARY_PARAMETERS LibraryParameters + ) + +/*++ + +Routine Description: + + Initializes the boot library. + +Arguments: + + InputParameters - pointer to the input parameters structure. + + LibraryParameters - pointer to the library parameters structure. + +Return Value: + + Any value returned by InitializeLibrary(). + +--*/ + +{ + return InitializeLibrary(InputParameters, LibraryParameters); +} + +NTSTATUS +BlDestroyLibrary ( + VOID + ) + +/*++ + +Routine Description: + + Cleans up after the boot library. + +Arguments: + + None. + +Return Value: + + STATUS_SUCCESS if successful. + Error status if an error is encountered. + +--*/ + +{ + return STATUS_SUCCESS; +}