Reactos

[UMPNPMGR] Fix RunningOnLiveMedium according to Hermes' suggestions

Note: Running a program on a LiveCD is not the same as running it in setup mode.

Eric Kohl 9fa8028a 92b8ca8e

+23 -16
+23 -16
base/services/umpnpmgr/umpnpmgr.c
··· 204 204 BOOL 205 205 RunningOnLiveMedium(VOID) 206 206 { 207 - WCHAR CommandLine[MAX_PATH]; 208 - HKEY hSetupKey; 207 + WCHAR Options[MAX_PATH]; 208 + PWSTR CurrentOption, NextOption; 209 + HKEY hControlKey; 209 210 DWORD dwType; 210 211 DWORD dwSize; 211 212 DWORD dwError; ··· 215 216 216 217 /* Open the Setup key */ 217 218 dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE, 218 - L"SYSTEM\\Setup", 219 + L"SYSTEM\\CurrentControlSet\\Control", 219 220 0, 220 221 KEY_QUERY_VALUE, 221 - &hSetupKey); 222 + &hControlKey); 222 223 if (dwError != ERROR_SUCCESS) 223 224 goto done; 224 225 225 226 /* Read the CmdLine value */ 226 - dwSize = sizeof(CommandLine); 227 - dwError = RegQueryValueExW(hSetupKey, 228 - L"CmdLine", 227 + dwSize = sizeof(Options); 228 + dwError = RegQueryValueExW(hControlKey, 229 + L"SystemStartOptions", 229 230 NULL, 230 231 &dwType, 231 - (LPBYTE)CommandLine, 232 + (LPBYTE)Options, 232 233 &dwSize); 233 - if (dwError != ERROR_SUCCESS || 234 - (dwType != REG_SZ && 235 - dwType != REG_EXPAND_SZ && 236 - dwType != REG_MULTI_SZ)) 234 + if ((dwError != ERROR_SUCCESS) || (dwType != REG_SZ)) 237 235 goto done; 238 236 239 237 /* Check for the '-mini' option */ 240 - if (wcsstr(CommandLine, L" -mini") != NULL) 238 + CurrentOption = Options; 239 + while (CurrentOption) 241 240 { 242 - DPRINT("Running on LiveMedium\n"); 243 - LiveMedium = TRUE; 241 + NextOption = wcschr(CurrentOption, L' '); 242 + if (NextOption) 243 + *NextOption = L'\0'; 244 + if (_wcsicmp(CurrentOption, L"MININT") == 0) 245 + { 246 + DPRINT("Found 'MININT' boot option\n"); 247 + LiveMedium = TRUE; 248 + goto done; 249 + } 250 + CurrentOption = NextOption ? NextOption + 1 : NULL; 244 251 } 245 252 246 253 done: 247 - RegCloseKey(hSetupKey); 254 + RegCloseKey(hControlKey); 248 255 249 256 return LiveMedium; 250 257 }