Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/127.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从DLL获取函数PTR_C#_C++_Dll - Fatal编程技术网

C# 从DLL获取函数PTR

C# 从DLL获取函数PTR,c#,c++,dll,C#,C++,Dll,我试图在当前进程中插入一个dll,以查找不同函数的偏移量 我的dll中有一个简单的函数,如下所示: void testfunction() 我试图通过一个C#app获得函数ptr 函数ptr每次返回0,即使该函数存在于dll中。 任何帮助都将不胜感激。该函数在DLL的导出表中未命名为testfunction,它已被类型信息弄乱。所以GetProcAddress找不到它。(P/invokeDllImportAttribute尝试了一系列名称,这些名称可能会找到它……也可能找不到。但是GetPro

我试图在当前进程中插入一个dll,以查找不同函数的偏移量

我的dll中有一个简单的函数,如下所示:

void testfunction()
我试图通过一个C#app获得函数ptr

函数ptr每次返回0,即使该函数存在于dll中。
任何帮助都将不胜感激。

该函数在DLL的导出表中未命名为
testfunction
,它已被类型信息弄乱。所以
GetProcAddress
找不到它。(P/invoke
DllImportAttribute
尝试了一系列名称,这些名称可能会找到它……也可能找不到。但是
GetProcAddress
需要精确匹配。)

为了导出一个完全没有损坏的函数,您需要使用
extern“C”
减少对函数名的损坏,然后还需要使用模块定义文件进行链接。比如:

LIBRARY test
EXPORTS
testfunction

有关完整信息,请参见

您的意思是_udeclspec(dllexport)void testfunction()?好的,这确实导出了名称有误的函数。在DLL上使用
dumpbin/exports
查看实际名称。要控制导出的名称(防止损坏),您需要使用模块定义文件。注意,像这样的库在这方面会有很大帮助,它具有在尝试损坏的表单时获取地址的函数。
LIBRARY test
EXPORTS
testfunction