Fix WxMsgTypes
This commit is contained in:
parent
de0c61cae9
commit
48091b8526
13
App/App.cpp
13
App/App.cpp
@ -39,12 +39,6 @@ int main()
|
|||||||
|
|
||||||
_wsetlocale(LC_ALL, L"chs"); // 这是个大坑,不设置中文直接不见了。。。
|
_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: ");
|
wprintf(L"WxInitSDK: ");
|
||||||
status = WxInitSDK();
|
status = WxInitSDK();
|
||||||
wcout << status << endl;
|
wcout << status << endl;
|
||||||
@ -53,6 +47,13 @@ int main()
|
|||||||
return 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");
|
wprintf(L"Message: 接收通知中......\n");
|
||||||
WxSetTextMsgCb(onTextMsg);
|
WxSetTextMsgCb(onTextMsg);
|
||||||
|
|
||||||
|
@ -19,9 +19,17 @@ interface ISpy
|
|||||||
BSTR content; // 消息内容,MAC版最大:16384,即16KB
|
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 IsLogin();
|
||||||
int SendTextMsg([ in, string ] const wchar_t *wxid, [ in, string ] const wchar_t *at_wxid, [ in, string ] const wchar_t *msg);
|
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 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();
|
void EnableReceiveMsg();
|
||||||
[callback] int ReceiveMsg([ in ] RpcMessage_t rpcMsg);
|
[callback] int ReceiveMsg([ in ] RpcMessage_t rpcMsg);
|
||||||
|
@ -113,6 +113,27 @@ int RpcSendImageMsg(const wchar_t *wxid, const wchar_t *path)
|
|||||||
return ret;
|
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)
|
int server_ReceiveMsg(RpcMessage_t rpcMsg)
|
||||||
{
|
{
|
||||||
WxMessage_t msg;
|
WxMessage_t msg;
|
||||||
|
@ -9,3 +9,4 @@ unsigned int __stdcall RpcSetTextMsgCb(void *p);
|
|||||||
int RpcIsLogin();
|
int RpcIsLogin();
|
||||||
int RpcSendTextMsg(const wchar_t *wxid, const wchar_t *at_wxid, const wchar_t *msg);
|
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);
|
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"
|
#include "util.h"
|
||||||
|
|
||||||
std::function<int(WxMessage_t)> g_cbReceiveTextMsg;
|
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()
|
int WxInitSDK()
|
||||||
{
|
{
|
||||||
@ -187,4 +169,19 @@ ContactMap_t WxGetContacts()
|
|||||||
return mContact;
|
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)); }
|
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) {
|
if (p != nullptr) {
|
||||||
ret = wstring(p);
|
ws = wstring(p);
|
||||||
SysFreeString(p);
|
SysFreeString(p);
|
||||||
}
|
}
|
||||||
return ret;
|
return ws;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetRpcMessage(WxMessage_t *wxMsg, RpcMessage_t rpcMsg)
|
void GetRpcMessage(WxMessage_t *wxMsg, RpcMessage_t rpcMsg)
|
||||||
|
@ -23,4 +23,5 @@ int GetWstringByAddress(DWORD address, wchar_t *buffer, DWORD buffer_size);
|
|||||||
BSTR GetBstrByAddress(DWORD address);
|
BSTR GetBstrByAddress(DWORD address);
|
||||||
void GetRpcMessage(WxMessage_t *wxMsg, RpcMessage_t rpcMsg);
|
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);
|
std::wstring GetUnicodeInfoByAddress(HANDLE hProcess, DWORD address);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "framework.h"
|
#include "framework.h"
|
||||||
|
|
||||||
#include "load_calls.h"
|
#include "load_calls.h"
|
||||||
#include "receive_msg.h"
|
#include "receive_msg.h"
|
||||||
@ -16,6 +16,25 @@ DWORD recvMsgCallAddr = 0;
|
|||||||
DWORD recvMsgJumpBackAddr = 0;
|
DWORD recvMsgJumpBackAddr = 0;
|
||||||
RpcMessage_t lMsg = { 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)
|
void DispatchMsg(DWORD reg)
|
||||||
{
|
{
|
||||||
DWORD* p = (DWORD*)reg; //消息结构基址
|
DWORD* p = (DWORD*)reg; //消息结构基址
|
||||||
|
@ -5,12 +5,14 @@
|
|||||||
#include "rpc_server.h"
|
#include "rpc_server.h"
|
||||||
#include "send_msg.h"
|
#include "send_msg.h"
|
||||||
#include "spy_types.h"
|
#include "spy_types.h"
|
||||||
|
#include "sdk.h"
|
||||||
|
|
||||||
#include "../Rpc/rpc_h.h"
|
#include "rpc_h.h"
|
||||||
#pragma comment(lib, "Rpcrt4.lib")
|
#pragma comment(lib, "Rpcrt4.lib")
|
||||||
|
|
||||||
extern HANDLE g_hEvent;
|
extern HANDLE g_hEvent;
|
||||||
extern MsgQueue_t g_MsgQueue;
|
extern MsgQueue_t g_MsgQueue;
|
||||||
|
extern const MsgTypesMap_t g_WxMsgTypes;
|
||||||
|
|
||||||
int server_IsLogin() { return IsLogin(); }
|
int server_IsLogin() { return IsLogin(); }
|
||||||
|
|
||||||
@ -53,6 +55,32 @@ int server_SendImageMsg(const wchar_t *wxid, const wchar_t *path)
|
|||||||
return 0;
|
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*/)
|
RPC_STATUS CALLBACK SecurityCallback(RPC_IF_HANDLE /*hInterface*/, void * /*pBindingHandle*/)
|
||||||
{
|
{
|
||||||
return RPC_S_OK; // Always allow anyone.
|
return RPC_S_OK; // Always allow anyone.
|
||||||
|
Loading…
Reference in New Issue
Block a user