https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f10437b1e2d3daffaa831d...
commit f10437b1e2d3daffaa831d006b5dcb2701024081 Author: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org AuthorDate: Mon Mar 21 23:07:50 2022 +0100 Commit: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org CommitDate: Thu Apr 7 03:19:11 2022 +0200
[FREELDR:NTLDR] Expose and use the CurrentControlSetKey handle.
This allows: (i) to shorten dramatically the lengths of the static registry path strings being used (and thus, allow for reduced binary file size), and (ii) to prepare future support for selecting different control sets (and related Last-Known-Good configurations). --- boot/freeldr/freeldr/ntldr/registry.c | 2 +- boot/freeldr/freeldr/ntldr/registry.h | 2 ++ boot/freeldr/freeldr/ntldr/winldr.c | 12 +++--------- boot/freeldr/freeldr/ntldr/wlregistry.c | 25 +++++++++---------------- 4 files changed, 15 insertions(+), 26 deletions(-)
diff --git a/boot/freeldr/freeldr/ntldr/registry.c b/boot/freeldr/freeldr/ntldr/registry.c index 3db27582935..ea68cc340dc 100644 --- a/boot/freeldr/freeldr/ntldr/registry.c +++ b/boot/freeldr/freeldr/ntldr/registry.c @@ -27,7 +27,7 @@ DBG_DEFAULT_CHANNEL(REGISTRY);
static PCMHIVE CmHive; static PCM_KEY_NODE RootKeyNode; -static HKEY CurrentControlSetKey; +HKEY CurrentControlSetKey;
PVOID NTAPI diff --git a/boot/freeldr/freeldr/ntldr/registry.h b/boot/freeldr/freeldr/ntldr/registry.h index 8368749339d..0743be4866e 100644 --- a/boot/freeldr/freeldr/ntldr/registry.h +++ b/boot/freeldr/freeldr/ntldr/registry.h @@ -32,6 +32,8 @@ LONG RegInitCurrentControlSet( _In_ BOOLEAN LastKnownGood);
+extern HKEY CurrentControlSetKey; + /* * LONG * RegCloseKey( diff --git a/boot/freeldr/freeldr/ntldr/winldr.c b/boot/freeldr/freeldr/ntldr/winldr.c index c923330d6be..5427b14fe22 100644 --- a/boot/freeldr/freeldr/ntldr/winldr.c +++ b/boot/freeldr/freeldr/ntldr/winldr.c @@ -473,9 +473,7 @@ WinLdrDetectVersion(VOID) LONG rc; HKEY hKey;
- rc = RegOpenKey(NULL, - L"\Registry\Machine\SYSTEM\CurrentControlSet\Control\Terminal Server", - &hKey); + rc = RegOpenKey(CurrentControlSetKey, L"Control\Terminal Server", &hKey); if (rc != ERROR_SUCCESS) { /* Key doesn't exist; assume NT 4.0 */ @@ -905,15 +903,11 @@ WinLdrInitErrataInf( /* Open either the 'BiosInfo' (Windows <= 2003) or the 'Errata' (Vista+) key */ if (OperatingSystemVersion >= _WIN32_WINNT_VISTA) { - rc = RegOpenKey(NULL, - L"\Registry\Machine\SYSTEM\CurrentControlSet\Control\Errata", - &hKey); + rc = RegOpenKey(CurrentControlSetKey, L"Control\Errata", &hKey); } else // (OperatingSystemVersion <= _WIN32_WINNT_WS03) { - rc = RegOpenKey(NULL, - L"\Registry\Machine\SYSTEM\CurrentControlSet\Control\BiosInfo", - &hKey); + rc = RegOpenKey(CurrentControlSetKey, L"Control\BiosInfo", &hKey); } if (rc != ERROR_SUCCESS) { diff --git a/boot/freeldr/freeldr/ntldr/wlregistry.c b/boot/freeldr/freeldr/ntldr/wlregistry.c index 92bf593743c..cc139b77111 100644 --- a/boot/freeldr/freeldr/ntldr/wlregistry.c +++ b/boot/freeldr/freeldr/ntldr/wlregistry.c @@ -20,6 +20,7 @@ ULONG TotalNLSSize = 0;
static BOOLEAN WinLdrGetNLSNames( + _In_ HKEY ControlSet, _Inout_ PUNICODE_STRING AnsiFileName, _Inout_ PUNICODE_STRING OemFileName, _Inout_ PUNICODE_STRING LangFileName, // CaseTable @@ -186,7 +187,8 @@ BOOLEAN WinLdrScanSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, WinLdrScanRegistry(&LoaderBlock->BootDriverListHead, SystemRoot);
/* Get names of NLS files */ - Success = WinLdrGetNLSNames(&AnsiFileName, + Success = WinLdrGetNLSNames(CurrentControlSetKey, + &AnsiFileName, &OemFileName, &LangFileName, &OemHalFileName); @@ -219,6 +221,7 @@ BOOLEAN WinLdrScanSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, // Queries registry for those three file names static BOOLEAN WinLdrGetNLSNames( + _In_ HKEY ControlSet, _Inout_ PUNICODE_STRING AnsiFileName, _Inout_ PUNICODE_STRING OemFileName, _Inout_ PUNICODE_STRING LangFileName, // CaseTable @@ -230,9 +233,7 @@ WinLdrGetNLSNames( WCHAR szIdBuffer[80];
/* Open the CodePage key */ - rc = RegOpenKey(NULL, - L"\Registry\Machine\SYSTEM\CurrentControlSet\Control\NLS\CodePage", - &hKey); + rc = RegOpenKey(ControlSet, L"Control\NLS\CodePage", &hKey); if (rc != ERROR_SUCCESS) { //TRACE("Couldn't open CodePage registry key"); @@ -305,9 +306,7 @@ WinLdrGetNLSNames( RegCloseKey(hKey);
/* Open the Language key */ - rc = RegOpenKey(NULL, - L"\Registry\Machine\SYSTEM\CurrentControlSet\Control\NLS\Language", - &hKey); + rc = RegOpenKey(ControlSet, L"Control\NLS\Language", &hKey); if (rc != ERROR_SUCCESS) { //TRACE("Couldn't open Language registry key"); @@ -545,9 +544,7 @@ WinLdrScanRegistry(IN OUT PLIST_ENTRY BootDriverListHead, BOOLEAN Success;
/* Get 'group order list' key */ - rc = RegOpenKey(NULL, - L"\Registry\Machine\SYSTEM\CurrentControlSet\Control\GroupOrderList", - &hOrderKey); + rc = RegOpenKey(CurrentControlSetKey, L"Control\GroupOrderList", &hOrderKey); if (rc != ERROR_SUCCESS) { TRACE_CH(REACTOS, "Failed to open the 'GroupOrderList' key (rc %d)\n", (int)rc); @@ -555,9 +552,7 @@ WinLdrScanRegistry(IN OUT PLIST_ENTRY BootDriverListHead, }
/* Get 'services' key */ - rc = RegOpenKey(NULL, - L"\Registry\Machine\SYSTEM\CurrentControlSet\Services", - &hServiceKey); + rc = RegOpenKey(CurrentControlSetKey, L"Services", &hServiceKey); if (rc != ERROR_SUCCESS) { TRACE_CH(REACTOS, "Failed to open the 'Services' key (rc %d)\n", (int)rc); @@ -566,9 +561,7 @@ WinLdrScanRegistry(IN OUT PLIST_ENTRY BootDriverListHead, }
/* Get 'service group order' key */ - rc = RegOpenKey(NULL, - L"\Registry\Machine\SYSTEM\CurrentControlSet\Control\ServiceGroupOrder", - &hGroupKey); + rc = RegOpenKey(CurrentControlSetKey, L"Control\ServiceGroupOrder", &hGroupKey); if (rc != ERROR_SUCCESS) { TRACE_CH(REACTOS, "Failed to open the 'ServiceGroupOrder' key (rc %d)\n", (int)rc);