Merge branch 'master' into MacFixed

This commit is contained in:
DavidXanatos 2024-11-14 08:51:07 +01:00 committed by GitHub
commit 4d328e7ed1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 82 additions and 2 deletions

View File

@ -12,6 +12,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- MacAddressValueMinor0=Number
- MacAddressValueMajor1=Number
- MacAddressValueMinor1=Number
- added "DiskSerialNumberValueX"(Fill number 0-9 to 'X') to set Disk Serial Number for indivdal box.
- added the ability to hide certificates in editbox in Global Setting (idea by Yeyixiao)
- added Opening a program in several sandboxes at once [#4231](https://github.com/sandboxie-plus/Sandboxie/issues/4231)
- added "Description" field inside the sandbox settings [#4243](https://github.com/sandboxie-plus/Sandboxie/issues/4243)

View File

@ -23,6 +23,8 @@
//#include <windows.h>
//#include "common/win32_ntddk.h"
#include "dll.h"
#include "obj.h"
#include <wchar.h>
#include "common/pool.h"
#include "common/map.h"
@ -517,10 +519,67 @@ _FX LANGID Kernel_GetSystemDefaultLangID()
//Kernel_GetVolumeInformationByHandleW
//----------------------------------------------------------------------------
wchar_t itoa0(int num) {
switch (num) {
case 0:return L'0';
case 1:return L'1';
case 2:return L'2';
case 3:return L'4';
case 5:return L'5';
case 6:return L'6';
case 7:return L'7';
case 8:return L'8';
case 9:return L'9';
default:return L'0';
}
}
int IsValidHexString(const wchar_t* hexString)
{
int length = lstrlen(hexString);
if (length != 9 || hexString[4] != L'-')
{
return 0;
}
for (int i = 0; i < length; i++)
{
if (i != 4 && !iswxdigit(hexString[i]))
{
return 0;
}
}
return 1;
}
unsigned long HexStringToULONG(const wchar_t* hexString) {
int length = lstrlen(hexString);
for (int i = 0; i < length; ++i) {
if (hexString[i] == L'-') {
length--;
}
}
wchar_t* cleanedHexString = (wchar_t*)Dll_Alloc(length + 1);
if (!cleanedHexString) {
return 0;
}
int j = 0;
for (int i = 0; i < lstrlen(hexString); ++i) {
if (hexString[i] != L'-') {
cleanedHexString[j++] = hexString[i];
}
}
cleanedHexString[j] = L'\0';
unsigned long ulongValue = wcstoul(cleanedHexString, NULL, 16);
Dll_Free(cleanedHexString);
return ulongValue;
}
_FX BOOL Kernel_GetVolumeInformationByHandleW(HANDLE hFile, LPWSTR lpVolumeNameBuffer, DWORD nVolumeNameSize, LPDWORD lpVolumeSerialNumber,LPDWORD lpMaximumComponentLength, LPDWORD lpFileSystemFlags, LPWSTR lpFileSystemNameBuffer, DWORD nFileSystemNameSize)
{
DWORD ourSerialNumber = 0;
static long num = 0;
BOOL rtn = __sys_GetVolumeInformationByHandleW(hFile, lpVolumeNameBuffer, nVolumeNameSize, &ourSerialNumber, lpMaximumComponentLength, lpFileSystemFlags, lpFileSystemNameBuffer, nFileSystemNameSize);
if (lpVolumeSerialNumber != NULL) {
@ -533,8 +592,28 @@ _FX BOOL Kernel_GetVolumeInformationByHandleW(HANDLE hFile, LPWSTR lpVolumeNameB
*lpVolumeSerialNumber = *lpCachedSerialNumber;
else
{
wchar_t Value[30] = { 0 };
//Sbie_snwprintf(KeyName, 30, L"%s%s", L"DiskSerialNumberValue", itoa0(num));
//DWORD conf = SbieApi_QueryConfNumber(NULL, KeyName, 0);
wchar_t handleName[MAX_PATH] = { 0 }, handleName2[23 + 1] = { 0 };
DWORD dWroteNum = 0;
Obj_GetObjectName(hFile, handleName, &dWroteNum);
if (dWroteNum > MAX_PATH)
ExitProcess(0);
strncpy_s(handleName2,24, handleName, 23);
//MessageBox(NULL,handleName2,handleName2,MB_OK);
SbieDll_GetSettingsForName(NULL, L"DiskSerialNumber", handleName2, Value, 30, L"0000-0000");
if (!IsValidHexString(Value))
*lpVolumeSerialNumber = Dll_rand();
else {
//*lpVolumeSerialNumber = conf;
DWORD conf=HexStringToULONG(Value);
if(conf==0)
*lpVolumeSerialNumber = Dll_rand();
else
*lpVolumeSerialNumber = conf;
}
num++;
map_insert(&Kernel_DiskSN, key, lpVolumeSerialNumber, sizeof(DWORD));
}