logo
down
shadow

Receiving message in C# from Firefox Extension through Native Messaging


Receiving message in C# from Firefox Extension through Native Messaging

By : Rob Duncan
Date : November 20 2020, 01:01 AM
I wish this helpful for you I have found the solution of my above questions. Below is my code for main.js file.
code :
var {Cu} = require("chrome");
var {ctypes} = Cu.import("resource://gre/modules/ctypes.jsm", null);

var self = require("sdk/self");
var tabs = require("sdk/tabs");

tabs.on('activate', callNative);

function callNative(tab)
{ 

    var ff;
    try {

    ff = ctypes.open("filename.dll");


    var nativeCaller = ff.declare("OpenStandardStreamIn", // function name
                            ctypes.default_abi, // call ABI
                            ctypes.int32_t,         // return type
                            ctypes.char.ptr,   // argument type
                            ctypes.char.ptr);   // argument type


    var ret = nativeCaller(tab.title, tab.url);
    ff.close();
    } catch (e) {

    }


}
#include <stdio.h>
#include <stdlib.h>

extern "C"
{
    _declspec(dllexport) int OpenStandardStreamIn(char *title, char *url)
    {
        FILE *fp;

        fp = fopen("dumfilename.txt", "a");

        fprintf(fp, "%s\n", title);
        fprintf(fp, "%s\n", url);

        fclose(fp);
    return 0;
    }
}


Share : facebook icon twitter icon
Chrome extension native messaging got error:"Specified native messaging host not found."

Chrome extension native messaging got error:"Specified native messaging host not found."


By : Erik Hulmák
Date : March 29 2020, 07:55 AM
around this issue The registry key should be HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\NativeMessagingHosts\com.my_company.my_application, and it's (Default) value should be D:\testC\debug\manifest.json.
From your description it seems that you are instead adding a string value with name com.my_company.my_application under the key HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\NativeMessagingHosts
Chrome Native Messaging -- Why am I receiving a "Specified native messaging host not found" error?

Chrome Native Messaging -- Why am I receiving a "Specified native messaging host not found" error?


By : golfer007
Date : March 29 2020, 07:55 AM
This might help you For Google Chrome, the system-wide directory for the manifest file is:
code :
~/Library/Application Support/Google/Chrome/NativeMessagingHosts/
~/Library/Application Support/Chromium/NativeMessagingHosts/
How to message child process in Firefox add-on like Chrome native messaging

How to message child process in Firefox add-on like Chrome native messaging


By : kabran
Date : March 29 2020, 07:55 AM
hop of those help? The problem here, is that Firefox is trying to read stdout as UTF-8 stream by default. Since UTF-8 doesn't use the full first byte, you get corrupted characters for example for 255. The solution is to tell Firefox to read in binary encoding, which means you'll have to manually parse the actual message content later on.
code :
var childProcess = spawn("mybin", [ '-a' ], { encoding: null });
var decoder = new TextDecoder("utf-8");
var readIncoming = (data) => {
    // read the first four bytes, which indicate the size of the following message
    var size = (new Uint32Array(data.subarray(0, 4).buffer))[0];
    //TODO: handle size > data.byteLength - 4
    // read the message
    var message = decoder.decode(data.subarray(4, size));
    //TODO: do stuff with message
    // Read the next message if there are more bytes.
    if(data.byteLength > 4 + size)
        readIncoming(data.subarray(4 + size));
};
childProcess.stdout.on('data', (data) => {
    // convert the data string to a byte array
    // The bytes got converted by char code, see https://dxr.mozilla.org/mozilla-central/source/addon-sdk/source/lib/sdk/system/child_process/subprocess.js#357
    var bytes = Uint8Array.from(data, (c) => c.charCodeAt(0));
    readIncoming(bytes);
});
Firefox Native Messaging runtime.LastError not giving any errors in case of no Native application installed on Connectna

Firefox Native Messaging runtime.LastError not giving any errors in case of no Native application installed on Connectna


