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

Merge pull request #85 from ljc545w/add/http_overload_api

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