Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crossin的编程教室
ComWeChatRobot
提交
e350df9f
C
ComWeChatRobot
项目概览
Crossin的编程教室
/
ComWeChatRobot
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
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,发现更多精彩内容 >>
提交
e350df9f
编写于
6月 06, 2022
作者:
L
ljc545w
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化部分逻辑
上级
38abfe37
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
151 addition
and
8 deletion
+151
-8
CWeChatRobot/InjertDll.cpp
CWeChatRobot/InjertDll.cpp
+2
-0
CWeChatRobot/pch.cpp
CWeChatRobot/pch.cpp
+60
-1
CWeChatRobot/pch.h
CWeChatRobot/pch.h
+13
-6
DWeChatRobot/dllmain.cpp
DWeChatRobot/dllmain.cpp
+3
-1
DWeChatRobot/pch.cpp
DWeChatRobot/pch.cpp
+68
-0
DWeChatRobot/pch.h
DWeChatRobot/pch.h
+5
-0
未找到文件。
CWeChatRobot/InjertDll.cpp
浏览文件 @
e350df9f
...
...
@@ -38,6 +38,8 @@ bool Injert(DWORD dwPid,wchar_t* workPath) {
string
name
=
_com_util
::
ConvertBSTRToString
((
BSTR
)
workPath
);
if
(
!
isFileExists_stat
(
name
))
{
MessageBox
(
NULL
,
dllpath
,
L"文件不存在"
,
MB_ICONWARNING
);
delete
[]
dllpath
;
dllpath
=
NULL
;
return
1
;
}
bool
status
=
InjectDll
(
dwPid
,
dllpath
);
...
...
CWeChatRobot/pch.cpp
浏览文件 @
e350df9f
...
...
@@ -44,7 +44,7 @@ wstring SelfInfoString = L"";
HANDLE
hProcess
=
NULL
;
bool
isFileExists_stat
(
string
&
name
)
{
BOOL
isFileExists_stat
(
string
&
name
)
{
struct
stat
buffer
;
return
(
stat
(
name
.
c_str
(),
&
buffer
)
==
0
);
}
...
...
@@ -226,4 +226,63 @@ wstring GetComWorkPath() {
int
pos
=
wpath
.
find_last_of
(
L"
\\
"
);
wpath
=
wpath
.
substr
(
0
,
pos
);
return
wpath
;
}
static
BOOL
GetWeChatInstallInfo
(
TCHAR
*
lpValueName
,
VOID
*
Value
,
DWORD
lpcbData
)
{
HKEY
hKey
=
NULL
;
ZeroMemory
(
Value
,
lpcbData
);
LSTATUS
lRet
=
RegOpenKeyEx
(
HKEY_CURRENT_USER
,
_T
(
"SOFTWARE
\\
Tencent
\\
WeChat"
),
0
,
KEY_QUERY_VALUE
,
&
hKey
);
if
(
lRet
!=
0
)
{
return
false
;
}
lRet
=
RegQueryValueEx
(
hKey
,
lpValueName
,
NULL
,
NULL
,
(
LPBYTE
)
Value
,
&
lpcbData
);
RegCloseKey
(
hKey
);
if
(
lRet
!=
0
)
{
return
false
;
}
return
true
;
}
tstring
GetWeChatInstallDir
()
{
TCHAR
*
szProductType
=
new
TCHAR
[
MAX_PATH
];
GetWeChatInstallInfo
((
TCHAR
*
)
TEXT
(
"InstallPath"
),
(
void
*
)
szProductType
,
MAX_PATH
);
tstring
wxdir
(
szProductType
);
delete
[]
szProductType
;
szProductType
=
NULL
;
return
wxdir
.
length
()
==
0
?
TEXT
(
""
)
:
wxdir
;
}
DWORD
GetWeChatVerInt
()
{
DWORD
version
=
0x0
;
GetWeChatInstallInfo
((
TCHAR
*
)
TEXT
(
"Version"
),
(
void
*
)
&
version
,
sizeof
(
DWORD
));
return
version
;
}
tstring
GetWeChatVerStr
()
{
BYTE
pversion
[
4
]
=
{
0
};
GetWeChatInstallInfo
((
TCHAR
*
)
TEXT
(
"Version"
),
(
void
*
)
pversion
,
sizeof
(
DWORD
));
TCHAR
*
temp
=
new
TCHAR
[
20
];
_stprintf_s
(
temp
,
20
,
_T
(
"%d.%d.%d.%d
\0
"
),
(
int
)(
pversion
[
3
]
-
0x60
),
(
int
)
pversion
[
2
],
(
int
)
pversion
[
1
],
(
int
)
pversion
[
0
]);
tstring
verStr
(
temp
);
delete
[]
temp
;
temp
=
NULL
;
return
verStr
;
}
VOID
StartWeChat
()
{
tstring
szAppName
=
GetWeChatInstallDir
();
if
(
szAppName
.
length
()
==
0
)
return
;
szAppName
+=
TEXT
(
"
\\
WeChat.exe"
);
STARTUPINFO
StartInfo
;
ZeroMemory
(
&
StartInfo
,
sizeof
(
StartInfo
));
PROCESS_INFORMATION
procStruct
;
ZeroMemory
(
&
procStruct
,
sizeof
(
procStruct
));
StartInfo
.
cb
=
sizeof
(
STARTUPINFO
);
if
(
CreateProcess
((
LPCTSTR
)
szAppName
.
c_str
(),
NULL
,
NULL
,
NULL
,
FALSE
,
NORMAL_PRIORITY_CLASS
,
NULL
,
NULL
,
&
StartInfo
,
&
procStruct
))
{
CloseHandle
(
procStruct
.
hProcess
);
CloseHandle
(
procStruct
.
hThread
);
}
}
\ No newline at end of file
CWeChatRobot/pch.h
浏览文件 @
e350df9f
...
...
@@ -29,15 +29,22 @@
#include "robotdata.h"
using
namespace
std
;
struct
testStruct
{
DWORD
type
;
wchar_t
*
desc
;
};
bool
isFileExists_stat
(
string
&
name
);
#ifdef _UNICODE
#define tstring std::wstring
#else
#define tstring std::string
#endif
BOOL
isFileExists_stat
(
string
&
name
);
DWORD
GetWeChatRobotBase
();
DWORD
GetWeChatPid
();
DWORD
StartRobotService
();
DWORD
StopRobotService
();
BOOL
CreateConsole
();
wstring
GetComWorkPath
();
\ No newline at end of file
wstring
GetComWorkPath
();
tstring
GetWeChatInstallDir
();
DWORD
GetWeChatVerInt
();
tstring
GetWeChatVerStr
();
VOID
StartWeChat
();
\ No newline at end of file
DWeChatRobot/dllmain.cpp
浏览文件 @
e350df9f
...
...
@@ -11,7 +11,9 @@ BOOL APIENTRY DllMain( HMODULE hModule,
case
DLL_PROCESS_ATTACH
:
{
#ifdef _DEBUG
PrintProcAddr
();
if
(
ProcessIsWeChat
())
{
PrintProcAddr
();
}
#endif
break
;
}
...
...
DWeChatRobot/pch.cpp
浏览文件 @
e350df9f
...
...
@@ -155,6 +155,7 @@ wchar_t* GetTimeW() {
void
PrintProcAddr
()
{
CreateConsole
();
printf
(
"WeChatVersion %s
\n
"
,
GetWeChatVerStr
().
c_str
());
printf
(
"SendImage 0x%08X
\n
"
,
(
DWORD
)
SendImage
);
printf
(
"SendText 0x%08X
\n
"
,
(
DWORD
)
SendText
);
printf
(
"SendFile 0x%08X
\n
"
,
(
DWORD
)
SendFile
);
...
...
@@ -170,4 +171,71 @@ void PrintProcAddr() {
printf
(
"VerifyFriendApply 0x%08X
\n
"
,
(
DWORD
)
VerifyFriendApply
);
printf
(
"AddFriendByV3 0x%08X
\n
"
,
(
DWORD
)
AddFriendByV3
);
printf
(
"AddFriendByWxid 0x%08X
\n
"
,
(
DWORD
)
AddFriendByWxid
);
}
BOOL
ProcessIsWeChat
()
{
char
szFileFullPath
[
MAX_PATH
]
=
{
0
},
szProcessName
[
MAX_PATH
]
=
{
0
};
GetModuleFileNameA
(
NULL
,
szFileFullPath
,
MAX_PATH
);
int
length
=
::
strlen
(
szFileFullPath
);
for
(
int
i
=
length
-
1
;
i
>=
0
;
i
--
)
{
if
(
szFileFullPath
[
i
]
==
'\\'
)
{
i
++
;
for
(
int
j
=
0
;
i
<=
length
;
j
++
)
{
szProcessName
[
j
]
=
szFileFullPath
[
i
++
];
}
break
;
}
}
if
(
::
strcmp
(
szProcessName
,
"WeChat.exe"
)
!=
0
)
{
return
FALSE
;
}
else
{
return
TRUE
;
}
}
DWORD
GetWeChatVerInt
()
{
WCHAR
VersionFilePath
[
MAX_PATH
];
BYTE
WeChatVersion
[
4
]
=
{
0
};
if
(
GetModuleFileName
((
HMODULE
)
GetWeChatWinBase
(),
VersionFilePath
,
MAX_PATH
)
==
0
)
{
return
0
;
}
VS_FIXEDFILEINFO
*
pVsInfo
;
unsigned
int
iFileInfoSize
=
sizeof
(
VS_FIXEDFILEINFO
);
int
iVerInfoSize
=
GetFileVersionInfoSize
(
VersionFilePath
,
NULL
);
if
(
iVerInfoSize
!=
0
)
{
char
*
pBuf
=
new
char
[
iVerInfoSize
];
if
(
GetFileVersionInfo
(
VersionFilePath
,
0
,
iVerInfoSize
,
pBuf
))
{
if
(
VerQueryValue
(
pBuf
,
TEXT
(
"
\\
"
),
(
void
**
)
&
pVsInfo
,
&
iFileInfoSize
))
{
WeChatVersion
[
3
]
=
(
BYTE
)(
0x60
+
(
pVsInfo
->
dwFileVersionMS
>>
16
)
&
0x0000FFFF
);
WeChatVersion
[
2
]
=
(
BYTE
)(
pVsInfo
->
dwFileVersionMS
&
0x0000FFFF
);
WeChatVersion
[
1
]
=
(
BYTE
)((
pVsInfo
->
dwFileVersionLS
>>
16
)
&
0x0000FFFF
);
WeChatVersion
[
0
]
=
(
BYTE
)(
pVsInfo
->
dwFileVersionLS
&
0x0000FFFF
);
}
}
delete
[]
pBuf
;
}
return
*
(
DWORD
*
)
WeChatVersion
;
}
string
GetWeChatVerStr
()
{
DWORD
WeChatVersion
=
GetWeChatVerInt
();
if
(
WeChatVersion
==
0
)
return
"null"
;
string
wxver
=
""
;
BYTE
*
pWxVer
=
(
BYTE
*
)
&
WeChatVersion
;
strstream
wxVer
;
wxVer
<<
(
int
)
pWxVer
[
3
]
-
0x60
<<
"."
<<
(
int
)
pWxVer
[
2
]
<<
"."
<<
(
int
)
pWxVer
[
1
]
<<
"."
<<
(
int
)
pWxVer
[
0
];
wxVer
>>
wxver
;
return
wxver
;
}
\ No newline at end of file
DWeChatRobot/pch.h
浏览文件 @
e350df9f
...
...
@@ -30,9 +30,11 @@
#include "VerifyFriendApply.h"
#include "AddFriend.h"
#include <vector>
#include <strstream>
#endif //PCH_H
using
namespace
std
;
#pragma comment(lib,"version.lib")
// 对于导出函数,需要使用此宏修饰
#define DLLEXPORT extern "C" __declspec(dllexport)
...
...
@@ -84,3 +86,6 @@ DLLEXPORT void UnHookAll();
wstring
wreplace
(
wstring
source
,
wchar_t
replaced
,
wstring
replaceto
);
void
PrintProcAddr
();
wchar_t
*
GetTimeW
();
BOOL
ProcessIsWeChat
();
DWORD
GetWeChatVerInt
();
string
GetWeChatVerStr
();
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录