2010-04-07 91 views
0

正在調用一個C++ dll,並試圖訪問它的函數。 下面是從DLL輸出的DUMPBIN /出口:奇怪的dumpbin導出表

Dump of file C:\C#Processes\SummarizerApp\SummarizerApp\lib\summarizer37.dll 
File Type: DLL 
Section contains the following exports for summarizer37.dll 

00000000 characteristics 
458962FF time date stamp Wed Dec 20 11:21:19 2006 
    0.00 version 
     1 ordinal base 
     4 number of functions 
     4 number of names 

ordinal hint RVA  name 

     1 0 00002960 [email protected]@@[email protected]@@Z 
     2 1 00016240 [email protected]@@[email protected]@@Z 
     3 2 000105E0 [email protected]@@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected] 
     4 3 0001BC40 [email protected]@@[email protected]@[email protected] 

Summary 

    4000 .data 
    B000 .rdata 
    4000 .reloc 
    2E000 .text 

採取注序#3。它包括幾個方法我需要調用,具體是:
make_summarization
summarization_input_options
summarization_sentence_output
summarization_phrase_output

這樣做的dll的JNI包裝和知道,上面的功能(這是所有類contructors)可供選擇來自JNI使用的「extern C」,以unmangled形式。 我可以使用dllimport的調用約定屬性對它們進行未修飾嗎?

在C++世界中,當多個函數在同一個序號下導出時,這意味着什麼?訪問它們的方法是什麼? 謝謝, 吉姆

回答

1

DllImport屬性的EntryPoint字段可用於import functions by ordinal(具有#前綴序)。
它也可以用於import functions by their mangled name
如果你真的擁有C++庫公開的所有功能的純「extern C」包裝器,那麼這很容易。
如果您不這樣做,您可以構建C++/CLI包裝程序以在託管和非託管之間建立橋樑。

vc\bin文件夾undname.exe可用於解碼編譯的C++名稱:

class inxight::summarization_interface * __cdecl inxight::make_summarization(
    class inxight::summarizer_interface &, 
    class inxight::byte_stream_interface &, 
    class inxight::summarization_input_options const &, 
    class inxight::summarization_sentence_output const &, 
    class inxight::summarization_phrase_output const &, 
    char const *, unsigned int , char const *) 
+0

OK,我看到,在序號3全亂了是最後一個功能我呼籲這個功能,並且我的想法是其他函數是參數,它們都是類對象。我可以構造(並已這樣做)的第一個參數,因爲它的構造函數被導出爲序數4(使用序數或錯位的名稱可以正常工作)。我如何得到其他構造函數?他們在C中可用。我卡住了嗎? JNI如何使它們可見?它是如何加載的DLL? – 2010-04-07 14:42:02

+0

@Jim:可能最簡單的方法是創建一個C++/CLI庫來包裝本地功能。這是 - 有點 - 類似於你必須用JNI做的事情(因爲你可以在本地(非託管)代碼中工作,並向託管世界展示對象/函數。) – 2010-04-07 14:50:28

+0

任何有關如何完成的好的參考? – 2010-04-07 14:55:24