【发布时间】:2014-03-19 21:48:54
【问题描述】:
我实际上使用的是非托管 C++ DLL,我无法访问 .h、.cpp 或 .lib,而只能访问 .DLL。
使用PE Explorer 并找到我想使用的功能后,我得到了:
@Tdtm_Dossier@Logon$qv; Index 1310; Unmangled Borland C++ Function: qualified function Tdtm_Dossier::Logon()
这是我使用dumpbin 得到的结果:
1310 11F9 00105234 @Tdtm_Dossier@Logon$qv
这是一个例外:
Unhandled Exception at 0x034B258C (modDll.dll) in functionsCpp.exe : 0xC0000005 :
Access violation writting to 0x000000AC.
我用来调用和使用这个函数的代码如下:
#include <stdio.h>
#include <Windows.h>
#include <iostream>
typedef int (*Logon)();
int main()
{
HMODULE modDll;
int resultLogon;
modDll= LoadLibrary("C:\\dll\\modDll.dll");
Logon logon;
logon = (Logon)GetProcAddress(modDll,"@Tdtm_Dossier@Logon$qv");
if(logon)
{
resultLogon = logon(); //<-- This is where I get the exception
printf("Function has been loaded\n");
}
else
// TODO: Error message
FreeLibrary(modDll);
}
由于 DLL 文档没有给我任何关于如何使用该函数的有趣信息,我不能指望它。
DLL 已正确加载,GetProcAddress 确实返回了一些内容。我猜(但我不确定)它与我的typedef 有关,但我无法弄清楚这个函数的返回类型可能是什么。
【问题讨论】:
-
@cup 是的,我已经检查过了,
GetProcAddress也是。它们都不是NULL。 -
尝试使用depends找出签名是什么。
-
你确定函数签名吗?它真的返回
int并且不带任何参数吗?