File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -208,6 +208,9 @@ Package GetSparsePackage()
208208
209209HRESULT NppShell::Installer::RegisterSparsePackage ()
210210{
211+ if (::GetSystemMetrics (SM_CLEANBOOT) > 0 )
212+ return S_FALSE; // Otherwise we will get an unhandled exception later due to HRESULT 0x8007043c (ERROR_NOT_SAFEBOOT_SERVICE).
213+
211214 PackageManager packageManager;
212215 AddPackageOptions options;
213216
@@ -232,6 +235,9 @@ HRESULT NppShell::Installer::RegisterSparsePackage()
232235
233236HRESULT NppShell::Installer::UnregisterSparsePackage ()
234237{
238+ if (::GetSystemMetrics (SM_CLEANBOOT) > 0 )
239+ return S_FALSE; // Only to speed up things a bit here. (code in the following GetSparsePackage() is safe against the ERROR_NOT_SAFEBOOT_SERVICE)
240+
235241 PackageManager packageManager;
236242 IIterable<Package> packages;
237243
@@ -291,6 +297,9 @@ HRESULT NppShell::Installer::UnregisterOldContextMenu()
291297
292298void ReRegisterSparsePackage ()
293299{
300+ if (::GetSystemMetrics (SM_CLEANBOOT) > 0 )
301+ return ; // Sparse package reg/unreg cannot be done in the Windows OS SafeMode.
302+
294303 winrt::init_apartment ();
295304
296305 // Since we are on Windows 11, we unregister the sparse package as well.
@@ -420,4 +429,4 @@ STDAPI CleanupDll()
420429
421430 // Then we get it moved out of the way and scheduled for deletion.
422431 return MoveFileToTempAndScheduleDeletion (currentFilePath, true );
423- }
432+ }
You can’t perform that action at this time.
0 commit comments