法一(推荐)
(1) dumpcpp dm.dll所在路径
(2) 导入这两个文件, 以及dm.dll, dmReg.dll
新建一个项目, 勾选ActiveQt container库
#pragma execution_character_set("utf-8")
#include <QtCore/QCoreApplication>
#include <windows.h>
#include <process.h>
#include <QDebug>
#include <QLibrary>
#include <QDir>
#include <QTextCodec>
#include "dm.h"
dm::dmsoft* g_pDm; // 全局大漠对象指针
#define ModuleName "Qt615.dll"
BOOL RegDll()
{
QString path = QDir::currentPath();
path.append("/" + QString(ModuleName));
qDebug() << path;
// path现在是qstr, 要把它转为szGbk
QByteArray arrGbk = QTextCodec::codecForName("gbk")->fromUnicode(path);
char* szGbkPath = arrGbk.data();
typedef int (WINAPI* pFunc)(char*, int);
pFunc reg = (pFunc)QLibrary::resolve("regQt.dll", "SetDllPathA");
return reg(szGbkPath, 1);
}
BOOL InitDm()
{
if (!RegDll())
return FALSE;
g_pDm = new dm::dmsoft();
qDebug() << "DLL Version:" << g_pDm->Ver();
// 破解插件VIP功能
DWORD dwDllBase = (DWORD)GetModuleHandleA(ModuleName);
try {
*(BYTE*)(dwDllBase + 1078240) = 1;
}
catch (...) {
qDebug() << "Crack DLL VIP Failed!";
return FALSE;
}
qDebug() << "Crack DLL VIP Success!";
return TRUE;
}
int main(int argc, char *argv[])
{
CoInitializeEx(nullptr, 0);
QCoreApplication a(argc, argv);
BOOL bRet = InitDm();
qDebug() << "大漠初始化结果:" << bRet;
g_pDm->MoveTo(300, 300);
return a.exec();
}
法二(在win7下无法正常使用)
(1) 生成tlh和tli两个文件
先在一个QT VS的控制台应用添加dm.dll, 再在main.cpp头部添加
#import “dm.dll” no_namespace
然后重新生成解决方案,在Debug目录下会生成这两个文件, 把它们复制到工作目录
(2) 然后把dm.tlh的include改成相对路径
(3) main函数如下
#include <QtCore/QCoreApplication>
#include "dm.tlh"
#include <QDebug>
#pragma execution_character_set("utf-8")
Idmsoft* GetDmObject() // 从大漠类库中获取大漠对象
{
Idmsoft* m_dm = NULL;
bool m_bInit = false;
typedef HRESULT(__stdcall* pfnGCO)(REFCLSID, REFIID, void**);
pfnGCO fnGCO = NULL;
HINSTANCE hdllInst = LoadLibrary(L"dm.dll");
fnGCO = (pfnGCO)GetProcAddress(hdllInst, "DllGetClassObject");
if (fnGCO != NULL)
{
IClassFactory* pcf = NULL;
HRESULT hr = (fnGCO)(__uuidof(dmsoft), IID_IClassFactory, (void**)&pcf);
if (SUCCEEDED(hr) && (pcf != NULL))
{
hr = pcf->CreateInstance(NULL, __uuidof(Idmsoft), (void**)&m_dm);
if ((SUCCEEDED(hr) && (m_dm != NULL)) == FALSE)
return FALSE;
}
pcf->Release();
m_bInit = true;
}
else
m_bInit = false;
return m_dm;
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
Idmsoft* pDm = GetDmObject();
qDebug() << pDm->Ver();
BOOL bRet = pDm->Reg("ws1648f49959469eb34f580d78057dxxxx", "xxxx");
qDebug() << "注册结果:" << bRet;
pDm->MoveTo(100, 100);
return a.exec();
}