This commit is contained in:
DavidXanatos 2023-12-03 17:01:00 +01:00
parent bc83bf1445
commit 8222b621fb
5 changed files with 118 additions and 92 deletions

View File

@ -5,6 +5,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [1.12.4 / 5.67.4] - 2023-12-
### Fixed
- fixed running sandboxed processes located in a imdisk volume [#3472](https://github.com/sandboxie-plus/Sandboxie/discussions/3472)
## [1.12.3 / 5.67.3] - 2023-12-02 ## [1.12.3 / 5.67.3] - 2023-12-02
### Added ### Added

View File

@ -21,8 +21,8 @@
#ifndef _MY_VERSION_H #ifndef _MY_VERSION_H
#define _MY_VERSION_H #define _MY_VERSION_H
#define MY_VERSION_BINARY 5,67,3 #define MY_VERSION_BINARY 5,67,4
#define MY_VERSION_STRING "5.67.3" #define MY_VERSION_STRING "5.67.4"
#define MY_ABI_VERSION 0x56700 #define MY_ABI_VERSION 0x56700
// These #defines are used by either Resource Compiler or NSIS installer // These #defines are used by either Resource Compiler or NSIS installer

View File

@ -7321,6 +7321,11 @@ _FX BOOLEAN SbieDll_TranslateNtToDosPath(WCHAR *path)
const FILE_DRIVE *drive; const FILE_DRIVE *drive;
ULONG path_len, prefix_len; ULONG path_len, prefix_len;
//
// sometimes we get a DOS path with the \??\ prefix
// in such cases we just quickly strip it and are done
//
if (_wcsnicmp(path, L"\\??\\", 4) == 0) { if (_wcsnicmp(path, L"\\??\\", 4) == 0) {
wmemmove(path, path + 4, wcslen(path) - 4 + 1); wmemmove(path, path + 4, wcslen(path) - 4 + 1);
@ -7368,6 +7373,20 @@ _FX BOOLEAN SbieDll_TranslateNtToDosPath(WCHAR *path)
return TRUE; return TRUE;
} }
//
// sometimes we have to use a path which has no drive letter
// to make this work we use the \\.\ prefix which replaces \Device\
// and is accepted by regular non NT Win32 APIs
//
if (_wcsnicmp(path, L"\\Device\\", 8) == 0) {
wcscpy(path, L"\\\\.\\");
wmemmove(path + 4, path + 8, wcslen(path + 8) + 1);
return TRUE;
}
return FALSE; return FALSE;
} }

View File

