This commit is contained in:
DavidXanatos 2021-10-25 18:22:45 +02:00
parent 070c82662e
commit 9fcfc4054e
7 changed files with 29 additions and 41 deletions

View File

@ -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);
}
@ -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;
@ -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) {
@ -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;
}

View File

@ -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;

View File

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

View File

@ -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);

View File

@ -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)

View File

@ -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(

View File

@ -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;
}
}
@ -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 });
@ -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');
@ -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;