This commit is contained in:
DavidXanatos 2021-10-19 19:45:48 +02:00
parent a3d9920e39
commit 0a6f5c79f7
3 changed files with 21 additions and 14 deletions

View File

@ -516,26 +516,33 @@ BOOLEAN SbieDll_MatchImage(const WCHAR* pat_str, const WCHAR* test_str, const WC
BOOLEAN SbieDll_GetStringForStringList(const WCHAR* string, const WCHAR* boxname, const WCHAR* setting, WCHAR* value, ULONG value_size)
{
BOOLEAN found = FALSE;
WCHAR buf[CONF_LINE_LEN];
ULONG index = 0;
while (1) {
NTSTATUS status = SbieApi_QueryConfAsIs(boxname, setting, index, buf, 64 * sizeof(WCHAR));
NTSTATUS status = SbieApi_QueryConfAsIs(boxname, setting, index, buf, sizeof(buf) - 4);
++index;
if (NT_SUCCESS(status)) {
WCHAR* ptr = wcschr(buf, L',');
if (ptr) *ptr = L'\0';
if (_wcsicmp(buf, string) == 0) {
if (ptr++)
if (ptr) {
// check specific value
*ptr++ = L'\0';
if (_wcsicmp(buf, string) == 0) {
wcscpy_s(value, value_size / sizeof(WCHAR), ptr);
else
*value = L'\0';
return TRUE;
found = TRUE;
break;
}
}
else if (!found) {
// default value
wcscpy_s(value, value_size / sizeof(WCHAR), buf);
found = TRUE;
}
}
else if (status != STATUS_BUFFER_TOO_SMALL)
break;
}
return FALSE;
return found;
}
@ -568,12 +575,12 @@ BOOLEAN SbieDll_CheckStringInList(const WCHAR* string, const WCHAR* boxname, con
//---------------------------------------------------------------------------
BOOLEAN SbieDll_GetBoolForStringFromList(const WCHAR* string, const WCHAR* boxname, const WCHAR* setting, BOOLEAN def_found, BOOLEAN not_found)
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_found);
return not_found;
return Config_String2Bool(buf, def);
return def;
}

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", TRUE, use_RpcMgmtSetComTimeout);
use_RpcMgmtSetComTimeout = SbieDll_GetBoolForStringFromList(CallingModule, NULL, 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", TRUE, use_RpcMgmtSetComTimeout);
use_RpcMgmtSetComTimeout = SbieDll_GetBoolForStringFromList(CallingModule, NULL, L"UseRpcMgmtSetComTimeout", use_RpcMgmtSetComTimeout);
//
// check for a "RpcPortBinding" entry

View File

@ -206,7 +206,7 @@ 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_found, BOOLEAN not_found);
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);