1 Star 0 Fork 1

陈奇/ComWeChatRobot

forked from Janisa/ComWeChatRobot 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
.github
3rdparty
CWeChatRobot
AddBrandContact.cpp
AddChatRoomMember.cpp
AddChatRoomMember.h
AddFriend.h
AddFriendByV3.cpp
AddFriendByWxid.cpp
CheckFriendStatus.cpp
CheckFriendStatus.h
DbBackup.cpp
DbBackup.h
DbExecuteSql.cpp
DbExecuteSql.h
DelChatRoomMember.cpp
DelChatRoomMember.h
DeleteUser.cpp
DeleteUser.h
EditRemark.cpp
EditRemark.h
ForwardMessage.cpp
ForwardMessage.h
FriendList.cpp
FriendList.h
GetA8Key.cpp
GetA8Key.h
GetChatRoomMemberNickname.cpp
GetChatRoomMemberNickname.h
GetChatRoomMembers.cpp
GetChatRoomMembers.h
GetDbHandles.cpp
GetDbHandles.h
GetHistoryPublicMsg.cpp
GetHistoryPublicMsg.h
GetMsgCDN.cpp
GetQrcodeImage.cpp
GetQrcodeImage.h
GetTransfer.cpp
GetTransfer.h
HookImageMessage.cpp
HookVoiceMessage.cpp
InjectDll.cpp
InjectDll.h
Logout.cpp
Logout.h
OpenBrowser.cpp
OpenBrowser.h
ReceiveMessage.cpp
ReceiveMessage.h
RobotEvent.cpp
RobotEvent.h
RobotEvent.rgs
SearchContact.h
SearchContactByCache.cpp
SearchContactByNet.cpp
SelfInfo.cpp
SelfInfo.h
SendAppMsg.cpp
SendAppMsg.h
SendArticle.cpp
SendArticle.h
SendAtText.cpp
SendAtText.h
SendCard.cpp
SendCard.h
SendEmotion.cpp
SendEmotion.h
SendFile.cpp
SendFile.h
SendImage.cpp
SendImage.h
SendText.cpp
SendText.h
SendXmlMsg.cpp
SendXmlMsg.h
SetChatRoomAnnouncement.cpp
SetChatRoomAnnouncement.h
SetChatRoomName.cpp
SetChatRoomName.h
SetChatRoomSelfNickname.cpp
SetChatRoomSelfNickname.h
VerifyFriendApply.cpp
VerifyFriendApply.h
WeChatRobot.cpp
WeChatRobot.h
WeChatRobot.rgs
WeChatRobotCOM.aps
WeChatRobotCOM.cpp
WeChatRobotCOM.idl
WeChatRobotCOM.rc
WeChatRobotCOM.rgs
WeChatRobotCOM.vcxproj
WeChatRobotCOM.vcxproj.filters
WeChatRobotCOM.vcxproj.user
WeChatRobotCOM_i.c
WeChatRobotCOM_i.h
WeChatRobotCOM_p.c
_IRobotEventEvents_CP.h
dlldata.c
framework.h
ntapi.cpp
ntapi.h
pch.cpp
pch.h
resource.h
robotdata.h
targetver.h
templatefunc.cpp
templatefunc.h
utils.h
wechatver.cpp
wechatver.h
xdlldata.c
xdlldata.h
DWeChatRobot
Python
old_projects
wxDriver
.clang-format
.gitignore
.pre-commit-config.yaml
ComWeChatRobot.sln
README.md
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
GetDbHandles.cpp 5.03 KB
一键复制 编辑 原始数据 按行查看 历史
#include "pch.h"
struct TableInfoAddrStruct
{
DWORD name;
DWORD l_name;
DWORD tbl_name;
DWORD l_tbl_name;
DWORD sql;
DWORD l_sql;
DWORD rootpage;
DWORD l_rootpage;
};
struct DbInfoAddrStruct
{
DWORD handle;
DWORD dbname;
DWORD l_dbname;
// vectorݽṹ
#ifdef _DEBUG
DWORD v_head;
#endif
DWORD v_data;
DWORD v_end1;
DWORD v_end2;
//
DWORD count;
DWORD extrainfo;
};
struct TableInfoStruct
{
char *name;
char *tbl_name;
char *sql;
char *rootpage;
};
struct DbInfoStruct
{
DWORD handle;
wchar_t *dbname;
vector<TableInfoStruct> tables;
DWORD count;
};
vector<DbInfoStruct> dbs;
SAFEARRAY *CreateDbInfoSafeArray()
{
SAFEARRAY *psaValue;
ULONG count = 0;
HRESULT hr = S_OK;
for (unsigned int i = 0; i < dbs.size(); i++)
{
count += dbs[i].count;
}
SAFEARRAYBOUND rgsaBound[3] = {{count, 0}, {6, 0}, {2, 0}};
psaValue = SafeArrayCreate(VT_VARIANT, 3, rgsaBound);
long index = 0;
for (unsigned int i = 0; i < dbs.size(); i++)
{
for (unsigned int j = 0; j < dbs[i].tables.size(); j++)
{
LONG ArrayIndex[3] = {index, 0, 0};
ArrayIndex[1] = 0;
ArrayIndex[2] = {0};
hr = SafeArrayPutElement(psaValue, ArrayIndex, &(_variant_t)L"dbname");
ArrayIndex[1] = 0;
ArrayIndex[2] = {1};
hr = SafeArrayPutElement(psaValue, ArrayIndex, &(_variant_t)dbs[i].dbname);
ArrayIndex[1] = 1;
ArrayIndex[2] = {0};
hr = SafeArrayPutElement(psaValue, ArrayIndex, &(_variant_t)L"Handle");
ArrayIndex[1] = 1;
ArrayIndex[2] = {1};
hr = SafeArrayPutElement(psaValue, ArrayIndex, &(_variant_t)dbs[i].handle);
ArrayIndex[1] = 2;
ArrayIndex[2] = {0};
hr = SafeArrayPutElement(psaValue, ArrayIndex, &(_variant_t)L"name");
ArrayIndex[1] = 2;
ArrayIndex[2] = {1};
hr = SafeArrayPutElement(psaValue, ArrayIndex, &(_variant_t)dbs[i].tables[j].name);
ArrayIndex[1] = 3;
ArrayIndex[2] = {0};
hr = SafeArrayPutElement(psaValue, ArrayIndex, &(_variant_t)L"tbl_name");
ArrayIndex[1] = 3;
ArrayIndex[2] = {1};
hr = SafeArrayPutElement(psaValue, ArrayIndex, &(_variant_t)dbs[i].tables[j].tbl_name);
ArrayIndex[1] = 4;
ArrayIndex[2] = {0};
hr = SafeArrayPutElement(psaValue, ArrayIndex, &(_variant_t)L"rootpage");
ArrayIndex[1] = 4;
ArrayIndex[2] = {1};
hr = SafeArrayPutElement(psaValue, ArrayIndex, &(_variant_t)dbs[i].tables[j].rootpage);
ArrayIndex[1] = 5;
ArrayIndex[2] = {0};
hr = SafeArrayPutElement(psaValue, ArrayIndex, &(_variant_t)L"sql");
ArrayIndex[1] = 5;
ArrayIndex[2] = {1};
hr = SafeArrayPutElement(psaValue, ArrayIndex, &(_variant_t)dbs[i].tables[j].sql);
index++;
}
}
return psaValue;
}
SAFEARRAY *GetDbHandles(DWORD pid)
{
dbs.clear();
WeChatProcess hp(pid);
if (!hp.m_init)
return NULL;
DWORD GetDbHandlesRemoteAddr = hp.GetProcAddr(GetDbHandlesRemote);
if (GetDbHandlesRemoteAddr == 0)
return NULL;
DWORD ret = CallRemoteFunction(hp.GetHandle(), GetDbHandlesRemoteAddr, NULL);
while (1)
{
DbInfoAddrStruct dbaddr = {0};
ReadProcessMemory(hp.GetHandle(), (LPCVOID)ret, &dbaddr, sizeof(DbInfoAddrStruct), 0);
if (dbaddr.handle == 0)
break;
DbInfoStruct db = {0};
db.handle = dbaddr.handle;
db.count = dbaddr.count;
db.dbname = new wchar_t[dbaddr.l_dbname + 1];
ReadProcessMemory(hp.GetHandle(), (LPCVOID)dbaddr.dbname, db.dbname, sizeof(wchar_t) * (dbaddr.l_dbname + 1), 0);
DWORD db_table_start_addr = dbaddr.v_data;
while (db_table_start_addr < dbaddr.v_end1)
{
TableInfoAddrStruct tbaddr = {0};
TableInfoStruct tb = {0};
ReadProcessMemory(hp.GetHandle(), (LPCVOID)db_table_start_addr, &tbaddr, sizeof(TableInfoAddrStruct), 0);
tb.name = new char[tbaddr.l_name + 1];
ReadProcessMemory(hp.GetHandle(), (LPCVOID)tbaddr.name, tb.name, tbaddr.l_name + 1, 0);
tb.tbl_name = new char[tbaddr.l_tbl_name + 1];
ReadProcessMemory(hp.GetHandle(), (LPCVOID)tbaddr.tbl_name, tb.tbl_name, tbaddr.l_tbl_name + 1, 0);
tb.rootpage = new char[tbaddr.l_rootpage + 1];
ReadProcessMemory(hp.GetHandle(), (LPCVOID)tbaddr.rootpage, tb.rootpage, tbaddr.l_rootpage + 1, 0);
tb.sql = new char[tbaddr.l_sql + 1];
ReadProcessMemory(hp.GetHandle(), (LPCVOID)tbaddr.sql, tb.sql, tbaddr.l_sql + 1, 0);
db.tables.push_back(tb);
db_table_start_addr += sizeof(TableInfoAddrStruct);
}
dbs.push_back(db);
ret += sizeof(DbInfoAddrStruct);
}
SAFEARRAY *psaValue = CreateDbInfoSafeArray();
return psaValue;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/chen_q_i/ComWeChatRobot.git
git@gitee.com:chen_q_i/ComWeChatRobot.git
chen_q_i
ComWeChatRobot
ComWeChatRobot
master

搜索帮助