Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidXanatos committed Oct 25, 2021
1 parent 070c826 commit 9fcfc40
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 41 deletions.
34 changes: 9 additions & 25 deletions Sandboxie/core/dll/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,20 +277,20 @@ BOOLEAN Config_String2Bool(const WCHAR* value, BOOLEAN defval)

_FX BOOLEAN Config_GetSettingsForImageName_bool(const WCHAR* setting, BOOLEAN defval)
{
return SbieDll_GetSettingsForImageName_bool(NULL, Dll_ImageName, setting, defval);
return SbieDll_GetSettingsForName_bool(NULL, Dll_ImageName, setting, defval);
}


//---------------------------------------------------------------------------
// SbieDll_GetSettingsForImageName_bool
// SbieDll_GetSettingsForName_bool
//---------------------------------------------------------------------------


_FX BOOLEAN SbieDll_GetSettingsForImageName_bool(
const WCHAR* boxname, const WCHAR* image_name, const WCHAR* setting, BOOLEAN defval)
_FX BOOLEAN SbieDll_GetSettingsForName_bool(
const WCHAR* boxname, const WCHAR* name, const WCHAR* setting, BOOLEAN defval)
{
WCHAR value[16];
SbieDll_GetSettingsForImageName(boxname, image_name, setting, value, sizeof(value), NULL);
SbieDll_GetSettingsForName(boxname, name, setting, value, sizeof(value), NULL);
return Config_String2Bool(value, defval);
}

Expand Down Expand Up @@ -329,12 +329,12 @@ _FX BOOLEAN Config_InitPatternList(const WCHAR* setting, LIST* list)


//---------------------------------------------------------------------------
// SbieDll_GetSettingsForImageName
// SbieDll_GetSettingsForName
//---------------------------------------------------------------------------


