由于某些原因,我可以将我的.dll加载到我的应用程序中,但是当我调用resolve函数时,它一直说无法加载函数。
typedef void (*SetKey_func)(const char *, const char *, const char *, const char *);
Crypt::Crypt(QObject *parent) : QObject(parent)
{
}
Crypt::~Crypt()
{
}
void Crypt::LoadCrypt()
{
QString file = QCoreApplication::applicationDirPath() + "/RockBase.dll";
library.setFileName(file);
library.load();
if( !library.isLoaded() )
{
//file not loaded
return;
}
else
{
// file loaded
}
}
然后我的函数decsetkey只是在.dll
中设置了键void Crypt::DecSetKey()
{
quint8 decKey1[] = { 0x7D, 0x44, 0x01, 0x00, 0x83, 0xEC, 0x24, 0x83, 0x25, 0xB8, 0x8C, 0x4A, 0x0D, 0x56, 0x8B, 0x75 };
quint8 decKey2[] = { 0x1C, 0x8D, 0x1C, 0x57, 0x50, 0xCE, 0xE8, 0x6F, 0x85, 0xFE, 0xFF, 0x8B };
quint8 decKey3[] = { 0x76, 0x0C, 0x50, 0x45, 0x14, 0x83, 0x65, 0xFC, 0x56, 0x50, 0x7D, 0xD1, 0x74, 0x03, 0xB8, 0x43 };
quint8 decKey4[] = { 0x8B, 0x47, 0xDD, 0x6A, 0xE8, 0x14, 0x83, 0xC4, 0xBC, 0xF3, 0x7F, 0x75 };
SetKey_func s_d_func = (SetKey_func)library.resolve( "?SetKey@CCrypto@RockBase@@QAEXPBD000@Z" );
if( s_d_func )
{
//"Successful loading of Decrypt CCrypto::SetKey function."));
s_d_func( 0, (const char*)decKey1, 0, 0 );
s_d_func((const char*)decKey2, 0, 0, 0);
s_d_func(0, (const char*)decKey3, 0, 0);
s_d_func((const char*)decKey4, 0, 0, 0);
}
else
{
//Unable to load Decrypt CCrypto::SetKey function."));
}
}
我在另一个类中调用函数
void patch::readdata()
{
Crypt *cryptinstance = new Crypt(this);
cryptinstance->DecSetKey();
}
我认为指针在我使用后被摧毁了。任何帮助都会对你的时间有所帮助。
答案 0 :(得分:0)
从命令行执行dumpbin /exports RockBaseML.dll
。您将看到代码尝试搜索时没有?SetKey@CCrypto@RockBase@@QAEXPBD000@Z
这样的导出函数。我找到的最接近的是这套:
C:\Users\jselbie\Downloads>dumpbin /exports RockBaseML.dll | findstr /i SetKey
116 73 00004DCF ?SetKey@CAesCrypto@RockBase@@UAEXPBD@Z
117 74 00004F3D ?SetKey@CDesCrypto@RockBase@@UAEXPBD@Z
118 75 00005051 ?SetKey@CRcCrypto@RockBase@@UAEXPBD@Z
119 76 0000525E ?SetKey@CRockCrypto@RockBase@@QAEXPBD000@Z
120 77 000054F2 ?SetKey@CStrmCrypto@RockBase@@UAEXPBD@Z