This commit is contained in:
DavidXanatos 2024-02-20 21:43:54 +01:00
parent d4bf08502c
commit 010d878a8e
3 changed files with 78 additions and 14 deletions

View File

@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
- added missing checkbox for API tracing
- fixed incompatibility with Windows ARM64 Insider build 26052 and later
- fixed [1.12.6] Symlink and open path issue [#3537](https://github.com/sandboxie-plus/Sandboxie/issues/3537)
### Changed
- changed DynData format to add flags

View File

@ -2692,6 +2692,12 @@ _FX NTSTATUS File_NtCreateFileImpl(
}
}
if (Dll_ApiTrace) {
WCHAR trace_str[2048];
ULONG len = Sbie_snwprintf(trace_str, 2048, L"File_NtCreateFileImpl %s DesiredAccess=0x%08X CreateDisposition=0x%08X CreateOptions=0x%08X", TruePath, DesiredAccess, CreateDisposition, CreateOptions);
SbieApi_MonitorPut2Ex(MONITOR_APICALL | MONITOR_TRACE, len, trace_str, FALSE, FALSE);
}
SkipOriginalTry = (status == STATUS_BAD_INITIAL_PC);
//if ( (wcsstr(TruePath, L"Harddisk0\\DR0") != 0) || wcsstr(TruePath, L"HarddiskVolume3") != 0) {
@ -3833,6 +3839,12 @@ ReparseLoop:
status = GetExceptionCode();
}
if (Dll_ApiTrace) {
WCHAR trace_str[2048];
ULONG len = Sbie_snwprintf(trace_str, 2048, L"File_NtCreateFileImpl status = 0x%08X", status);
SbieApi_MonitorPut2Ex(MONITOR_APICALL | MONITOR_TRACE, len, trace_str, FALSE, FALSE);
}
SetLastError(LastError);
return status;
}
@ -5047,6 +5059,12 @@ _FX NTSTATUS File_NtQueryFullAttributesFileImpl(
ObjectAttributes->RootDirectory, ObjectAttributes->ObjectName,
&TruePath, &CopyPath, &FileFlags);
if (Dll_ApiTrace) {
WCHAR trace_str[2048];
ULONG len = Sbie_snwprintf(trace_str, 2048, L"File_NtQueryFullAttributesFileImpl %s", TruePath);
SbieApi_MonitorPut2Ex(MONITOR_APICALL | MONITOR_TRACE, len, trace_str, FALSE, FALSE);
}
if (! NT_SUCCESS(status)) {
if (status == STATUS_BAD_INITIAL_PC) {
@ -5243,6 +5261,12 @@ _FX NTSTATUS File_NtQueryFullAttributesFileImpl(
status = STATUS_OBJECT_NAME_INVALID;
}
if (Dll_ApiTrace) {
WCHAR trace_str[2048];
ULONG len = Sbie_snwprintf(trace_str, 2048, L"File_NtQueryFullAttributesFileImpl status = 0x%08X", status);
SbieApi_MonitorPut2Ex(MONITOR_APICALL | MONITOR_TRACE, len, trace_str, FALSE, FALSE);
}
Dll_PopTlsNameBuffer(TlsData);
SetLastError(LastError);
return status;
@ -5563,6 +5587,12 @@ _FX ULONG File_GetFinalPathNameByHandleW(
err = GetLastError();
}
if (Dll_ApiTrace) {
WCHAR trace_str[2048];
ULONG len = Sbie_snwprintf(trace_str, 2048, L"File_GetFinalPathNameByHandleW %s", lpszFilePath);
SbieApi_MonitorPut2Ex(MONITOR_APICALL | MONITOR_TRACE, len, trace_str, FALSE, FALSE);
}
SetLastError(err);
return rc;
}
@ -5578,11 +5608,11 @@ _FX WCHAR *File_GetFinalPathNameByHandleW_2(WCHAR *TruePath, ULONG dwFlags)
static const WCHAR *_DosPrefix = L"\\\\?\\UNC\\";
const FILE_DRIVE *file_drive;
const FILE_LINK *file_link;
const WCHAR *suffix;
const WCHAR *suffix, *suffix2;
WCHAR *path;
WCHAR *ReparsedPath;
ULONG TruePath_len;
ULONG suffix_len;
ULONG suffix_len, suffix2_len;
WCHAR drive_letter;
BOOLEAN AddBackslash;
@ -5679,6 +5709,7 @@ _FX WCHAR *File_GetFinalPathNameByHandleW_2(WCHAR *TruePath, ULONG dwFlags)
ReparsedPath = NULL;
AddBackslash = FALSE;
drive_letter = 0;
suffix2 = NULL;
file_link = File_FindPermLinksForMatchPath(TruePath, TruePath_len);
if (file_link) {
@ -5728,18 +5759,33 @@ _FX WCHAR *File_GetFinalPathNameByHandleW_2(WCHAR *TruePath, ULONG dwFlags)
file_drive = File_GetDriveForPath(TruePath, TruePath_len);
if (! file_drive) {
file_drive = File_GetDriveForPath(file_link->src, file_link->src_len);
if (!file_drive) {
// release lock by File_FindPermLinksForMatchPath
LeaveCriticalSection(File_DrivesAndLinks_CritSec);
SetLastError(ERROR_PATH_NOT_FOUND);
return NULL;
}
else
{
drive_letter = file_drive->letter;
suffix = file_link->src + file_drive->len;
suffix2 = TruePath + file_link->dst_len;
// release lock by File_GetDriveForPath
LeaveCriticalSection(File_DrivesAndLinks_CritSec);
}
}
else
{
drive_letter = file_drive->letter;
suffix = TruePath + file_drive->len;
// release lock by File_GetDriveForPath
LeaveCriticalSection(File_DrivesAndLinks_CritSec);
}
}
// release lock by File_FindPermLinksForMatchPath
@ -5785,11 +5831,15 @@ _FX WCHAR *File_GetFinalPathNameByHandleW_2(WCHAR *TruePath, ULONG dwFlags)
} else { // VOLUME_NAME_DOS
suffix_len = wcslen(suffix);
path = Dll_AllocTemp((suffix_len + 16) * sizeof(WCHAR));
suffix2_len = suffix2 ? wcslen(suffix2) : 0;
path = Dll_AllocTemp((suffix_len + suffix2_len + 16) * sizeof(WCHAR));
wmemcpy(path, _DosPrefix, 4);
path[4] = drive_letter;
path[5] = L':';
wmemcpy(path + 6, suffix, suffix_len + 1);
if (suffix2)
wcscat(path, suffix2);
}
if (AddBackslash)

View File

@ -1328,7 +1328,7 @@ _FX FILE_LINK *File_FindPermLinksForMatchPath(
link = List_Head(File_PermLinks);
while (link) {
const ULONG src_len = link->src_len;
/*const ULONG src_len = link->src_len;
if (
#ifdef WOW64_FS_REDIR
@ -1338,6 +1338,19 @@ _FX FILE_LINK *File_FindPermLinksForMatchPath(
(name[src_len] == L'\\' || name[src_len] == L'\0') &&
_wcsnicmp(name, link->src, src_len) == 0) {
return link;
}*/
const ULONG dst_len = link->dst_len;
if (
#ifdef WOW64_FS_REDIR
link != File_Wow64FileLink &&
#endif WOW64_FS_REDIR
name_len >= dst_len &&
(name[dst_len] == L'\\' || name[dst_len] == L'\0') &&
_wcsnicmp(name, link->dst, dst_len) == 0) {
return link;
}