_FX BOOLEAN SbieDll_GetSettingsForImageName(
const WCHAR* boxname, const WCHAR* image_name, const WCHAR* setting, WCHAR* value, ULONG value_size, const WCHAR* deftext)
_FX BOOLEAN SbieDll_GetSettingsForName(
const WCHAR* boxname, const WCHAR* name, const WCHAR* setting, WCHAR* value, ULONG value_size, const WCHAR* deftext)
{
WCHAR conf_buf[2048];
ULONG found_level = -1;
Expand All @@ -349,7 +349,7 @@ _FX BOOLEAN SbieDll_GetSettingsForImageName(
++index;

ULONG level = -1;
WCHAR* found_value = Config_MatchImageAndGetValue(conf_buf, image_name, &level);
WCHAR* found_value = Config_MatchImageAndGetValue(conf_buf, name, &level);
if (!found_value || level > found_level)
continue;
//if (found_value) {
Expand Down Expand Up @@ -568,19 +568,3 @@ BOOLEAN SbieDll_CheckStringInList(const WCHAR* string, const WCHAR* boxname, con
}
return FALSE;
}


//---------------------------------------------------------------------------
// SbieDll_GetBoolForStringFromList
//---------------------------------------------------------------------------


BOOLEAN SbieDll_GetBoolForStringFromList(const WCHAR* string, const WCHAR* boxname, const WCHAR* setting, BOOLEAN def)
{
WCHAR buf[32];
if (SbieDll_GetStringForStringList(string, boxname, setting, buf, sizeof(buf)))
return Config_String2Bool(buf, def);
return def;
}


2 changes: 1 addition & 1 deletion Sandboxie/core/dll/guititle.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ _FX BOOLEAN Gui_InitTitle(void)
// initialize title variables
//

SbieDll_GetStringForStringList(Dll_ImageName, NULL, L"BoxNameTitle", buf, sizeof(buf));
SbieDll_GetSettingsForName(NULL, Dll_ImageName, L"BoxNameTitle", buf, sizeof(buf), NULL);
if (*buf == L'y' || *buf == L'Y') { // indicator + box name

UNICODE_STRING uni;
Expand Down
4 changes: 2 additions & 2 deletions Sandboxie/core/dll/rpcrt.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ _FX ULONG RpcRt_RpcBindingFromStringBindingW(
if (CallingModule)
{
// get the DLL specific preset if present
use_RpcMgmtSetComTimeout = SbieDll_GetBoolForStringFromList(CallingModule, NULL, L"UseRpcMgmtSetComTimeout", use_RpcMgmtSetComTimeout);
use_RpcMgmtSetComTimeout = SbieDll_GetSettingsForName_bool(NULL, CallingModule, L"UseRpcMgmtSetComTimeout", use_RpcMgmtSetComTimeout);

//
// check for a "RpcPortBinding" entry
Expand Down Expand Up @@ -834,7 +834,7 @@ _FX RPC_STATUS RpcRt_RpcBindingCreateW(
if (CallingModule)
{
// get the DLL specific preset if present
use_RpcMgmtSetComTimeout = SbieDll_GetBoolForStringFromList(CallingModule, NULL, L"UseRpcMgmtSetComTimeout", use_RpcMgmtSetComTimeout);
use_RpcMgmtSetComTimeout = SbieDll_GetSettingsForName_bool(NULL, CallingModule, L"UseRpcMgmtSetComTimeout", use_RpcMgmtSetComTimeout);

//
// check for a "RpcPortBinding" entry
Expand Down
9 changes: 4 additions & 5 deletions Sandboxie/core/dll/sbiedll.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,12 @@ SBIEDLL_EXPORT BOOLEAN SbieDll_MatchImage(const WCHAR* pat_str, const WCHAR* te

SBIEDLL_EXPORT BOOLEAN SbieDll_GetStringForStringList(const WCHAR* string, const WCHAR* boxname, const WCHAR* setting, WCHAR* value, ULONG value_size);
SBIEDLL_EXPORT BOOLEAN SbieDll_CheckStringInList(const WCHAR* string, const WCHAR* boxname, const WCHAR* setting);
SBIEDLL_EXPORT BOOLEAN SbieDll_GetBoolForStringFromList(const WCHAR* string, const WCHAR* boxname, const WCHAR* setting, BOOLEAN def);

SBIEDLL_EXPORT BOOLEAN SbieDll_GetSettingsForImageName(
const WCHAR* boxname, const WCHAR* image_name, const WCHAR* setting, WCHAR* value, ULONG value_size, const WCHAR* deftext);
SBIEDLL_EXPORT BOOLEAN SbieDll_GetSettingsForName(
const WCHAR* boxname, const WCHAR* name, const WCHAR* setting, WCHAR* value, ULONG value_size, const WCHAR* deftext);

SBIEDLL_EXPORT BOOLEAN SbieDll_GetSettingsForImageName_bool(
const WCHAR* boxname, const WCHAR* image_name, const WCHAR* setting, BOOLEAN defval);
SBIEDLL_EXPORT BOOLEAN SbieDll_GetSettingsForName_bool(
const WCHAR* boxname, const WCHAR* name, const WCHAR* setting, BOOLEAN defval);

SBIEDLL_EXPORT BOOLEAN SbieDll_GetBorderColor(const WCHAR* box_name, COLORREF* color, BOOL* title, int* width);

Expand Down
2 changes: 1 addition & 1 deletion Sandboxie/core/dll/userenv.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ _FX BOOLEAN UserEnv_InitVer(HMODULE module)
void* GetVersionExA;

WCHAR str[32];
if (SbieDll_GetSettingsForImageName(NULL, Dll_ImageName, L"OverrideOsBuild", str, sizeof(str), NULL))
if (SbieDll_GetSettingsForName(NULL, Dll_ImageName, L"OverrideOsBuild", str, sizeof(str), NULL))
UserEnv_dwBuildNumber = _wtoi(str);

if (UserEnv_dwBuildNumber == 0 && Dll_OsBuild < 9600)
Expand Down
2 changes: 1 addition & 1 deletion Sandboxie/core/svc/iphlpserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ MSG_HEADER *IpHlpServer::CreateHandler(MSG_HEADER *msg, HANDLE idProcess)
if (!NT_SUCCESS(SbieApi_QueryProcess(idProcess, boxname, exename, NULL, NULL)))
return SHORT_REPLY(E_FAIL);

if (!SbieDll_GetSettingsForImageName_bool(boxname, exename, L"AllowNetworkAccess", TRUE))
if (!SbieDll_GetSettingsForName_bool(boxname, exename, L"AllowNetworkAccess", TRUE))
return SHORT_REPLY(ERROR_ACCESS_DENIED);

if (0 != SbieApi_CheckInternetAccess(
Expand Down
17 changes: 11 additions & 6 deletions Sandboxie/core/svc/sbieiniserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1004,8 +1004,8 @@ MSG_HEADER *SbieIniServer::GetSetting(MSG_HEADER *msg)
}
else if (_wcsicmp(I->Name.c_str(), req->setting) == 0) {
if(!iniData.empty()) // string list
iniData.push_back(L'\0');
//iniData.push_back(L'\n');
//iniData.push_back(L'\0');
iniData.push_back(L'\n');
iniData += I->Value;
}
}
Expand Down Expand Up @@ -1099,7 +1099,7 @@ ULONG SbieIniServer::SetSetting(MSG_HEADER* msg)

if (have_value)
{
for (WCHAR* value = req->value; req->value_len > 0 && *value != L'\0';)
/*for (WCHAR* value = req->value; req->value_len > 0 && *value != L'\0';)
{
pSection->Entries.insert(pos, SIniEntry{ req->setting, value });
Expand All @@ -1109,8 +1109,13 @@ ULONG SbieIniServer::SetSetting(MSG_HEADER* msg)
req->value_len -= 1;
value += len + 1;
}
}
/*for (WCHAR* value = req->value; *value != L'\0'; )
}*/

//
// Note: SbieCtrl passes a \n separated list to replace all values in a string list
//

for (WCHAR* value = req->value; *value != L'\0'; )
{
ULONG cpylen, skiplen;
WCHAR *cr = wcschr(value, L'\n');
Expand All @@ -1127,7 +1132,7 @@ ULONG SbieIniServer::SetSetting(MSG_HEADER* msg)
pSection->Entries.insert(pos, SIniEntry{ req->setting, std::wstring(value, cpylen) });

value += skiplen;
}*/
}
}

return STATUS_SUCCESS;
Expand Down

0 comments on commit 9fcfc40

Please sign in to comment.