Skip to content

Commit

Permalink
1.12.4
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidXanatos committed Dec 3, 2023
1 parent bc83bf1 commit 8222b62
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 92 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

### Added
Expand Down
4 changes: 2 additions & 2 deletions Sandboxie/common/my_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#ifndef _MY_VERSION_H
#define _MY_VERSION_H

#define MY_VERSION_BINARY 5,67,3
#define MY_VERSION_STRING "5.67.3"
#define MY_VERSION_BINARY 5,67,4
#define MY_VERSION_STRING "5.67.4"
#define MY_ABI_VERSION 0x56700

// These #defines are used by either Resource Compiler or NSIS installer
Expand Down
19 changes: 19 additions & 0 deletions Sandboxie/core/dll/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -7321,6 +7321,11 @@ _FX BOOLEAN SbieDll_TranslateNtToDosPath(WCHAR *path)
const FILE_DRIVE *drive;
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) {

wmemmove(path, path + 4, wcslen(path) - 4 + 1);
Expand Down Expand Up @@ -7368,6 +7373,20 @@ _FX BOOLEAN SbieDll_TranslateNtToDosPath(WCHAR *path)
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;
}

Expand Down
178 changes: 89 additions & 89 deletions Sandboxie/core/dll/file_snapshots.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
BOOLEAN foundSection = FALSE;
BOOLEAN foundKey = FALSE;

ULONG sectionLen = wcslen(section);
ULONG keyLen = wcslen(key);

UNICODE_STRING objname;
RtlInitUnicodeString(&objname, fileNtPath);

OBJECT_ATTRIBUTES objattrs;
InitializeObjectAttributes(&objattrs, &objname, OBJ_CASE_INSENSITIVE, NULL, NULL);

HANDLE hIniFile;
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)))
{
LARGE_INTEGER fileSize;
GetFileSizeEx(hIniFile, &fileSize);

char* iniDataPtr = (char*)Dll_Alloc((ULONG)fileSize.QuadPart + 128);
DWORD bytesRead;
ReadFile(hIniFile, iniDataPtr, (DWORD)fileSize.QuadPart, &bytesRead, NULL);
iniDataPtr[bytesRead] = L'\0';

int ByteSize = MultiByteToWideChar(CP_UTF8, 0, (char*)iniDataPtr, bytesRead, NULL, 0) + 1;
WCHAR* Buffer = (WCHAR*)Dll_Alloc(ByteSize * sizeof(wchar_t));
bytesRead = MultiByteToWideChar(CP_UTF8, 0, (char*)iniDataPtr, bytesRead, Buffer, ByteSize);

Dll_Free(iniDataPtr);

WCHAR* Next = Buffer;
while (*Next) {
WCHAR* Line = Next;
WCHAR* End = wcschr(Line, L'\n');
if (End == NULL) {
End = wcschr(Line, L'\0');
Next = End;
}
else
Next = End + 1;
ULONG LineLen = (ULONG)(End - Line);
if (LineLen >= 1 && Line[LineLen - 1] == L'\r')
LineLen -= 1;

WCHAR savechar = Line[LineLen];
Line[LineLen] = L'\0';

WCHAR* ptr = Line;
ULONG len = LineLen;
while (*ptr == L' ' || *ptr == L'\t') { ptr++; len--; }

if (!foundSection)
{
if (ptr[0] == L'[' && len - 2 >= sectionLen && _wcsnicmp(ptr + 1, section, sectionLen) == 0 && ptr[1 + sectionLen] == L']')
foundSection = TRUE;
}
else if (ptr[0] == L'[')
foundSection = FALSE;
else // in section
{
if (len - 1 >= keyLen && _wcsnicmp(ptr, key, keyLen) == 0 && ptr[keyLen] == L'=')
{
foundKey = TRUE;
ptr += keyLen + 1;
while (*ptr == L' ' || *ptr == L'\t') { ptr++; }
wcscpy_s(returnedString, size, ptr);
break;
}
}

Line[LineLen] = savechar;
}

Dll_Free(Buffer);

NtClose(hIniFile);
}

if (!foundKey)
wcscpy_s(returnedString, size, defaultVal);

