提交 bb03a235 编写于 作者: L ljc545w

修复部分已知BUG

上级 44599f26
...@@ -81,17 +81,21 @@ DWORD GetWeChatRobotBase() { ...@@ -81,17 +81,21 @@ DWORD GetWeChatRobotBase() {
return dwHandle; return dwHandle;
} }
void GetProcOffset(wchar_t* workPath) { BOOL GetProcOffset(wchar_t* workPath) {
wchar_t* dllpath = new wchar_t[MAX_PATH]; wchar_t* dllpath = new wchar_t[MAX_PATH];
swprintf_s(dllpath, MAX_PATH, L"%ws%ws%ws", workPath, L"\\", dllname); swprintf_s(dllpath, MAX_PATH, L"%ws%ws%ws", workPath, L"\\", dllname);
string name = _com_util::ConvertBSTRToString((BSTR)dllpath); string name = _com_util::ConvertBSTRToString((BSTR)dllpath);
if (!isFileExists_stat(name)) { if (!isFileExists_stat(name)) {
MessageBoxA(NULL, name.c_str(), "文件不存在", MB_ICONWARNING); MessageBoxA(NULL, name.c_str(), "文件不存在", MB_ICONWARNING);
return; return 1;
} }
HMODULE hd = LoadLibraryW(dllpath); HMODULE hd = LoadLibraryW(dllpath);
if (!hd) if (!hd) {
return; wchar_t info[MAX_PATH] = { 0 };
swprintf_s(info, MAX_PATH, L"无法加载位于%ws的%ws", workPath, dllname);
MessageBox(NULL, info, L"致命错误", MB_ICONWARNING);
return 1;
}
DWORD WeChatBase = (DWORD)GetModuleHandleW(dllname); DWORD WeChatBase = (DWORD)GetModuleHandleW(dllname);
DWORD SendImageProcAddr = (DWORD)GetProcAddress(hd, SendImageRemote); DWORD SendImageProcAddr = (DWORD)GetProcAddress(hd, SendImageRemote);
...@@ -153,6 +157,7 @@ void GetProcOffset(wchar_t* workPath) { ...@@ -153,6 +157,7 @@ void GetProcOffset(wchar_t* workPath) {
FreeLibrary(hd); FreeLibrary(hd);
delete[] dllpath; delete[] dllpath;
dllpath = NULL; dllpath = NULL;
return 0;
} }
DWORD GetWeChatPid() { DWORD GetWeChatPid() {
...@@ -174,13 +179,16 @@ DWORD StartRobotService() { ...@@ -174,13 +179,16 @@ DWORD StartRobotService() {
} }
wstring wworkPath = GetComWorkPath(); wstring wworkPath = GetComWorkPath();
wchar_t* workPath = (wchar_t*)wworkPath.c_str(); wchar_t* workPath = (wchar_t*)wworkPath.c_str();
if (GetProcOffset(workPath) != 0) {
hProcess = NULL;
return 1;
}
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, wxPid); hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, wxPid);
bool status = Injert(wxPid, workPath); bool status = Injert(wxPid, workPath);
if (status == 1) { if (status != 0) {
CloseHandle(hProcess); CloseHandle(hProcess);
return status; hProcess = NULL;
} }
GetProcOffset(workPath);
return status; return status;
} }
...@@ -189,11 +197,14 @@ DWORD StopRobotService() { ...@@ -189,11 +197,14 @@ DWORD StopRobotService() {
if (!hProcess) if (!hProcess)
return cpid; return cpid;
DWORD wxPid = GetWeChatPid(); DWORD wxPid = GetWeChatPid();
CheckFriendStatusFinish(); if (wxPid && GetWeChatRobotBase()) {
StopReceiveMessage(); CheckFriendStatusFinish();
RemoveDll(wxPid); StopReceiveMessage();
RemoveDll(wxPid);
}
ZeroMemory((wchar_t*)SelfInfoString.c_str(), SelfInfoString.length() * 2 + 2); ZeroMemory((wchar_t*)SelfInfoString.c_str(), SelfInfoString.length() * 2 + 2);
CloseHandle(hProcess); CloseHandle(hProcess);
hProcess = NULL;
return cpid; return cpid;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册