diff --git a/CHANGELOG.md b/CHANGELOG.md index 71e73c2a..e2780c6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - added "HideDiskSerialNumber"(bool) return random value when applications tries to get disk serial number + ## [1.14.6 / 5.69.6] - 2024-07-30 ### Added @@ -21,7 +22,6 @@ This project adheres to [Semantic Versioning](http://semver.org/). - ## [1.14.5 / 5.69.5] - 2024-07-23 ### Added diff --git a/Sandboxie/common/my_version.h b/Sandboxie/common/my_version.h index e02088f0..edde3fbf 100644 --- a/Sandboxie/common/my_version.h +++ b/Sandboxie/common/my_version.h @@ -26,7 +26,7 @@ #define VERSION_MJR 5 #define VERSION_MIN 69 -#define VERSION_REV 6 +#define VERSION_REV 7 #define VERSION_UPD 0 #if VERSION_UPD > 0 diff --git a/Sandboxie/core/dll/custom.c b/Sandboxie/core/dll/custom.c index 3cf7d3bf..035d855d 100644 --- a/Sandboxie/core/dll/custom.c +++ b/Sandboxie/core/dll/custom.c @@ -1536,6 +1536,12 @@ _FX BOOLEAN Custom_OsppcDll(HMODULE module) NtClose(hOfficeKey); return TRUE; } + + +//--------------------------------------------------------------------------- +// Custom_ProductID +//--------------------------------------------------------------------------- + /*static wchar_t GetCharFromInt(int a) { switch (a) { case 0: @@ -1571,6 +1577,7 @@ _FX BOOLEAN Custom_OsppcDll(HMODULE module) } return 0; } + static int GetIntLen(DWORD n) { int count = 0; while (n != 0) @@ -1580,13 +1587,16 @@ static int GetIntLen(DWORD n) { } return count; }*/ + static unsigned long seed = 1; + int my_rand(void) { seed = (seed * 214013L + 2531011L) >> 16; return((unsigned)seed & 0x7fff); } + /*char* my_itoa(int num, char* str, int radix) { char index[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; @@ -1626,6 +1636,7 @@ int my_rand(void) return str; }*/ + wchar_t* GuidToString(const GUID guid) { static wchar_t buf[64] = {0}; @@ -1637,7 +1648,8 @@ wchar_t* GuidToString(const GUID guid) return buf; } -_FX BOOLEAN Custom_ProductID(void) { +_FX BOOLEAN Custom_ProductID(void) +{ if (SbieApi_QueryConfBool(NULL, L"RandomRegUID", FALSE)) { NTSTATUS status; UNICODE_STRING uni; @@ -1735,6 +1747,7 @@ _FX BOOLEAN Custom_ProductID(void) { } return TRUE; } + #ifndef _M_ARM64 //--------------------------------------------------------------------------- diff --git a/Sandboxie/core/dll/kernel.c b/Sandboxie/core/dll/kernel.c index 870e2c19..2219e68f 100644 --- a/Sandboxie/core/dll/kernel.c +++ b/Sandboxie/core/dll/kernel.c @@ -69,16 +69,7 @@ typedef LCID (*P_GetSystemDefaultLCID)(); typedef LANGID (*P_GetSystemDefaultLangID)(); -typedef BOOL (*P_GetVolumeInformationByHandleW)( - HANDLE hFile, - LPWSTR lpVolumeNameBuffer, - DWORD nVolumeNameSize, - LPDWORD lpVolumeSerialNumber, - LPDWORD lpMaximumComponentLength, - LPDWORD lpFileSystemFlags, - LPWSTR lpFileSystemNameBuffer, - DWORD nFileSystemNameSize -); +typedef BOOL (*P_GetVolumeInformationByHandleW)(HANDLE hFile, LPWSTR lpVolumeNameBuffer, DWORD nVolumeNameSize, LPDWORD lpVolumeSerialNumber,LPDWORD lpMaximumComponentLength, LPDWORD lpFileSystemFlags, LPWSTR lpFileSystemNameBuffer, DWORD nFileSystemNameSize); //typedef int (*P_GetLocaleInfoEx)(LPCWSTR lpLocaleName, LCTYPE LCType, LPWSTR lpLCData, int cchData); @@ -160,16 +151,8 @@ static LCID Kernel_GetSystemDefaultLCID(); static LANGID Kernel_GetSystemDefaultLangID(); -static BOOL Kernel_GetVolumeInformationByHandleW( - HANDLE hFile, - LPWSTR lpVolumeNameBuffer, - DWORD nVolumeNameSize, - LPDWORD lpVolumeSerialNumber, - LPDWORD lpMaximumComponentLength, - LPDWORD lpFileSystemFlags, - LPWSTR lpFileSystemNameBuffer, - DWORD nFileSystemNameSize - ); +static BOOL Kernel_GetVolumeInformationByHandleW(HANDLE hFile, LPWSTR lpVolumeNameBuffer, DWORD nVolumeNameSize, LPDWORD lpVolumeSerialNumber, LPDWORD lpMaximumComponentLength, LPDWORD lpFileSystemFlags, LPWSTR lpFileSystemNameBuffer, DWORD nFileSystemNameSize); + //--------------------------------------------------------------------------- // Kernel_Init //--------------------------------------------------------------------------- @@ -267,8 +250,9 @@ _FX BOOLEAN Kernel_Init() SBIEDLL_HOOK(Kernel_, GetSystemDefaultLCID); SBIEDLL_HOOK(Kernel_, GetSystemDefaultLangID); } - if (SbieApi_QueryConfBool(NULL, L"HideDiskSerialNumber", FALSE)) - { + + if (SbieApi_QueryConfBool(NULL, L"HideDiskSerialNumber", FALSE)) { + void* GetVolumeInformationByHandleW = GetProcAddress(Dll_KernelBase ? Dll_KernelBase : Dll_Kernel32, "GetVolumeInformationByHandleW"); if (GetVolumeInformationByHandleW) { SBIEDLL_HOOK(Kernel_, GetVolumeInformationByHandleW); @@ -517,33 +501,28 @@ _FX LANGID Kernel_GetSystemDefaultLangID() } +//---------------------------------------------------------------------------- +//Kernel_GetVolumeInformationByHandleW +//---------------------------------------------------------------------------- + static unsigned long Kernel_seed = 1; + int Kernel_rand(void) { Kernel_seed = (Kernel_seed * 214013L + 2531011L) >> 16; return((unsigned)Kernel_seed & 0x7fff); } -//---------------------------------------------------------------------------- -//Kernel_GetVolumeInformationByHandleW -//---------------------------------------------------------------------------- -_FX BOOL Kernel_GetVolumeInformationByHandleW( - HANDLE hFile, - LPWSTR lpVolumeNameBuffer, - DWORD nVolumeNameSize, - LPDWORD lpVolumeSerialNumber, - LPDWORD lpMaximumComponentLength, - LPDWORD lpFileSystemFlags, - LPWSTR lpFileSystemNameBuffer, - DWORD nFileSystemNameSize -) { + +_FX BOOL Kernel_GetVolumeInformationByHandleW(HANDLE hFile, LPWSTR lpVolumeNameBuffer, DWORD nVolumeNameSize, LPDWORD lpVolumeSerialNumber,LPDWORD lpMaximumComponentLength, LPDWORD lpFileSystemFlags, LPWSTR lpFileSystemNameBuffer, DWORD nFileSystemNameSize) +{ + // todo remember returned values and dont return a new rand each time + DWORD ourSerialNumber = 0; BOOL rtn = __sys_GetVolumeInformationByHandleW(hFile, lpVolumeNameBuffer, nVolumeNameSize, &ourSerialNumber, lpMaximumComponentLength, lpFileSystemFlags, lpFileSystemNameBuffer, nFileSystemNameSize); - if (lpVolumeSerialNumber == NULL) - return rtn; - else { + if (lpVolumeSerialNumber != NULL) { Kernel_seed = __sys_GetTickCount(); - *lpVolumeSerialNumber = Kernel_rand()%0x10000; - return rtn; + *lpVolumeSerialNumber = Kernel_rand() % 0x10000; } + return rtn; } diff --git a/SandboxiePlus/version.h b/SandboxiePlus/version.h index 2dc866c1..8eb585de 100644 --- a/SandboxiePlus/version.h +++ b/SandboxiePlus/version.h @@ -2,7 +2,7 @@ #define VERSION_MJR 1 #define VERSION_MIN 14 -#define VERSION_REV 6 +#define VERSION_REV 7 #define VERSION_UPD 0 #ifndef STR