法一(推荐)

(1) dumpcpp dm.dll所在路径

以获取dm.h 和 dm.cpp

(2) 导入这两个文件, 以及dm.dll, dmReg.dll

新建一个项目, 勾选ActiveQt container库

  1. #pragma execution_character_set("utf-8")
  2. #include <QtCore/QCoreApplication>
  3. #include <windows.h>
  4. #include <process.h>
  5. #include <QDebug>
  6. #include <QLibrary>
  7. #include <QDir>
  8. #include <QTextCodec>
  9. #include "dm.h"
  10. dm::dmsoft* g_pDm; // 全局大漠对象指针
  11. #define ModuleName "Qt615.dll"
  12. BOOL RegDll()
  13. {
  14. QString path = QDir::currentPath();
  15. path.append("/" + QString(ModuleName));
  16. qDebug() << path;
  17. // path现在是qstr, 要把它转为szGbk
  18. QByteArray arrGbk = QTextCodec::codecForName("gbk")->fromUnicode(path);
  19. char* szGbkPath = arrGbk.data();
  20. typedef int (WINAPI* pFunc)(char*, int);
  21. pFunc reg = (pFunc)QLibrary::resolve("regQt.dll", "SetDllPathA");
  22. return reg(szGbkPath, 1);
  23. }
  24. BOOL InitDm()
  25. {
  26. if (!RegDll())
  27. return FALSE;
  28. g_pDm = new dm::dmsoft();
  29. qDebug() << "DLL Version:" << g_pDm->Ver();
  30. // 破解插件VIP功能
  31. DWORD dwDllBase = (DWORD)GetModuleHandleA(ModuleName);
  32. try {
  33. *(BYTE*)(dwDllBase + 1078240) = 1;
  34. }
  35. catch (...) {
  36. qDebug() << "Crack DLL VIP Failed!";
  37. return FALSE;
  38. }
  39. qDebug() << "Crack DLL VIP Success!";
  40. return TRUE;
  41. }
  42. int main(int argc, char *argv[])
  43. {
  44. CoInitializeEx(nullptr, 0);
  45. QCoreApplication a(argc, argv);
  46. BOOL bRet = InitDm();
  47. qDebug() << "大漠初始化结果:" << bRet;
  48. g_pDm->MoveTo(300, 300);
  49. return a.exec();
  50. }

法二(在win7下无法正常使用)

(1) 生成tlh和tli两个文件

先在一个QT VS的控制台应用添加dm.dll, 再在main.cpp头部添加
#import “dm.dll” no_namespace
然后重新生成解决方案,在Debug目录下会生成这两个文件, 把它们复制到工作目录
image.png

(2) 然后把dm.tlh的include改成相对路径

image.png

(3) main函数如下

  1. #include <QtCore/QCoreApplication>
  2. #include "dm.tlh"
  3. #include <QDebug>
  4. #pragma execution_character_set("utf-8")
  5. Idmsoft* GetDmObject() // 从大漠类库中获取大漠对象
  6. {
  7. Idmsoft* m_dm = NULL;
  8. bool m_bInit = false;
  9. typedef HRESULT(__stdcall* pfnGCO)(REFCLSID, REFIID, void**);
  10. pfnGCO fnGCO = NULL;
  11. HINSTANCE hdllInst = LoadLibrary(L"dm.dll");
  12. fnGCO = (pfnGCO)GetProcAddress(hdllInst, "DllGetClassObject");
  13. if (fnGCO != NULL)
  14. {
  15. IClassFactory* pcf = NULL;
  16. HRESULT hr = (fnGCO)(__uuidof(dmsoft), IID_IClassFactory, (void**)&pcf);
  17. if (SUCCEEDED(hr) && (pcf != NULL))
  18. {
  19. hr = pcf->CreateInstance(NULL, __uuidof(Idmsoft), (void**)&m_dm);
  20. if ((SUCCEEDED(hr) && (m_dm != NULL)) == FALSE)
  21. return FALSE;
  22. }
  23. pcf->Release();
  24. m_bInit = true;
  25. }
  26. else
  27. m_bInit = false;
  28. return m_dm;
  29. }
  30. int main(int argc, char *argv[])
  31. {
  32. QCoreApplication a(argc, argv);
  33. Idmsoft* pDm = GetDmObject();
  34. qDebug() << pDm->Ver();
  35. BOOL bRet = pDm->Reg("ws1648f49959469eb34f580d78057dxxxx", "xxxx");
  36. qDebug() << "注册结果:" << bRet;
  37. pDm->MoveTo(100, 100);
  38. return a.exec();
  39. }