By : Raybomber
Date : March 29 2020, 07:55 AM
hope this fix your issue Issue here was that port.error was not giving any error response in Firefox versions less than 52 , Due to which I was facing problem in identifying whether native app is installed or not.
After discussion on Mozilla Community (https://discourse.mozilla-community.org/t/firefox-native-messaging-runtime-lasterror-not-giving-any-errors-in-case-of-no-native-application-installed-on-connectnative/12880/4) , we found that it is actually missed and a bug is already reported : https://bugzilla.mozilla.org/show_bug.cgi?id=12994116 which will be resolved in Firefox 52.
Native-Messaging firefox extension example "ping_pong" not working because of TypeError

Native-Messaging firefox extension example "ping_pong" not working because of TypeError


By : user2800982
Date : March 29 2020, 07:55 AM
it should still fix some issue I'm trying to use native-messaging in a firefox extension. I tried to build the example from this https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_messaging , Using Python 2 it works fine for me (on Linux).
code :
#!/usr/bin/python2 -u
path\to\python2
#!/usr/bin/python -u

# Note that running python with the `-u` flag is required on Windows,
# in order to ensure that stdin and stdout are opened in binary, rather
# than text, mode.

import json
import sys
import struct


# Read a message from stdin and decode it.
def get_message():

    # use buffer to get bytes
    raw_length = sys.stdin.buffer.read(4)


    #raise ValueError(raw_length)

    if not raw_length:
        sys.exit(0)
    message_length = struct.unpack('=I', raw_length)[0]
    message = sys.stdin.buffer.read(message_length).decode("utf-8")
    return json.loads(message)


# Encode a message for transmission, given its content.
def encode_message(message_content):
    encoded_content = json.dumps(message_content).encode("utf-8")
    encoded_length = struct.pack('=I', len(encoded_content))
    return {'length': encoded_length, 'content': struct.pack(str(len(encoded_content))+"s",encoded_content)}


# Send an encoded message to stdout.
def send_message(encoded_message):
    #raise ValueError(encoded_message)
    sys.stdout.buffer.write(encoded_message['length'])
    sys.stdout.buffer.write(encoded_message['content'])
    sys.stdout.buffer.flush()


while True:
    message = get_message()
    if message == "ping":
        send_message(encode_message("pong"))
Related Posts Related Posts :
  • What could be causing my WhatsApp Stickers Pack not to work?
  • How Can I Reorder/Sort The Collections List in Directus?
  • Is this language generic/mighty enough to be used for a generic game AI?
  • graphite, use regular expressions to select the target, or an alternative
  • subtract functions with type real in ml
  • how to filter '(' in navision 2013
  • sending sms from a mobile browser
  • NuGet behind firewall
  • Gstreamer hangs while generating timelapse from JPEGs on Raspberry pi
  • How to retrieve total view count of large number of pages combined from the GA API
  • Websites rich with exercices or explanation for SML?
  • Is there a TempData equivalent in ServiceStack?
  • scipy-0.12.0 failing to install on mountain lion using python setup.py install
  • Looking for simplest option to render Razor cshtml pages in a console application without any web server
  • Evaluating variables at a specific time in Modelica
  • When I run the Application, only "web" engine is running in GlassFish. "webservices" is not started
  • How To Set MIME Type Of Google Drive File
  • Remove Missing Values in Weka
  • Reloading a UICollectionView using reloadData method returns immediately before reloading data
  • carrot2 - can I cluster documents from a folder?
  • StreamSocket has no Close Implementation in C#
  • Rails, Foundation 4, Respond.js not working properly in IE8
  • How can i create imagesurface from cairo xlib's Graphics Context using cairo and x11 Api's?
  • CKEditor "overflow: scroll" on parent causes toolbar to freeze at initial position
  • Differences between components and controls in ENYO
  • Photoshop making isometric?
  • Does Intel IPP 8.0 support in-place operations?
  • What is Object dictionary in CANOpen?
  • Example of orbBasic Indexed User Variables
  • convert to ABSOLUTE in logback
  • How to conditionally download file using p:fileDownload
  • Error on pod install
  • Set HTTP GET Parameters in Finagle
  • different attack that uses sql injection
  • How can I change my xampp username not as 'root'
  • AMQP Content header payload structure
  • Apache POI formula evaluation not working for Excel IF
  • How can I trace RESTEasy's dispatch?
  • Map Freezes on iOS 7 with Google Maps SDK 1.4
  • Comparing lists, is the subset list within the first list
  • Non-ascii character highlight in Sublime Text 2
  • Installing Magit in Aquamacs
  • Receiving error - System.Net.Mail.SmtpException: 4.3.2 try again later
  • Coreaudio render callback in monotouch
  • The command 'yarn --v' also initiates 'yarn install' and installs packages automatically. Why is this happening?
  • save multiple matches in a list (grep or awk)
  • Can a number register be used in a groff request?
  • Mapping FAQ with RASA for large dataset (2000+)
  • Fragment not receiving LiveData updates after remove + add
  • FitText.js makes text bigger rather than smaller
  • ARM - Implementing stack with load/store multiple register values
  • How to check if a ChromeCast Session is already in progress
  • ngForm inside a Carousel Slide in UI Bootstrap not working
  • Clearing attributes in Tritium
  • "vagrant up" failing: Vagrant VM failed to remain in the running state
  • ftsearch returning empty docs
  • What are the advantages of setting "hive.exec.parallel" to false in Hive ?
  • Creating a root certificate in FiddlerCore
  • How to access app.config in a blueprint?
  • DB2 RECORDSET table name converted to uppercase
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org