1.12.2
This commit is contained in:
parent
ecaf79dad2
commit
cf46502292
|
@ -33,6 +33,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||
- fixed UNEXPECTED_KERNEL_MODE_TRAP BSOD when opening any web link from sandboxed Microsoft 365 app (e.g. Outlook, Word) [#3427](https://github.com/sandboxie-plus/Sandboxie/issues/3427)
|
||||
- fixed issue with force process warning message
|
||||
- fixed online updater does not respect portable mode [#3406](https://github.com/sandboxie-plus/Sandboxie/issues/3406)
|
||||
- fixed Snapshot feature does not work on encrypted boxes [#3439](https://github.com/sandboxie-plus/Sandboxie/issues/3439)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -672,7 +672,7 @@ _FX BOOLEAN File_LoadPathTree_internal(LIST* Root, const WCHAR* name, WCHAR* (*T
|
|||
} else
|
||||
Next = End + 1;
|
||||
LONG LineLen = (LONG)(End - Line);
|
||||
if (LineLen > 1 && Line[LineLen - 1] == L'\r')
|
||||
if (LineLen >= 1 && Line[LineLen - 1] == L'\r')
|
||||
LineLen -= 1;
|
||||
|
||||
WCHAR savechar = Line[LineLen];
|
||||
|
|
|
@ -431,6 +431,97 @@ _FX ULONG File_IsDeletedEx(const WCHAR* TruePath, const WCHAR* CopyPath, FILE_SN
|
|||
return (Flags & FILE_DELETED_MASK);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// GetPrivateProfileStringNt
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// File_InitSnapshots
|
||||
|
@ -445,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 };
|
||||
GetPrivateProfileStringW(L"Current", L"Snapshot", L"", Snapshot, FILE_MAX_SNAPSHOT_ID, SnapshotsIni);
|
||||
GetPrivateProfileStringNt(L"Current", L"Snapshot", L"", Snapshot, FILE_MAX_SNAPSHOT_ID, SnapshotsIni);
|
||||
|
||||
if (*Snapshot == 0)
|
||||
return; // not using snapshots
|
||||
|
@ -479,10 +570,10 @@ _FX void File_InitSnapshots(void)
|
|||
}
|
||||
|
||||
//WCHAR SnapshotName[BOXNAME_COUNT] = { 0 };
|
||||
//GetPrivateProfileStringW(SnapshotId, L"Name", L"", SnapshotName, BOXNAME_COUNT, SnapshotsIni);
|
||||
//GetPrivateProfileStringNt(SnapshotId, L"Name", L"", SnapshotName, BOXNAME_COUNT, SnapshotsIni);
|
||||
//wcscpy(Cur_Snapshot->Name, SnapshotName);
|
||||
|
||||
GetPrivateProfileStringW(SnapshotId, L"Parent", L"", Snapshot, 16, SnapshotsIni);
|
||||
GetPrivateProfileStringNt(SnapshotId, L"Parent", L"", Snapshot, 16, SnapshotsIni);
|
||||
|
||||
if (*Snapshot == 0)
|
||||
break; // no more snapshots
|
||||
|
|
Loading…
Reference in New Issue