2014-11-20 7 views
1

편집 :js-ctypes에서 dll 사용하기 mozilla add-on sdk - 프로그램의 STDOUT을 보시겠습니까? 나는 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")을하고있는 경우? 내 브라우저 콘솔이나 dos 콘솔에 기록되지 않는 것 같습니다. "cfx ​​run"을 실행하고 있습니다.

+1

이 주제에 대한 좋은 주제 : https://ask.mozilla.org/question/1086/x11-getting-output-of-nsiprocess/?answer=1116#post-id-1116 – Noitidart

+0

Hrmm. 공유 라이브러리에서 메소드를 실행하는 것과는 대조적으로, 추가 기능에서 쉘 명령을 실행하는 것에 대해 이야기하는 것 같습니다 - 아니면 제가 잘못 생각합니까? – Derek

+0

당신 말이 맞아요. DLL의 출력을 얻으려면 쉘을 사용하여 실행 한 다음 쉘의 출력을 얻어야합니다. subprocess.jsm을 확인하십시오. – Noitidart

답변

0

터미널 창에서 Firefox를 시작하면 으로 출력되어야합니다.

+0

수 있습니다. 자바 스크립트 console.log()와 같은 터미널 창에서 결과를 볼 수 있지만 C 프로그램의 출력이 보이지 않는 것 같습니다. – Derek

+0

@Derek firefox를 시작해야한다고 생각합니다. -console 명령 행 옵션은 여기를 참조하십시오. : http://stackoverflow.com/a/10793558/1828637 (나는 이것이 창만이라고 생각한다) – Noitidart

+2

흥미롭게도 - 내가 https://github.com/matthewkastor/Redirector/archive/master.zip을 사용하고 firefox를 사용하여 콘솔 출력을 얻을 수 있습니다. 나는'cfx'가 파이어 폭스에'-console'을 넘기는 데 사용할 수있는'--binary-args' 옵션을 가지고 있다는 것을 발견했습니다. 이렇게하면 터미널에 파이어 폭스가 생기지 만 출력이 나오지 않습니다. 그러나 빈 터미널 (파이어 폭스를 차단 함)을 닫으면 출력이 원래 터미널에서'cfx run'으로 표시됩니다. – Derek