Fix WxMsgTypes

This commit is contained in:
Changhua
2022-08-07 20:08:54 +08:00
parent de0c61cae9
commit 48091b8526
9 changed files with 112 additions and 36 deletions
+21
View File
@@ -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;
+1
View File
@@ -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);
+16 -19
View File
@@ -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;
}
+4 -4
View File
@@ -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)
+2 -1
View File
@@ -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);