未验证 提交 f40e2afd 编写于 作者: J Jack Li 提交者: GitHub

Merge pull request #65 from amchii/fix-multiprocess

修复多开微信情况下获取个人信息共用字符串的问题
...@@ -18,3 +18,8 @@ ...@@ -18,3 +18,8 @@
packages packages
mongoose.c mongoose.c
mongoose.h mongoose.h
# VSCode
.vscode
# JetBrians IDE
.idea
...@@ -20,8 +20,9 @@ VOID DeleteSelfInfoCache(DWORD pid,HANDLE hProcess) { ...@@ -20,8 +20,9 @@ VOID DeleteSelfInfoCache(DWORD pid,HANDLE hProcess) {
} }
std::wstring GetSelfInfo(DWORD pid) { std::wstring GetSelfInfo(DWORD pid) {
if (SelfInfoString.compare(L"")) { if (PidToSelfInfoString.count(pid)!=0)
return SelfInfoString; {
return PidToSelfInfoString[pid];
} }
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid); HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
if (!hProcess) if (!hProcess)
...@@ -48,14 +49,14 @@ std::wstring GetSelfInfo(DWORD pid) { ...@@ -48,14 +49,14 @@ std::wstring GetSelfInfo(DWORD pid) {
wchar_t* wmessage = new wchar_t[selfinfo.length + 1]; wchar_t* wmessage = new wchar_t[selfinfo.length + 1];
ZeroMemory(wmessage, (selfinfo.length + 1) * 2); ZeroMemory(wmessage, (selfinfo.length + 1) * 2);
ReadProcessMemory(hProcess, (LPCVOID)selfinfo.message, wmessage, selfinfo.length * 2, &dwWriteSize); ReadProcessMemory(hProcess, (LPCVOID)selfinfo.message, wmessage, selfinfo.length * 2, &dwWriteSize);
SelfInfoString += wmessage; PidToSelfInfoString[pid] = wmessage;
delete[] wmessage; delete[] wmessage;
wmessage = NULL; wmessage = NULL;
} }
DeleteSelfInfoCache(pid,hProcess); DeleteSelfInfoCache(pid,hProcess);
CloseHandle(hProcess); CloseHandle(hProcess);
return SelfInfoString; return PidToSelfInfoString[pid];
} }
BOOL isWxLogin(DWORD pid) { BOOL isWxLogin(DWORD pid) {
......
// pch.cpp: 与预编译标头对应的源文件 // pch.cpp: 与预编译标头对应的源文件
#include "pch.h" #include "pch.h"
// 当使用预编译的头时,需要使用此源文件,编译才能成功。 // 当使用预编译的头时,需要使用此源文件,编译才能成功。
DWORD SendImageOffset = 0x0; DWORD SendImageOffset = 0x0;
DWORD SendTextOffset = 0x0; DWORD SendTextOffset = 0x0;
DWORD SendFileOffset = 0x0; DWORD SendFileOffset = 0x0;
...@@ -56,7 +56,7 @@ DWORD UnHookVoiceMsgRemoteOffset = 0x0; ...@@ -56,7 +56,7 @@ DWORD UnHookVoiceMsgRemoteOffset = 0x0;
DWORD ChangeWeChatVerRemoteOffset = 0x0; DWORD ChangeWeChatVerRemoteOffset = 0x0;
wstring SelfInfoString = L""; map<DWORD, wstring> PidToSelfInfoString;
BOOL isFileExists_stat(string& name) { BOOL isFileExists_stat(string& name) {
struct stat buffer; struct stat buffer;
...@@ -132,7 +132,7 @@ BOOL GetProcOffset(wchar_t* workPath) { ...@@ -132,7 +132,7 @@ BOOL GetProcOffset(wchar_t* workPath) {
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 0; return 0;
} }
HMODULE hd = LoadLibrary(dllpath); HMODULE hd = LoadLibrary(dllpath);
...@@ -242,11 +242,11 @@ BOOL GetProcOffset(wchar_t* workPath) { ...@@ -242,11 +242,11 @@ BOOL GetProcOffset(wchar_t* workPath) {
} }
DWORD GetWeChatPid() { DWORD GetWeChatPid() {
HWND hCalc = FindWindow(NULL, L"微信"); HWND hCalc = FindWindow(NULL, L"微信");
DWORD wxPid = 0; DWORD wxPid = 0;
GetWindowThreadProcessId(hCalc, &wxPid); GetWindowThreadProcessId(hCalc, &wxPid);
if (wxPid == 0) { if (wxPid == 0) {
hCalc = FindWindow(NULL, L"微信测试版"); hCalc = FindWindow(NULL, L"微信测试版");
GetWindowThreadProcessId(hCalc, &wxPid); GetWindowThreadProcessId(hCalc, &wxPid);
} }
return wxPid; return wxPid;
...@@ -257,8 +257,8 @@ DWORD StartRobotService(DWORD pid) { ...@@ -257,8 +257,8 @@ DWORD StartRobotService(DWORD pid) {
wchar_t* workPath = (wchar_t*)wworkPath.c_str(); wchar_t* workPath = (wchar_t*)wworkPath.c_str();
if (!GetProcOffset(workPath)) { if (!GetProcOffset(workPath)) {
wchar_t info[200] = { 0 }; wchar_t info[200] = { 0 };
swprintf_s(info, 200, L"COM无法加载位于%ws的%ws!", workPath, dllname); swprintf_s(info, 200, L"COM无法加载位于%ws的%ws!", workPath, dllname);
MessageBox(NULL, info, L"致命错误!", MB_ICONWARNING); MessageBox(NULL, info, L"致命错误!", MB_ICONWARNING);
return 1; return 1;
}; };
bool status = Inject(pid, workPath); bool status = Inject(pid, workPath);
...@@ -270,7 +270,7 @@ DWORD StopRobotService(DWORD pid) { ...@@ -270,7 +270,7 @@ DWORD StopRobotService(DWORD pid) {
if (pid == 0) if (pid == 0)
return cpid; return cpid;
RemoveDll(pid); RemoveDll(pid);
ZeroMemory((wchar_t*)SelfInfoString.c_str(), SelfInfoString.length() * 2 + 2); PidToSelfInfoString.erase(pid);
return 0; return 0;
} }
...@@ -279,7 +279,7 @@ wstring GetComWorkPath() { ...@@ -279,7 +279,7 @@ wstring GetComWorkPath() {
GetModuleFileName(NULL, szFilePath, MAX_PATH); GetModuleFileName(NULL, szFilePath, MAX_PATH);
wstring wpath = szFilePath; wstring wpath = szFilePath;
int pos = wpath.find_last_of(L"\\"); int pos = wpath.find_last_of(L"\\");
wpath = wpath.substr(0,pos); wpath = wpath.substr(0, pos);
return wpath; return wpath;
} }
......
...@@ -15,13 +15,14 @@ ...@@ -15,13 +15,14 @@
#include "stdlib.h" #include "stdlib.h"
#include <tchar.h> #include <tchar.h>
#include <stdio.h> #include <stdio.h>
#include <windows.h> #include <Windows.h>
#include <TlHelp32.h> #include <TlHelp32.h>
#include <atlconv.h> #include <atlconv.h>
#include <tchar.h> #include <tchar.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <direct.h> #include <direct.h>
#include <vector> #include <vector>
#include <map>
#include <comutil.h> #include <comutil.h>
#pragma comment(lib, "comsuppw.lib") #pragma comment(lib, "comsuppw.lib")
......
...@@ -50,7 +50,7 @@ extern DWORD VerifyFriendApplyOffset; ...@@ -50,7 +50,7 @@ extern DWORD VerifyFriendApplyOffset;
extern DWORD GetSelfInfoOffset; extern DWORD GetSelfInfoOffset;
extern DWORD DeleteSelfInfoCacheOffset; extern DWORD DeleteSelfInfoCacheOffset;
extern wstring SelfInfoString; extern map<DWORD, wstring> PidToSelfInfoString;
extern DWORD isWxLoginOffset; extern DWORD isWxLoginOffset;
extern DWORD CheckFriendStatusRemoteOffset; extern DWORD CheckFriendStatusRemoteOffset;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册