【发布时间】: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控制台。
【问题讨论】:
-
嗯。这似乎是在谈论从插件运行 shell 命令,而不是在共享库中运行方法 - 还是我弄错了?
-
你是对的。要获取 dll 的输出,您必须使用 shell 运行它,然后获取 shell 的输出。查看 subprocess.jsm。
-
您可能会发现这很有用:mar10.noblogs.org/post/2014/10/02/…
标签: javascript dll firefox-addon firefox-addon-sdk jsctypes