[NTOS:CM] Adapt cmboot.c for usage in NT/ReactOS bootloader.
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Mon, 21 Mar 2022 22:16:19 +0000 (23:16 +0100)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 16 Apr 2022 16:37:45 +0000 (18:37 +0200)
commit6ff02323684cac98a944b54916ad3fb652a1304d
treef71dbfcea00741ab47d13280814b5326158b21d7
parent6a03fb7099eb4b1a36e24d9c99e36265d2948bfc
[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 **
ntoskrnl/config/cmboot.c
ntoskrnl/config/cmsysini.c
ntoskrnl/include/internal/cm.h
ntoskrnl/include/internal/cmboot.h [new file with mode: 0644]
ntoskrnl/include/internal/io.h