Fix WxMsgTypes
This commit is contained in:
parent
de0c61cae9
commit
48091b8526
15
App/App.cpp
15
App/App.cpp
@ -39,19 +39,20 @@ int main()
|
||||
|
||||
_wsetlocale(LC_ALL, L"chs"); // 这是个大坑,不设置中文直接不见了。。。
|
||||
|
||||
// 获取消息类型
|
||||
const MsgTypesMap_t WxMsgTypes = WxGetMsgTypes();
|
||||
for (auto it = WxMsgTypes.begin(); it != WxMsgTypes.end(); ++it) {
|
||||
wprintf(L"%d: %s\n", it->first, it->second.c_str());
|
||||
}
|
||||
|
||||
wprintf(L"WxInitSDK: ");
|
||||
status = WxInitSDK();
|
||||
wcout << status << endl;
|
||||
wprintf(L"%d\n", status);
|
||||
if (status != 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取消息类型
|
||||
wprintf(L"获取消息类型\n");
|
||||
const MsgTypesMap_t WxMsgTypes = WxGetMsgTypes();
|
||||
for (auto it = WxMsgTypes.begin(); it != WxMsgTypes.end(); ++it) {
|
||||
wprintf(L"%d: %s\n", it->first, it->second.c_str());
|
||||
}
|
||||
|
||||
wprintf(L"Message: 接收通知中......\n");
|
||||
WxSetTextMsgCb(onTextMsg);
|
||||
|
10
Rpc/rpc.idl
10
Rpc/rpc.idl
@ -17,11 +17,19 @@ interface ISpy
|
||||
BSTR wxId; // 发送人微信ID
|
||||
BSTR roomId; // 群ID
|
||||
BSTR content; // 消息内容,MAC版最大:16384,即16KB
|
||||
} RpcMessage_t;
|
||||
} RpcMessage_t;
|
||||
|
||||
typedef struct RpcIntBstrPair {
|
||||
int key;
|
||||
BSTR value;
|
||||
} RpcIntBstrPair_t;
|
||||
typedef RpcIntBstrPair_t* PRpcIntBstrPair_t;
|
||||
typedef RpcIntBstrPair_t** PPRpcIntBstrPair_t;
|
||||
|
||||
int IsLogin();
|
||||
int SendTextMsg([ in, string ] const wchar_t *wxid, [ in, string ] const wchar_t *at_wxid, [ in, string ] const wchar_t *msg);
|
||||
int SendImageMsg([ in, string ] const wchar_t *wxid, [ in, string ] const wchar_t *path);
|
||||
int GetMsgTypes([ out ] int *pNum, [ out, size_is(, *pNum) ] PPRpcIntBstrPair_t *msgTypes);
|
||||
|
||||
void EnableReceiveMsg();
|
||||
[callback] int ReceiveMsg([ in ] RpcMessage_t rpcMsg);
|
||||
|
@ -113,6 +113,27 @@ int RpcSendImageMsg(const wchar_t *wxid, const wchar_t *path)
|
||||
return ret;
|
||||
}
|
||||
|
||||
PPRpcIntBstrPair_t RpcGetMsgTypes(int *pNum)
|
||||
{
|
||||
int ret = 0;
|
||||
unsigned long ulCode = 0;
|
||||
PPRpcIntBstrPair_t ppRpcMsgTypes = NULL;
|
||||
|
||||
RpcTryExcept{ ret = client_GetMsgTypes(pNum, &ppRpcMsgTypes); }
|
||||
RpcExcept(1)
|
||||
{
|
||||
ulCode = RpcExceptionCode();
|
||||
printf("RpcGetMsgTypes exception 0x%lx = %ld\n", ulCode, ulCode);
|
||||
}
|
||||
RpcEndExcept;
|
||||
if (ret != 0) {
|
||||
printf("GetMsgTypes Failed: %d\n", ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ppRpcMsgTypes;
|
||||
}
|
||||
|
||||
int server_ReceiveMsg(RpcMessage_t rpcMsg)
|
||||
{
|
||||
WxMessage_t msg;
|
||||
|
@ -9,3 +9,4 @@ unsigned int __stdcall RpcSetTextMsgCb(void *p);
|
||||
int RpcIsLogin();
|
||||
int RpcSendTextMsg(const wchar_t *wxid, const wchar_t *at_wxid, const wchar_t *msg);
|
||||
int RpcSendImageMsg(const wchar_t *wxid, const wchar_t *path);
|
||||
RpcIntBstrPair_t** RpcGetMsgTypes(int *pNum);
|
||||
|
35
SDK/sdk.cpp
35
SDK/sdk.cpp
@ -13,24 +13,6 @@
|
||||
#include "util.h"
|
||||
|
||||
std::function<int(WxMessage_t)> g_cbReceiveTextMsg;
|
||||
static const MsgTypesMap_t WxMsgTypes = MsgTypesMap_t { { 0x01, L"文字" },
|
||||
{ 0x03, L"图片" },
|
||||
{ 0x22, L"语音" },
|
||||
{ 0x25, L"好友确认" },
|
||||
{ 0x28, L"POSSIBLEFRIEND_MSG" },
|
||||
{ 0x2A, L"名片" },
|
||||
{ 0x2B, L"视频" },
|
||||
{ 0x2F, L"石头剪刀布 | 表情图片" },
|
||||
{ 0x30, L"位置" },
|
||||
{ 0x31, L"共享实时位置、文件、转账、链接" },
|
||||
{ 0x32, L"VOIPMSG" },
|
||||
{ 0x33, L"微信初始化" },
|
||||
{ 0x34, L"VOIPNOTIFY" },
|
||||
{ 0x35, L"VOIPINVITE" },
|
||||
{ 0x3E, L"小视频" },
|
||||
{ 0x270F, L"SYSNOTICE" },
|
||||
{ 0x2710, L"红包、系统消息" },
|
||||
{ 0x2712, L"撤回消息" } };
|
||||
|
||||
int WxInitSDK()
|
||||
{
|
||||
@ -187,4 +169,19 @@ ContactMap_t WxGetContacts()
|
||||
return mContact;
|
||||
}
|
||||
|
||||
MsgTypesMap_t WxGetMsgTypes() { return WxMsgTypes; }
|
||||
MsgTypesMap_t WxGetMsgTypes()
|
||||
{
|
||||
static MsgTypesMap_t WxMsgTypes;
|
||||
if (WxMsgTypes.empty()) {
|
||||
int size = 0;
|
||||
PPRpcIntBstrPair_t pp = RpcGetMsgTypes(&size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
WxMsgTypes.insert(make_pair(pp[i]->key, GetWstringFromBstr(pp[i]->value)));
|
||||
midl_user_free(pp[i]);
|
||||
}
|
||||
midl_user_free(pp);
|
||||
}
|
||||
|
||||
return WxMsgTypes;
|
||||
}
|
||||
|
||||
|
@ -169,14 +169,14 @@ int GetWstringByAddress(DWORD address, wchar_t *buffer, DWORD buffer_size)
|
||||
|
||||
BSTR GetBstrByAddress(DWORD address) { return SysAllocStringLen(GET_WSTRING(address), GET_DWORD(address + 4)); }
|
||||
|
||||
static wstring GetWstringFromBstr(BSTR p)
|
||||
wstring GetWstringFromBstr(BSTR p)
|
||||
{
|
||||
wstring ret = L"";
|
||||
wstring ws = L"";
|
||||
if (p != nullptr) {
|
||||
ret = wstring(p);
|
||||
ws = wstring(p);
|
||||
SysFreeString(p);
|
||||
}
|
||||
return ret;
|
||||
return ws;
|
||||
}
|
||||
|
||||
void GetRpcMessage(WxMessage_t *wxMsg, RpcMessage_t rpcMsg)
|
||||
|
@ -22,5 +22,6 @@ bool GetFileVersion(const wchar_t *filePath, wchar_t *version);
|
||||
int GetWstringByAddress(DWORD address, wchar_t *buffer, DWORD buffer_size);
|
||||
BSTR GetBstrByAddress(DWORD address);
|
||||
void GetRpcMessage(WxMessage_t *wxMsg, RpcMessage_t rpcMsg);
|
||||
DWORD GetMemoryIntByAddress(HANDLE hProcess, DWORD address);
|
||||
DWORD GetMemoryIntByAddress(HANDLE hProcess, DWORD address);
|
||||
std::wstring GetWstringFromBstr(BSTR p);
|
||||
std::wstring GetUnicodeInfoByAddress(HANDLE hProcess, DWORD address);
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "framework.h"
|
||||
#include "framework.h"
|
||||
|
||||
#include "load_calls.h"
|
||||
#include "receive_msg.h"
|
||||
@ -15,6 +15,25 @@ DWORD reg_buffer = 0;
|
||||
DWORD recvMsgCallAddr = 0;
|
||||
DWORD recvMsgJumpBackAddr = 0;
|
||||
RpcMessage_t lMsg = { 0 };
|
||||
|
||||
extern const MsgTypesMap_t g_WxMsgTypes = MsgTypesMap_t { { 0x01, L"文字" },
|
||||
{ 0x03, L"图片" },
|
||||
{ 0x22, L"语音" },
|
||||
{ 0x25, L"好友确认" },
|
||||
{ 0x28, L"POSSIBLEFRIEND_MSG" },
|
||||
{ 0x2A, L"名片" },
|
||||
{ 0x2B, L"视频" },
|
||||
{ 0x2F, L"石头剪刀布 | 表情图片" },
|
||||
{ 0x30, L"位置" },
|
||||
{ 0x31, L"共享实时位置、文件、转账、链接" },
|
||||
{ 0x32, L"VOIPMSG" },
|
||||
{ 0x33, L"微信初始化" },
|
||||
{ 0x34, L"VOIPNOTIFY" },
|
||||
{ 0x35, L"VOIPINVITE" },
|
||||
{ 0x3E, L"小视频" },
|
||||
{ 0x270F, L"SYSNOTICE" },
|
||||
{ 0x2710, L"红包、系统消息" },
|
||||
{ 0x2712, L"撤回消息" } };
|
||||
|
||||
void DispatchMsg(DWORD reg)
|
||||
{
|
||||
|
@ -4,13 +4,15 @@
|
||||
#include "monitor.h"
|
||||
#include "rpc_server.h"
|
||||
#include "send_msg.h"
|
||||
#include "spy_types.h"
|
||||
#include "spy_types.h"
|
||||
#include "sdk.h"
|
||||
|
||||
#include "../Rpc/rpc_h.h"
|
||||
#pragma comment(lib, "Rpcrt4.lib")
|
||||
#include "rpc_h.h"
|
||||
#pragma comment(lib, "Rpcrt4.lib")
|
||||
|
||||
extern HANDLE g_hEvent;
|
||||
extern MsgQueue_t g_MsgQueue;
|
||||
extern const MsgTypesMap_t g_WxMsgTypes;
|
||||
|
||||
int server_IsLogin() { return IsLogin(); }
|
||||
|
||||
@ -52,6 +54,32 @@ int server_SendImageMsg(const wchar_t *wxid, const wchar_t *path)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int server_GetMsgTypes(int *pNum, PPRpcIntBstrPair_t *msgTypes)
|
||||
{
|
||||
*pNum = g_WxMsgTypes.size();
|
||||
PPRpcIntBstrPair_t pp = (PPRpcIntBstrPair_t)midl_user_allocate(*pNum * sizeof(RpcIntBstrPair_t));
|
||||
if (pp == NULL) {
|
||||
printf("server_GetMsgTypes midl_user_allocate Failed for pp\n");
|
||||
return -2;
|
||||
}
|
||||
int index = 0;
|
||||
for (auto it = g_WxMsgTypes.begin(); it != g_WxMsgTypes.end(); ++it) {
|
||||
PRpcIntBstrPair_t p = (PRpcIntBstrPair_t)midl_user_allocate(sizeof(RpcIntBstrPair_t));
|
||||
if (p == NULL) {
|
||||
printf("server_GetMsgTypes midl_user_allocate Failed for p\n");
|
||||
return -3;
|
||||
}
|
||||
|
||||
p->key = it->first;
|
||||
p->value = SysAllocString(it->second.c_str());
|
||||
pp[index++] = p;
|
||||
}
|
||||
|
||||
*msgTypes = pp;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
RPC_STATUS CALLBACK SecurityCallback(RPC_IF_HANDLE /*hInterface*/, void * /*pBindingHandle*/)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user