reactos/ntoskrnl/include/internal/cmboot.h
Hermès Bélusca-Maïto 6ff0232368
[NTOS:CM] Adapt cmboot.c for usage in NT/ReactOS bootloader.
- Add a new cmboot.h header to isolate the boot-support definitions
  shared with the NT/ReactOS bootloader.

- Move CmpFreeDriverList() to cmboot.c so that we can use it for
  cleanup paths in the NT/ReactOS bootloader.

- CmpFindControlSet(): Directly build the control set name in UNICODE,
  instead of doing an ANSI->UNICODE conversion.

- Directly assign the CurrentControlSet\Services constant string,
  instead of going the route of init-empty-string + append-string.
  This is possible since that string is not modified later.

- Remove ASSERT(FALSE), replacing them with correct failure handling.

- Add cleanup paths in CmpAddDriverToList().

- Simplify and fix CmpFreeDriverList(): it's the full DriverNode
  that needs to be freed; not the LIST_ENTRY pointer.

- Add other validity checks:
  * Registry value types and data sizes;
  * For multi-strings, verify that they are NULL-terminated.
  * For (multi-)strings, check whether they are NULL-terminated before
    optionally removing their trailing NULL character from the count.
    Check also whether they are of zero-length and take appropriate
    action where necessary.

- Add CmpIsDriverInList() for future usage in CMBOOT compiled in
  bootloader mode.

- Add SAL annotations and Doxygen documentation.

- Add debug traces.

- Formatting / code style fixes.

** TODO: Fix SafeBoot support **
2022-04-16 18:37:45 +02:00

80 lines
1.5 KiB
C

/*
* PROJECT: ReactOS Kernel
* LICENSE: BSD - See COPYING.ARM in the top level directory
* PURPOSE: Configuration Manager - Boot Initialization Internal header
* COPYRIGHT: Copyright 2010 ReactOS Portable Systems Group
*
* NOTE: This module is shared by both the kernel and the bootloader.
*/
//
// Boot Driver Node
//
typedef struct _BOOT_DRIVER_NODE
{
BOOT_DRIVER_LIST_ENTRY ListEntry;
UNICODE_STRING Group;
UNICODE_STRING Name;
ULONG Tag;
ULONG ErrorControl;
} BOOT_DRIVER_NODE, *PBOOT_DRIVER_NODE;
//
// Boot Routines
//
CODE_SEG("INIT")
HCELL_INDEX
NTAPI
CmpFindControlSet(
_In_ PHHIVE SystemHive,
_In_ HCELL_INDEX RootCell,
_In_ PCUNICODE_STRING SelectKeyName,
_Out_ PBOOLEAN AutoSelect);
//
// Driver List Routines
//
#ifdef _BLDR_
CODE_SEG("INIT")
BOOLEAN
NTAPI
CmpIsDriverInList(
_In_ PLIST_ENTRY DriverListHead,
_In_ PCUNICODE_STRING DriverName,
_Out_opt_ PBOOT_DRIVER_NODE* FoundDriver);
#endif /* _BLDR_ */
CODE_SEG("INIT")
BOOLEAN
NTAPI
CmpFindDrivers(
_In_ PHHIVE Hive,
_In_ HCELL_INDEX ControlSet,
_In_ SERVICE_LOAD_TYPE LoadType,
_In_opt_ PCWSTR BootFileSystem,
_Inout_ PLIST_ENTRY DriverListHead);
CODE_SEG("INIT")
BOOLEAN
NTAPI
CmpSortDriverList(
_In_ PHHIVE Hive,
_In_ HCELL_INDEX ControlSet,
_Inout_ PLIST_ENTRY DriverListHead);
CODE_SEG("INIT")
BOOLEAN
NTAPI
CmpResolveDriverDependencies(
_Inout_ PLIST_ENTRY DriverListHead);
CODE_SEG("INIT")
VOID
NTAPI
CmpFreeDriverList(
_In_ PHHIVE Hive,
_Inout_ PLIST_ENTRY DriverListHead);