未验证 提交 be0260eb 编写于 作者: J Jack Li 提交者: GitHub

Merge pull request #85 from ljc545w/add/http_overload_api

http接口重载
......@@ -116,6 +116,12 @@ DWORD CheckFriendStatusRemote(LPVOID lparameter)
CheckFriendStatus((wchar_t *)lparameter);
return LocalFriendStatus;
}
#else
DWORD __stdcall CheckFriendStatus(wstring wxid)
{
CheckFriendStatus((LPWSTR)wxid.c_str());
return LocalFriendStatus;
}
#endif
/*
......
#pragma once
#include<windows.h>
#include <windows.h>
using namespace std;
#ifndef USE_SOCKET
extern "C" __declspec(dllexport) DWORD CheckFriendStatusRemote(LPVOID lparameter);
#else
DWORD __stdcall CheckFriendStatus(wstring wxid);
#endif
VOID __stdcall CheckFriendStatus(wchar_t* wxid);
VOID __stdcall CheckFriendStatus(wchar_t *wxid);
VOID UnHookFriendStatusCode();
VOID HookFriendStatusCode();
\ No newline at end of file
VOID HookFriendStatusCode();
......@@ -313,6 +313,7 @@
<ClInclude Include="GetChatRoomMembers.h" />
<ClInclude Include="GetDbHandles.h" />
<ClInclude Include="LogMsgInfo.h" />
<ClInclude Include="http_overload.hpp" />
<ClInclude Include="pch.h" />
<ClInclude Include="ReceiveMessage.h" />
<ClInclude Include="SelfInfo.h" />
......
......@@ -222,6 +222,9 @@
<ClInclude Include="GetChatRoomMemberNickname.h">
<Filter>群相关\获取群成员昵称</Filter>
</ClInclude>
<ClInclude Include="http_overload.hpp">
<Filter>wxsocket</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
......
......@@ -15,7 +15,7 @@ BOOL EditRemarkRemote(LPVOID lpParameter)
}
#endif // !USE_SOCKET
BOOL EditRemark(wchar_t *wxid, wchar_t *remark)
BOOL __stdcall EditRemark(wchar_t *wxid, wchar_t *remark)
{
DWORD EditRemarkCall = GetWeChatWinBase() + EditRemarkCallOffset;
WxString pwxid(wxid);
......
#pragma once
#include<windows.h>
BOOL EditRemark(wchar_t* wxid, wchar_t* remark);
#include <windows.h>
BOOL __stdcall EditRemark(wchar_t *wxid, wchar_t *remark);
#ifndef USE_SOCKET
extern "C" __declspec(dllexport) BOOL EditRemarkRemote(LPVOID lpParameter);
#endif // !USE_SOCKET
#include "pch.h"
#include <vector>
#include <vector>
// 通讯录左树偏移
#define LeftTreeOffset 0x23668F4
......@@ -7,56 +7,67 @@
// 保存所有好友信息的动态数组
vector<WxFriendStruct> WxFriendList;
#ifndef USE_SOCKET
/*
* 供外部调用的获取好友列表接口1
* return:int,联系人数量
*/
int GetFriendListInit() {
GetFriendList();
int GetFriendListInit()
{
GetFriendList();
#ifdef _DEBUG
cout << WxFriendList.size() << endl;
cout << WxFriendList.size() << endl;
#endif
return WxFriendList.size() == 0 ? 0 : WxFriendList.size() - 1;
return WxFriendList.size() == 0 ? 0 : WxFriendList.size() - 1;
}
#ifndef USE_SOCKET
/*
* 供外部调用的获取好友列表接口2
* return:DWORD,WxFriendList第一个成员地址
*/
DWORD GetFriendListRemote() {
if (WxFriendList.size() == 0 || WxFriendList.size() - 1 == 0)
return 0;
DWORD GetFriendListRemote()
{
if (WxFriendList.size() == 0 || WxFriendList.size() - 1 == 0)
return 0;
#ifdef _DEBUG
printf("0x%08X\n", (DWORD)&WxFriendList[0]);
printf("0x%08X\n", (DWORD)&(WxFriendList[0].wxIdAddr));
printf("0x%08X\n", (DWORD)&WxFriendList[0]);
printf("0x%08X\n", (DWORD) & (WxFriendList[0].wxIdAddr));
#endif
return (DWORD)&WxFriendList[0].wxIdAddr;
return (DWORD)&WxFriendList[0].wxIdAddr;
}
/*
* 供外部调用的获取好友列表接口3,清空缓存
* return:void
*/
void GetFriendListFinish() {
WxFriendList.clear();
cout << WxFriendList.size() << endl;
void GetFriendListFinish()
{
WxFriendList.clear();
cout << WxFriendList.size() << endl;
}
#else
vector<WxFriendStruct> GetWxContact()
{
WxFriendList.clear();
GetFriendList();
return WxFriendList;
}
#endif
/*
* 获取好友列表的具体实现
* return:void
*/
WxFriendStruct* __stdcall GetFriendList() {
WxFriendStruct *__stdcall GetFriendList()
{
#ifdef _DEBUG
wcout.imbue(locale("chs"));
wcout.imbue(locale("chs"));
#endif
DWORD WeChatWinBase = GetWeChatWinBase();
DWORD LeftTreeAddr = 0;
DWORD RightTreeAddr = 0;
DWORD LeftTreeHead = 0;
DWORD baseAddr = WeChatWinBase + LeftTreeOffset;
__asm {
DWORD WeChatWinBase = GetWeChatWinBase();
DWORD LeftTreeAddr = 0;
DWORD RightTreeAddr = 0;
DWORD LeftTreeHead = 0;
DWORD baseAddr = WeChatWinBase + LeftTreeOffset;
__asm {
pushad;
mov eax, dword ptr[baseAddr];
mov eax, dword ptr[eax];
......@@ -67,15 +78,16 @@ WxFriendStruct* __stdcall GetFriendList() {
mov ecx, dword ptr[eax + 0x4];
mov RightTreeAddr, ecx;
popad;
}
while (1) {
DWORD wxIdAddr = 0;
DWORD wxNumberAddr = 0;
DWORD wxNickNameAddr = 0;
DWORD wxRemarkAddr = 0;
}
__asm {
while (1)
{
DWORD wxIdAddr = 0;
DWORD wxNumberAddr = 0;
DWORD wxNickNameAddr = 0;
DWORD wxRemarkAddr = 0;
__asm {
pushad;
mov eax, dword ptr [LeftTreeAddr];
mov ecx, eax;
......@@ -93,17 +105,18 @@ WxFriendStruct* __stdcall GetFriendList() {
mov ecx, dword ptr [eax];
mov LeftTreeAddr, ecx;
popad;
}
WxFriendStruct p(wxIdAddr, wxNumberAddr, wxNickNameAddr, wxRemarkAddr);
WxFriendList.push_back(p);
}
WxFriendStruct p(wxIdAddr, wxNumberAddr, wxNickNameAddr, wxRemarkAddr);
WxFriendList.push_back(p);
#ifdef _DEBUG
wcout << (wchar_t*)(*(DWORD*)p.wxIdAddr) << endl;
wcout << (wchar_t *)(*(DWORD *)p.wxIdAddr) << endl;
#endif
if (LeftTreeAddr == LeftTreeHead) {
break;
}
}
WxFriendStruct nullp(NULL, NULL, NULL, NULL);
WxFriendList.push_back(nullp);
return WxFriendList.data();
}
\ No newline at end of file
if (LeftTreeAddr == LeftTreeHead)
{
break;
}
}
WxFriendStruct nullp(NULL, NULL, NULL, NULL);
WxFriendList.push_back(nullp);
return WxFriendList.data();
}
#pragma once
WxFriendStruct* __stdcall GetFriendList();
#include <vector>
#include "wxdata.h"
using namespace std;
WxFriendStruct *__stdcall GetFriendList();
#ifndef USE_SOCKET
extern "C" __declspec(dllexport) DWORD GetFriendListRemote();
extern "C" __declspec(dllexport) int GetFriendListInit();
extern "C" __declspec(dllexport) void GetFriendListFinish();
#endif
\ No newline at end of file
#else
vector<WxFriendStruct> GetWxContact();
#endif
......@@ -50,9 +50,7 @@ wstring GetChatRoomMemberNickname(wchar_t *chatroomid, wchar_t *wxid)
}
else
{
wchar_t *buffer = GetUserNickNameByWxId(wxid);
nickname += wstring(buffer);
delete[] buffer;
nickname += GetUserNickNameByWxId(wxid);
}
return nickname;
}
#pragma once
#include<windows.h>
#include <windows.h>
BOOL __stdcall GetChatRoomMembers(wchar_t* chatroomid);
BOOL __stdcall GetChatRoomMembers(wchar_t *chatroomid);
#ifndef USE_SOCKET
extern "C" __declspec(dllexport) DWORD GetChatRoomMembersRemote(LPVOID lparameter);
#endif
\ No newline at end of file
#else
wstring __stdcall GetChatRoomMembers(wstring chatroomid);
#endif
......@@ -53,6 +53,18 @@ DWORD GetChatRoomMembersRemote(LPVOID lparameter)
}
return 0;
}
#else
wstring __stdcall GetChatRoomMembers(wstring chatroomid)
{
GetChatRoomMembers((wchar_t *)chatroomid.c_str());
if (chatroominfo.length == 0)
return L"";
wstring members(chatroominfo.members);
delete[] chatroominfo.members;
chatroominfo.members = NULL;
chatroominfo.length = 0;
return members;
}
#endif
/*
......
#include "pch.h"
// 联系人相关库偏移
#define SqlHandleMicroMsgOffset 0x2366934
#define SqlHandleMicroMsgOffset 0x2366934
// 公众号相关库偏移
#define SqlHandlePublicMsgOffset 0x239E3C8
// 聊天记录相关库偏移
......@@ -15,14 +15,16 @@ vector<DbInfoStruct> dbs;
* dbname:数据库名
* return:DWORD,如果检索成功,返回数据库句柄,否则返回`0`
*/
DWORD GetDbHandleByDbName(wchar_t* dbname) {
if (dbs.size() == 0)
GetDbHandles();
for (unsigned int i = 0; i < dbs.size() - 1; i++) {
if (!lstrcmpW(dbs[i].dbname, dbname))
return dbs[i].handle;
}
return 0;
DWORD GetDbHandleByDbName(wchar_t *dbname)
{
if (dbs.size() == 0)
GetDbHandles();
for (unsigned int i = 0; i < dbs.size() - 1; i++)
{
if (!lstrcmpW(dbs[i].dbname, dbname))
return dbs[i].handle;
}
return 0;
}
/*
......@@ -30,10 +32,11 @@ DWORD GetDbHandleByDbName(wchar_t* dbname) {
* return:DWORD,`dbs`首个成员地址
*/
#ifndef USE_SOCKET
DWORD GetDbHandlesRemote() {
if (dbs.size() == 0)
GetDbHandles();
return (DWORD)dbs.data() ;
DWORD GetDbHandlesRemote()
{
if (dbs.size() == 0)
GetDbHandles();
return (DWORD)dbs.data();
}
#endif
......@@ -41,15 +44,16 @@ DWORD GetDbHandlesRemote() {
* 获取数据库信息的具体实现
* return:void
*/
void* GetDbHandles() {
dbs.clear();
DWORD WeChatWinBase = GetWeChatWinBase();
DWORD SqlHandleBaseAddr = WeChatWinBase + SqlHandleMicroMsgOffset;
DWORD SqlHandleBeginAddr = 0x0;
DWORD SqlHandleEndAddr = 0x0;
DWORD SqlHandlePublicMsgAddr = *(DWORD*)(WeChatWinBase + SqlHandlePublicMsgOffset);
DWORD SqlHandleMSGAddr = *(DWORD*)(WeChatWinBase + SqlHandleMSGOffset);
__asm {
vector<void *> GetDbHandles()
{
dbs.clear();
DWORD WeChatWinBase = GetWeChatWinBase();
DWORD SqlHandleBaseAddr = WeChatWinBase + SqlHandleMicroMsgOffset;
DWORD SqlHandleBeginAddr = 0x0;
DWORD SqlHandleEndAddr = 0x0;
DWORD SqlHandlePublicMsgAddr = *(DWORD *)(WeChatWinBase + SqlHandlePublicMsgOffset);
DWORD SqlHandleMSGAddr = *(DWORD *)(WeChatWinBase + SqlHandleMSGOffset);
__asm {
mov eax, [SqlHandleBaseAddr];
mov ecx, [eax];
add ecx, 0x1428;
......@@ -57,71 +61,80 @@ void* GetDbHandles() {
mov SqlHandleBeginAddr, eax;
mov eax, [ecx + 0x4];
mov SqlHandleEndAddr, eax;
}
DWORD dwHandle = 0x0;
wstring dbnames = L"";
// 获取联系人数据库句柄
while (SqlHandleBeginAddr < SqlHandleEndAddr) {
dwHandle = *(DWORD*)SqlHandleBeginAddr;
SqlHandleBeginAddr += 0x4;
if (SqlHandleBeginAddr == SqlHandleEndAddr)
break;
if(dbnames.find(L"|" + (wstring)(wchar_t*)(*(DWORD*)(dwHandle + 0x50)) + L"|",0) != wstring::npos)
continue;
DbInfoStruct db = { 0 };
dbnames = dbnames + L"|" + (wchar_t*)(*(DWORD*)(dwHandle + 0x50)) + L"|";
db.dbname = (wchar_t*)(*(DWORD*)(dwHandle + 0x50));
db.l_dbname = wcslen(db.dbname);
db.handle = *(DWORD*)(dwHandle + 0x3C);
ExecuteSQL(*(DWORD*)(dwHandle + 0x3C), "select * from sqlite_master where type=\"table\";",(DWORD)GetDbInfo,&db);
dbs.push_back(db);
}
// 获取公众号数据库句柄
for (int i = 1; i < 4; i++) {
dwHandle = *((DWORD*)(SqlHandlePublicMsgAddr + i * 0x4));
if (dbnames.find(L"|" + (wstring)(wchar_t*)(*(DWORD*)(dwHandle + 0x50)) + L"|", 0) != wstring::npos)
continue;
DbInfoStruct db = { 0 };
dbnames = dbnames + L"|" + (wchar_t*)(*(DWORD*)(dwHandle + 0x50)) + L"|";
db.dbname = (wchar_t*)(*(DWORD*)(dwHandle + 0x50));
db.l_dbname = wcslen(db.dbname);
db.handle = *(DWORD*)(dwHandle + 0x3C);
ExecuteSQL(*(DWORD*)(dwHandle + 0x3C), "select * from sqlite_master where type=\"table\";", (DWORD)GetDbInfo, &db);
dbs.push_back(db);
}
// 获取聊天记录数据库句柄
int msgdb_count = *(int*)(SqlHandleMSGAddr + 0x4);
DWORD MsgdwHandle = *(DWORD*)(SqlHandleMSGAddr + 0x1C);
for (int i = 0; i < msgdb_count; i++) {
for (int j = 0; j < 4; j++) {
dwHandle = *(DWORD*)(MsgdwHandle + 0x14 + j * 4);
if (dbnames.find(L"|" + (wstring)(wchar_t*)(*(DWORD*)(dwHandle + 0x50)) + L"|", 0) != wstring::npos)
continue;
DbInfoStruct db = { 0 };
dbnames = dbnames + L"|" + (wchar_t*)(*(DWORD*)(dwHandle + 0x50)) + L"|";
db.dbname = (wchar_t*)(*(DWORD*)(dwHandle + 0x50));
db.l_dbname = wcslen(db.dbname);
db.handle = *(DWORD*)(dwHandle + 0x3C);
ExecuteSQL(*(DWORD*)(dwHandle + 0x3C), "select * from sqlite_master where type=\"table\";", (DWORD)GetDbInfo, &db);
dbs.push_back(db);
}
MsgdwHandle += 0x68;
}
// 添加一个空结构体,作为读取结束标志
DbInfoStruct db_end = { 0 };
dbs.push_back(db_end);
}
DWORD dwHandle = 0x0;
wstring dbnames = L"";
// 获取联系人数据库句柄
while (SqlHandleBeginAddr < SqlHandleEndAddr)
{
dwHandle = *(DWORD *)SqlHandleBeginAddr;
SqlHandleBeginAddr += 0x4;
if (SqlHandleBeginAddr == SqlHandleEndAddr)
break;
if (dbnames.find(L"|" + (wstring)(wchar_t *)(*(DWORD *)(dwHandle + 0x50)) + L"|", 0) != wstring::npos)
continue;
DbInfoStruct db = {0};
dbnames = dbnames + L"|" + (wchar_t *)(*(DWORD *)(dwHandle + 0x50)) + L"|";
db.dbname = (wchar_t *)(*(DWORD *)(dwHandle + 0x50));
db.l_dbname = wcslen(db.dbname);
db.handle = *(DWORD *)(dwHandle + 0x3C);
ExecuteSQL(*(DWORD *)(dwHandle + 0x3C), "select * from sqlite_master where type=\"table\";", (DWORD)GetDbInfo, &db);
dbs.push_back(db);
}
// 获取公众号数据库句柄
for (int i = 1; i < 4; i++)
{
dwHandle = *((DWORD *)(SqlHandlePublicMsgAddr + i * 0x4));
if (dbnames.find(L"|" + (wstring)(wchar_t *)(*(DWORD *)(dwHandle + 0x50)) + L"|", 0) != wstring::npos)
continue;
DbInfoStruct db = {0};
dbnames = dbnames + L"|" + (wchar_t *)(*(DWORD *)(dwHandle + 0x50)) + L"|";
db.dbname = (wchar_t *)(*(DWORD *)(dwHandle + 0x50));
db.l_dbname = wcslen(db.dbname);
db.handle = *(DWORD *)(dwHandle + 0x3C);
ExecuteSQL(*(DWORD *)(dwHandle + 0x3C), "select * from sqlite_master where type=\"table\";", (DWORD)GetDbInfo, &db);
dbs.push_back(db);
}
// 获取聊天记录数据库句柄
int msgdb_count = *(int *)(SqlHandleMSGAddr + 0x4);
DWORD MsgdwHandle = *(DWORD *)(SqlHandleMSGAddr + 0x1C);
for (int i = 0; i < msgdb_count; i++)
{
for (int j = 0; j < 4; j++)
{
dwHandle = *(DWORD *)(MsgdwHandle + 0x14 + j * 4);
if (dbnames.find(L"|" + (wstring)(wchar_t *)(*(DWORD *)(dwHandle + 0x50)) + L"|", 0) != wstring::npos)
continue;
DbInfoStruct db = {0};
dbnames = dbnames + L"|" + (wchar_t *)(*(DWORD *)(dwHandle + 0x50)) + L"|";
db.dbname = (wchar_t *)(*(DWORD *)(dwHandle + 0x50));
db.l_dbname = wcslen(db.dbname);
db.handle = *(DWORD *)(dwHandle + 0x3C);
ExecuteSQL(*(DWORD *)(dwHandle + 0x3C), "select * from sqlite_master where type=\"table\";", (DWORD)GetDbInfo, &db);
dbs.push_back(db);
}
MsgdwHandle += 0x68;
}
// 添加一个空结构体,作为读取结束标志
DbInfoStruct db_end = {0};
dbs.push_back(db_end);
#ifdef _DEBUG
for (unsigned int i = 0; i < dbs.size() - 1; i++) {
printf("dbname = %ws,handle = 0x%08X,table_count:%d\n",dbs[i].dbname,dbs[i].handle,dbs[i].tables.size());
for (unsigned int j = 0; j < dbs[i].tables.size();j++) {
cout << "name = " << dbs[i].tables[j].name << endl;
cout << "tbl_name = " << dbs[i].tables[j].tbl_name << endl;
cout << "rootpage = " << dbs[i].tables[j].rootpage << endl;
cout << "sql = " << dbs[i].tables[j].sql << endl;
cout << endl;
}
cout << endl;
}
for (unsigned int i = 0; i < dbs.size() - 1; i++)
{
printf("dbname = %ws,handle = 0x%08X,table_count:%d\n", dbs[i].dbname, dbs[i].handle, dbs[i].tables.size());
for (unsigned int j = 0; j < dbs[i].tables.size(); j++)
{
cout << "name = " << dbs[i].tables[j].name << endl;
cout << "tbl_name = " << dbs[i].tables[j].tbl_name << endl;
cout << "rootpage = " << dbs[i].tables[j].rootpage << endl;
cout << "sql = " << dbs[i].tables[j].sql << endl;
cout << endl;
}
cout << endl;
}
#endif
return dbs.data();
}
\ No newline at end of file
vector<void *> ret_array;
for (auto it : dbs)
ret_array.push_back(&it);
return ret_array;
}
#pragma once
#include<windows.h>
#include <windows.h>
#include <vector>
using namespace std;
void* GetDbHandles();
vector<void *> GetDbHandles();
#ifndef USE_SOCKET
extern "C" __declspec(dllexport) DWORD GetDbHandlesRemote();
#endif
DWORD GetDbHandleByDbName(wchar_t* dbname);
\ No newline at end of file
DWORD GetDbHandleByDbName(wchar_t *dbname);
#pragma once
#include<windows.h>
wstring __stdcall GetUserInfoByWxId(wchar_t* wxid);
wchar_t* __stdcall GetUserNickNameByWxId(wchar_t* wxid);
void* __stdcall SearchContactByNet(wchar_t* keyword);
#include <windows.h>
#include <map>
using namespace std;
wstring __stdcall GetUserInfoByWxId(wchar_t *wxid);
wstring __stdcall GetUserNickNameByWxId(wchar_t *wxid);
void *__stdcall SearchContactByNet(wchar_t *keyword);
void UnHookSearchContact();
#ifndef USE_SOCKET
extern "C" __declspec(dllexport) DWORD GetWxUserInfoRemote(LPVOID lparamter);
extern "C" __declspec(dllexport) VOID DeleteUserInfoCacheRemote();
extern "C" __declspec(dllexport) DWORD SearchContactByNetRemote(LPVOID keyword);
#endif
\ No newline at end of file
#else
map<wstring, wstring> __stdcall SearchContactByNet(wstring keyword);
#endif
......@@ -174,8 +174,9 @@ wstring __stdcall GetUserInfoByWxId(wchar_t *wxid)
* wxid:联系人wxid
* return:wchar_t*,获取到的wxid
*/
wchar_t *__stdcall GetUserNickNameByWxId(wchar_t *wxid)
wstring __stdcall GetUserNickNameByWxId(wchar_t *wxid)
{
wstring wstr;
DWORD WeChatWinBase = GetWeChatWinBase();
DWORD WxGetUserInfoCall1 = WeChatWinBase + GetUserInfoCall1Offset;
DWORD WxGetUserInfoCall2 = WeChatWinBase + GetUserInfoCall2Offset;
......@@ -204,13 +205,15 @@ wchar_t *__stdcall GetUserNickNameByWxId(wchar_t *wxid)
mov address, ebx;
popad;
}
wchar_t *NickName = NULL;
if (isSuccess)
{
DWORD length = *(DWORD *)(address + 0x6C + 0x4);
NickName = new wchar_t[length + 1];
ZeroMemory(NickName, (length + 1) * 2);
memcpy(NickName, (wchar_t *)(*(DWORD *)(address + 0x6C)), length * 2);
wchar_t *buffer = new wchar_t[length + 1];
ZeroMemory(buffer, (length + 1) * 2);
memcpy(buffer, (wchar_t *)(*(DWORD *)(address + 0x6C)), length * 2);
wstr = wstring(buffer);
delete[] buffer;
buffer = NULL;
}
char deletebuffer[0x410] = {0};
__asm {
......@@ -223,5 +226,5 @@ wchar_t *__stdcall GetUserNickNameByWxId(wchar_t *wxid)
call DeleteUserInfoCacheCall2;
popad;
}
return NickName;
return wstr;
}
......@@ -260,4 +260,22 @@ DWORD SearchContactByNetRemote(LPVOID keyword)
SearchContactByNet((wchar_t *)keyword);
return (DWORD)&userinfo;
}
#else
map<wstring, wstring> __stdcall SearchContactByNet(wstring keyword)
{
SearchContactByNet((wchar_t *)keyword.c_str());
map<wstring, wstring> m_info;
m_info[L"keyword"] = userinfo.keyword;
m_info[L"v3"] = userinfo.v3;
m_info[L"NickName"] = userinfo.NickName;
m_info[L"Signature"] = userinfo.Signature;
m_info[L"Nation"] = userinfo.Nation;
m_info[L"Province"] = userinfo.Province;
m_info[L"City"] = userinfo.City;
m_info[L"BigAvatar"] = userinfo.BigAvatar;
m_info[L"SmallAvatar"] = userinfo.SmallAvatar;
m_info[L"Sex"] = userinfo.sex == 1 ? L"1" : L"2";
DeleteUserInfoCache();
return m_info;
}
#endif
......@@ -75,14 +75,14 @@ void __stdcall SendAtText(wchar_t *wsChatRoomId, DWORD wsWxId[], wchar_t *wsText
int querySuccess = 0;
for (int i = 0; i < length; i++)
{
wchar_t *nickname = NULL;
wstring nickname;
if (!lstrcmpW((wchar_t *)wsWxId[i], (wchar_t *)L"notify@all"))
{
nickname = (wchar_t *)L"所有人";
nickname = L"所有人";
}
else
nickname = GetUserNickNameByWxId((wchar_t *)wsWxId[i]);
if (!nickname)
if (nickname.length() == 0)
continue;
WxString temp = {0};
temp.buffer = (wchar_t *)wsWxId[i];
......
#pragma once
#include "pch.h"
#ifdef USE_SOCKET
#define WS2LW(wstr) (LPWSTR) wstr.c_str()
void __stdcall SendText(wstring wxid, wstring msg)
{
return SendText(WS2LW(wxid), WS2LW(msg));
}
void __stdcall SendAtText(wstring wsChatRoomId, vector<wstring> wxids, wstring wsTextMsg, BOOL AutoNickName)
{
vector<DWORD> wxid_list;
for (auto wxid : wxids)
wxid_list.push_back((DWORD)wxid.c_str());
return SendAtText(WS2LW(wsChatRoomId), wxid_list.data(), WS2LW(wsTextMsg), wxid_list.size(), AutoNickName);
}
BOOL __stdcall SendCard(wstring receiver, wstring sharedwxid, wstring nickname)
{
return SendCard(WS2LW(receiver), WS2LW(sharedwxid), WS2LW(nickname));
}
void __stdcall SendImage(wstring receiver, wstring ImagePath)
{
return SendImage(WS2LW(receiver), WS2LW(ImagePath));
}
void __stdcall SendFile(wstring receiver, wstring FilePath)
{
return SendFile(WS2LW(receiver), WS2LW(FilePath));
}
BOOL __stdcall SendArticle(wstring wxid, wstring title, wstring abstract, wstring url, wstring imgpath)
{
return SendArticle(WS2LW(wxid), WS2LW(title), WS2LW(abstract), WS2LW(url), WS2LW(imgpath));
}
BOOL __stdcall SendAppMsg(wstring wxid, wstring appid)
{
return SendAppMsg(WS2LW(wxid), WS2LW(appid));
}
BOOL __stdcall DeleteUser(wstring wxid)
{
return DeleteUser(WS2LW(wxid));
}
wstring __stdcall GetUserInfoByWxId(wstring wxid)
{
return GetUserInfoByWxId(WS2LW(wxid));
}
wstring __stdcall GetUserNickNameByWxId(wstring wxid)
{
return GetUserNickNameByWxId(WS2LW(wxid));
}
BOOL __stdcall AddFriendByV3(wstring v3, wstring message, int AddType)
{
return AddFriendByV3(WS2LW(v3), WS2LW(message), AddType);
}
BOOL __stdcall AddFriendByWxid(wstring wxid, wstring message)
{
return AddFriendByWxid(WS2LW(wxid), WS2LW(message));
}
BOOL __stdcall AddBrandContact(wstring PublicId)
{
return AddBrandContact(WS2LW(PublicId));
}
BOOL __stdcall VerifyFriendApply(wstring v3_data, wstring v4_data)
{
return VerifyFriendApply(WS2LW(v3_data), WS2LW(v4_data));
}
BOOL __stdcall EditRemark(wstring wxid, wstring remark)
{
return EditRemark(WS2LW(wxid), WS2LW(remark));
}
wstring __stdcall GetChatRoomMemberNickname(wstring chatroomid, wstring wxid)
{
return GetChatRoomMemberNickname(WS2LW(chatroomid), WS2LW(wxid));
}
BOOL __stdcall DelChatRoomMember(wstring chatroomid, vector<wstring> wxids)
{
vector<wchar_t *> wxid_list;
for (auto wxid : wxids)
wxid_list.push_back((wchar_t *)wxid.c_str());
return DelChatRoomMember(WS2LW(chatroomid), wxid_list.data(), wxid_list.size());
}
BOOL __stdcall AddChatRoomMember(wstring chatroomid, vector<wstring> wxids)
{
vector<wchar_t *> wxid_list;
for (auto wxid : wxids)
wxid_list.push_back((wchar_t *)wxid.c_str());
return AddChatRoomMember(WS2LW(chatroomid), wxid_list.data(), wxid_list.size());
}
BOOL __stdcall SetChatRoomAnnouncement(wstring chatroomid, wstring announcement)
{
return SetChatRoomAnnouncement(WS2LW(chatroomid), WS2LW(announcement));
}
BOOL __stdcall SetChatRoomName(wstring chatroomid, wstring chatroomname)
{
return SetChatRoomName(WS2LW(chatroomid), WS2LW(chatroomname));
}
BOOL __stdcall SetChatRoomSelfNickname(wstring chatroomid, wstring nickname)
{
return SetChatRoomSelfNickname(WS2LW(chatroomid), WS2LW(nickname));
}
BOOL __stdcall ChangeWeChatVersion(wstring verStr)
{
return ChangeWeChatVer(WS2LW(verStr));
}
int __stdcall BackupSQLiteDB(DWORD DbHandle, wstring BackupFile)
{
string filepath = unicode_to_utf8(WS2LW(BackupFile));
return BackupSQLiteDB(DbHandle, filepath.c_str());
}
#endif
......@@ -54,15 +54,16 @@ BOOL FindOrCreateDirectory(const wchar_t *pszPath)
/*
* 将宽字节字符串转换成`std::string`
*/
void unicode_to_string(std::string &szDst, wchar_t *wchar)
string unicode_to_gb2312(wchar_t *wchar)
{
wchar_t *wText = wchar;
DWORD dwNum = WideCharToMultiByte(CP_OEMCP, NULL, wText, -1, NULL, 0, NULL, FALSE);
char *psText;
psText = new char[dwNum];
WideCharToMultiByte(CP_OEMCP, NULL, wText, -1, psText, dwNum, NULL, FALSE);
szDst = psText;
DWORD dwNum = WideCharToMultiByte(CP_ACP, NULL, wText, -1, NULL, 0, NULL, FALSE);
char *psText = new char[dwNum + 1];
WideCharToMultiByte(CP_ACP, NULL, wText, -1, psText, dwNum, NULL, FALSE);
psText[dwNum] = '\0';
string szDst(psText);
delete[] psText;
return szDst;
}
/*
......@@ -79,7 +80,6 @@ string utf8_to_gb2312(const char *strUTF8)
char *szGBK = new char[len + 1];
memset(szGBK, 0, len + 1);
WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, szGBK, len, NULL, NULL);
//strUTF8 = szGBK;
string strTemp(szGBK);
delete[] szGBK;
delete[] wszGBK;
......@@ -101,6 +101,18 @@ wstring utf8_to_unicode(const char *buffer)
return ret;
}
string unicode_to_utf8(wchar_t *wstr)
{
int c_size = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, FALSE);
char *buffer = new char[c_size + 1];
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, buffer, c_size, NULL, FALSE);
buffer[c_size] = '\0';
string str(buffer);
delete[] buffer;
buffer = NULL;
return str;
}
/*
* 对任意地址添加HOOK
* dwHookAddr:HOOK的目标地址
......@@ -205,6 +217,7 @@ void PrintProcAddr()
{
CreateConsole();
printf("WeChatVersion %s\n", GetWeChatVerStr().c_str());
#ifndef USE_SOCKET
printf("SendImage 0x%08X\n", (DWORD)SendImage);
printf("SendText 0x%08X\n", (DWORD)SendText);
printf("SendFile 0x%08X\n", (DWORD)SendFile);
......@@ -228,6 +241,7 @@ void PrintProcAddr()
printf("SetChatRoomAnnouncement 0x%08X\n", (DWORD)SetChatRoomAnnouncement);
printf("SetChatRoomSelfNickname 0x%08X\n", (DWORD)SetChatRoomSelfNickname);
printf("SetChatRoomName 0x%08X\n", (DWORD)SetChatRoomName);
#endif
}
BOOL ProcessIsWeChat()
......
......@@ -37,8 +37,9 @@ using namespace std;
BOOL CreateConsole(void);
DWORD GetWeChatWinBase();
void unicode_to_string(std::string &szDst, wchar_t *wchar);
string unicode_to_gb2312(wchar_t *wchar);
string utf8_to_gb2312(const char *strUTF8);
string unicode_to_utf8(wchar_t *wstr);
wstring utf8_to_unicode(const char *buffer);
void HookAnyAddress(DWORD dwHookAddr, LPVOID dwJmpAddress, char *originalRecieveCode);
void UnHookAnyAddress(DWORD dwHookAddr, char *originalRecieveCode);
......
......@@ -5,6 +5,7 @@
#include "mongoose/mongoose.c"
// json: https://github.com/nlohmann/json
#include "json/json.hpp"
#include "http_overload.hpp"
using namespace nlohmann;
static struct mg_mgr mgr;
......@@ -29,7 +30,6 @@ json methods = {{"GET", HTTP_METHOD_GET}, {"POST", HTTP_METHOD_POST}};
#define STOI_S(str) (is_digit_number(str) ? stoi(str) : 0)
#define POST_PARAM(jData, key) utf8_to_unicode(string(jData[key]).c_str())
#define GET_PARAM(hm, name) getMgVarW(hm, name)
#define W2LPW(wstr) (LPWSTR) wstr.c_str()
bool is_digit_number(string str)
{
......@@ -136,19 +136,16 @@ void request_event(mg_http_message *hm)
{
wstring wxid = get_http_param_str(hm, jData, "wxid", method);
wstring msg = get_http_param_str(hm, jData, "msg", method);
SendText(W2LPW(wxid), W2LPW(msg));
SendText(wxid, msg);
break;
}
case WECHAT_MSG_SEND_AT:
{
wstring chatroom = get_http_param_str(hm, jData, "chatroom_id", method);
vector<wstring> wxids = get_http_param_array(hm, jData, "wxids", method);
vector<DWORD> wxidptrs;
for (auto wxid : wxids)
wxidptrs.push_back((DWORD)wxid.c_str());
wstring msg = get_http_param_str(hm, jData, "msg", method);
int auto_nickname = get_http_param_int(hm, jData, "auto_nickname", method);
SendAtText(W2LPW(chatroom), wxidptrs.data(), W2LPW(msg), wxids.size(), auto_nickname);
SendAtText(chatroom, wxids, msg, auto_nickname);
break;
}
case WECHAT_MSG_SEND_CARD:
......@@ -156,21 +153,21 @@ void request_event(mg_http_message *hm)
wstring receiver = get_http_param_str(hm, jData, "receiver", method);
wstring shared_wxid = get_http_param_str(hm, jData, "shared_wxid", method);
wstring nickname = get_http_param_str(hm, jData, "nickname", method);
SendCard(W2LPW(receiver), W2LPW(shared_wxid), W2LPW(nickname));
SendCard(receiver, shared_wxid, nickname);
break;
}
case WECHAT_MSG_SEND_IMAGE:
{
wstring receiver = get_http_param_str(hm, jData, "receiver", method);
wstring img_path = get_http_param_str(hm, jData, "img_path", method);
SendImage(W2LPW(receiver), W2LPW(img_path));
SendImage(receiver, img_path);
break;
}
case WECHAT_MSG_SEND_FILE:
{
wstring receiver = get_http_param_str(hm, jData, "receiver", method);
wstring file_path = get_http_param_str(hm, jData, "file_path", method);
SendFile(W2LPW(receiver), W2LPW(file_path));
SendFile(receiver, file_path);
break;
}
case WECHAT_MSG_SEND_ARTICLE:
......@@ -180,14 +177,14 @@ void request_event(mg_http_message *hm)
wstring abstract = get_http_param_str(hm, jData, "abstract", method);
wstring url = get_http_param_str(hm, jData, "url", method);
wstring img_path = get_http_param_str(hm, jData, "img_path", method);
SendArticle(W2LPW(wxid), W2LPW(title), W2LPW(abstract), W2LPW(url), W2LPW(img_path));
SendArticle(wxid, title, abstract, url, img_path);
break;
}
case WECHAT_MSG_SEND_APP:
{
wstring wxid = get_http_param_str(hm, jData, "wxid", method);
wstring appid = get_http_param_str(hm, jData, "appid", method);
SendAppMsg(W2LPW(wxid), W2LPW(appid));
SendAppMsg(wxid, appid);
break;
}
default:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册