diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c20d6c1..b6284cb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [1.15.2 / 5.70.2] - 2024-10- ### Added +- added "MacAddressValueMajorX"(fill 'X' with number 0-9) and "MacAddressValueMinorX"(fill 'X' with number 0-9) to set MAC address for each box(You must set both two options at the same time). + - For example: + - MacAddressValueMajor0=Number + - 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) diff --git a/Sandboxie/core/dll/custom.c b/Sandboxie/core/dll/custom.c index 633433bb..37b292e9 100644 --- a/Sandboxie/core/dll/custom.c +++ b/Sandboxie/core/dll/custom.c @@ -1588,11 +1588,24 @@ LABEL_9: return result; } */ - +wchar_t itoa1(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'; + } +} ULONG Nsi_NsiAllocateAndGetTable(int a1, struct NPI_MODULEID* NPI_MS_ID, unsigned int TcpInformationId, void **pAddrEntry, int SizeOfAddrEntry, void **a6, int a7, void **pStateEntry, int SizeOfStateEntry, void **pOwnerEntry, int SizeOfOwnerEntry, DWORD *Count, int a13) { ULONG ret = __sys_NsiAllocateAndGetTable(a1, NPI_MS_ID, TcpInformationId, pAddrEntry, SizeOfAddrEntry, a6, a7, pStateEntry, SizeOfStateEntry, pOwnerEntry, SizeOfOwnerEntry, Count, a13); - + static long num = 0; if (memcmp(NPI_MS_ID, NPI_MS_NDIS_MODULEID, 24) == 0 && pStateEntry) { typedef struct _STATE_ENTRY { @@ -1630,8 +1643,20 @@ ULONG Nsi_NsiAllocateAndGetTable(int a1, struct NPI_MODULEID* NPI_MS_ID, unsigne memcpy(pEntry->Address, lpMac, 8); else { - *(DWORD*)&pEntry->Address[0] = Dll_rand(); - *(DWORD*)&pEntry->Address[4] = Dll_rand(); + wchar_t KeyName1[30] = {0}, KeyName2[30] = {0}; + Sbie_snwprintf(KeyName1, 30, L"%s%s", L"MacAddressValueMajor", itoa1(num)); + Sbie_snwprintf(KeyName2, 30, L"%s%s", L"MacAddressValueMinor", itoa1(num)); + DWORD mac = SbieApi_QueryConfNumber(NULL, KeyName2, 0); + DWORD mac2 = SbieApi_QueryConfNumber(NULL,KeyName2,0); + if (mac != 0 && mac2 != 0) { + *(DWORD*)&pEntry->Address[0] = mac; + *(DWORD*)&pEntry->Address[4] = mac2; + } + else { + *(DWORD*)&pEntry->Address[0] = Dll_rand(); + *(DWORD*)&pEntry->Address[4] = Dll_rand(); + } + num++; map_insert(&Custom_NicMac, (void*)key, pEntry->Address, 8); }