Refactoring
This commit is contained in:
parent
0d228745ac
commit
53370ca8b6
@ -108,20 +108,20 @@ int WxInitSDK(bool debug, int port)
|
|||||||
MessageBoxA(NULL, "注入失败", "WxInitSDK", 0);
|
MessageBoxA(NULL, "注入失败", "WxInitSDK", 0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
injected = true;
|
||||||
|
|
||||||
util::PortPath pp = { 0 };
|
util::PortPath pp = { 0 };
|
||||||
pp.port = port;
|
pp.port = port;
|
||||||
snprintf(pp.path, MAX_PATH, "%s", std::filesystem::current_path().string().c_str());
|
snprintf(pp.path, MAX_PATH, "%s", std::filesystem::current_path().string().c_str());
|
||||||
|
|
||||||
bool ok = call_dll_func_ex(wcProcess, spyDllPath, spyBase, "InitSpy", (LPVOID)&pp, sizeof(util::PortPath), &status);
|
status = -3; // TODO: 统一错误码
|
||||||
if (!ok || status != 0) {
|
bool success = call_dll_func_ex(wcProcess, spyDllPath, spyBase, "InitSpy", (LPVOID)&pp, sizeof(util::PortPath),
|
||||||
MessageBoxA(NULL, "初始化失败", "WxInitSDK", 0);
|
(DWORD *)&status);
|
||||||
|
if (!success || status != 0) {
|
||||||
WxDestroySDK();
|
WxDestroySDK();
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
injected = true;
|
return status;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int WxDestroySDK()
|
int WxDestroySDK()
|
||||||
@ -137,6 +137,7 @@ int WxDestroySDK()
|
|||||||
if (!eject_dll(wcProcess, spyBase)) {
|
if (!eject_dll(wcProcess, spyBase)) {
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
injected = false;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ int InitSpy(LPVOID args)
|
|||||||
g_WeChatWinDllAddr = reinterpret_cast<UINT64>(dll_addr);
|
g_WeChatWinDllAddr = reinterpret_cast<UINT64>(dll_addr);
|
||||||
} else {
|
} else {
|
||||||
LOG_ERROR("获取 WeChatWin.dll 模块地址失败");
|
LOG_ERROR("获取 WeChatWin.dll 模块地址失败");
|
||||||
return; // TODO: 退出进程,避免后面操作失败
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string version = util::get_wechat_version();
|
std::string version = util::get_wechat_version();
|
||||||
@ -28,7 +28,7 @@ int InitSpy(LPVOID args)
|
|||||||
if (version != SUPPORT_VERSION) {
|
if (version != SUPPORT_VERSION) {
|
||||||
LOG_ERROR(msg);
|
LOG_ERROR(msg);
|
||||||
MessageBoxA(NULL, msg.c_str(), "错误", MB_ICONERROR);
|
MessageBoxA(NULL, msg.c_str(), "错误", MB_ICONERROR);
|
||||||
return -1;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO(msg);
|
LOG_INFO(msg);
|
||||||
|
Loading…
Reference in New Issue
Block a user