SbieShell: The Shell Inside the Sandbox

SbieShell is a third-generation fork of ReactOS Explorer, rebuilt to give Sandboxie's isolated desktops a taskbar, a Start menu, and a working file browser.

7 min read • View on GitHub • More from sandboxie-plus

A wide editorial illustration of a Windows-style desktop. In the center sits a transparent glass cube, a literal sandbox, containing a miniature but fully-formed desktop with its own taskbar, Start button, window frames, and tiny icons. The host desktop around the cube has its own taskbar and window frames at normal scale. The image explains the core idea of SbieShell: a complete shell running nested inside another, isolated from the host.
SbieShell runs a complete desktop environment inside Sandboxie's isolated desktops, a shell within a shell.
Key Takeaways

The Window That Calls Itself CabinetWClass

In explorer.h, a single line defines the class name for the shell's frame windows. It is not SbieShell's own name. It is Explorer's.

#define CLASSNAME_FRAME  TEXT("CabinetWClass")   // same class name for frame window as in MS Explorer

That is not a bug or a leftover. The comment says so. CabinetWClass is the class name Explorer uses for its folder windows. Third-party software that enumerates windows looking for it will find SbieShell's windows instead. The shell earns the right to coexist with the rest of Windows by answering to Windows' name.

The deception goes further than a string. ExplorerCmd parses the command grammar that Explorer's shortcuts and Open verbs use.

/e,/root,c:\
::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::{21EC2020-3AEA-1069-A2DD-08002B30309D}

The /e and /root switches, the CLSID paths that name shell folders like Control Panel. A shortcut written years ago still lands in the right place, because SbieShell speaks the same language. Compatibility here is not a feature bolted on. It is the shell's survival strategy: be indistinguishable.

Why Sandboxie Needs Its Own Shell

Sandboxie runs programs in isolated environments. Isolation changes where files and registry keys live, but it does not change what a program expects to see when it asks for a desktop. A program that wants a taskbar wants a taskbar.

The obvious answer, run the host's explorer.exe inside the sandbox, is the wrong one. Explorer is a large, stateful process with hooks and shell extensions that assume it owns the machine. Running a second copy inside a sandbox invites conflicts. So each isolated desktop gets its own shell, a smaller one built to live there.

The part that makes this more than a convenience is in globals.h. The Desktop struct already models a desktop as a thing with its own windows.

struct Desktop {
    set<HWND> _windows;
    WindowHandle _hwndForeground;
    list<MinimizeStruct> _minimized;
    void ToggleMinimize();
};

A window set, a foreground window, a minimized list. Explorer proper has exactly one desktop. This structure assumes there could be more, and tracks the state each one would need. That assumption is the seam Sandboxie needed, and it was sitting in the code years before Sandboxie asked for it.

A close-up editorial illustration of a workbench seen from the side. Three seashells are lined up left to right, each carved with increasingly detailed Windows desktop features. The leftmost is plain and rough, the middle has a taskbar and Start button carved into its surface, and the rightmost has a complete miniature desktop etched into it with tiny window frames, icons, and a taskbar. A chisel lies between the middle and right shells with wood shavings scattered around. The image turns the fork chain from ReactOS Explorer to WinXShell to SbieShell into a single physical object.
Three generations of shell, carved from the same material: ROS Explorer, then WinXShell, then SbieShell.

Three Generations of Shell

SbieShell did not start as SbieShell. The README is plain about the lineage.

A shell program (desktop, startmenu, taskbar, notifyarea, etc) for the isolated sandboxie desktops. It is based on the ROS Explorer.

SbieShell project README, Project description · sandboxie-plus/SbieShell

WinXShell itself descends from ROS Explorer, Martin Fuchs's LGPL shell written for ReactOS between 2003 and 2006. That makes SbieShell a third-generation fork: a shell built for ReactOS, adapted for Windows PE, adapted again for Sandboxie's isolated desktops.

The code still carries evidence of its travels. Guards like #ifndef __WINE__ keep it compiling on Wine, and a ROSSHELL macro marks the ReactOS code paths. A shell written for one operating system now runs on three, because the code was written to be portable before anyone knew it would need to be.

One Icon, Three Ways to Find It

The most interesting engineering in the repo is also the least visible. A shell repaints constantly: every folder view, every taskbar button, every tray icon. If each repaint re-extracted an icon from disk, the desktop would stutter. So the icon cache in globals.h is built to answer the same question three different ways.

An icon can be requested by file path, by a resource index inside an EXE or DLL, or by a shell namespace item (a PIDL). Rather than force callers to normalize their request, IconCache keeps three separate maps.

typedef map<CacheKey, ICON_ID>    PathCacheMap;   // (path, flags)
typedef map<IdxCacheKey, ICON_ID> IdxCacheMap;    // (path, (index, flags))
typedef map<PidlCacheKey, ICON_ID> PidlCacheMap;  // (ShellPath, flags)

Three drawers, one output. Every request resolves to a single ICON_ID, and the Icon struct behind it carries one of four types. IT_STATIC is a shared icon. IT_CACHED is owned by the cache. IT_DYNAMIC is an HICON the shell owns and must destroy. IT_SYSCACHE is an index into the system image list. Accessors enforce the distinction: get_hicon() returns 0 for IT_SYSCACHE, and get_sysiml_idx() returns -1 for everything else.

The _LAZY_ICONEXTRACT flag pushes extraction to paint time, so the cache only pays for icons it actually shows. Ownership is hand-rolled, and destroy() must be called manually for IT_DYNAMIC. That is the classic leak-or-double-free surface of Win32 C++, and the code lives with it in exchange for speed.

The icon cache answers one question three ways. Path, path plus index, and PIDL all resolve through a single ICON_ID.

How SbieShell Compares

SbieShell is easy to misplace in a lineup of Start menu replacements. It is not one. The table below puts it next to the shells it resembles and the shells it descends from.

SbieShellWindows ExplorerWinXShellReactOS ExplorerOpen-ShellCairo Desktop
PurposeShell for Sandboxie isolated desktopsDefault Windows shellExplorer replacement for Windows and PEExplorer replacement for ReactOSStart menu and shell customizationDesktop shell replacement
Target environmentSandboxie isolated desktopsHost WindowsWinPE and custom Windows imagesReactOSWindows hostWindows host
LineageROS Explorer to WinXShellMicrosoftROS ExplorerIndependentIndependentIndependent
LicenseLGPL-2.1ProprietaryUpstream variesGPL and LGPLGPLGPL
Runs inside a sandboxYes, by designNoNot its purposeNoNoNo

The row that matters is the last one. None of the others are built to run inside a sandbox. That single constraint explains the impersonation, the per-desktop model, and the icon cache. SbieShell is not trying to replace Explorer everywhere. It is trying to be Explorer in a place Explorer cannot go.