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 003d0dc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 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();
9 changes: 6 additions & 3 deletions WeChatFerry/wcf/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

void help()
{
printf("\nUsage: \n启动: wcf.exe start port [debug]\n关闭: wcf.exe stop\nport: 命令端口, 消息端口为命令端口+1\n");
printf("\nUsage: \n启动: wcf.exe start port [debug]\n关闭: wcf.exe stop\nport: 命令端口, 消息端口为命令端口+1\n指定微信pid启动: wcf.exe start port pid仅在你知道这是什么时候使用\n");
}

int main(int argc, char *argv[])
Expand All @@ -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 003d0dc

Please sign in to comment.