Skip to content

WeChat Channels and Mini Programs Fail to Open in Sandboxie-Plus #5662

Open

Description

@haobinnan

Describe what you noticed and did

Steps to reproduce

  1. Launch WeChat for Windows inside a Sandboxie-Plus sandbox.
  2. Open Moments (朋友圈) and verify that posts can be viewed normally.
  3. Click Channels (视频号).
  4. Return to WeChat and click Mini Programs (小程序).

Actual behavior

  • Moments works normally, and posts can be viewed.
  • Clicking Channels or Mini Programs produces no visible response.
  • Neither feature opens or displays any content.

This issue may be related to compatibility between recent versions of WeChat for Windows and Sandboxie-Plus.

I have not yet confirmed the root cause.

How often did you encounter it so far?

The issue occurs when I try to open Channels or Mini Programs in the sandbox. Moments continues to work normally.

Expected behavior

Channels and Mini Programs should open and display their content normally when WeChat for Windows is running inside a Sandboxie-Plus sandbox, just as Moments does.

Affected program

WeChat for Windows, [insert the exact version number here]

Download link

https://weixin.qq.com/

Where is the program located?

Not relevant to my request.

Did the program or any related process close unexpectedly?

No, not at all.

Crash dump

No response

What version of Sandboxie are you running now?

1.18.8

Is it a new installation of Sandboxie?

