Why loading an extension needs the DevTools pipe
Perch drives its own Chrome over the DevTools protocol, through a pipe rather than a port, and on Windows that takes a hand-built process launch.
A pipe rather than a port
--remote-debugging-port opens a listener that any local process can drive, including anything else running as you. --remote-debugging-pipe doesn't, and on top of that it's the only transport that accepts Extensions.loadUnpacked.
The Windows problem
On POSIX the pipe is just file descriptors 3 and 4, but Windows has no descriptor inheritance, and instead the C runtime rebuilds its table from an undocumented blob in STARTUPINFO.lpReserved2. That means .NET's Process.Start can't do it, so Perch calls CreateProcess through P/Invoke with that blob built by hand.
It's the same technique Node uses for extra stdio, which is how Puppeteer drives Chrome over a pipe on Windows. Since it was the riskiest part of the port, it was built and proven first.
An afternoon on one GUID
CreateForWindow wants the WinRT interface IID rather than the projected class GUID, and the wrong one returns E_NOINTERFACE, which C# surfaces as an InvalidCastException with nothing pointing at the cause.
This is a shorter version of a post on the Pioneering blog, so if you want the full story, read the original on pioneering.app.
Next postWhat Chrome will and won't let an app hide
