diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a74277e..75b20e84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - fixed Applications cannot be launched as admin in a sandbox with "UseCreateToken/SandboxieAllGroup" enabled when using an MSFT account [#4022](https://github.com/sandboxie-plus/Sandboxie/issues/4022) - fixed Firefox issue with Sbie 1.14.1 and 1.14.2 [#4012](https://github.com/sandboxie-plus/Sandboxie/issues/4012) - rolled back the driver verifier fix added in 1.14.1 - +- fixed CustomChromiumFlags and --single-argument issue [#4033](https://github.com/sandboxie-plus/Sandboxie/issues/4033) diff --git a/Sandboxie/core/dll/kernel.c b/Sandboxie/core/dll/kernel.c index 62f4390b..867c4cbb 100644 --- a/Sandboxie/core/dll/kernel.c +++ b/Sandboxie/core/dll/kernel.c @@ -112,12 +112,27 @@ _FX BOOLEAN Kernel_Init() status = SbieApi_QueryConfAsIs(NULL, L"CustomChromiumFlags", 0, CustomChromiumFlags, ARRAYSIZE(CustomChromiumFlags)); if (NT_SUCCESS(status)) { + const WCHAR* lpCommandLine = ProcessParms->CommandLine.Buffer; + const WCHAR* lpArguments = SbieDll_FindArgumentEnd(lpCommandLine); + if (lpArguments == NULL) + lpArguments = wcsrchr(lpCommandLine, L'\0'); + Kernel_CommandLineW.MaximumLength = ProcessParms->CommandLine.MaximumLength + (CONF_LINE_LEN + 8) * sizeof(WCHAR); Kernel_CommandLineW.Buffer = LocalAlloc(LMEM_FIXED,Kernel_CommandLineW.MaximumLength); - wcscpy(Kernel_CommandLineW.Buffer, ProcessParms->CommandLine.Buffer); - if(Kernel_CommandLineW.Buffer[ProcessParms->CommandLine.Length/sizeof(WCHAR) - 1] != L' ') + + // copy argument 0 + wmemcpy(Kernel_CommandLineW.Buffer, lpCommandLine, lpArguments - lpCommandLine); + Kernel_CommandLineW.Buffer[lpArguments - lpCommandLine] = 0; + + // add custom arguments + if(Kernel_CommandLineW.Buffer[lpArguments - lpCommandLine - 1] != L' ') wcscat(Kernel_CommandLineW.Buffer, L" "); wcscat(Kernel_CommandLineW.Buffer, CustomChromiumFlags); + + // add remaining arguments + wcscat(Kernel_CommandLineW.Buffer, lpArguments); + + Kernel_CommandLineW.Length = wcslen(Kernel_CommandLineW.Buffer) * sizeof(WCHAR); RtlUnicodeStringToAnsiString(&Kernel_CommandLineA, &Kernel_CommandLineW, TRUE);