Repository navigation
Allow different host executable file extension, not only .exe #13
Copy link
Copy link
Open
Description
I'm developing small extension with NHM. I used .bat file for NHM entry point.
Here is log from NMD:
18:12:56:7651 - I am [z2dlp_host.proxy.bat.exe:16772], launched by [cmd:20152].
18:12:56:7661 - GetStartupInfo() says dwFlags=0x0, excludes STARTF_USESTDHANDLES; stdin=0xffffffffffffffff; stdout=0xffffffffffffffff; stderr=0xffffffffffffffff.
18:12:56:7671 - GetStdHandle() says stdin=(0x8, FileTypePipe); stdout=(0xc, FileTypePipe); stderr=(0x0, FileTypeUnknownHandleInvalid).
18:12:56:7671 - extension: chrome-extension://pedcomindcpbnadoenfgnjandcieiani/
18:12:56:7671 - parent-window: 001213bc
18:12:56:7671 - Listening for messages...
18:12:56:7981 - Checking for D:\Z-Data\git\qt-apps\yt-2dlp-ext\native_host\z2dlp_host.bat.exe...
18:12:56:7981 - Did not find any likely nativeHost for pedcomindcpbnadoenfgnjandcieiani. If you are using this tool as a mock,
the Injector tab allows sending messages to the browser.
18:12:56:7981 - GetStdHandle() says stdin=(0x8, FileTypePipe); stdout=(0xc, FileTypePipe); stderr=(0x0, FileTypeUnknownHandleInvalid).
18:12:56:8091 - {"action":"ping"}
18:13:06:2561 - Injecting message to extension '{"example_1": "to browser", "field_2": 2, "field_3":false}'
18:13:13:5834 - Got EOF while trying to read message size from (Extension); got only 0 bytes. Disconnecting.
Here is host manifest (proxied)
{
"name": "z2dlp_host",
"description": "z2dlp Native Messaging Host",
"path": "D:\\Z-Data\\git\\qt-apps\\yt-2dlp-ext\\native_host\\z2dlp_host.proxy.bat.exe",
"type": "stdio",
"allowed_origins": [
"chrome-extension://pedcomindcpbnadoenfgnjandcieiani/",
"chrome-extension://edcocgnlkdijkkiebalenphmfakmmoif/"
],
"allowed_extensions": ["z2dlp_ext@zuko.pro"]
}
The real path of NHM is D:\\Z-Data\\git\\qt-apps\\yt-2dlp-ext\\native_host\\z2dlp_host.bat
I also tried "path": "D:\\Z-Data\\git\\qt-apps\\yt-2dlp-ext\\native_host\\z2dlp_host.bat.proxy.exe",
but chrome give
[296:15180:0115/182248.856:WARNING:launch_context.cc(195)] Found manifest, but not the binary for native messaging host z2dlp_host. Host path specified in the manifest: D:\Z-Data\git\qt-apps\yt-2dlp-ext\native_host\z2dlp_host.bat.proxy.exe
[296:17800:0115/182248.856:INFO:CONSOLE(554)] "Native host test error: Error: Specified native messaging host not found.", source: chrome-extension://pedcomindcpbnadoenfgnjandcieiani/options/options.js (554)
Then i rename NMD to z2dlp_host.bat.proxy.exe, doing test again. We back to Did not find any likely nativeHost for situation
Metadata
Metadata
Assignees
Labels
No labels
Activity
ericlaw1979 commentedon Jan 15, 2025
Thanks for reporting!
Fascinating. I'm a bit shocked that ever works, and it will not work with this extension, which I wrote with the expectation that it be used with a
.exebacked native host. I'd love to see what your batch file looks like to understand how this scenario is implemented.There are definitely configurations where I wouldn't expect a batch file to work in the real-world (e.g. if the system has CMD disabled) even without the debugger.
tansautn commentedon Jan 16, 2025
Thank you, I just hope that more people can access this useful debugging tool.
For me, compiling the host into a .exe file isn't too difficult or time-consuming. However, using a .bat launcher is a much more time- and effort-saving approach for me. That's why I chose to use it.
And if I remember correctly, on MDN (Mozilla), their guide on NHM also uses a .bat file as the entry point.
Below is my .bat script. It's simply a Python launcher—nothing mysterious here.