return STATUS_SUCCESS;
}
//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 foundKey = FALSE;
//
// ULONG sectionLen = wcslen(section);
// ULONG keyLen = wcslen(key);
//
// UNICODE_STRING objname;
// RtlInitUnicodeString(&objname, fileNtPath);
//
// OBJECT_ATTRIBUTES objattrs;
// InitializeObjectAttributes(&objattrs, &objname, OBJ_CASE_INSENSITIVE, NULL, NULL);
//
// HANDLE hIniFile;
// 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)))
// {
// LARGE_INTEGER fileSize;
// GetFileSizeEx(hIniFile, &fileSize);
//
// char* iniDataPtr = (char*)Dll_Alloc((ULONG)fileSize.QuadPart + 128);
// DWORD bytesRead;
// ReadFile(hIniFile, iniDataPtr, (DWORD)fileSize.QuadPart, &bytesRead, NULL);
// iniDataPtr[bytesRead] = L'\0';
//
// int ByteSize = MultiByteToWideChar(CP_UTF8, 0, (char*)iniDataPtr, bytesRead, NULL, 0) + 1;
// WCHAR* Buffer = (WCHAR*)Dll_Alloc(ByteSize * sizeof(wchar_t));
// bytesRead = MultiByteToWideChar(CP_UTF8, 0, (char*)iniDataPtr, bytesRead, Buffer, ByteSize);
//
// Dll_Free(iniDataPtr);
//
// WCHAR* Next = Buffer;
// while (*Next) {
// WCHAR* Line = Next;
// WCHAR* End = wcschr(Line, L'\n');
// if (End == NULL) {
// End = wcschr(Line, L'\0');
// Next = End;
// }
// else
// Next = End + 1;
// ULONG LineLen = (ULONG)(End - Line);
// if (LineLen >= 1 && Line[LineLen - 1] == L'\r')
// LineLen -= 1;
//
// WCHAR savechar = Line[LineLen];
// Line[LineLen] = L'\0';
//
// WCHAR* ptr = Line;
// ULONG len = LineLen;
// while (*ptr == L' ' || *ptr == L'\t') { ptr++; len--; }
//
// if (!foundSection)
// {
// if (ptr[0] == L'[' && len - 2 >= sectionLen && _wcsnicmp(ptr + 1, section, sectionLen) == 0 && ptr[1 + sectionLen] == L']')
// foundSection = TRUE;
// }
// else if (ptr[0] == L'[')
// foundSection = FALSE;
// else // in section
// {
// if (len - 1 >= keyLen && _wcsnicmp(ptr, key, keyLen) == 0 && ptr[keyLen] == L'=')
// {
// foundKey = TRUE;
// ptr += keyLen + 1;
// while (*ptr == L' ' || *ptr == L'\t') { ptr++; }
// wcscpy_s(returnedString, size, ptr);
// break;
// }
// }
//
// Line[LineLen] = savechar;
// }
//
// Dll_Free(Buffer);
//
// NtClose(hIniFile);
// }
//
// if (!foundKey)
// wcscpy_s(returnedString, size, defaultVal);
//
// return STATUS_SUCCESS;
//}


//---------------------------------------------------------------------------
Expand All @@ -536,10 +536,10 @@ _FX void File_InitSnapshots(void)
WCHAR SnapshotsIni[MAX_PATH] = { 0 };
wcscpy(SnapshotsIni, Dll_BoxFilePath);
wcscat(SnapshotsIni, L"\\Snapshots.ini");
//SbieDll_TranslateNtToDosPath(SnapshotsIni);
SbieDll_TranslateNtToDosPath(SnapshotsIni);

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)
return; // not using snapshots
Expand Down Expand Up @@ -570,10 +570,10 @@ _FX void File_InitSnapshots(void)
}

//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);

GetPrivateProfileStringNt(SnapshotId, L"Parent", L"", Snapshot, 16, SnapshotsIni);
GetPrivateProfileStringW(SnapshotId, L"Parent", L"", Snapshot, 16, SnapshotsIni);

if (*Snapshot == 0)
break; // no more snapshots
Expand Down
2 changes: 1 addition & 1 deletion SandboxiePlus/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#define VERSION_MJR 1
#define VERSION_MIN 12
#define VERSION_REV 3
#define VERSION_REV 4
#define VERSION_UPD 0

#ifndef STR
Expand Down

0 comments on commit 8222b62

Please sign in to comment.