mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 17:44:45 +00:00
[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 **
This commit is contained in:
parent
6a03fb7099
commit
6ff0232368
5 changed files with 785 additions and 371 deletions
File diff suppressed because it is too large
Load diff
|
@ -1721,55 +1721,6 @@ CmInitSystem1(VOID)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
CODE_SEG("INIT")
|
||||
VOID
|
||||
NTAPI
|
||||
CmpFreeDriverList(IN PHHIVE Hive,
|
||||
IN PLIST_ENTRY DriverList)
|
||||
{
|
||||
PLIST_ENTRY NextEntry, OldEntry;
|
||||
PBOOT_DRIVER_NODE DriverNode;
|
||||
PAGED_CODE();
|
||||
|
||||
/* Parse the current list */
|
||||
NextEntry = DriverList->Flink;
|
||||
while (NextEntry != DriverList)
|
||||
{
|
||||
/* Get the driver node */
|
||||
DriverNode = CONTAINING_RECORD(NextEntry, BOOT_DRIVER_NODE, ListEntry.Link);
|
||||
|
||||
/* Get the next entry now, since we're going to free it later */
|
||||
OldEntry = NextEntry;
|
||||
NextEntry = NextEntry->Flink;
|
||||
|
||||
/* Was there a name? */
|
||||
if (DriverNode->Name.Buffer)
|
||||
{
|
||||
/* Free it */
|
||||
CmpFree(DriverNode->Name.Buffer, DriverNode->Name.Length);
|
||||
}
|
||||
|
||||
/* Was there a registry path? */
|
||||
if (DriverNode->ListEntry.RegistryPath.Buffer)
|
||||
{
|
||||
/* Free it */
|
||||
CmpFree(DriverNode->ListEntry.RegistryPath.Buffer,
|
||||
DriverNode->ListEntry.RegistryPath.MaximumLength);
|
||||
}
|
||||
|
||||
/* Was there a file path? */
|
||||
if (DriverNode->ListEntry.FilePath.Buffer)
|
||||
{
|
||||
/* Free it */
|
||||
CmpFree(DriverNode->ListEntry.FilePath.Buffer,
|
||||
DriverNode->ListEntry.FilePath.MaximumLength);
|
||||
}
|
||||
|
||||
/* Now free the node, and move on */
|
||||
CmpFree(OldEntry, sizeof(BOOT_DRIVER_NODE));
|
||||
}
|
||||
}
|
||||
|
||||
CODE_SEG("INIT")
|
||||
PUNICODE_STRING*
|
||||
NTAPI
|
||||
|
|
|
@ -5,9 +5,12 @@
|
|||
* PURPOSE: Internal header for the Configuration Manager
|
||||
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
||||
*/
|
||||
#define _CM_
|
||||
#include "cmlib.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cmlib.h>
|
||||
#include <cmreslist.h>
|
||||
#include "cmboot.h"
|
||||
|
||||
//
|
||||
// Define this if you want debugging support
|
||||
|
@ -1168,16 +1171,6 @@ CmpCreateLinkNode(
|
|||
//
|
||||
// Boot Routines
|
||||
//
|
||||
CODE_SEG("INIT")
|
||||
HCELL_INDEX
|
||||
NTAPI
|
||||
CmpFindControlSet(
|
||||
IN PHHIVE SystemHive,
|
||||
IN HCELL_INDEX RootCell,
|
||||
IN PUNICODE_STRING SelectKeyName,
|
||||
OUT PBOOLEAN AutoSelect
|
||||
);
|
||||
|
||||
CODE_SEG("INIT")
|
||||
VOID
|
||||
NTAPI
|
||||
|
@ -1453,41 +1446,6 @@ CmGetSystemDriverList(
|
|||
VOID
|
||||
);
|
||||
|
||||
CODE_SEG("INIT")
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
CmpFindDrivers(
|
||||
IN PHHIVE Hive,
|
||||
IN HCELL_INDEX ControlSet,
|
||||
IN SERVICE_LOAD_TYPE LoadType,
|
||||
IN PWSTR BootFileSystem OPTIONAL,
|
||||
IN PLIST_ENTRY DriverListHead
|
||||
);
|
||||
|
||||
CODE_SEG("INIT")
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
CmpSortDriverList(
|
||||
IN PHHIVE Hive,
|
||||
IN HCELL_INDEX ControlSet,
|
||||
IN PLIST_ENTRY DriverListHead
|
||||
);
|
||||
|
||||
CODE_SEG("INIT")
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
CmpResolveDriverDependencies(
|
||||
IN PLIST_ENTRY DriverListHead
|
||||
);
|
||||
|
||||
CODE_SEG("INIT")
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
CmpIsSafe(
|
||||
IN PHHIVE Hive,
|
||||
IN HCELL_INDEX SafeBootCell,
|
||||
IN HCELL_INDEX DriverCell);
|
||||
|
||||
//
|
||||
// Global variables accessible from all of Cm
|
||||
//
|
||||
|
|
80
ntoskrnl/include/internal/cmboot.h
Normal file
80
ntoskrnl/include/internal/cmboot.h
Normal file
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* 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);
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Kernel
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: ntoskrnl/include/internal/io.h
|
||||
* PURPOSE: Internal header for the I/O Manager
|
||||
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
||||
*/
|
||||
* PROJECT: ReactOS Kernel
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: ntoskrnl/include/internal/io.h
|
||||
* PURPOSE: Internal header for the I/O Manager
|
||||
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
||||
*/
|
||||
|
||||
#include "ntdddisk.h"
|
||||
|
||||
|
@ -410,18 +410,6 @@ typedef struct _DRIVER_INFORMATION
|
|||
NTSTATUS Status;
|
||||
} DRIVER_INFORMATION, *PDRIVER_INFORMATION;
|
||||
|
||||
//
|
||||
// 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;
|
||||
|
||||
//
|
||||
// List of Bus Type GUIDs
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue