Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome Plugin: Accessing named pipes on Windows

I need to write a plugin for Chrome which, if running on Windows and the browser's URL matches something specific, can open a named pipe to a certain process running on the OS.

What's the best choice of plugin for Chrome? Should I go with a Native Client or can I use something less intrusive (although I realize named pipes by definition are quite intrusive)?

like image 645
dreijer Avatar asked Feb 27 '12 23:02

dreijer


People also ask

Where are Chrome plugins located?

Google Chrome To view the plug-ins installed in Chrome, type chrome://plugins into Chrome's address bar and press Enter. This page shows all the installed browser plug-ins enabled in Google Chrome. To disable a plug-in, click the Disable link under it.

What is a named pipe in Windows?

A named pipe is a named, one-way or duplex pipe for communication between the pipe server and one or more pipe clients. All instances of a named pipe share the same pipe name, but each instance has its own buffers and handles, and provides a separate conduit for client/server communication.

How do you make a named pipe in Windows?

To create an instance of a named pipe by using CreateNamedPipe, the user must have FILE_CREATE_PIPE_INSTANCE access to the named pipe object. If a new named pipe is being created, the access control list (ACL) from the security attributes parameter defines the discretionary access control for the named pipe.


2 Answers

Native Client is indeed sandboxed, as indicated by the comments, and NPAPI is retired.

Two current solutions for contacting a running native app are those:

  1. Use HTTP, optionally with WebSockets, with the native application (or a proxy application that will talk to a third-party app using any native method, including pipes) acting as a server on localhost and the extension trying to connect to a known port. GhostText is an example of this architecture.

  2. Use Native Messaging. It's important to understand limitations of this approach:

    • It acts as a pipe to an external process, but must follow the Native Messaging (JSON-based) protocol.
    • It cannot attach to a currently running process (or pipe): Chrome can only start a new instance of the Native Host, and contact cannot be initiated from outside.

    So with those limitations in mind, your Native Host would be a proxy that will, itself, attach to the named pipe in question and relay the data, translating it to/from the Native Messaging protocol.

like image 107
Xan Avatar answered Sep 27 '22 16:09

Xan


You know, strangely enough I just noticed you can view named pipes via:

file://./pipe/

I discovered this when I was reading the Wikipedia article about them, copied it, and then later thought I copied a URL and accidentally pasted that into chrome instead.

You can't even access that from explorer or the file system.

like image 20
Brent Rittenhouse Avatar answered Sep 27 '22 17:09

Brent Rittenhouse