Receive Messages from Chrome Extension in a C++ programe

628 views
Skip to first unread message

Vikas Pushkar

unread,
Jul 4, 2016, 11:39:32 AM7/4/16
to Chromium-Extensions-Announce
I have a Chrome extension which starts a C++ exe through NativeHostMEssaging( through the json file which points to this C++ exe). this exe tries to read the messages send from extension. first it reads 4 bytes and which depicts the length, then it reads the number of byte equal to length. The very fisrt thing that this C++ exe does is to wait for a message from extension. but this C++ exe never receives anything from extension and keeps on waiting ( nothing is there on the STDIN(0). Is this a security issue or i am doing some minor mistake? or the read/write sequence is wrong.

Vikas Pushkar

unread,
Jul 5, 2016, 1:06:36 AM7/5/16
to Chromium-Extensions-Announce
Is this a real difficult Question ??

Antony Sargent

unread,
Jul 6, 2016, 4:08:17 PM7/6/16
to Vikas Pushkar, Chromium-Extensions-Announce
It's hard to know what's going wrong without seeing the source of your native messaging host. I'd suggest starting with something very simple, like having your native messaging host just take the bytes it reads from stdin and write them out to a log file; then have your extension use chrome.runtime.sendNativeMessage to send a simple message, and check the log file to see that the host received it. 

--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/30efd09a-a559-4735-9073-b395f88bb10d%40chromium.org.

Vikas Pushkar

unread,
Jul 6, 2016, 10:38:12 PM7/6/16
to Chromium-Extensions-Announce
Thanks for replying I have got it working, at least I received what was sent by extension, the problem was the studio mode it was text by default when I changed it to binary, I started receiving msgs. There is one issue still the when I try to apply strcmp or stroke like function to it , it does not go through. Let's say extension sends "hello" n in native code I do strcmp(rcv,"hello") it returns non zero value. Any suggestion on these issue?

Antony Sargent

unread,
Jul 7, 2016, 1:23:34 PM7/7/16
to Vikas Pushkar, Chromium-Extensions-Announce
Sounds like your native code might not be interpreting the format properly; see

"The same format is used to send messages in both directions: each message is serialized using JSON, UTF-8 encoded and is preceded with 32-bit message length in native byte order."

and also 





On Wed, Jul 6, 2016 at 7:38 PM, Vikas Pushkar <vikasku...@gmail.com> wrote:
Thanks for replying I have got it working, at least I received what was sent by extension, the problem was the studio mode it was text by default when I changed it to binary, I started receiving msgs. There is one issue still the when I try to apply strcmp or stroke like function to it , it does not go through. Let's say extension sends "hello" n in native code I do strcmp(rcv,"hello") it returns non zero value. Any suggestion on these issue?
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.

Vikas Pushkar

unread,
Jul 7, 2016, 2:39:12 PM7/7/16
to Antony Sargent, Chromium-Extensions-Announce

Got it working, thanks

Reply all
Reply to author
Forward
0 new messages