From ad7f4a88f4215a6adb1cf14c5321a5fbc511358d Mon Sep 17 00:00:00 2001 From: DavidXanatos Date: Sat, 28 May 2022 21:53:41 +0200 Subject: [PATCH] 1.1.1 --- Sandboxie/core/dll/file_del.c | 12 +++++++++--- Sandboxie/core/dll/file_init.c | 11 +++++++++-- Sandboxie/core/dll/key.c | 13 +++++++------ Sandboxie/core/dll/key_del.c | 6 ++++-- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/Sandboxie/core/dll/file_del.c b/Sandboxie/core/dll/file_del.c index 50ef6d76..dea013e2 100644 --- a/Sandboxie/core/dll/file_del.c +++ b/Sandboxie/core/dll/file_del.c @@ -472,8 +472,12 @@ _FX BOOLEAN File_LoadPathTree_internal(LIST* Root, const WCHAR* name) HANDLE hPathsFile; hPathsFile = CreateFile(PathsFile, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (hPathsFile == INVALID_HANDLE_VALUE) + if (hPathsFile == INVALID_HANDLE_VALUE) { + hPathsFile = CreateFile(PathsFile, FILE_APPEND_DATA, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (hPathsFile != INVALID_HANDLE_VALUE) + CloseHandle(hPathsFile); return FALSE; + } File_ClearPathBranche_internal(Root); @@ -562,9 +566,9 @@ _FX VOID File_RefreshPathTree() // File_LoadPathTree(); - } - FindNextChangeNotification(File_BoxRootWatcher); // rearm the watcher + FindNextChangeNotification(File_BoxRootWatcher); // rearm the watcher + } } @@ -592,6 +596,8 @@ _FX BOOLEAN File_InitDelete_v2() File_BoxRootWatcher = FindFirstChangeNotification(BoxFilePath, FALSE, FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_LAST_WRITE); + FindNextChangeNotification(File_BoxRootWatcher); // arm the watcher + return TRUE; } diff --git a/Sandboxie/core/dll/file_init.c b/Sandboxie/core/dll/file_init.c index 27f049e7..25982c6d 100644 --- a/Sandboxie/core/dll/file_init.c +++ b/Sandboxie/core/dll/file_init.c @@ -142,16 +142,23 @@ _FX BOOLEAN File_Init(void) File_DriveAddSN = SbieApi_QueryConfBool(NULL, L"UseVolumeSerialNumbers", FALSE); - File_Delete_v2 = SbieApi_QueryConfBool(NULL, L"UseFileDeleteV2", FALSE); - File_NoReparse = SbieApi_QueryConfBool(NULL, L"NoPathReparse", FALSE); if (! File_InitDrives(0xFFFFFFFF)) return FALSE; + File_Delete_v2 = SbieApi_QueryConfBool(NULL, L"UseFileDeleteV2", FALSE); if (File_Delete_v2) File_InitDelete_v2(); + // this is here as it requirers file stuff to be set up + extern BOOLEAN Key_Delete_v2; + BOOLEAN Key_InitDelete_v2(); + Key_Delete_v2 = SbieApi_QueryConfBool(NULL, L"UseRegDeleteV2", FALSE); + if (Key_Delete_v2) + Key_InitDelete_v2(); + + // this requirers key stuff to be set up if (SbieApi_QueryConfBool(NULL, L"SeparateUserFolders", TRUE)) { if (!File_InitUsers()) return FALSE; diff --git a/Sandboxie/core/dll/key.c b/Sandboxie/core/dll/key.c index 6ecf6dec..89f30f2b 100644 --- a/Sandboxie/core/dll/key.c +++ b/Sandboxie/core/dll/key.c @@ -362,11 +362,6 @@ _FX BOOLEAN Key_Init(void) Key_UseObjectNames = SbieApi_QueryConfBool(NULL, L"UseObjectNameForKeys", FALSE); - Key_Delete_v2 = SbieApi_QueryConfBool(NULL, L"UseRegDeleteV2", FALSE); - - if (Key_Delete_v2) - Key_InitDelete_v2(); - List_Init(&Key_Handles); List_Init(&Key_MergeCacheList); @@ -2515,7 +2510,13 @@ _FX NTSTATUS Key_NtDeleteValueKey( status = __sys_NtDeleteValueKey(KeyHandle, ValueName); - } if (Key_Delete_v2){ + } else if (Key_Delete_v2) { + + RtlInitUnicodeString(&objname, CopyPath); + + OBJECT_ATTRIBUTES objattrs; + InitializeObjectAttributes(&objattrs, &objname, OBJ_CASE_INSENSITIVE, NULL, NULL); + Key_CreatePath(&objattrs, NULL); Key_MarkDeletedEx_v2(TruePath, ValueName->Buffer); diff --git a/Sandboxie/core/dll/key_del.c b/Sandboxie/core/dll/key_del.c index 934d4972..6870d56b 100644 --- a/Sandboxie/core/dll/key_del.c +++ b/Sandboxie/core/dll/key_del.c @@ -172,9 +172,9 @@ _FX VOID Key_RefreshPathTree() // Key_LoadPathTree(); - } - FindNextChangeNotification(Key_BoxRootWatcher); // rearm the watcher + FindNextChangeNotification(Key_BoxRootWatcher); // rearm the watcher + } } @@ -202,6 +202,8 @@ _FX BOOLEAN Key_InitDelete_v2() Key_BoxRootWatcher = FindFirstChangeNotification(BoxFilePath, FALSE, FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_LAST_WRITE); + FindNextChangeNotification(Key_BoxRootWatcher); // arm the watcher + return TRUE; }