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

Merge pull request #65 from amchii/fix-multiprocess

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