【问题标题】:Using dll in js-ctypes mozilla add-on sdk - view program's STDOUT?在 js-ctypes mozilla add-on sdk 中使用 dll - 查看程序的 STDOUT?
【发布时间】:2014-11-20 22:18:18
【问题描述】:

已编辑,因为我的 DLL 构建错误:

我已经构建了一个 DLL,如果我对 DLL 执行 dumpbin /exports 命令,我会看到以下内容:

Dump of file stun_driver.dll

File Type: DLL

  Section contains the following exports for stun_driver.dll

00000000 characteristics
546E6C63 time date stamp Thu Nov 20 17:34:11 2014
    0.00 version
       1 ordinal base
       4 number of functions
       4 number of names

ordinal hint RVA      name

      1    0 00001005 OPENSSL_Applink = @ILT+0(_OPENSSL_Applink)
      2    1 00001320 launch_stun = @ILT+795(_launch_stun)
      3    2 000011D6 stop_stun = @ILT+465(_stop_stun)
      4    3 00001078 test_print = @ILT+115(_test_print)

  Summary

   1A000 .data
    2000 .idata
   46000 .rdata
    F000 .reloc
  135000 .text

我执行“test_print”函数的代码如下:

/* import js-ctypes */
 Cu.import("resource://gre/modules/ctypes.jsm")
 var stun_driver = ctypes.open("C:\\stun_driver.dll");

const test_print = stun_driver.declare("test_print", ctypes.default_abi, ctypes.int32_t);
.
.
.//in a button
test_print();

所以我的问题是,如果我的test_print() 正在执行printf("Hello World"),那么该文本会去哪里?它似乎没有被记录到我的浏览器控制台,或者我正在运行“cfx run”的dos控制台。

【问题讨论】:

标签: javascript dll firefox-addon firefox-addon-sdk jsctypes


【解决方案1】:

如果您从终端窗口启动 Firefox,您应该在那里看到输出。

【讨论】:

  • 我可以从 javascript console.log() 之类的终端窗口中看到输出,但我似乎没有看到我的 C 程序的任何输出
  • @Derek 我认为您必须使用 -console 命令行选项启动 Firefox,请参见此处:stackoverflow.com/a/10793558/1828637(我认为这仅适用于 Windows)
  • 有趣的是——如果我使用github.com/matthewkastor/Redirector/archive/master.zip 并使用它启动firefox,我可以获得控制台输出。我刚刚发现 cfx 有一个选项 --binary-args 可以用来将 -console 传递给 firefox。这使得终端提出了 Firefox,但没有输出。但是,如果我关闭那个空白终端(它会关闭 firefox),我会看到输出显示在原始终端中,其中包含我的 cfx run
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-31
  • 1970-01-01
  • 2013-10-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多