From 0705ceae3e334641a41e05c536d916ed7fe7ef51 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 7 Jun 2011 16:42:43 +0000 Subject: [PATCH] [NTOSKRNL/USERINIT/WIN32K] Implement support for SafeMode boot Patch by Adam Kachwalla (geekdundee at gmail dot com) See issue #6275 for more details. svn path=/trunk/; revision=52132 --- .../base/shell/explorer/services/startup.c | 6 + reactos/base/system/services/database.c | 55 ++++- reactos/base/system/userinit/userinit.c | 61 +++++ reactos/boot/bootdata/hivesys_amd64.inf | 137 +++++++++++ reactos/boot/bootdata/hivesys_i386.inf | 138 +++++++++++ reactos/ntoskrnl/config/cmboot.c | 139 ++++++++++- reactos/ntoskrnl/ex/init.c | 5 +- reactos/ntoskrnl/include/internal/cm.h | 7 + .../subsystems/win32/win32k/ntuser/desktop.c | 220 ++++++++++-------- .../subsystems/win32/win32k/ntuser/metric.c | 17 +- .../win32/win32k/objects/freetype.c | 10 +- 11 files changed, 681 insertions(+), 114 deletions(-) diff --git a/reactos/base/shell/explorer/services/startup.c b/reactos/base/shell/explorer/services/startup.c index 1208a32f0d6..ba435632fd9 100644 --- a/reactos/base/shell/explorer/services/startup.c +++ b/reactos/base/shell/explorer/services/startup.c @@ -369,6 +369,9 @@ static BOOL ProcessRunKeys(HKEY hkRoot, LPCWSTR szKeyName, BOOL bDelete, continue; } + /* safe mode - force to run if prefixed with asterisk */ + if (GetSystemMetrics(SM_CLEANBOOT) && (szValue[0] != L'*')) continue; + if (bDelete && (res=RegDeleteValueW(hkRun, szValue))!=ERROR_SUCCESS) { printf("Couldn't delete value - %ld, %ld. Running command anyways.\n", i, res); @@ -467,6 +470,9 @@ int startup(int argc, const char *argv[]) } else ops=DEFAULT; + /* do not run certain items in Safe Mode */ + if(GetSystemMetrics(SM_CLEANBOOT)) ops.startup = FALSE; + /* Perform the ops by order, stopping if one fails, skipping if necessary */ /* Shachar: Sorry for the perl syntax */ res=(ops.ntonly || !ops.preboot || wininit()) && diff --git a/reactos/base/system/services/database.c b/reactos/base/system/services/database.c index 3cf8c4aa3df..0d7ec77e152 100644 --- a/reactos/base/system/services/database.c +++ b/reactos/base/system/services/database.c @@ -1135,14 +1135,65 @@ ScmAutoStartServices(VOID) PLIST_ENTRY ServiceEntry; PSERVICE_GROUP CurrentGroup; PSERVICE CurrentService; + WCHAR szSafeBootServicePath[MAX_PATH]; + DWORD dwError; + HKEY hKey; ULONG i; - /* Clear 'ServiceVisited' flag */ + /* Clear 'ServiceVisited' flag (or set if not to start in Safe Mode) */ ServiceEntry = ServiceListHead.Flink; while (ServiceEntry != &ServiceListHead) { CurrentService = CONTAINING_RECORD(ServiceEntry, SERVICE, ServiceListEntry); - CurrentService->ServiceVisited = FALSE; + /* Build the safe boot path */ + wcscpy(szSafeBootServicePath, + L"SYSTEM\\CurrentControlSet\\Control\\SafeBoot"); + switch(GetSystemMetrics(SM_CLEANBOOT)) + { + /* NOTE: Assumes MINIMAL (1) and DSREPAIR (3) load same items */ + case 1: + case 3: wcscat(szSafeBootServicePath, L"\\Minimal\\"); break; + case 2: wcscat(szSafeBootServicePath, L"\\Network\\"); break; + } + if(GetSystemMetrics(SM_CLEANBOOT)) + { + /* If key does not exist then do not assume safe mode */ + dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE, + szSafeBootServicePath, + 0, + KEY_READ, + &hKey); + if(dwError == ERROR_SUCCESS) + { + RegCloseKey(hKey); + /* Finish Safe Boot path off */ + wcsncat(szSafeBootServicePath, + CurrentService->lpServiceName, + MAX_PATH - wcslen(szSafeBootServicePath)); + /* Check that the key is in the Safe Boot path */ + dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE, + szSafeBootServicePath, + 0, + KEY_READ, + &hKey); + if(dwError != ERROR_SUCCESS) + { + /* Mark service as visited so it is not auto-started */ + CurrentService->ServiceVisited = TRUE; + } + else + { + /* Must be auto-started in safe mode - mark as unvisited */ + RegCloseKey(hKey); + CurrentService->ServiceVisited = FALSE; + } + } + else + { + DPRINT1("WARNING: Could not open the associated Safe Boot key!"); + CurrentService->ServiceVisited = FALSE; + } + } ServiceEntry = ServiceEntry->Flink; } diff --git a/reactos/base/system/userinit/userinit.c b/reactos/base/system/userinit/userinit.c index 81027d4b964..6dbf1bb6c34 100644 --- a/reactos/base/system/userinit/userinit.c +++ b/reactos/base/system/userinit/userinit.c @@ -274,9 +274,70 @@ VOID StartShell(VOID) { WCHAR Shell[MAX_PATH]; TCHAR szMsg[RC_STRING_MAX_SIZE]; + DWORD Type, Size; + DWORD Value = 0; + LONG rc; + HKEY hKey; TRACE("()\n"); + /* Safe Mode shell run */ + rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"SYSTEM\\CurrentControlSet\\Control\\SafeBoot\\Option", + 0, KEY_QUERY_VALUE, &hKey); + if(rc == ERROR_SUCCESS) + { + Size = sizeof(Value); + rc = RegQueryValueExW(hKey, L"UseAlternateShell", NULL, + &Type, (LPBYTE)&Value, &Size); + if(rc == ERROR_SUCCESS) + { + RegCloseKey(hKey); + if(Type == REG_DWORD) + { + if(Value) + { + /* Safe Mode Alternate Shell required */ + rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"SYSTEM\\CurrentControlSet\\Control\\SafeBoot", + 0, KEY_READ, &hKey); + if(rc == ERROR_SUCCESS) + { + Size = MAX_PATH * sizeof(WCHAR); + rc = RegQueryValueExW(hKey, L"AlternateShell", NULL, + &Type, (LPBYTE)Shell, &Size); + if(rc == ERROR_SUCCESS) + { + RegCloseKey(hKey); + if ((Type == REG_SZ) || (Type == REG_EXPAND_SZ)) + { + TRACE("Key located - %s\n", debugstr_w(Shell)); + /* Try to run alternate shell */ + if (TryToStartShell(Shell)) + { + TRACE("Alternate shell started (Safe Mode)\n"); + return; + } + } + else + { + WARN("Wrong type %lu (expected %u or %u)\n", + Type, REG_SZ, REG_EXPAND_SZ); + } + } + else + { + WARN("Alternate shell in Safe Mode required but not specified."); + } + } + } + } + else + { + WARN("Wrong type %lu (expected %u)\n", Type, REG_DWORD); + } + } + } /* Try to run shell in user key */ if (GetShell(Shell, HKEY_CURRENT_USER) && TryToStartShell(Shell)) { diff --git a/reactos/boot/bootdata/hivesys_amd64.inf b/reactos/boot/bootdata/hivesys_amd64.inf index af890ec1b55..9ba0a7f47f5 100644 --- a/reactos/boot/bootdata/hivesys_amd64.inf +++ b/reactos/boot/bootdata/hivesys_amd64.inf @@ -8,6 +8,143 @@ HKLM,"SYSTEM\CurrentControlSet\Control","WaitToKillServiceTimeout",2,"20000" HKLM,"SYSTEM\CurrentControlSet\Control\Biosinfo","InfName",2,"biosinfo.inf" HKLM,"SYSTEM\CurrentControlSet\Control\PnP",,0x00000012 +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot","AlternateShell",2,"cmd.exe" + +; Safe Boot drivers +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\AppMgmt","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\Base","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\Boot Bus Extender","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\Boot file system","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\CryptSvc","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\DcomLaunch","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\dmadmin","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\dmboot.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\dmio.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\dmload.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\dmserver","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\EventLog","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\File system","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\Filter","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\HelpSvc","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\Netlogon","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\PCI Configuration","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\PlugPlay","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\PNP Filter","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\Primary disk","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\RpcSs","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\SCSI Class","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\sermouse.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\sr.sys","",0x00000000,"FSFilter System Recovery" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\SRService","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\System Bus Extender","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\vga.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\vgasave.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\WinMgmt","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\{36FC9E60-C465-11CF-8056-444553540000}","",0x00000000,"Universal Serial Bus controllers" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\{4D36E965-E325-11CE-BFC1-08002BE10318}","",0x00000000,"CD-ROM Drive" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\{4D36E967-E325-11CE-BFC1-08002BE10318}","",0x00000000,"DiskDrive" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\{4D36E969-E325-11CE-BFC1-08002BE10318}","",0x00000000,"Standard floppy disk controller" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\{4D36E96A-E325-11CE-BFC1-08002BE10318}","",0x00000000,"Hdc" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\{4D36E96B-E325-11CE-BFC1-08002BE10318}","",0x00000000,"Keyboard" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\{4D36E96F-E325-11CE-BFC1-08002BE10318}","",0x00000000,"Mouse" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\{4D36E977-E325-11CE-BFC1-08002BE10318}","",0x00000000,"PCMCIA Adapters" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\{4D36E97B-E325-11CE-BFC1-08002BE10318}","",0x00000000,"SCSIAdapter" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\{4D36E97D-E325-11CE-BFC1-08002BE10318}","",0x00000000,"System" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\{4D36E980-E325-11CE-BFC1-08002BE10318}","",0x00000000,"Floppy disk drive" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\{71A27CDD-812A-11D0-BEC7-08002BE2092F}","",0x00000000,"Volume" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\{745A17A0-74D3-11D0-B6FE-00A0C90F57DA}","",0x00000000,"Human Interface Devices" + +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\AFD","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\AppMgmt","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Base","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Boot Bus Extender","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Boot file system","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Browser","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\CryptSvc","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\DcomLaunch","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Dhcp","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\dmadmin","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\dmboot.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\dmio.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\dmload.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\dmserver","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\DnsCache","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\EventLog","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\File system","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Filter","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\HelpSvc","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\ip6fw.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\ipnat.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\LanmanServer","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\LanmanWorkstation","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\LmHosts","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Messenger","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\NDIS","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\NDIS Wrapper","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Ndisuio","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\NetBIOS","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\NetBIOSGroup","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\NetBT","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\NetDDEGroup","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Netlogon","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\NetMan","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Network","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\NetworkProvider","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\NtLmSsp","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\PCI Configuration","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\PlugPlay","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\PNP Filter","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\PNP_TDI","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Primary disk","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\rdpcdd.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\rdpdd.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\rdpwd.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\rdsessmgr","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\RpcSs","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\SCSI Class","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\sermouse.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\SharedAccess","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\sr.sys","",0x00000000,"FSFilter System Recovery" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\SRService","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Streams Drivers","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\System Bus Extender","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Tcpip","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\TDI","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\tdpipe.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\tdtcp.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\termservice","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\vga.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\vgasave.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\WinMgmt","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\WZCSVC","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{36FC9E60-C465-11CF-8056-444553540000}","",0x00000000,"Universal Serial Bus controllers" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E965-E325-11CE-BFC1-08002BE10318}","",0x00000000,"CD-ROM Drive" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E967-E325-11CE-BFC1-08002BE10318}","",0x00000000,"DiskDrive" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E969-E325-11CE-BFC1-08002BE10318}","",0x00000000,"Standard floppy disk controller" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E96A-E325-11CE-BFC1-08002BE10318}","",0x00000000,"Hdc" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E96B-E325-11CE-BFC1-08002BE10318}","",0x00000000,"Keyboard" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E96F-E325-11CE-BFC1-08002BE10318}","",0x00000000,"Mouse" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}","",0x00000000,"Net" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E973-E325-11CE-BFC1-08002BE10318}","",0x00000000,"NetClient" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E974-E325-11CE-BFC1-08002BE10318}","",0x00000000,"NetService" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E975-E325-11CE-BFC1-08002BE10318}","",0x00000000,"NetTrans" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E977-E325-11CE-BFC1-08002BE10318}","",0x00000000,"PCMCIA Adapters" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E97B-E325-11CE-BFC1-08002BE10318}","",0x00000000,"SCSIAdapter" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E97D-E325-11CE-BFC1-08002BE10318}","",0x00000000,"System" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E980-E325-11CE-BFC1-08002BE10318}","",0x00000000,"Floppy disk drive" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{71A27CDD-812A-11D0-BEC7-08002BE2092F}","",0x00000000,"Volume" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{745A17A0-74D3-11D0-B6FE-00A0C90F57DA}","",0x00000000,"Human Interface Devices" + +; ReactOS specific - required to load in Safe Mode and for debugging in Safe Mode (until vga.sys and vgasave.sys are implemented) +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\Debug","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\vgamp.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\vbemp.sys","",0x00000000,"Driver" + +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Debug","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\vgamp.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\vbemp.sys","",0x00000000,"Driver" + +; Other HKLM,"SYSTEM\CurrentControlSet\Control\FileSystem","NtfsDisable8dot3NameCreation",0x00010003,0 HKLM,"SYSTEM\CurrentControlSet\Control\FileSystem","Win31FileSystem",0x00010001,0 HKLM,"SYSTEM\CurrentControlSet\Control\FileSystem","Win95TruncatedExtensions",0x00010001,1 diff --git a/reactos/boot/bootdata/hivesys_i386.inf b/reactos/boot/bootdata/hivesys_i386.inf index 3561a0d9bff..42517d9f37e 100644 --- a/reactos/boot/bootdata/hivesys_i386.inf +++ b/reactos/boot/bootdata/hivesys_i386.inf @@ -7,6 +7,144 @@ HKLM,"SYSTEM\CurrentControlSet\Control","CurrentUser",2,"USERNAME" HKLM,"SYSTEM\CurrentControlSet\Control","WaitToKillServiceTimeout",2,"20000" HKLM,"SYSTEM\CurrentControlSet\Control\Biosinfo","InfName",2,"biosinfo.inf" HKLM,"SYSTEM\CurrentControlSet\Control\PnP",,0x00000012 + +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot","AlternateShell",2,"cmd.exe" + +; Safe Boot drivers +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\AppMgmt","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\Base","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\Boot Bus Extender","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\Boot file system","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\CryptSvc","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\DcomLaunch","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\dmadmin","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\dmboot.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\dmio.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\dmload.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\dmserver","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\EventLog","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\File system","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\Filter","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\HelpSvc","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\Netlogon","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\PCI Configuration","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\PlugPlay","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\PNP Filter","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\Primary disk","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\RpcSs","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\SCSI Class","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\sermouse.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\sr.sys","",0x00000000,"FSFilter System Recovery" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\SRService","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\System Bus Extender","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\vga.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\vgasave.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\WinMgmt","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\{36FC9E60-C465-11CF-8056-444553540000}","",0x00000000,"Universal Serial Bus controllers" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\{4D36E965-E325-11CE-BFC1-08002BE10318}","",0x00000000,"CD-ROM Drive" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\{4D36E967-E325-11CE-BFC1-08002BE10318}","",0x00000000,"DiskDrive" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\{4D36E969-E325-11CE-BFC1-08002BE10318}","",0x00000000,"Standard floppy disk controller" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\{4D36E96A-E325-11CE-BFC1-08002BE10318}","",0x00000000,"Hdc" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\{4D36E96B-E325-11CE-BFC1-08002BE10318}","",0x00000000,"Keyboard" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\{4D36E96F-E325-11CE-BFC1-08002BE10318}","",0x00000000,"Mouse" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\{4D36E977-E325-11CE-BFC1-08002BE10318}","",0x00000000,"PCMCIA Adapters" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\{4D36E97B-E325-11CE-BFC1-08002BE10318}","",0x00000000,"SCSIAdapter" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\{4D36E97D-E325-11CE-BFC1-08002BE10318}","",0x00000000,"System" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\{4D36E980-E325-11CE-BFC1-08002BE10318}","",0x00000000,"Floppy disk drive" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\{71A27CDD-812A-11D0-BEC7-08002BE2092F}","",0x00000000,"Volume" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\{745A17A0-74D3-11D0-B6FE-00A0C90F57DA}","",0x00000000,"Human Interface Devices" + +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\AFD","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\AppMgmt","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Base","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Boot Bus Extender","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Boot file system","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Browser","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\CryptSvc","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\DcomLaunch","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Dhcp","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\dmadmin","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\dmboot.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\dmio.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\dmload.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\dmserver","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\DnsCache","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\EventLog","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\File system","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Filter","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\HelpSvc","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\ip6fw.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\ipnat.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\LanmanServer","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\LanmanWorkstation","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\LmHosts","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Messenger","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\NDIS","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\NDIS Wrapper","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Ndisuio","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\NetBIOS","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\NetBIOSGroup","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\NetBT","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\NetDDEGroup","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Netlogon","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\NetMan","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Network","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\NetworkProvider","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\NtLmSsp","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\PCI Configuration","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\PlugPlay","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\PNP Filter","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\PNP_TDI","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Primary disk","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\rdpcdd.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\rdpdd.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\rdpwd.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\rdsessmgr","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\RpcSs","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\SCSI Class","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\sermouse.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\SharedAccess","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\sr.sys","",0x00000000,"FSFilter System Recovery" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\SRService","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Streams Drivers","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\System Bus Extender","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Tcpip","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\TDI","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\tdpipe.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\tdtcp.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\termservice","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\vga.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\vgasave.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\WinMgmt","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\WZCSVC","",0x00000000,"Service" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{36FC9E60-C465-11CF-8056-444553540000}","",0x00000000,"Universal Serial Bus controllers" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E965-E325-11CE-BFC1-08002BE10318}","",0x00000000,"CD-ROM Drive" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E967-E325-11CE-BFC1-08002BE10318}","",0x00000000,"DiskDrive" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E969-E325-11CE-BFC1-08002BE10318}","",0x00000000,"Standard floppy disk controller" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E96A-E325-11CE-BFC1-08002BE10318}","",0x00000000,"Hdc" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E96B-E325-11CE-BFC1-08002BE10318}","",0x00000000,"Keyboard" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E96F-E325-11CE-BFC1-08002BE10318}","",0x00000000,"Mouse" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}","",0x00000000,"Net" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E973-E325-11CE-BFC1-08002BE10318}","",0x00000000,"NetClient" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E974-E325-11CE-BFC1-08002BE10318}","",0x00000000,"NetService" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E975-E325-11CE-BFC1-08002BE10318}","",0x00000000,"NetTrans" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E977-E325-11CE-BFC1-08002BE10318}","",0x00000000,"PCMCIA Adapters" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E97B-E325-11CE-BFC1-08002BE10318}","",0x00000000,"SCSIAdapter" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E97D-E325-11CE-BFC1-08002BE10318}","",0x00000000,"System" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{4D36E980-E325-11CE-BFC1-08002BE10318}","",0x00000000,"Floppy disk drive" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{71A27CDD-812A-11D0-BEC7-08002BE2092F}","",0x00000000,"Volume" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\{745A17A0-74D3-11D0-B6FE-00A0C90F57DA}","",0x00000000,"Human Interface Devices" + +; ReactOS specific - required to load in Safe Mode and for debugging in Safe Mode (until vga.sys and vgasave.sys are implemented) +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\Debug","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\vgamp.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\vbemp.sys","",0x00000000,"Driver" + +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Debug","",0x00000000,"Driver Group" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\vgamp.sys","",0x00000000,"Driver" +HKLM,"SYSTEM\CurrentControlSet\Control\SafeBoot\Network\vbemp.sys","",0x00000000,"Driver" + +; Other HKLM,"SYSTEM\CurrentControlSet\Control\Arbiters",,0x00000012 HKLM,"SYSTEM\CurrentControlSet\Control\Arbiters\AllocationOrder","Root",0x000a0001,\ diff --git a/reactos/ntoskrnl/config/cmboot.c b/reactos/ntoskrnl/config/cmboot.c index 1416c4dfe01..6af7e3c16f6 100644 --- a/reactos/ntoskrnl/config/cmboot.c +++ b/reactos/ntoskrnl/config/cmboot.c @@ -12,7 +12,11 @@ #include "ntoskrnl.h" #define NDEBUG #include "debug.h" - + +/* GLOBALS ********************************************************************/ + +extern ULONG InitSafeBootMode; + /* FUNCTIONS ******************************************************************/ HCELL_INDEX @@ -383,6 +387,7 @@ CmpFindDrivers(IN PHHIVE Hive, IN PLIST_ENTRY DriverListHead) { HCELL_INDEX ServicesCell, ControlCell, GroupOrderCell, DriverCell; + HCELL_INDEX SafeBootCell = HCELL_NIL; UNICODE_STRING Name; ULONG i; WCHAR Buffer[128]; @@ -416,6 +421,31 @@ CmpFindDrivers(IN PHHIVE Hive, GroupOrderCell = CmpFindSubKeyByName(Hive, Node, &Name); if (GroupOrderCell == HCELL_NIL) return FALSE; + /* Get Safe Boot cell */ + if(InitSafeBootMode) + { + /* Open the Safe Boot key */ + RtlInitUnicodeString(&Name, L"SafeBoot"); + Node = HvGetCell(Hive, ControlCell); + ASSERT(Node); + SafeBootCell = CmpFindSubKeyByName(Hive, Node, &Name); + if (SafeBootCell == HCELL_NIL) return FALSE; + + /* Open the correct start key (depending on the mode) */ + Node = HvGetCell(Hive, SafeBootCell); + ASSERT(Node); + switch(InitSafeBootMode) + { + /* NOTE: Assumes MINIMAL (1) and DSREPAIR (3) load same items */ + case 1: + case 3: RtlInitUnicodeString(&Name, L"Minimal"); break; + case 2: RtlInitUnicodeString(&Name, L"Network"); break; + default: return FALSE; + } + SafeBootCell = CmpFindSubKeyByName(Hive, Node, &Name); + if(SafeBootCell == HCELL_NIL) return FALSE; + } + /* Build the root registry path */ RtlInitEmptyUnicodeString(&KeyPath, Buffer, sizeof(Buffer)); RtlAppendUnicodeToString(&KeyPath, L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\"); @@ -425,8 +455,9 @@ CmpFindDrivers(IN PHHIVE Hive, DriverCell = CmpFindSubKeyByNumber(Hive, ServicesNode, i); while (DriverCell != HCELL_NIL) { - /* Make sure it's a driver of this start type */ - if (CmpIsLoadType(Hive, DriverCell, LoadType)) + /* Make sure it's a driver of this start type AND is "safe" to load */ + if (CmpIsLoadType(Hive, DriverCell, LoadType) && + CmpIsSafe(Hive, SafeBootCell, DriverCell)) { /* Add it to the list */ CmpAddDriverToList(Hive, @@ -687,4 +718,106 @@ CmpResolveDriverDependencies(IN PLIST_ENTRY DriverListHead) return TRUE; } +BOOLEAN +NTAPI +INIT_FUNCTION +CmpIsSafe(IN PHHIVE Hive, + IN HCELL_INDEX SafeBootCell, + IN HCELL_INDEX DriverCell) +{ + PCM_KEY_NODE SafeBootNode; + PCM_KEY_NODE DriverNode; + PCM_KEY_VALUE KeyValue; + HCELL_INDEX CellIndex; + ULONG Length = 0; + UNICODE_STRING Name; + PWCHAR OriginalName; + ASSERT(Hive->ReleaseCellRoutine == NULL); + + /* Driver key node (mandatory) */ + ASSERT(DriverCell != HCELL_NIL); + DriverNode = HvGetCell(Hive, DriverCell); + ASSERT(DriverNode); + + /* Safe boot key node (optional but return TRUE if not present) */ + if(SafeBootCell == HCELL_NIL) return TRUE; + SafeBootNode = HvGetCell(Hive, SafeBootCell); + if(!SafeBootNode) return FALSE; + + /* Search by the name from the group */ + RtlInitUnicodeString(&Name, L"Group"); + CellIndex = CmpFindValueByName(Hive, DriverNode, &Name); + if(CellIndex != HCELL_NIL) + { + KeyValue = HvGetCell(Hive, CellIndex); + ASSERT(KeyValue); + if (KeyValue->Type == REG_SZ || KeyValue->Type == REG_EXPAND_SZ) + { + /* Compose the search 'key' */ + Name.Buffer = (PWCHAR)CmpValueToData(Hive, KeyValue, &Length); + if (!Name.Buffer) return FALSE; + Name.Length = Length - sizeof(UNICODE_NULL); + Name.MaximumLength = Name.Length; + /* Search for corresponding key in the Safe Boot key */ + CellIndex = CmpFindSubKeyByName(Hive, SafeBootNode, &Name); + if(CellIndex != HCELL_NIL) return TRUE; + } + } + + /* Group has not been found - find driver name */ + Name.Length = DriverNode->Flags & KEY_COMP_NAME ? + CmpCompressedNameSize(DriverNode->Name, + DriverNode->NameLength) : + DriverNode->NameLength; + Name.MaximumLength = Name.Length; + /* Now allocate the buffer for it and copy the name */ + Name.Buffer = CmpAllocate(Name.Length, FALSE, TAG_CM); + if (!Name.Buffer) return FALSE; + if (DriverNode->Flags & KEY_COMP_NAME) + { + /* Compressed name */ + CmpCopyCompressedName(Name.Buffer, + Name.Length, + DriverNode->Name, + DriverNode->NameLength); + } + else + { + /* Normal name */ + RtlCopyMemory(Name.Buffer, DriverNode->Name, DriverNode->NameLength); + } + CellIndex = CmpFindSubKeyByName(Hive, SafeBootNode, &Name); + RtlFreeUnicodeString(&Name); + if(CellIndex != HCELL_NIL) return TRUE; + + /* Not group or driver name - search by image name */ + RtlInitUnicodeString(&Name, L"ImagePath"); + CellIndex = CmpFindValueByName(Hive, DriverNode, &Name); + if(CellIndex != HCELL_NIL) + { + KeyValue = HvGetCell(Hive, CellIndex); + ASSERT(KeyValue); + if (KeyValue->Type == REG_SZ || KeyValue->Type == REG_EXPAND_SZ) + { + /* Compose the search 'key' */ + OriginalName = (PWCHAR)CmpValueToData(Hive, KeyValue, &Length); + if (!OriginalName) return FALSE; + /* Get the base image file name */ + Name.Buffer = wcsrchr(OriginalName, L'\\'); + if (!Name.Buffer) return FALSE; + ++Name.Buffer; + /* Length of the base name must be >=1 */ + Name.Length = Length - ((PUCHAR)Name.Buffer - (PUCHAR)OriginalName) + - sizeof(UNICODE_NULL); + if(Name.Length < 1) return FALSE; + Name.MaximumLength = Name.Length; + /* Search for corresponding key in the Safe Boot key */ + CellIndex = CmpFindSubKeyByName(Hive, SafeBootNode, &Name); + if(CellIndex != HCELL_NIL) return TRUE; + } + } + /* Nothing found - nothing else to search */ + return FALSE; +} + /* EOF */ diff --git a/reactos/ntoskrnl/ex/init.c b/reactos/ntoskrnl/ex/init.c index 7f4c8457178..d197e9d6283 100644 --- a/reactos/ntoskrnl/ex/init.c +++ b/reactos/ntoskrnl/ex/init.c @@ -1792,7 +1792,10 @@ Phase1InitializationDiscard(IN PVOID Context) &KeyPartialInfo, sizeof(KeyPartialInfo), &Length); - if (!NT_SUCCESS(Status)) AlternateShell = FALSE; + if (!(NT_SUCCESS(Status) || Status == STATUS_BUFFER_OVERFLOW)) + { + AlternateShell = FALSE; + } } /* Create the option key */ diff --git a/reactos/ntoskrnl/include/internal/cm.h b/reactos/ntoskrnl/include/internal/cm.h index d7d118cfa44..c70e9c064ae 100644 --- a/reactos/ntoskrnl/include/internal/cm.h +++ b/reactos/ntoskrnl/include/internal/cm.h @@ -1569,6 +1569,13 @@ CmpResolveDriverDependencies( IN PLIST_ENTRY DriverListHead ); +BOOLEAN +NTAPI +CmpIsSafe( + IN PHHIVE Hive, + IN HCELL_INDEX SafeBootCell, + IN HCELL_INDEX DriverCell); + // // Global variables accessible from all of Cm // diff --git a/reactos/subsystems/win32/win32k/ntuser/desktop.c b/reactos/subsystems/win32/win32k/ntuser/desktop.c index 3dbfdcf117e..b10e238fcf4 100644 --- a/reactos/subsystems/win32/win32k/ntuser/desktop.c +++ b/reactos/subsystems/win32/win32k/ntuser/desktop.c @@ -1346,6 +1346,7 @@ NtUserPaintDesktop(HDC hDC) HWND hWndDesktop; BOOL doPatBlt = TRUE; PWND WndDesktop; + static WCHAR s_wszSafeMode[] = L"Safe Mode"; int len; COLORREF color_old; UINT align_old; @@ -1367,133 +1368,132 @@ NtUserPaintDesktop(HDC hDC) RETURN(FALSE); } - DesktopBrush = (HBRUSH)WndDesktop->pcls->hbrBackground; - - - /* - * Paint desktop background - */ - - if (WinSta->hbmWallpaper != NULL) - { - PWND DeskWin; - - DeskWin = UserGetWindowObject(hWndDesktop); - - if (DeskWin) - { - SIZE sz; - int x, y; - HDC hWallpaperDC; - - sz.cx = DeskWin->rcWindow.right - DeskWin->rcWindow.left; - sz.cy = DeskWin->rcWindow.bottom - DeskWin->rcWindow.top; + if (!UserGetSystemMetrics(SM_CLEANBOOT)) + { + DesktopBrush = (HBRUSH)WndDesktop->pcls->hbrBackground; - if (WinSta->WallpaperMode == wmStretch || - WinSta->WallpaperMode == wmTile) - { - x = 0; - y = 0; - } - else - { - /* Find the upper left corner, can be negtive if the bitmap is bigger then the screen */ - x = (sz.cx / 2) - (WinSta->cxWallpaper / 2); - y = (sz.cy / 2) - (WinSta->cyWallpaper / 2); - } + /* + * Paint desktop background + */ + if (WinSta->hbmWallpaper != NULL) + { + SIZE sz; + int x, y; + HDC hWallpaperDC; - hWallpaperDC = NtGdiCreateCompatibleDC(hDC); - if(hWallpaperDC != NULL) - { - HBITMAP hOldBitmap; + sz.cx = WndDesktop->rcWindow.right - WndDesktop->rcWindow.left; + sz.cy = WndDesktop->rcWindow.bottom - WndDesktop->rcWindow.top; - /* fill in the area that the bitmap is not going to cover */ - if (x > 0 || y > 0) + if (WinSta->WallpaperMode == wmStretch || + WinSta->WallpaperMode == wmTile) { - /* FIXME - clip out the bitmap - can be replaced with "NtGdiPatBlt(hDC, x, y, WinSta->cxWallpaper, WinSta->cyWallpaper, PATCOPY | DSTINVERT);" - once we support DSTINVERT */ - PreviousBrush = NtGdiSelectBrush(hDC, DesktopBrush); - NtGdiPatBlt(hDC, Rect.left, Rect.top, Rect.right, Rect.bottom, PATCOPY); - NtGdiSelectBrush(hDC, PreviousBrush); + x = 0; + y = 0; } + else + { + /* Find the upper left corner, can be negtive if the bitmap is bigger then the screen */ + x = (sz.cx / 2) - (WinSta->cxWallpaper / 2); + y = (sz.cy / 2) - (WinSta->cyWallpaper / 2); + } + + hWallpaperDC = NtGdiCreateCompatibleDC(hDC); + if(hWallpaperDC != NULL) + { + HBITMAP hOldBitmap; - /*Do not fill the background after it is painted no matter the size of the picture */ - doPatBlt = FALSE; + /* fill in the area that the bitmap is not going to cover */ + if (x > 0 || y > 0) + { + /* FIXME - clip out the bitmap + can be replaced with "NtGdiPatBlt(hDC, x, y, WinSta->cxWallpaper, WinSta->cyWallpaper, PATCOPY | DSTINVERT);" + once we support DSTINVERT */ + PreviousBrush = NtGdiSelectBrush(hDC, DesktopBrush); + NtGdiPatBlt(hDC, Rect.left, Rect.top, Rect.right, Rect.bottom, PATCOPY); + NtGdiSelectBrush(hDC, PreviousBrush); + } - hOldBitmap = NtGdiSelectBitmap(hWallpaperDC, WinSta->hbmWallpaper); + /*Do not fill the background after it is painted no matter the size of the picture */ + doPatBlt = FALSE; - if (WinSta->WallpaperMode == wmStretch) - { - if(Rect.right && Rect.bottom) - NtGdiStretchBlt(hDC, - x, - y, - sz.cx, - sz.cy, - hWallpaperDC, - 0, - 0, - WinSta->cxWallpaper, - WinSta->cyWallpaper, - SRCCOPY, - 0); + hOldBitmap = NtGdiSelectBitmap(hWallpaperDC, WinSta->hbmWallpaper); - } - else if (WinSta->WallpaperMode == wmTile) - { - /* paint the bitmap across the screen then down */ - for(y = 0; y < Rect.bottom; y += WinSta->cyWallpaper) + if (WinSta->WallpaperMode == wmStretch) { - for(x = 0; x < Rect.right; x += WinSta->cxWallpaper) - { - NtGdiBitBlt(hDC, + if(Rect.right && Rect.bottom) + NtGdiStretchBlt(hDC, x, y, - WinSta->cxWallpaper, - WinSta->cyWallpaper, + sz.cx, + sz.cy, hWallpaperDC, 0, 0, + WinSta->cxWallpaper, + WinSta->cyWallpaper, SRCCOPY, - 0, 0); + + } + else if (WinSta->WallpaperMode == wmTile) + { + /* paint the bitmap across the screen then down */ + for(y = 0; y < Rect.bottom; y += WinSta->cyWallpaper) + { + for(x = 0; x < Rect.right; x += WinSta->cxWallpaper) + { + NtGdiBitBlt(hDC, + x, + y, + WinSta->cxWallpaper, + WinSta->cyWallpaper, + hWallpaperDC, + 0, + 0, + SRCCOPY, + 0, + 0); + } } } + else + { + NtGdiBitBlt(hDC, + x, + y, + WinSta->cxWallpaper, + WinSta->cyWallpaper, + hWallpaperDC, + 0, + 0, + SRCCOPY, + 0, + 0); + } + NtGdiSelectBitmap(hWallpaperDC, hOldBitmap); + NtGdiDeleteObjectApp(hWallpaperDC); } - else - { - NtGdiBitBlt(hDC, - x, - y, - WinSta->cxWallpaper, - WinSta->cyWallpaper, - hWallpaperDC, - 0, - 0, - SRCCOPY, - 0, - 0); - } - NtGdiSelectBitmap(hWallpaperDC, hOldBitmap); - NtGdiDeleteObjectApp(hWallpaperDC); - } - } - } + } + } + else + { + /* Black desktop background in Safe Mode */ + DesktopBrush = StockObjects[BLACK_BRUSH]; + } - /* Back ground is set to none, clear the screen */ - if (doPatBlt) - { + /* Back ground is set to none, clear the screen */ + if (doPatBlt) + { PreviousBrush = NtGdiSelectBrush(hDC, DesktopBrush); NtGdiPatBlt(hDC, Rect.left, Rect.top, Rect.right, Rect.bottom, PATCOPY); NtGdiSelectBrush(hDC, PreviousBrush); - } + } /* * Display system version on the desktop background */ - if (g_PaintDesktopVersion) + if (g_PaintDesktopVersion||UserGetSystemMetrics(SM_CLEANBOOT)) { static WCHAR s_wszVersion[256] = {0}; RECTL rect; @@ -1519,7 +1519,29 @@ NtUserPaintDesktop(HDC hDC) align_old = IntGdiSetTextAlign(hDC, TA_RIGHT); mode_old = IntGdiSetBkMode(hDC, TRANSPARENT); - GreExtTextOutW(hDC, rect.right-16, rect.bottom-48, 0, NULL, s_wszVersion, len, NULL, 0); + if(!UserGetSystemMetrics(SM_CLEANBOOT)) + { + GreExtTextOutW(hDC, rect.right-16, rect.bottom-48, 0, NULL, s_wszVersion, len, NULL, 0); + } + else + { + /* Safe Mode */ + /* Version information text in top center */ + IntGdiSetTextAlign(hDC, TA_CENTER|TA_TOP); + GreExtTextOutW(hDC, (rect.right+rect.left)/2, rect.top, 0, NULL, s_wszVersion, len, NULL, 0); + /* Safe Mode text in corners */ + len = wcslen(s_wszSafeMode); + IntGdiSetTextAlign(hDC, TA_RIGHT|TA_TOP); + GreExtTextOutW(hDC, rect.right, rect.top, 0, NULL, s_wszSafeMode, len, NULL, 0); + IntGdiSetTextAlign(hDC, TA_RIGHT|TA_BASELINE); + GreExtTextOutW(hDC, rect.right, rect.bottom, 0, NULL, s_wszSafeMode, len, NULL, 0); + IntGdiSetTextAlign(hDC, TA_LEFT|TA_TOP); + GreExtTextOutW(hDC, rect.left, rect.top, 0, NULL, s_wszSafeMode, len, NULL, 0); + IntGdiSetTextAlign(hDC, TA_LEFT|TA_BASELINE); + GreExtTextOutW(hDC, rect.left, rect.bottom, 0, NULL, s_wszSafeMode, len, NULL, 0); + + } + IntGdiSetBkMode(hDC, mode_old); IntGdiSetTextAlign(hDC, align_old); diff --git a/reactos/subsystems/win32/win32k/ntuser/metric.c b/reactos/subsystems/win32/win32k/ntuser/metric.c index e8829570a16..060f0df11be 100644 --- a/reactos/subsystems/win32/win32k/ntuser/metric.c +++ b/reactos/subsystems/win32/win32k/ntuser/metric.c @@ -23,9 +23,21 @@ BOOL FASTCALL InitMetrics(VOID) { - INT *piSysMet; + INT *piSysMet = gpsi->aiSysMet; ULONG Width, Height; + /* note: used for the SM_CLEANBOOT metric */ + DWORD dwValue = 0; + HKEY hKey = 0; + + /* Clean boot */ + piSysMet[SM_CLEANBOOT] = 0; // fallback value of 0 (normal mode) + if(NT_SUCCESS(RegOpenKey(L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Control\\SafeBoot\\Option", &hKey))) + { + if(RegReadDWORD(hKey, L"OptionValue", &dwValue)) piSysMet[SM_CLEANBOOT] = (INT)dwValue; + ZwClose(hKey); + } + /* FIXME: HACK, due to missing PDEV on first init */ if (!pPrimarySurface) { @@ -38,8 +50,6 @@ InitMetrics(VOID) Height = pPrimarySurface->gdiinfo.ulVertRes; } - piSysMet = gpsi->aiSysMet; - /* Screen sizes */ piSysMet[SM_CXSCREEN] = Width; piSysMet[SM_CYSCREEN] = Height; @@ -146,7 +156,6 @@ InitMetrics(VOID) piSysMet[SM_SLOWMACHINE] = 0; piSysMet[SM_SECURE] = 0; piSysMet[SM_DBCSENABLED] = 0; - piSysMet[SM_CLEANBOOT] = 0; piSysMet[SM_SHOWSOUNDS] = gspv.bShowSounds; piSysMet[SM_MIDEASTENABLED] = 0; piSysMet[SM_CMONITORS] = 1; diff --git a/reactos/subsystems/win32/win32k/objects/freetype.c b/reactos/subsystems/win32/win32k/objects/freetype.c index 2315b9058cc..1c3a9259582 100644 --- a/reactos/subsystems/win32/win32k/objects/freetype.c +++ b/reactos/subsystems/win32/win32k/objects/freetype.c @@ -2165,8 +2165,8 @@ TextIntGetTextExtentPoint(PDC dc, error = FT_Set_Pixel_Sizes(face, TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfWidth, /* FIXME should set character height if neg */ - (TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfHeight == 0 ? - dc->ppdev->devinfo.lfDefaultFont.lfHeight : abs(TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfHeight))); + (TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfHeight == 0 ? + dc->ppdev->devinfo.lfDefaultFont.lfHeight : abs(TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfHeight))); if (error) { DPRINT1("Error in setting pixel sizes: %u\n", error); @@ -3394,13 +3394,13 @@ GreExtTextOutW( previous = 0; - if (pdcattr->lTextAlign & TA_RIGHT) + if ((pdcattr->lTextAlign & TA_CENTER) == TA_CENTER) { - RealXStart -= TextWidth; + RealXStart -= TextWidth / 2; } else { - RealXStart -= TextWidth / 2; + RealXStart -= TextWidth; } } -- 2.17.1