Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
m0_71398851
ComWeChatRobot
提交
74e6b992
C
ComWeChatRobot
项目概览
m0_71398851
/
ComWeChatRobot
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ComWeChatRobot
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
74e6b992
编写于
8月 05, 2022
作者:
A
amchii
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
StartRobotSerivice可重入
上级
d4546759
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
37 addition
and
9 deletion
+37
-9
CWeChatRobot/WeChatRobotCOM.idl
CWeChatRobot/WeChatRobotCOM.idl
+1
-1
CWeChatRobot/pch.cpp
CWeChatRobot/pch.cpp
+34
-7
CWeChatRobot/pch.h
CWeChatRobot/pch.h
+2
-1
Release/CWeChatRobot.exe
Release/CWeChatRobot.exe
+0
-0
未找到文件。
CWeChatRobot/WeChatRobotCOM.idl
浏览文件 @
74e6b992
...
...
@@ -69,7 +69,7 @@ interface IWeChatRobot : IDispatch
interface
IRobotEvent
:
IDispatch
{
[
id
(
1
),
helpstring
(
"用于微信主动推送消息"
)
]
HRESULT
CPostMessage
(
[
in
]
DWORD
pid
,
[
in
]
int
msgtype
,
[
in
]
VARIANT
*
msg
,
[
out
,
retval
]
int
*
__result
)
;
[
id
(
2
),
helpstring
(
"用于
微信主动推送消息
"
)
]
HRESULT
CRegisterWxPidWithCookie
(
[
in
]
DWORD
pid
,
[
in
]
DWORD
cookie
,
[
out
,
retval
]
int
*
__result
)
;
[
id
(
2
),
helpstring
(
"用于
客户端通过微信PID注册消息接收服务
"
)
]
HRESULT
CRegisterWxPidWithCookie
(
[
in
]
DWORD
pid
,
[
in
]
DWORD
cookie
,
[
out
,
retval
]
int
*
__result
)
;
}
;
[
uuid
(
721
abb35
-
141
a
-
4
aa2
-
94
f2
-
762
e2833fa6c
),
...
...
CWeChatRobot/pch.cpp
浏览文件 @
74e6b992
...
...
@@ -2,6 +2,14 @@
#include "pch.h"
/*
* 保证RobotService可以重复调用及停止,类似于可重入锁,用于支持多个客户端同时调用
* StopRobotService的次数必须不小于StartRobotService才可以停止服务,当服务已经停止后
* 可以重复调用StopRobotService,但只需一次StartRobotService即可将计数置0并开启服务
*/
map
<
DWORD
,
short
>
ServiceCount
;
// 当使用预编译的头时,需要使用此源文件,编译才能成功。
BOOL
isFileExists_stat
(
string
&
name
)
{
...
...
@@ -54,18 +62,37 @@ DWORD GetWeChatPid() {
return
wxPid
;
}
DWORD
StartRobotService
(
DWORD
pid
)
{
wstring
wworkPath
=
GetComWorkPath
();
wchar_t
*
workPath
=
(
wchar_t
*
)
wworkPath
.
c_str
();
bool
status
=
Inject
(
pid
,
workPath
);
return
status
;
DWORD
StartRobotService
(
DWORD
pid
)
{
if
(
ServiceCount
[
pid
]
<
0
)
{
ServiceCount
[
pid
]
=
0
;
}
if
(
ServiceCount
[
pid
]
==
0
)
{
wstring
wworkPath
=
GetComWorkPath
();
wchar_t
*
workPath
=
(
wchar_t
*
)
wworkPath
.
c_str
();
bool
status
=
Inject
(
pid
,
workPath
);
if
(
!
status
)
{
++
ServiceCount
[
pid
];
}
return
status
;
}
++
ServiceCount
[
pid
];
return
0
;
}
DWORD
StopRobotService
(
DWORD
pid
)
{
DWORD
StopRobotService
(
DWORD
pid
)
{
DWORD
cpid
=
GetCurrentProcessId
();
if
(
pid
==
0
)
return
cpid
;
RemoveDll
(
pid
);
--
ServiceCount
[
pid
];
if
(
ServiceCount
[
pid
]
==
0
)
{
RemoveDll
(
pid
);
}
return
0
;
}
...
...
CWeChatRobot/pch.h
浏览文件 @
74e6b992
...
...
@@ -15,13 +15,14 @@
#include "stdlib.h"
#include <tchar.h>
#include <stdio.h>
#include <
w
indows.h>
#include <
W
indows.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")
...
...
Release/CWeChatRobot.exe
浏览文件 @
74e6b992
无法预览此类型文件
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录