This commit is contained in:
DavidXanatos 2022-06-08 11:53:59 +02:00
parent e806da601b
commit 2859471549
2 changed files with 28 additions and 24 deletions

View File

@ -247,7 +247,7 @@ _FX BOOLEAN AdvApi_Init(HMODULE module)
// only hook SetSecurityInfo if this is Chrome. Outlook 2013 uses delayed loading and will cause infinite callbacks
// Starting with Win 10, we only want to hook ntmarta!SetSecurityInfo. Do NOT hook advapi!SetSecurityInfo. Delay loading for advapi will cause infinite recursion.
// Note: the infinite recursion issue has been resolved int 5.43
if ((Dll_ImageType == DLL_IMAGE_GOOGLE_CHROME) || (Dll_ImageType == DLL_IMAGE_ACROBAT_READER)) {
if ((Dll_ImageType == DLL_IMAGE_GOOGLE_CHROME) || (Dll_ImageType == DLL_IMAGE_ACROBAT_READER) || Config_GetSettingsForImageName_bool(L"UseSbieDeskHack", FALSE)) {
SetSecurityInfo = __sys_SetSecurityInfo;
GetSecurityInfo = __sys_GetSecurityInfo;
SBIEDLL_HOOK(AdvApi_, SetSecurityInfo);
@ -730,7 +730,7 @@ _FX BOOLEAN Ntmarta_Init(HMODULE module)
#define GETPROC2(x,s) __sys_Ntmarta_##x##s = (P_##x) Ldr_GetProcAddrNew(DllName_ntmarta, L#x L#s,#x #s);
GETPROC2(GetSecurityInfo, );
if ((Dll_ImageType == DLL_IMAGE_GOOGLE_CHROME) || (Dll_ImageType == DLL_IMAGE_ACROBAT_READER)) {
if ((Dll_ImageType == DLL_IMAGE_GOOGLE_CHROME) || (Dll_ImageType == DLL_IMAGE_ACROBAT_READER) || Config_GetSettingsForImageName_bool(L"UseSbieDeskHack", FALSE)) {
GetSecurityInfo = __sys_Ntmarta_GetSecurityInfo;
if (GetSecurityInfo)

View File

@ -578,18 +578,22 @@ _FX HDESK Gui_OpenDesktopA(
//---------------------------------------------------------------------------
//Gui_CreateWindowStationW
//---------------------------------------------------------------------------
extern HANDLE Sandboxie_WinSta;
_FX HANDLE Gui_CreateWindowStationW (void *lpwinsta, DWORD dwFlags, ACCESS_MASK dwDesiredAccess, LPSECURITY_ATTRIBUTES lpsa) {
_FX HANDLE Gui_CreateWindowStationW (void *lpwinsta, DWORD dwFlags, ACCESS_MASK dwDesiredAccess, LPSECURITY_ATTRIBUTES lpsa)
{
HANDLE myHandle = 0;
myHandle = __sys_CreateWindowStationW(lpwinsta, dwFlags, dwDesiredAccess, lpsa);
if (!myHandle) {
if(Sandboxie_WinSta)
return Sandboxie_WinSta;
SbieApi_Log(2205, L"CreateWindowStation");
}
if (myHandle)
return myHandle;
extern HANDLE Sandboxie_WinSta;
if(Sandboxie_WinSta && ((Dll_ImageType == DLL_IMAGE_GOOGLE_CHROME) || (Dll_ImageType == DLL_IMAGE_MOZILLA_FIREFOX) || Config_GetSettingsForImageName_bool(L"UseSbieWndStation", TRUE)))
return Sandboxie_WinSta;
SbieApi_Log(2205, L"CreateWindowStation");
return 0;
}
@ -598,22 +602,26 @@ _FX HANDLE Gui_CreateWindowStationW (void *lpwinsta, DWORD dwFlags, ACCESS_MASK
//---------------------------------------------------------------------------
_FX HANDLE Gui_CreateWindowStationA (void *lpwinsta, DWORD dwFlags, ACCESS_MASK dwDesiredAccess, LPSECURITY_ATTRIBUTES lpsa) {
_FX HANDLE Gui_CreateWindowStationA (void *lpwinsta, DWORD dwFlags, ACCESS_MASK dwDesiredAccess, LPSECURITY_ATTRIBUTES lpsa)
{
HANDLE myHandle = 0;
myHandle = __sys_CreateWindowStationA(lpwinsta, dwFlags, dwDesiredAccess, lpsa);
if (!myHandle) {
if(Sandboxie_WinSta)
return Sandboxie_WinSta;
SbieApi_Log(2205, L"CreateWindowStation");
}
if (myHandle)
return myHandle;
extern HANDLE Sandboxie_WinSta;
if(Sandboxie_WinSta && ((Dll_ImageType == DLL_IMAGE_GOOGLE_CHROME) || (Dll_ImageType == DLL_IMAGE_MOZILLA_FIREFOX) || Config_GetSettingsForImageName_bool(L"UseSbieWndStation", TRUE)))
return Sandboxie_WinSta;
SbieApi_Log(2205, L"CreateWindowStation");
return 0;
}
//---------------------------------------------------------------------------
// Gui_CreateDesktopW
//---------------------------------------------------------------------------
extern HANDLE Sandboxie_Desktop;
_FX HDESK Gui_CreateDesktopW(
void *lpszDesktop, void *lpszDevice, void *DevMode, ULONG dwFlags,
@ -625,7 +633,7 @@ _FX HDESK Gui_CreateDesktopW(
if (rc)
return rc;
if (!Config_GetSettingsForImageName_bool(L"UseSbieWndStation", TRUE) && (Dll_ImageType != DLL_IMAGE_GOOGLE_CHROME) && (Dll_ImageType != DLL_IMAGE_MOZILLA_FIREFOX))
if ((Dll_ImageType == DLL_IMAGE_GOOGLE_CHROME) || (Dll_ImageType == DLL_IMAGE_ACROBAT_READER) || Config_GetSettingsForImageName_bool(L"UseSbieDeskHack", FALSE))
{
//Call the system CreateDesktopW without a security context.
//This works in tandem with the Ntmarta_GetSecurityInfo hook (see in advapi.c).
@ -639,8 +647,6 @@ _FX HDESK Gui_CreateDesktopW(
return rc;
}
if (Sandboxie_Desktop)
return Sandboxie_Desktop;
SbieApi_Log(2205, L"CreateDesktop");
return CreateEvent(NULL, FALSE, FALSE, NULL);
}
@ -661,15 +667,13 @@ _FX HDESK Gui_CreateDesktopA(
if (rc)
return rc;
if (!Config_GetSettingsForImageName_bool(L"UseSbieWndStation", TRUE) && (Dll_ImageType != DLL_IMAGE_GOOGLE_CHROME) && (Dll_ImageType != DLL_IMAGE_MOZILLA_FIREFOX))
if ((Dll_ImageType == DLL_IMAGE_GOOGLE_CHROME) || (Dll_ImageType == DLL_IMAGE_ACROBAT_READER) || Config_GetSettingsForImageName_bool(L"UseSbieDeskHack", FALSE))
{
rc = __sys_CreateDesktopA(lpszDesktop, NULL, NULL, dwFlags, dwDesiredAccess, NULL);
if (rc)
return rc;
}
if (Sandboxie_Desktop)
return Sandboxie_Desktop;
SbieApi_Log(2205, L"CreateDesktop");
return CreateEvent(NULL, FALSE, FALSE, NULL);
}