This commit is contained in:
DavidXanatos 2022-05-28 09:40:14 +02:00
parent ffa1f78ce4
commit 15d12d77da
8 changed files with 156 additions and 136 deletions

View File

@ -21,8 +21,8 @@
#ifndef _MY_VERSION_H
#define _MY_VERSION_H
#define MY_VERSION_BINARY 5,56,0
#define MY_VERSION_STRING "5.56.0"
#define MY_VERSION_BINARY 5,56,1
#define MY_VERSION_STRING "5.56.1"
#define MY_VERSION_COMPAT "5.55.0" // this refers to the driver ABI compatibility
// These #defines are used by either Resource Compiler or NSIS installer

View File

@ -629,14 +629,8 @@ BOOLEAN Handle_Init(void);
BOOLEAN Key_Init(void);
extern BOOLEAN Key_Delete_v2;
BOOLEAN Key_InitDelete_v2();
BOOLEAN File_Init(void);
extern BOOLEAN File_Delete_v2;
BOOLEAN File_InitDelete_v2();
BOOLEAN Ipc_Init(void);
BOOLEAN Secure_Init(void);

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020-2021 David Xanatos, xanasoft.com
* Copyright 2020-2022 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -420,6 +420,15 @@ _FX void Dll_InitInjected(void)
}
}
if (ok) {
//
// ipc must be initialized before anythign else to make delete v2 work
//
ok = Ipc_Init();
}
if (ok) {
//
@ -444,9 +453,6 @@ _FX void Dll_InitInjected(void)
if (ok)
ok = File_Init();
if (ok)
ok = Ipc_Init();
if (ok)
ok = Secure_Init();
@ -462,12 +468,6 @@ _FX void Dll_InitInjected(void)
if (ok)
ok = Gui_InitConsole1();
// we need ipc stuff to be up hance we initialize delete stuff second to last
if (ok && File_Delete_v2)
File_InitDelete_v2();
if (ok && Key_Delete_v2)
Key_InitDelete_v2();
if (ok) // Note: Ldr_Init may cause rpcss to be started early
ok = Ldr_Init(); // last to initialize

View File

@ -149,6 +149,9 @@ _FX BOOLEAN File_Init(void)
if (! File_InitDrives(0xFFFFFFFF))
return FALSE;
if (File_Delete_v2)
File_InitDelete_v2();
if (SbieApi_QueryConfBool(NULL, L"SeparateUserFolders", TRUE)) {
if (!File_InitUsers())
return FALSE;

View File

@ -364,6 +364,9 @@ _FX BOOLEAN Key_Init(void)
Key_Delete_v2 = SbieApi_QueryConfBool(NULL, L"UseRegDeleteV2", FALSE);
if (Key_Delete_v2)
Key_InitDelete_v2();
List_Init(&Key_Handles);
List_Init(&Key_MergeCacheList);

View File

@ -2000,6 +2000,24 @@ _FX ULONG Sxs_CheckManifestForCreateProcess(const WCHAR *DosPath)
}
//---------------------------------------------------------------------------
// Sxs_PreferExternal
//---------------------------------------------------------------------------
_FX BOOLEAN Sxs_PreferExternal(THREAD_DATA *TlsData)
{
if (!TlsData->proc_image_path)
return FALSE;
WCHAR *ptr1 = wcsrchr(TlsData->proc_image_path, L'\\');
WCHAR value[16];
SbieDll_GetSettingsForName(NULL, ptr1 + 1, L"PreferExternalManifest", value, sizeof(value), NULL);
return Config_String2Bool(value, FALSE);
}
//---------------------------------------------------------------------------
// Sxs_KeyCallback
//---------------------------------------------------------------------------
@ -2014,82 +2032,79 @@ _FX BOOLEAN Sxs_KeyCallback(const WCHAR *path, HANDLE *out_handle)
// a pre-set value for PreferExternalManifest
//
if (!Config_GetSettingsForImageName_bool(L"PreferExternalManifest", FALSE))
return FALSE;
THREAD_DATA *TlsData = Dll_GetTlsData(NULL);
if (TlsData->proc_image_path) {
if (!Sxs_PreferExternal(TlsData))
return FALSE;
if (_wcsnicmp(path, L"\\Registry\\Machine\\", 18) == 0) {
if (_wcsnicmp(path, L"\\Registry\\Machine\\", 18) == 0) {
BOOLEAN redirect = FALSE;
BOOLEAN redirect = FALSE;
path += 18;
if (_wcsnicmp(path, L"Components", 10) == 0)
path += 18;
if (_wcsnicmp(path, L"Components", 10) == 0)
redirect = TRUE;
else if (_wcsnicmp(path, L"Software\\", 9) == 0) {
path += 9;
if (_wcsnicmp(path, L"Wow6432Node\\", 12) == 0)
path += 12;
if (0 == _wcsicmp(path,
L"Microsoft\\Windows\\CurrentVersion\\SideBySide"))
redirect = TRUE;
}
else if (_wcsnicmp(path, L"Software\\", 9) == 0) {
if (redirect) {
path += 9;
const WCHAR *ValueName = L"PreferExternalManifest";
extern WCHAR *Support_SbieSvcKeyPath;
if (_wcsnicmp(path, L"Wow6432Node\\", 12) == 0)
path += 12;
UNICODE_STRING objname;
OBJECT_ATTRIBUTES objattrs;
HANDLE handle;
if (0 == _wcsicmp(path,
L"Microsoft\\Windows\\CurrentVersion\\SideBySide"))
redirect = TRUE;
}
InitializeObjectAttributes(
&objattrs, &objname, OBJ_CASE_INSENSITIVE, NULL, NULL);
if (redirect) {
RtlInitUnicodeString(&objname, Support_SbieSvcKeyPath);
const WCHAR *ValueName = L"PreferExternalManifest";
extern WCHAR *Support_SbieSvcKeyPath;
if (0 != __sys_NtOpenKey(&handle, KEY_READ, &objattrs))
handle = NULL;
UNICODE_STRING objname;
OBJECT_ATTRIBUTES objattrs;
HANDLE handle;
if (handle) {
InitializeObjectAttributes(
&objattrs, &objname, OBJ_CASE_INSENSITIVE, NULL, NULL);
union {
KEY_VALUE_PARTIAL_INFORMATION kvpi;
ULONG space[6];
} info;
ULONG len;
RtlInitUnicodeString(&objname, Support_SbieSvcKeyPath);
RtlInitUnicodeString(&objname, ValueName);
if (0 != __sys_NtOpenKey(&handle, KEY_READ, &objattrs))
handle = NULL;
if (0 != NtQueryValueKey(
handle, &objname, KeyValuePartialInformation,
&info, sizeof(info), &len))
info.kvpi.Type = 0;
if (handle) {
if (info.kvpi.Type == REG_DWORD &&
info.kvpi.DataLength == sizeof(ULONG) &&
*(ULONG *)info.kvpi.Data != 0) {
union {
KEY_VALUE_PARTIAL_INFORMATION kvpi;
ULONG space[6];
} info;
ULONG len;
//WCHAR txt[1024];
//Sbie_snwprintf(txt, 1024, L"REDIR KEY - %s\n", path);
//OutputDebugString(txt);
RtlInitUnicodeString(&objname, ValueName);
if (0 != NtQueryValueKey(
handle, &objname, KeyValuePartialInformation,
&info, sizeof(info), &len))
info.kvpi.Type = 0;
if (info.kvpi.Type == REG_DWORD &&
info.kvpi.DataLength == sizeof(ULONG) &&
*(ULONG *)info.kvpi.Data != 0) {
//WCHAR txt[1024];
//Sbie_snwprintf(txt, 1024, L"REDIR KEY - %s\n", path);
//OutputDebugString(txt);
*out_handle = handle;
return TRUE;
}
CloseHandle(handle);
*out_handle = handle;
return TRUE;
}
SbieApi_Log(2205, ValueName);
CloseHandle(handle);
}
SbieApi_Log(2205, ValueName);
}
}
@ -2111,96 +2126,93 @@ _FX BOOLEAN Sxs_FileCallback(const WCHAR *path, HANDLE *out_handle)
// our installation home directory
//
if (!Config_GetSettingsForImageName_bool(L"PreferExternalManifest", FALSE))
return FALSE;
THREAD_DATA *TlsData = Dll_GetTlsData(NULL);
if (TlsData->proc_image_path) {
if (!Sxs_PreferExternal(TlsData))
return FALSE;
const WCHAR *_Manifest_Txt = L"\\Manifest1.txt";
const WCHAR *_Config_Txt = L"\\Manifest2.txt";
const WCHAR *_Empty_Txt = L"\\Manifest0.txt";
const WCHAR *FileName = NULL;
ULONG FileSize = 0;
const WCHAR *_Manifest_Txt = L"\\Manifest1.txt";
const WCHAR *_Config_Txt = L"\\Manifest2.txt";
const WCHAR *_Empty_Txt = L"\\Manifest0.txt";
const WCHAR *FileName = NULL;
ULONG FileSize = 0;
WCHAR *ptr1 = wcsrchr(TlsData->proc_image_path, L'\\');
WCHAR *ptr2 = wcsrchr(path, L'\\');
ULONG len = 0;
if (ptr1)
len = wcslen(ptr1);
WCHAR *ptr1 = wcsrchr(TlsData->proc_image_path, L'\\');
WCHAR *ptr2 = wcsrchr(path, L'\\');
ULONG len = 0;
if (ptr1)
len = wcslen(ptr1);
if (len && ptr2 && _wcsnicmp(ptr1, ptr2, len) == 0) {
if (len && ptr2 && _wcsnicmp(ptr1, ptr2, len) == 0) {
if (_wcsicmp(ptr2 + len, Sxs_manifest) == 0) {
FileName = _Manifest_Txt;
FileSize = 364;
if (_wcsicmp(ptr2 + len, Sxs_manifest) == 0) {
FileName = _Manifest_Txt;
FileSize = 364;
} else if (_wcsicmp(ptr2 + len, Sxs_config) == 0) {
FileName = _Config_Txt;
FileSize = 92;
}
} else if (_wcsicmp(ptr2 + len, Sxs_config) == 0) {
FileName = _Config_Txt;
FileSize = 92;
}
}
if (FileName && (! TlsData->proc_create_process_as_invoker)) {
if (FileName && (! TlsData->proc_create_process_as_invoker)) {
//
// if the EXE does not explicitly say in its manifest:
// requestedExecutionLevel level="asInvoker"
// then we use the empty manifest/config files, to allow
// UAC to use its auto-elevation heuristics
//
//
// if the EXE does not explicitly say in its manifest:
// requestedExecutionLevel level="asInvoker"
// then we use the empty manifest/config files, to allow
// UAC to use its auto-elevation heuristics
//
FileName = _Empty_Txt;
FileSize = 2;
}
FileName = _Empty_Txt;
FileSize = 2;
}
if (FileName) {
if (FileName) {
HANDLE handle;
HANDLE handle;
WCHAR *FilePath = Dll_AllocTemp(MAX_PATH * 2 * sizeof(WCHAR));
wcscpy(FilePath, Dll_HomeDosPath);
wcscat(FilePath, FileName);
WCHAR *FilePath = Dll_AllocTemp(MAX_PATH * 2 * sizeof(WCHAR));
wcscpy(FilePath, Dll_HomeDosPath);
wcscat(FilePath, FileName);
//OutputDebugString(L"*** *** ***\n");
//OutputDebugString(FilePath);
//OutputDebugString(L"*** *** ***\n");
//OutputDebugString(L"*** *** ***\n");
//OutputDebugString(FilePath);
//OutputDebugString(L"*** *** ***\n");
handle = CreateFile(FilePath, FILE_READ_DATA, FILE_SHARE_READ,
NULL, OPEN_EXISTING, 0, NULL);
handle = CreateFile(FilePath, FILE_READ_DATA, FILE_SHARE_READ,
NULL, OPEN_EXISTING, 0, NULL);
Dll_Free(FilePath);
Dll_Free(FilePath);
if (handle == INVALID_HANDLE_VALUE)
handle = NULL;
if (handle == INVALID_HANDLE_VALUE)
handle = NULL;
if (handle) {
if (handle) {
IO_STATUS_BLOCK IoStatusBlock;
FILE_NETWORK_OPEN_INFORMATION open_info;
IO_STATUS_BLOCK IoStatusBlock;
FILE_NETWORK_OPEN_INFORMATION open_info;
NTSTATUS status = NtQueryInformationFile(
handle, &IoStatusBlock, &open_info,
sizeof(FILE_NETWORK_OPEN_INFORMATION),
FileNetworkOpenInformation);
NTSTATUS status = NtQueryInformationFile(
handle, &IoStatusBlock, &open_info,
sizeof(FILE_NETWORK_OPEN_INFORMATION),
FileNetworkOpenInformation);
if (NT_SUCCESS(status) &&
open_info.EndOfFile.QuadPart == FileSize) {
if (NT_SUCCESS(status) &&
open_info.EndOfFile.QuadPart == FileSize) {
//WCHAR txt[1024];
//Sbie_snwprintf(txt, 1024, L"REDIR FILE - %s\n", path);
//OutputDebugString(txt);
//WCHAR txt[1024];
//Sbie_snwprintf(txt, 1024, L"REDIR FILE - %s\n", path);
//OutputDebugString(txt);
*out_handle = handle;
return TRUE;
}
CloseHandle(handle);
*out_handle = handle;
return TRUE;
}
SbieApi_Log(2205, FileName + 1);
CloseHandle(handle);
}
SbieApi_Log(2205, FileName + 1);
}
return FALSE;

View File

@ -635,6 +635,14 @@ Tmpl.Title=#4338,Microsoft Edge
Tmpl.Class=WebBrowser
OpenFilePath=msedge.exe,%Tmpl.Edge%\*
[Template_LastPass]
Tmpl.Title=MS Edge for windows 11
Tmpl.Class=WebBrowser
Tmpl.Url=https://www.microsoft.com/en-us/edge
Tmpl.Scan=s
Tmpl.ScanFile=C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe
PreferExternalManifest=msedge.exe,y
#
# Vivaldi
#

View File

@ -2,7 +2,7 @@
#define VERSION_MJR 1
#define VERSION_MIN 1
#define VERSION_REV 0
#define VERSION_REV 1
#define VERSION_UPD 0
#ifndef STR