I just updated Sandboxie from a previous version (I don't remember which one).

Is it a regression from previous versions?

No response

In which sandbox type you have this problem?

In a standard isolation sandbox (yellow sandbox icon).

Can you reproduce this problem on a new empty sandbox?

I can confirm it also on a new empty sandbox.

What is your Windows edition and version?

11 26h2

In which Windows account you have this problem?

A Microsoft account (Administrator).

Please mention any installed security software

microsoft

Did you previously enable some security policy settings outside Sandboxie?

No response

Trace log

No response

Sandboxie.ini configuration

Activity

  1. happyEddiehorse commented on Oct 21, 2026

    @happyEddiehorse

    Confirming this on Sandboxie-Plus 1.18.8 with Windows 11 26H2 — same symptom set.

    Environment

    • Sandboxie-Plus 1.18.8 / 5.73.8 (x64)
    • Windows 11 26H2, build 26300.9711
    • WeChat for Windows 4.x — Weixin.exe, build 4.1.15.13
    • WeChat is installed only inside the sandbox (no host installation; inside the box: C:\Program Files\Tencent\Weixin)
    • Box: standard isolation, WeChat01 with custom rules
    • Security software: Huorong 6.0.12.1

    Steps to reproduce

    1. Start Weixin.exe from inside the box.
    2. Moments (朋友圈) loads normally.
    3. Click Channels (视频号) — nothing happens: no window, no error dialog, no visible reaction.
    4. Click Mini Programs (小程序) — same, nothing opens.
    5. Open a chat link that WeChat renders in its built-in browser — also fails to open.

    Expected behavior

    Channels, Mini Programs and the built-in browser should open inside the box, as they do on the host.

    Observed details

    • WeChatAppEx.exe never appears in the box's process list — I watched the list for ~10 s after each click.
    • This used to work and stopped around mid-September 2026; no change was made to the box configuration.
    • The camera problem on this machine is tracked separately in Allow access to camera and microphone on WINDOWS 11 #1669 and is not part of this report.

    Relevant configuration (sanitized excerpt)

    [WeChat01]
    Enabled=y
    ConfigLevel=10
    DropAdminRights=y
    FakeAdminRights=y
    OpenWinClass=#
    ; these entries carry no CLSID and appear to be ignored:
    OpenClsid=Weixin.exe,
    OpenClsid=WeChatAppEx.exe,
    SpecialImage=chrome,WeChatAppEx.exe
    ; ... other box rules omitted ...

    The full Sandboxie.ini can be attached on request (sanitized), along with a trace log (ClsidTrace=* / IpcTrace=*) if that would help.

  2. kakiii commented on Nov 2, 2026

    @kakiii

    A reversible workaround resolved similar symptoms on my machine.

    Environment:

    • Windows 11 26H2, build 26300.9711
    • Sandboxie Plus 1.18.8 / core 5.73.8
    • Weixin 4.1.15.56, installed inside DefaultBox

    Chat links, official-account articles, Channels, and Mini Programs would not open. “Open third-party webpages using the system default browser” was disabled. Restarting Weixin did not help.

    What worked:

    1. Fully exit Weixin and confirm its processes have stopped.
    2. Locate this directory inside the sandbox’s physical storage, rather than in the host profile:
      user\current\AppData\Roaming\Tencent\xwechat\XPlugin\Plugins\RadiumWMPF
    3. Rename it to a timestamped backup, keeping its contents.
    4. Start Weixin in the same sandbox, log in, and open an article or Channels to trigger component restoration.

    Weixin recreated RadiumWMPF version 25799. Opening content then worked, and the resulting WeChatAppEx.exe processes were confirmed to belong to DefaultBox.

    Additional observations:

    • Both the old and recreated version 25799 passed all 42 file checks against their component manifests. This does not establish binary corruption as the cause.
    • The existing SpecialImage=chrome,WeChatAppEx.exe rule was retained.
    • Temporarily adding SpecialImage=chrome,Weixin.exe did not help and was reverted.
    • No resource-access exceptions were added, and chat-history directories were left untouched.

    This is a successful workaround from one machine, not a confirmed root cause or a verified general fix. Long-term persistence has not yet been tested.

  3. haobinnan commented on Nov 3, 2026

    @haobinnan
    Author

    Have you tested this method with Weixin 4.2? I just tried it with Weixin 4.2, following your instructions, but unfortunately, it didn't work. The issue still persists.@kakiii

  4. haobinnan commented on Nov 3, 2026

    @haobinnan
    Author

    One additional note: After renaming the RadiumWMPF folder and rebuilding the project, I performed a binary comparison between the newly generated RadiumWMPF folder and the original folder. All files were identical, with no differences found.

  5. haobinnan commented on Nov 3, 2026

    @haobinnan
    Author

    Enabled=y
    BlockNetworkFiles=y
    RecoverFolder=%Desktop%
    BorderColor=#02f6f6,off,6
    Template=OpenBluetooth
    Template=FileCopy
    Template=qWave
    Template=BlockPorts
    Template=LingerPrograms
    Template=AutoRecoverIgnore
    Template=SkipHook
    ConfigLevel=10
    UseFileDeleteV2=y
    UseRegDeleteV2=y
    BoxNameTitle=-
    BreakoutFolder=C:\Program Files (x86)\Microsoft\Edge\Application
    AutoRecover=y
    ClosedIpcPath=,*
    ProcessGroup=,TSVNCache.exe,TSVNCache.exe
    SpecialImage=chrome,QQ.exe
    SpecialImage=chrome,QQEX.exe
    SpecialImage=chrome,Weixin.exe
    SpecialImage=chrome,WeChatAppEx.exe

  6. happyEddiehorse commented on Nov 3, 2026

    @happyEddiehorse

    Thanks @kakiii — I followed your workaround exactly as described, and unfortunately it does not resolve the problem on my machine. Details below, in case they help narrow it down.

    Environment: Sandboxie-Plus 1.18.8 / 5.73.8, Windows 11 26H2 build 26300.9711, Weixin 4.1.15.13 installed only inside the sandbox (box WeChat01), Huorong 6.0.12.1.

    What I did:

    1. Fully exited Weixin and confirmed no Weixin.exe / WeChatAppEx.exe processes remained.
    2. Renamed …\user\current\AppData\Roaming\Tencent\xwechat\XPlugin\Plugins\RadiumWMPF to RadiumWMPF.bak-20261103, leaving all contents untouched (44 files, 413.3 MB).
    3. Started Weixin inside the same box, logged in, and opened an official-account article and Channels to trigger component provisioning.

    Result:

    • Weixin recreated the directory within seconds of startup — but as version 26042, i.e. the same version that was there before, not 25799.
    • The recreated tree again has 44 files / 413.3 MB, and it is byte-identical to the backup: MD5 of WeChatAppEx.exe (1A511CA8…), xweb_elf.dll (DFA8A9F5…) and 26042\extracted\file_component.xml (D0061D3A…) all match the backup exactly.
    • Behaviour is unchanged: clicking Channels or Mini Programs still does nothing, and WeChatAppEx.exe never starts.
    • This is consistent with @haobinnan's finding that the regenerated files were identical to the originals.

    Two extra data points:

    • I sampled the process table every 80 ms for 180 s while clicking Channels: no new process appeared at all, and no new minidump was written. So on this build the child process is never created — it is not "created and then crashes immediately".
    • log\radium\host_20261103.xlog was last written when Weixin started and did not grow when I clicked, i.e. the WMPF host did not react to the click at all. At the same time, wmpf_host_export_x64.dll is loaded into the main Weixin.exe process, so the host-side DLL loads fine and the failure happens after that point.

    On 4.1.15.13 the rename is effectively a no-op, so this looks version-dependent rather than file-corruption-related.

  7. haobinnan commented on Nov 12, 2026

    @haobinnan
    Author

    Based on the findings so far, I suspect the underlying problem is that WeChatAppEx.exe cannot be launched properly inside the Sandboxie sandbox.

    The issue does not appear to be caused by missing or corrupted files in the RadiumWMPF directory. Regenerating the directory produces identical files, but the problem remains unchanged.

    The key observation is that WeChatAppEx.exe is never created when clicking Channels or Mini Programs. This suggests that the failure occurs before the child process is actually launched.

    I think we should focus on investigating why Sandboxie cannot properly start WeChatAppEx.exe, or why the process creation request is not being triggered, rather than continuing to investigate the component files themselves.

    At this point, this is still a suspected cause rather than a confirmed root cause.

  8. Ben-md5 commented on Nov 13, 2026

    @Ben-md5

    Same problem here, with one data point that may help narrow it down: “the failure follows the WeChat main program version, not the WMPF component version.”

    Environment

    • Sandboxie-Plus 1.18.8
    • Windows 11 Pro, build 26300.9974
    • WeChat is installed only inside the box
    • Box settings: UsePrivacyMode=y, NoSecurityIsolation=y, OpenCredentials=y, Template=RpcPortBindingsExt

    What happened

    • WeChat auto-updated itself to 4.2.0.53; one minute later the RadiumWMPF component went from 2.5.7.25819 to 2.5.8.26134.
    • From that moment the built-in browser stopped working. Links open in the default browser instead (the "open in default browser" setting is OFF).

    Observed with WeChat 4.2.0.53 + WMPF 26134 (broken)

    • At WeChat startup, Weixin.exe launches WeChatAppEx.exe 5 times within about 1 second. Each instance lives roughly 0.25 s and exits.
    • No crash dump is written, and the WMPF main log is not written at all.
    • After the 5 failures WeChat gives up, and every link click launches the default browser.
    • Launch command line (paths shortened):
      "%APPDATA%\Tencent\xwechat\xplugin\plugins\RadiumWMPF\WeChatAppEx.exe" --log-level=2 --helper-handle-value=... --flue-runtime-dir="%APPDATA%\Tencent\xwechat\xplugin\plugins\RadiumWMPF\26134\extracted\runtime" --product-id=1002 --wmpf_root_dir="%APPDATA%\Tencent\xwechat\radium" --instance-index=0 --mojo-platform-channel-handle=...
    • All 41 files of component 26134 match the MD5s in its manifest, and all executables have valid signatures, so the component is not corrupted.
    • Restarting the sandbox did not help.

    Observed after downgrading to WeChat 4.1.12.55 (works)

    • Same box, same settings, same WMPF 26134 files, nothing else changed.
    • WeChatAppEx.exe starts and stays alive (browser, GPU and renderer processes), and articles open in the built-in browser again.
    • The child processes run from ...\RadiumWMPF\26134\extracted\runtime\WeChatAppEx.exe, i.e. still component 26134.

    Notes

    • With 4.2.0.53 the process is started through the top-level RadiumWMPF\WeChatAppEx.exe stub with --flue-runtime-dir. I could not read the command line of the browser main process under 4.1.12.55, so I cannot say whether the launch method differs between the two versions.
    • I saw SandboxieRpcSs.exe: SBIE2203 ... connect C00000A5 (msg_id 0x1782) once when the failure first appeared. It did not show up again after restarting the sandbox, while the failure persisted, so it may be unrelated.
    • A resource access monitor log from an earlier occurrence on another machine (WMPF 26073, WeChat version unknown) showed WeChatAppEx.exe loading only xweb_elf.dll and base system DLLs. flue.dll was never opened, and there were no notable denied entries.
    • I have not tested SpecialImage or any OpenFilePath workaround.

    Current workaround: stay on WeChat 4.1.12.55 and keep it from auto-updating.

  9. haobinnan commented on Nov 13, 2026

    @haobinnan
    Author

    Same problem here, with one data point that may help narrow it down: “the failure follows the WeChat main program version, not the WMPF component version.”

    Environment

    • Sandboxie-Plus 1.18.8
    • Windows 11 Pro, build 26300.9974
    • WeChat is installed only inside the box
    • Box settings: , , , UsePrivacyMode=y``NoSecurityIsolation=y``OpenCredentials=y``Template=RpcPortBindingsExt

    What happened

    • WeChat auto-updated itself to 4.2.0.53; one minute later the RadiumWMPF component went from 2.5.7.25819 to 2.5.8.26134.
    • From that moment the built-in browser stopped working. Links open in the default browser instead (the "open in default browser" setting is OFF).

    Observed with WeChat 4.2.0.53 + WMPF 26134 (broken)

    • At WeChat startup, Weixin.exe launches 5 times within about 1 second. Each instance lives roughly 0.25 s and exits.WeChatAppEx.exe
    • No crash dump is written, and the WMPF main log is not written at all.
    • After the 5 failures WeChat gives up, and every link click launches the default browser.
    • Launch command line (paths shortened):
      "%APPDATA%\Tencent\xwechat\xplugin\plugins\RadiumWMPF\WeChatAppEx.exe" --log-level=2 --helper-handle-value=... --flue-runtime-dir="%APPDATA%\Tencent\xwechat\xplugin\plugins\RadiumWMPF\26134\extracted\runtime" --product-id=1002 --wmpf_root_dir="%APPDATA%\Tencent\xwechat\radium" --instance-index=0 --mojo-platform-channel-handle=...
    • All 41 files of component 26134 match the MD5s in its manifest, and all executables have valid signatures, so the component is not corrupted.
    • Restarting the sandbox did not help.

    Observed after downgrading to WeChat 4.1.12.55 (works)

    • Same box, same settings, same WMPF 26134 files, nothing else changed.
    • WeChatAppEx.exe starts and stays alive (browser, GPU and renderer processes), and articles open in the built-in browser again.
    • The child processes run from , i.e. still component 26134....\RadiumWMPF\26134\extracted\runtime\WeChatAppEx.exe

    Notes

    • With 4.2.0.53 the process is started through the top-level stub with . I could not read the command line of the browser main process under 4.1.12.55, so I cannot say whether the launch method differs between the two versions.RadiumWMPF\WeChatAppEx.exe``--flue-runtime-dir
    • I saw once when the failure first appeared. It did not show up again after restarting the sandbox, while the failure persisted, so it may be unrelated.SandboxieRpcSs.exe: SBIE2203 ... connect C00000A5 (msg_id 0x1782)
    • A resource access monitor log from an earlier occurrence on another machine (WMPF 26073, WeChat version unknown) showed loading only and base system DLLs. was never opened, and there were no notable denied entries.WeChatAppEx.exe``xweb_elf.dll``flue.dll
    • I have not tested or any workaround.SpecialImage``OpenFilePath

    Current workaround: stay on WeChat 4.1.12.55 and keep it from auto-updating.

    Your analysis is very helpful. However, I'm a little concerned that even if we report this issue to Tencent, they may not be willing to spend time addressing it.

    Alternatively, would you be willing to try reporting this issue to Tencent? Perhaps raising it through their official channels might help bring it to their attention.

  10. cssxn commented on Nov 18, 2026

    @cssxn
    Contributor

    I was faced the same issue and fixed, here is the pr and analysis report

    #5729

    Sandboxie rewrites the main module path with the on-disk letter case, breaking applications that compare it case-sensitively against argv[0]

    Root cause analysis and fix proposal. Applies to Sandboxie/core/dll/ldr_init.c (+110 / −1).


    TL;DR

    Cause. When SbieDll creates a process it derives the image name from a file handle
    (SbieDll_GetHandlePath), so the child's ImagePathName carries the spelling the file system
    reports. lpCommandLine is passed through unchanged, so argv[0] keeps the spelling the caller
    used. Ldr_FixImagePath() then writes the file-system spelling into LDR_MODULE.FullDllName,
    BaseDllName and RTL_USER_PROCESS_PARAMETERS.ImagePathName.

    Both strings denote the same file, and Windows treats them as equal. Applications that compare
    GetModuleFileName() against argv[0] case-sensitively do not. Chromium's
    FilePath::AppendRelativePath() compares every path component strictly and exempts only the drive
    letter, so it concludes the paths are unrelated. WeChat 4.x WeChatAppEx.exe is one such
    application: it cannot compute its plugin root, fails to locate flue.dll, and calls
    ExitProcess(7).

    Fix. In Ldr_FixImagePath(), read argv[0] from
    RTL_USER_PROCESS_PARAMETERS.CommandLine. If it equals the boxed true path ignoring case,
    use its spelling; otherwise keep the current behaviour. One file, no struct changes, no driver
    rebuild.


    1. Symptom

    Item Value
    Host Weixin.exe 4.2.0.53
    Child process WeChatAppEx.exe (the Chromium container used for mini-programs, official-account articles, notes)
    Location %APPDATA%\Tencent\xwechat\XPlugin\Plugins\RadiumWMPF\WeChatAppEx.exe
    Symptom inside the sandbox The process exits immediately with code 7; the host relaunches it in a loop. Opening a note or an official-account article does nothing.
    Outside the sandbox Works normally (11 WeChatAppEx processes, stable)
    Scope Any sandboxed application that compares the module path against its command line case-sensitively. Chromium / CEF / Electron are at risk.

    2. Root cause

      Parent process (Weixin.exe)
        CreateProcessW(lpApplicationName = NULL,
                       lpCommandLine   = "...\"C:\Users\...\XPlugin\Plugins\RadiumWMPF\WeChatAppEx.exe\" --type=...")
                                                                      ^ caller spelling
                        |
                        v
      SbieDll hooks CreateProcessInternalW
        - opens the image to learn its real path:
              CreateFileW(ImagePathName->Buffer, ...)  ->  Proc_StoreImagePath()  ->  SbieDll_GetHandlePath()
                                                                                      ^ object manager
                                                                                        => ON-DISK SPELLING
        - passes that string as lpApplicationName  (proc.c)
        - passes lpCommandLine through unchanged
                        |
                        v
      Child process initialisation:  Ldr_FixImagePath()          <- defect site
        TruePathForBoxedPath = File_GetTruePathForBoxedPath(FullName->Buffer, TRUE)
            strips the redirect prefix, copies the remainder verbatim  => ON-DISK SPELLING
        Ldr_FixImagePath_3(TruePathForBoxedPath, ...)
            overwrites LDR.FullDllName / LDR.BaseDllName
            overwrites RTL_USER_PROCESS_PARAMETERS.ImagePathName
                        |
                        v
      What the child observes:
        GetModuleFileNameW()  -> "...\XPlugin\Plugins\RadiumWMPF\WeChatAppEx.exe"   (on-disk spelling)
        GetCommandLineW()     -> "...\xplugin\plugins\RadiumWMPF\WeChatAppEx.exe"  (caller spelling)
                                  ^ same file, two strings, differing only in case
                        |
                        v
      WeChatAppEx (Chromium base/files/file_path.cc)
        FilePath::AppendRelativePath()
          - compares component by component, strictly, except the drive letter
          - "XPlugin" != "xplugin"  =>  returns false
          - the plugin root is never derived, the flue.dll path is invalid
                        |
                        v
      flue.dll load fails  ->  ExitProcess(7)
    

    The keyword here is that the path is not wrong — it is a second, equally valid spelling of the
    same path. The sandbox's redirect logic is correct; the failure comes from the application
    comparing two strings that Windows itself considers equal.


    3. Evidence

    3.1 Process level — it is an explicit exit, not a crash

    • Procmon: WeChatAppEx.exe starts and exits within a few hundred milliseconds, and there is no
      path event for flue.dll at all
      — not even a failed open.
      → The failure happens while building the path, before any file is touched. Rules out
      permissions, redirection and missing files.
    • WinDbg (bp kernel32!ExitProcess): breaks in ExitProcess with argument 7.
      → Not an access violation.

    3.2 Binary level — one single blocking branch (IDA)

    Address Content Note
    0x14007211E two branches (v40 / v42) converging on the same failure candidate
    0x72924 GetRelativePath call site, rax = 0 the blocking branch
    0xBBDF cmp r9w,[rcx+r8*2] — strict per-WCHAR compare comparison logic
    0xBC4B lea ebx,[r11+20h] — skip drive letter only the drive letter is exempt
    0x1A177F A->a lowercase map used by a different, lenient code path

    Dynamic confirmation: forcing rax = 1 at 0x72924 makes the process start normally. The return
    value is the only blocker, and it is decided purely by the string comparison.

    3.3 Source level — where the wrong spelling is written

    Location Role
    ldr_init.c:466 File_GetTruePathForBoxedPath(FullName->Buffer, TRUE)
    ldr_init.c:471 Ldr_FixImagePath_3(TruePathForBoxedPath, ...) — the overwrite
    ldr_init.c:610-612 writes ProcessParms->ImagePathName
    file.c File_GetTruePathForBoxedPath() → File_GetName() string-level prefix remapping; the remainder, including its case, is copied verbatim
    proc.c Proc_StoreImagePath() → SbieDll_GetHandlePath() derives the image path from a handle → on-disk spelling
    proc.c Proc_CreateProcessInternalW() lpApplicationName = TlsData->proc_image_path;

    3.4 Controlled experiments

    The image path is not influenced by how the caller spells it:

    • Running a probe with three different spellings of its own path inside the sandbox always
      reported the same on-disk spelling from GetModuleFileNameW().
    • Renaming the on-disk directory XPlugin\Plugins to lowercase changed the reported spelling to
      lowercase, and WeChat's notes started working.
    • After the fix, GetModuleFileNameW() returns the launch spelling and WeChat works normally.

    4. Why only some applications are affected

    Most programs take the directory from GetModuleFileName() and concatenate; they never compare, so
    they cannot notice. The affected pattern is:

    Pattern Behaviour Risk
    Chromium FilePath::AppendRelativePath() compares every component strictly except the drive letter high
    Deriving the install root from argv[0] and comparing with the API result treats argv[0] as authoritative high
    Module path used in a hash key different case → cache miss medium
    Pure concatenation the file system resolves it none

    This is therefore not a WeChat bug. It is a general compatibility issue that WeChat 4.2 happens to
    expose most visibly.


    5. Fix

    5.1 Approach

    Read argv[0] from RTL_USER_PROCESS_PARAMETERS.CommandLine. If it is the same file as
    TruePathForBoxedPath — that is, _wcsicmp() == 0 — use its spelling to overwrite the module
    path. In every other case keep the current behaviour.

    No struct change, no change to proc.c, no driver rebuild.

    5.2 At the overwrite site

            if (TruePathForBoxedPath) {
    
                WCHAR *LaunchPath;
    
                //
                // TruePathForBoxedPath is the user visible path derived from the
                // redirected image location.  It carries the spelling that the
                // file system reports, which may differ in letter case from the
                // spelling used on the command line.
                //
                // Applications doing a case sensitive comparison of
                // GetModuleFileName() against argv[0] then conclude that a file
                // is missing.  Chromium FilePath::AppendRelativePath()
                // (base/files/file_path.cc) is such a case: it compares every
                // component strictly except the drive letter.
                //
                // Windows paths are case insensitive, so when argv[0] denotes the
                // very same file, prefer its spelling to keep the module path
                // consistent with what the caller passed in.
                //
    
                LaunchPath = Ldr_GetLaunchImagePath();
    
                if (LaunchPath &&
                        _wcsicmp(LaunchPath, TruePathForBoxedPath) == 0) {
    
                    Ldr_FixImagePath_3(LaunchPath, FullName, BaseName);
    
                } else {
    
                    Ldr_FixImagePath_3(TruePathForBoxedPath, FullName, BaseName);
                }
    
                if (LaunchPath)
                    Dll_Free(LaunchPath);
    
                Dll_Free(TruePathForBoxedPath);
    
                Ldr_BoxedImage = TRUE;
    
            } else if (KernelPath &&
                            _wcsicmp(KernelPath, FullName->Buffer) != 0) {

    5.3 The helper

    //---------------------------------------------------------------------------
    // Ldr_GetLaunchImagePath
    //---------------------------------------------------------------------------
    
    
    //
    // Returns argv[0] of the current process as recorded in the command line,
    // with surrounding quotes removed, or NULL when it cannot be used.
    // Only absolute paths with a drive letter are returned, everything else is
    // ignored so that the caller can fall back to its default behaviour.
    // The caller must release the result with Dll_Free().
    //
    
    _FX WCHAR *Ldr_GetLaunchImagePath(void)
    {
        RTL_USER_PROCESS_PARAMETERS *ProcessParms =
                                        Proc_GetRtlUserProcessParameters();
        const WCHAR *CmdLine;
        const WCHAR *Start;
        const WCHAR *End;
        WCHAR *Result;
        ULONG Len;
    
        if (! ProcessParms)
            return NULL;
    
        CmdLine = ProcessParms->CommandLine.Buffer;
        if (! CmdLine)
            return NULL;
    
        //
        // skip leading white space, then take either everything up to the
        // closing quote, or everything up to the first white space
        //
    
        Start = CmdLine;
        while (*Start == L' ' || *Start == L'\t')
            ++Start;
    
        if (*Start == L'"') {
    
            ++Start;
            End = Start;
            while (*End && *End != L'"')
                ++End;
    
        } else {
    
            End = Start;
            while (*End && *End != L' ' && *End != L'\t')
                ++End;
        }
    
        Len = (ULONG)(End - Start);
        if (Len < 3)
            return NULL;
    
        //
        // only drive absolute paths are useful for the comparison in the caller
        //
    
        if (Start[1] != L':' || (Start[2] != L'\\' && Start[2] != L'/'))
            return NULL;
    
        Result = (WCHAR *)Dll_AllocTemp((Len + 1) * sizeof(WCHAR));
        if (! Result)
            return NULL;
    
        wmemcpy(Result, Start, Len);
        Result[Len] = L'\0';
    
        return Result;
    }

    plus the forward declaration next to the other Ldr_* prototypes.

    5.4 Why this is safe

    • The substitution only happens when _wcsicmp(argv[0], TruePathForBoxedPath) == 0. The character
      sequence cannot change, so no path redirection and no access-control change is possible.
    • Everything else falls back to the existing behaviour: relative paths, bare file names, 8.3 short
      names, symbolic links, forward slashes, and forced processes where the kernel path differs.
    • Dll_AllocTemp / Dll_Free is the pairing already used in this translation unit
      (Ldr_LoadAndFix_IsClosedFilePath).
    • Proc_GetRtlUserProcessParameters() is already used by Ldr_FixImagePath_3() and
      Ldr_FixImagePath_DllPath().
    • Cost: one string scan and one temporary allocation, once per process, during initialisation.
    • Only the main image is touched. Ldr_FixImagePath_DllPath() is untouched.
    • Downstream consumers are unaffected: Ldr_ImageTruePath follows the new value,
      file.c compares it with _wcsicmp, SbieDll_MatchPath() is case-insensitive, and the
      NtQueryAttributesFile probe in dllmain.c uses OBJ_CASE_INSENSITIVE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions