Skip to content

Commit

Permalink
specify pid of wechat for multi-wechat
Browse files Browse the repository at this point in the history
  • Loading branch information
DuGuYifei committed Oct 30, 2023
1 parent 2213085 commit b7e81d3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
18 changes: 11 additions & 7 deletions WeChatFerry/sdk/sdk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static int GetDllPath(bool debug, wchar_t *dllPath)
return 0;
}

int WxInitSDK(bool debug, int port)
int WxInitSDK(bool debug, int port, int inputPid)
{
int status = 0;
DWORD wcPid = 0;
Expand All @@ -43,13 +43,17 @@ int WxInitSDK(bool debug, int port)
return status;
}

status = OpenWeChat(&wcPid);
if (status != 0) {
MessageBox(NULL, L"打开微信失败", L"WxInitSDK", 0);
return status;
}
if(inputPid != 0) {
wcPid = inputPid;
} else {
status = OpenWeChat(&wcPid);
if (status != 0) {
MessageBox(NULL, L"打开微信失败", L"WxInitSDK", 0);
return status;
}

Sleep(2000); // 等待微信打开
Sleep(2000); // 等待微信打开
}
wcProcess = InjectDll(wcPid, spyDllPath, &spyBase);
if (wcProcess == NULL) {
MessageBox(NULL, L"注入失败", L"WxInitSDK", 0);
Expand Down
2 changes: 1 addition & 1 deletion WeChatFerry/sdk/sdk.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once

int WxInitSDK(bool debug, int port);
int WxInitSDK(bool debug, int port, int inputPid);
int WxDestroySDK();
7 changes: 5 additions & 2 deletions WeChatFerry/wcf/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ int main(int argc, char *argv[])

if (strcmp(argv[1], "start") == 0) {
int port = strtol(argv[2], NULL, 10);

ret = WxInitSDK(debug, port);
int inputPid = 0;
if (!debug && argc == 4) {
inputPid = strtol(argv[3], NULL, 10)
}
ret = WxInitSDK(debug, port, inputPid);
} else if (strcmp(argv[1], "stop") == 0) {
ret = WxDestroySDK();
} else {
Expand Down

0 comments on commit b7e81d3

Please sign in to comment.