@ -436,91 +436,91 @@ _FX ULONG File_IsDeletedEx(const WCHAR* TruePath, const WCHAR* CopyPath, FILE_SN
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
NTSTATUS GetPrivateProfileStringNt(const wchar_t* section, const wchar_t* key, const wchar_t* defaultVal, wchar_t* returnedString, size_t size, const wchar_t* fileNtPath) //NTSTATUS GetPrivateProfileStringNt(const wchar_t* section, const wchar_t* key, const wchar_t* defaultVal, wchar_t* returnedString, size_t size, const wchar_t* fileNtPath)
{ //{
BOOLEAN foundSection = FALSE; // BOOLEAN foundSection = FALSE;
BOOLEAN foundKey = FALSE; // BOOLEAN foundKey = FALSE;
//
ULONG sectionLen = wcslen(section); // ULONG sectionLen = wcslen(section);
ULONG keyLen = wcslen(key); // ULONG keyLen = wcslen(key);
//
UNICODE_STRING objname; // UNICODE_STRING objname;
RtlInitUnicodeString(&objname, fileNtPath); // RtlInitUnicodeString(&objname, fileNtPath);
//
OBJECT_ATTRIBUTES objattrs; // OBJECT_ATTRIBUTES objattrs;
InitializeObjectAttributes(&objattrs, &objname, OBJ_CASE_INSENSITIVE, NULL, NULL); // InitializeObjectAttributes(&objattrs, &objname, OBJ_CASE_INSENSITIVE, NULL, NULL);
//
HANDLE hIniFile; // HANDLE hIniFile;
IO_STATUS_BLOCK IoStatusBlock; // IO_STATUS_BLOCK IoStatusBlock;
if (NT_SUCCESS(NtCreateFile(&hIniFile, GENERIC_READ | SYNCHRONIZE, &objattrs, &IoStatusBlock, NULL, 0, FILE_SHARE_READ, FILE_OPEN, FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE, NULL, 0))) // if (NT_SUCCESS(NtCreateFile(&hIniFile, GENERIC_READ | SYNCHRONIZE, &objattrs, &IoStatusBlock, NULL, 0, FILE_SHARE_READ, FILE_OPEN, FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE, NULL, 0)))
{ // {
LARGE_INTEGER fileSize; // LARGE_INTEGER fileSize;
GetFileSizeEx(hIniFile, &fileSize); // GetFileSizeEx(hIniFile, &fileSize);
//
char* iniDataPtr = (char*)Dll_Alloc((ULONG)fileSize.QuadPart + 128); // char* iniDataPtr = (char*)Dll_Alloc((ULONG)fileSize.QuadPart + 128);
DWORD bytesRead; // DWORD bytesRead;
ReadFile(hIniFile, iniDataPtr, (DWORD)fileSize.QuadPart, &bytesRead, NULL); // ReadFile(hIniFile, iniDataPtr, (DWORD)fileSize.QuadPart, &bytesRead, NULL);
iniDataPtr[bytesRead] = L'\0'; // iniDataPtr[bytesRead] = L'\0';
//
int ByteSize = MultiByteToWideChar(CP_UTF8, 0, (char*)iniDataPtr, bytesRead, NULL, 0) + 1; // int ByteSize = MultiByteToWideChar(CP_UTF8, 0, (char*)iniDataPtr, bytesRead, NULL, 0) + 1;
WCHAR* Buffer = (WCHAR*)Dll_Alloc(ByteSize * sizeof(wchar_t)); // WCHAR* Buffer = (WCHAR*)Dll_Alloc(ByteSize * sizeof(wchar_t));
bytesRead = MultiByteToWideChar(CP_UTF8, 0, (char*)iniDataPtr, bytesRead, Buffer, ByteSize); // bytesRead = MultiByteToWideChar(CP_UTF8, 0, (char*)iniDataPtr, bytesRead, Buffer, ByteSize);
//
Dll_Free(iniDataPtr); // Dll_Free(iniDataPtr);
//
WCHAR* Next = Buffer; // WCHAR* Next = Buffer;
while (*Next) { // while (*Next) {
WCHAR* Line = Next; // WCHAR* Line = Next;
WCHAR* End = wcschr(Line, L'\n'); // WCHAR* End = wcschr(Line, L'\n');
if (End == NULL) { // if (End == NULL) {
End = wcschr(Line, L'\0'); // End = wcschr(Line, L'\0');
Next = End; // Next = End;
} // }
else // else
Next = End + 1; // Next = End + 1;
ULONG LineLen = (ULONG)(End - Line); // ULONG LineLen = (ULONG)(End - Line);
if (LineLen >= 1 && Line[LineLen - 1] == L'\r') // if (LineLen >= 1 && Line[LineLen - 1] == L'\r')
LineLen -= 1; // LineLen -= 1;
//
WCHAR savechar = Line[LineLen]; // WCHAR savechar = Line[LineLen];
Line[LineLen] = L'\0'; // Line[LineLen] = L'\0';
//
WCHAR* ptr = Line; // WCHAR* ptr = Line;
ULONG len = LineLen; // ULONG len = LineLen;
while (*ptr == L' ' || *ptr == L'\t') { ptr++; len--; } // while (*ptr == L' ' || *ptr == L'\t') { ptr++; len--; }
//
if (!foundSection) // if (!foundSection)
{ // {
if (ptr[0] == L'[' && len - 2 >= sectionLen && _wcsnicmp(ptr + 1, section, sectionLen) == 0 && ptr[1 + sectionLen] == L']') // if (ptr[0] == L'[' && len - 2 >= sectionLen && _wcsnicmp(ptr + 1, section, sectionLen) == 0 && ptr[1 + sectionLen] == L']')
foundSection = TRUE; // foundSection = TRUE;
} // }
else if (ptr[0] == L'[') // else if (ptr[0] == L'[')
foundSection = FALSE; // foundSection = FALSE;
else // in section // else // in section
{ // {
if (len - 1 >= keyLen && _wcsnicmp(ptr, key, keyLen) == 0 && ptr[keyLen] == L'=') // if (len - 1 >= keyLen && _wcsnicmp(ptr, key, keyLen) == 0 && ptr[keyLen] == L'=')
{ // {
foundKey = TRUE; // foundKey = TRUE;
ptr += keyLen + 1; // ptr += keyLen + 1;
while (*ptr == L' ' || *ptr == L'\t') { ptr++; } // while (*ptr == L' ' || *ptr == L'\t') { ptr++; }
wcscpy_s(returnedString, size, ptr); // wcscpy_s(returnedString, size, ptr);
break; // break;
} // }
} // }
//
Line[LineLen] = savechar; // Line[LineLen] = savechar;
} // }
//
Dll_Free(Buffer); // Dll_Free(Buffer);
//
NtClose(hIniFile); // NtClose(hIniFile);
} // }
//
if (!foundKey) // if (!foundKey)
wcscpy_s(returnedString, size, defaultVal); // wcscpy_s(returnedString, size, defaultVal);
//
return STATUS_SUCCESS; // return STATUS_SUCCESS;
} //}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -536,10 +536,10 @@ _FX void File_InitSnapshots(void)
WCHAR SnapshotsIni[MAX_PATH] = { 0 }; WCHAR SnapshotsIni[MAX_PATH] = { 0 };
wcscpy(SnapshotsIni, Dll_BoxFilePath); wcscpy(SnapshotsIni, Dll_BoxFilePath);
wcscat(SnapshotsIni, L"\\Snapshots.ini"); wcscat(SnapshotsIni, L"\\Snapshots.ini");
//SbieDll_TranslateNtToDosPath(SnapshotsIni); SbieDll_TranslateNtToDosPath(SnapshotsIni);
WCHAR Snapshot[FILE_MAX_SNAPSHOT_ID] = { 0 }; WCHAR Snapshot[FILE_MAX_SNAPSHOT_ID] = { 0 };
GetPrivateProfileStringNt(L"Current", L"Snapshot", L"", Snapshot, FILE_MAX_SNAPSHOT_ID, SnapshotsIni); GetPrivateProfileStringW(L"Current", L"Snapshot", L"", Snapshot, FILE_MAX_SNAPSHOT_ID, SnapshotsIni);
if (*Snapshot == 0) if (*Snapshot == 0)
return; // not using snapshots return; // not using snapshots
@ -570,10 +570,10 @@ _FX void File_InitSnapshots(void)
} }
//WCHAR SnapshotName[BOXNAME_COUNT] = { 0 }; //WCHAR SnapshotName[BOXNAME_COUNT] = { 0 };
//GetPrivateProfileStringNt(SnapshotId, L"Name", L"", SnapshotName, BOXNAME_COUNT, SnapshotsIni); //GetPrivateProfileStringW(SnapshotId, L"Name", L"", SnapshotName, BOXNAME_COUNT, SnapshotsIni);
//wcscpy(Cur_Snapshot->Name, SnapshotName); //wcscpy(Cur_Snapshot->Name, SnapshotName);
GetPrivateProfileStringNt(SnapshotId, L"Parent", L"", Snapshot, 16, SnapshotsIni); GetPrivateProfileStringW(SnapshotId, L"Parent", L"", Snapshot, 16, SnapshotsIni);
if (*Snapshot == 0) if (*Snapshot == 0)
break; // no more snapshots break; // no more snapshots

View File

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