Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set MAC address for each box #4249

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).


## [1.1x.xx / 5.xx.xx] - 2024-xx-xx

### 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

## [1.14.10 / 5.69.10] - 2024-10-03

### Added
Expand Down
33 changes: 29 additions & 4 deletions Sandboxie/core/dll/custom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1588,11 +1588,24 @@ __int64 __fastcall AllocateAndGetAdaptersInfo(PIP_ADAPTER_INFO a1)
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 {
Expand Down Expand Up @@ -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);
}

Expand Down