From 1c0bdaf73dfb60a33104ad8e68cfeb17c736ed44 Mon Sep 17 00:00:00 2001 From: ttttupup Date: Wed, 24 Jul 2024 22:47:58 +0800 Subject: [PATCH] feat: 3.9.11.19 --- app/3rdparty/Detours | 2 +- app/base/src/include/utils.h | 7 + app/wxhelper/CMakeLists.txt | 2 +- app/wxhelper/src/chat_controller.cc | 69 ++- app/wxhelper/src/chat_room_controller.cc | 69 ++- app/wxhelper/src/contacts_controller.cc | 87 ++- app/wxhelper/src/http_router.h | 2 +- app/wxhelper/src/misc_controller.cc | 75 ++- app/wxhelper/src/offset.h | 108 ++++ app/wxhelper/src/wechat_interface.h | 25 + app/wxhelper/src/wechat_service.cc | 710 +++++++++++++++++++++-- app/wxhelper/src/wechat_service.h | 30 +- app/wxhelper/src/wxutils.cc | 14 + app/wxhelper/src/wxutils.h | 6 + script/ghidra_script/NamedScript.java | 129 ++++ script/ghidra_script/Sqllite3Script.java | 328 +++++++++++ 16 files changed, 1536 insertions(+), 127 deletions(-) create mode 100644 script/ghidra_script/NamedScript.java create mode 100644 script/ghidra_script/Sqllite3Script.java diff --git a/app/3rdparty/Detours b/app/3rdparty/Detours index 4b8c659..f920490 160000 --- a/app/3rdparty/Detours +++ b/app/3rdparty/Detours @@ -1 +1 @@ -Subproject commit 4b8c659f549b0ab21cf649377c7a84eb708f5e68 +Subproject commit f9204902c3e41ec7b78d1c4db069fcbac0e1a69a diff --git a/app/base/src/include/utils.h b/app/base/src/include/utils.h index cd1da97..17e2caf 100644 --- a/app/base/src/include/utils.h +++ b/app/base/src/include/utils.h @@ -7,6 +7,13 @@ namespace base { namespace utils { + +#define STRINGIFY(S) #S +#define DEFER_STRINGIFY(S) STRINGIFY(S) +#define PRAGMA_MESSAGE(MSG) _Pragma(STRINGIFY(message(MSG))) +#define FORMATTED_MESSAGE(MSG) "warning [TODO-" DEFER_STRINGIFY(__COUNTER__) "] " MSG " : " __FILE__ "(" DEFER_STRINGIFY(__LINE__) ")" +#define TODO(MSG) PRAGMA_MESSAGE(FORMATTED_MESSAGE(MSG)) + std::wstring Utf8ToWstring(const std::string &str); std::string WstringToUtf8(const std::wstring &str); diff --git a/app/wxhelper/CMakeLists.txt b/app/wxhelper/CMakeLists.txt index 59724eb..3360f85 100644 --- a/app/wxhelper/CMakeLists.txt +++ b/app/wxhelper/CMakeLists.txt @@ -30,7 +30,7 @@ add_subdirectory(../base base) add_library(wxhelper SHARED ${CPP_FILES} ${ASM_FILES}) -target_compile_definitions(wxhelper PRIVATE WECHAT_VERSION=391019) +target_compile_definitions(wxhelper PRIVATE WECHAT_VERSION=391119) # target_include_directories(wxhelper # PRIVATE ../base/src/include diff --git a/app/wxhelper/src/chat_controller.cc b/app/wxhelper/src/chat_controller.cc index 44ea1ce..0c60ead 100644 --- a/app/wxhelper/src/chat_controller.cc +++ b/app/wxhelper/src/chat_controller.cc @@ -5,6 +5,7 @@ #include "spdlog/spdlog.h" #include "wechat_interface.h" #include "wechat_service.h" +#include "utils.h" namespace jsonutils = wxhelper::jsonutils; namespace wxhelper { @@ -20,6 +21,7 @@ std::string ChatController::SendTextMsg(std::string params) { } std::string ChatController::SendImageMsg(std::string params) { + SPDLOG_INFO("SendImageMsg params={}", params); nlohmann::json jp = nlohmann::json::parse(params); std::wstring wxid = jsonutils::GetWStringParam(jp, "wxid"); std::wstring image_path = jsonutils::GetWStringParam(jp, "imagePath"); @@ -30,6 +32,7 @@ std::string ChatController::SendImageMsg(std::string params) { } std::string ChatController::SendFileMsg(std::string params) { + SPDLOG_INFO("SendFileMsg params={}", params); nlohmann::json jp = nlohmann::json::parse(params); std::wstring wxid = jsonutils::GetWStringParam(jp, "wxid"); std::wstring file_path = jsonutils::GetWStringParam(jp, "filePath"); @@ -40,6 +43,7 @@ std::string ChatController::SendFileMsg(std::string params) { } std::string ChatController::SendAtText(std::string params) { + SPDLOG_INFO("SendAtText params={}", params); nlohmann::json jp = nlohmann::json::parse(params); std::wstring chat_room_id = jsonutils::GetWStringParam(jp, "chatRoomId"); std::vector wxids = jsonutils::GetArrayParam(jp, "wxids"); @@ -51,6 +55,7 @@ std::string ChatController::SendAtText(std::string params) { } std::string ChatController::SendMultiAtText(std::string params) { + SPDLOG_INFO("SendMultiAtText params={}", params); nlohmann::json jp = nlohmann::json::parse(params); nlohmann::json array = jp["at"]; std::vector> at; @@ -67,19 +72,39 @@ std::string ChatController::SendMultiAtText(std::string params) { return ret.dump(); } + std::string ChatController::SendCustomEmotion(std::string params) { - nlohmann::json ret = { - {"code", 200}, {"data", {}}, {"msg", "Not Implemented"}}; + SPDLOG_INFO("SendCustomEmotion params={}", params); + nlohmann::json jp = nlohmann::json::parse(params); + std::wstring wxid = jsonutils::GetWStringParam(jp, "wxid"); + std::wstring file_path = jsonutils::GetWStringParam(jp, "filePath"); + int64_t success = + wechat::WeChatService::GetInstance().SendCustomEmotion(file_path, wxid); + nlohmann::json ret = {{"code", success}, {"data", {}}, {"msg", "success"}}; return ret.dump(); } +TODO("") std::string ChatController::SendApplet(std::string params) { - nlohmann::json ret = { - {"code", 200}, {"data", {}}, {"msg", "Not Implemented"}}; + SPDLOG_INFO("SendApplet params={}", params); + nlohmann::json jp = nlohmann::json::parse(params); + std::wstring wxid = jsonutils::GetWStringParam(jp, "wxid"); + std::wstring waid_concat = jsonutils::GetWStringParam(jp, "waidConcat"); + std::wstring waid = jsonutils::GetWStringParam(jp, "waid"); + std::wstring app_wxid = jsonutils::GetWStringParam(jp, "appletWxid"); + std::wstring json_param = jsonutils::GetWStringParam(jp, "jsonParam"); + std::wstring head_url = jsonutils::GetWStringParam(jp, "headImgUrl"); + std::wstring main_img = jsonutils::GetWStringParam(jp, "mainImg"); + std::wstring index_page = jsonutils::GetWStringParam(jp, "indexPage"); + int64_t success = wechat::WeChatService::GetInstance().SendApplet( + wxid, waid_concat, waid, waid, app_wxid, json_param, head_url, main_img, + index_page); + nlohmann::json ret = {{"code", success}, {"data", {}}, {"msg", "success"}}; return ret.dump(); } std::string ChatController::SendPatMsg(std::string params) { + SPDLOG_INFO("SendPatMsg params={}", params); nlohmann::json jp = nlohmann::json::parse(params); std::wstring room_id = jsonutils::GetWStringParam(jp, "receiver"); std::wstring wxid = jsonutils::GetWStringParam(jp, "wxid"); @@ -91,37 +116,55 @@ std::string ChatController::SendPatMsg(std::string params) { } std::string ChatController::ForwardMsg(std::string params) { + SPDLOG_INFO("ForwardMsg params={}", params); nlohmann::json jp = nlohmann::json::parse(params); std::wstring wxid = jsonutils::GetWStringParam(jp, "wxid"); int64_t msg_id = jsonutils::GetInt64Param(jp, "msgId"); int64_t success = wechat::WeChatService::GetInstance().ForwardMsg(msg_id, wxid); - nlohmann::json ret = { - {"code", success}, {"data", {}}, {"msg", "Not Implemented"}}; + nlohmann::json ret = {{"code", success}, {"data", {}}, {"msg", "success"}}; return ret.dump(); } std::string ChatController::ForwardPublicMsgByMsgId(std::string params) { - nlohmann::json ret = { - {"code", 200}, {"data", {}}, {"msg", "Not Implemented"}}; + SPDLOG_INFO("ForwardPublicMsgByMsgId params={}", params); + + nlohmann::json jp = nlohmann::json::parse(params); + std::wstring wxid = jsonutils::GetWStringParam(jp, "wxid"); + int64_t msg_id = jsonutils::GetInt64Param(jp, "msgId"); + int64_t success = + wechat::WeChatService::GetInstance().ForwardPublicMsgByMsgId(wxid, + msg_id); + + nlohmann::json ret = {{"code", success}, {"data", {}}, {"msg", "success"}}; return ret.dump(); } std::string ChatController::ForwardPublicMsg(std::string params) { - nlohmann::json ret = { - {"code", 200}, {"data", {}}, {"msg", "Not Implemented"}}; + SPDLOG_INFO("ForwardPublicMsg params={}", params); + nlohmann::json jp = nlohmann::json::parse(params); + std::wstring wxid = jsonutils::GetWStringParam(jp, "wxid"); + std::wstring appname = jsonutils::GetWStringParam(jp, "appName"); + std::wstring username = jsonutils::GetWStringParam(jp, "userName"); + std::wstring title = jsonutils::GetWStringParam(jp, "title"); + std::wstring url = jsonutils::GetWStringParam(jp, "url"); + std::wstring thumburl = jsonutils::GetWStringParam(jp, "thumbUrl"); + std::wstring digest = jsonutils::GetWStringParam(jp, "digest"); + INT64 success = wechat::WeChatService::GetInstance().ForwardPublicMsg( + wxid, title, url, thumburl, username, appname, digest); + nlohmann::json ret = {{"code", success}, {"data", {}}, {"msg", "success"}}; return ret.dump(); } std::string ChatController::GetContactOrChatRoomNickname(std::string params) { + SPDLOG_INFO("GetContactOrChatRoomNickname params={}", params); int64_t success = -1; nlohmann::json jp = nlohmann::json::parse(params); std::wstring wxid = jsonutils::GetWStringParam(jp, "wxid"); std::wstring nickname = wechat::WeChatService::GetInstance().GetContactOrChatRoomNickname(wxid); - nlohmann::json ret = {{"code", success}, - {"data", {"nickname", nickname}}, - {"msg", "Not Implemented"}}; + nlohmann::json ret = { + {"code", success}, {"data", {"nickname", nickname}}, {"msg", "success"}}; return ret.dump(); } diff --git a/app/wxhelper/src/chat_room_controller.cc b/app/wxhelper/src/chat_room_controller.cc index 5e89278..af044e9 100644 --- a/app/wxhelper/src/chat_room_controller.cc +++ b/app/wxhelper/src/chat_room_controller.cc @@ -5,6 +5,7 @@ #include "spdlog/spdlog.h" #include "wechat_interface.h" #include "wechat_service.h" +#include "utils.h" namespace wxhelper { std::string ChatRoomController::GetChatRoomDetailInfo(std::string params) { nlohmann::json jp = nlohmann::json::parse(params); @@ -31,7 +32,8 @@ std::string ChatRoomController::GetMemberFromChatRoom(std::string params) { wechat::ChatRoomMemberInner member; int64_t success = wechat::WeChatService::GetInstance().GetMemberFromChatRoom( room_id, member); - nlohmann::json ret_data = {{"code", success}, {"data", {}}, {"msg", "success"}}; + nlohmann::json ret_data = { + {"code", success}, {"data", {}}, {"msg", "success"}}; if (success > 0) { nlohmann::json member_info = { {"admin", member.admin}, @@ -56,8 +58,7 @@ std::string ChatRoomController::AddMemberToChatRoom(std::string params) { } int64_t success = wechat::WeChatService::GetInstance().AddMemberToChatRoom( room_id, wxid_list); - nlohmann::json ret = { - {"code", success}, {"data", {}}, {"msg", "success"}}; + nlohmann::json ret = {{"code", success}, {"data", {}}, {"msg", "success"}}; return ret.dump(); } std::string ChatRoomController::DelMemberFromChatRoom(std::string params) { @@ -70,44 +71,80 @@ std::string ChatRoomController::DelMemberFromChatRoom(std::string params) { for (unsigned int i = 0; i < wxids.size(); i++) { wxid_list.push_back(wxids[i]); } - INT64 success = wechat::WeChatService::GetInstance().DelMemberFromChatRoom( + int64_t success = wechat::WeChatService::GetInstance().DelMemberFromChatRoom( room_id, wxid_list); nlohmann::json ret_data = { {"code", success}, {"msg", "success"}, {"data", {}}}; return ret_data.dump(); } std::string ChatRoomController::CreateChatRoom(std::string params) { - nlohmann::json ret = { - {"code", 200}, {"data", {}}, {"msg", "Not Implemented"}}; + SPDLOG_INFO("CreateChatRoom params:{}", params); + nlohmann::json jp = nlohmann::json::parse(params); + std::vector wxids = jsonutils::GetArrayParam(jp, "memberIds"); + int64_t success = wechat::WeChatService::GetInstance().CreateChatRoom(wxids); + nlohmann::json ret = {{"code", success}, {"data", {}}, {"msg", "success"}}; return ret.dump(); } std::string ChatRoomController::QuitChatRoom(std::string params) { - nlohmann::json ret = { - {"code", 200}, {"data", {}}, {"msg", "Not Implemented"}}; + SPDLOG_INFO("QuitChatRoom params:{}", params); + nlohmann::json jp = nlohmann::json::parse(params); + std::wstring room_id = jsonutils::GetWStringParam(jp, "chatRoomId"); + int64_t success = wechat::WeChatService::GetInstance().QuitChatRoom(room_id); + nlohmann::json ret = {{"code", success}, {"data", {}}, {"msg", "success"}}; return ret.dump(); } std::string ChatRoomController::InviteMemberToChatRoom(std::string params) { - nlohmann::json ret = { - {"code", 200}, {"data", {}}, {"msg", "Not Implemented"}}; + SPDLOG_INFO("InviteMemberToChatRoom params:{}", params); + nlohmann::json jp = nlohmann::json::parse(params); + std::wstring room_id = jsonutils::GetWStringParam(jp, "chatRoomId"); + std::vector wxids = jsonutils::GetArrayParam(jp, "memberIds"); + int64_t success = wechat::WeChatService::GetInstance().InviteMemberToChatRoom( + room_id, wxids); + nlohmann::json ret = {{"code", success}, {"data", {}}, {"msg", "success"}}; return ret.dump(); } std::string ChatRoomController::TopMsg(std::string params) { - return std::string(); + SPDLOG_INFO("TopMsg params:{}", params); + nlohmann::json jp = nlohmann::json::parse(params); + int64_t msg_id = jsonutils::GetInt64Param(jp, "msgId"); + int64_t success = wechat::WeChatService::GetInstance().SetTopMsg(msg_id); + nlohmann::json ret = {{"code", success}, {"data", {}}, {"msg", "success"}}; + return ret.dump(); } std::string ChatRoomController::RemoveTopMsg(std::string params) { - nlohmann::json ret = { - {"code", 200}, {"data", {}}, {"msg", "Not Implemented"}}; + SPDLOG_INFO("RemoveTopMsg params:{}", params); + nlohmann::json jp = nlohmann::json::parse(params); + std::wstring room_id = jsonutils::GetWStringParam(jp, "chatRoomId"); + int64_t msg_id = jsonutils::GetInt64Param(jp, "msgId"); + int64_t success = + wechat::WeChatService::GetInstance().RemoveTopMsg(room_id, msg_id); + nlohmann::json ret = {{"code", success}, {"data", {}}, {"msg", "success"}}; return ret.dump(); } std::string ChatRoomController::GetChatRoomMemberNickname(std::string params) { + SPDLOG_INFO("GetChatRoomMemberNickname params:{}", params); + nlohmann::json jp = nlohmann::json::parse(params); + std::wstring room_id = jsonutils::GetWStringParam(jp, "chatRoomId"); + std::wstring member_id = jsonutils::GetWStringParam(jp, "memberId"); + std::wstring name = wechat::WeChatService::GetInstance().GetChatRoomMemberNickname(room_id, + member_id); nlohmann::json ret = { - {"code", 200}, {"data", {}}, {"msg", "Not Implemented"}}; + {"code", 1}, + {"data", {{"nickname", base::utils::WstringToUtf8(name)}}}, + {"msg", "success"}}; return ret.dump(); } std::string ChatRoomController::ModifyChatRoomMemberNickName( std::string params) { - nlohmann::json ret = { - {"code", 200}, {"data", {}}, {"msg", "Not Implemented"}}; + SPDLOG_INFO("ModifyChatRoomMemberNickName params:{}", params); + nlohmann::json jp = nlohmann::json::parse(params); + std::wstring room_id = jsonutils::GetWStringParam(jp, "chatRoomId"); + std::wstring wxid = jsonutils::GetWStringParam(jp, "wxid"); + std::wstring nickName = jsonutils::GetWStringParam(jp, "nickName"); + int64_t success = + wechat::WeChatService::GetInstance().ModChatRoomMemberNickName( + room_id, wxid, nickName); + nlohmann::json ret = {{"code", success}, {"msg", "success"}, {"data", {}}}; return ret.dump(); } } // namespace wxhelper diff --git a/app/wxhelper/src/contacts_controller.cc b/app/wxhelper/src/contacts_controller.cc index 9d638d7..616f391 100644 --- a/app/wxhelper/src/contacts_controller.cc +++ b/app/wxhelper/src/contacts_controller.cc @@ -1,13 +1,14 @@ #include "contacts_controller.h" +#include "json_utils.h" #include "nlohmann/json.hpp" #include "spdlog/spdlog.h" #include "wechat_interface.h" -#include "json_utils.h" #include "wechat_service.h" namespace jsonutils = wxhelper::jsonutils; - -std::string wxhelper::ContactsController::GetContactList(std::string params) { +namespace wxhelper { +std::string ContactsController::GetContactList(std::string params) { + SPDLOG_INFO("GetContactList params:{}", params); std::vector vec; int64_t success = wechat::WeChatService::GetInstance().GetContacts(vec); nlohmann::json ret_data = { @@ -34,33 +35,83 @@ std::string wxhelper::ContactsController::GetContactList(std::string params) { return ret_data.dump(); } -std::string wxhelper::ContactsController::GetContactProfile( +std::string ContactsController::GetContactProfile( std::string params) { - nlohmann::json ret = { - {"code", 200}, {"data", {}}, {"msg", "Not Implemented"}}; + SPDLOG_INFO("GetContactProfile params:{}", params); + nlohmann::json jp = nlohmann::json::parse(params); + std::wstring wxid = jsonutils::GetWStringParam(jp, "wxid"); + wechat::ContactProfileInner profile; + int64_t success = + wechat::WeChatService::GetInstance().GetContactByWxid(wxid, profile); + nlohmann::json ret = {{"code", success}, {"msg", "success"}, {"data", {}}}; + if (success == 1) { + nlohmann::json contact_profile = { + {"account", profile.account}, {"headImage", profile.head_image}, + {"nickname", profile.nickname}, {"v3", profile.v3}, + {"wxid", profile.wxid}, + }; + ret["data"] = contact_profile; + } + return ret.dump(); } -std::string wxhelper::ContactsController::DelContact(std::string params) { - nlohmann::json ret = { - {"code", 200}, {"data", {}}, {"msg", "Not Implemented"}}; +std::string ContactsController::DelContact(std::string params) { + SPDLOG_INFO("DelContact params:{}", params); + nlohmann::json jp = nlohmann::json::parse(params); + std::wstring wxid = jsonutils::GetWStringParam(jp, "wxid"); + int64_t success = wechat::WeChatService::GetInstance().DelContact(wxid); + nlohmann::json ret = {{"code", success}, {"data", {}}, {"msg", "success"}}; return ret.dump(); } -std::string wxhelper::ContactsController::SearchContact(std::string params) { - nlohmann::json ret = { - {"code", 200}, {"data", {}}, {"msg", "Not Implemented"}}; +std::string ContactsController::SearchContact(std::string params) { + SPDLOG_INFO("SearchContact params:{}", params); + nlohmann::json jp = nlohmann::json::parse(params); + std::wstring keyword = jsonutils::GetWStringParam(jp, "keyword"); + wechat::SearchContactInner contact; + int64_t success = + wechat::WeChatService::GetInstance().SearchContact(keyword, contact); + nlohmann::json ret = {{"code", success}, {"data", {}}, {"msg", "success"}}; + if (success == 1) { + nlohmann::json info = { + {"bigImage", contact.big_image}, + {"smallImage", contact.small_image}, + {"city", contact.city}, + {"nation", contact.nation}, + {"nickname", contact.nickname}, + {"province", contact.province}, + {"sex", contact.sex}, + {"signature", contact.signature}, + {"v2", contact.v2}, + {"v3", contact.v3}, + }; + ret["data"] = info; + } + return ret.dump(); } -std::string wxhelper::ContactsController::AddContact(std::string params) { - nlohmann::json ret = { - {"code", 200}, {"data", {}}, {"msg", "Not Implemented"}}; +std::string ContactsController::AddContact(std::string params) { + SPDLOG_INFO("AddContact params:{}", params); + nlohmann::json jp = nlohmann::json::parse(params); + std::wstring wxid = jsonutils::GetWStringParam(jp, "wxid"); + std::wstring msg = jsonutils::GetWStringParam(jp, "msg"); + int64_t success = + wechat::WeChatService::GetInstance().AddFriendByWxid(wxid, msg); + nlohmann::json ret = {{"code", success}, {"data", {}}, {"msg", "success"}}; return ret.dump(); } -std::string wxhelper::ContactsController::VerifyApply(std::string params) { - nlohmann::json ret = { - {"code", 200}, {"data", {}}, {"msg", "Not Implemented"}}; +std::string ContactsController::VerifyApply(std::string params) { + SPDLOG_INFO("VerifyApply params:{}", params); + nlohmann::json jp = nlohmann::json::parse(params); + std::wstring v3 = jsonutils::GetWStringParam(jp, "v3"); + std::wstring v4 = jsonutils::GetWStringParam(jp, "v4"); + int32_t permission = jsonutils::GetIntParam(jp, "permission"); + int64_t success = + wechat::WeChatService::GetInstance().VerifyApply(v3, v4, permission); + nlohmann::json ret = {{"code", success}, {"data", {}}, {"msg", "success"}}; return ret.dump(); } +} \ No newline at end of file diff --git a/app/wxhelper/src/http_router.h b/app/wxhelper/src/http_router.h index 2cca129..6a16bdc 100644 --- a/app/wxhelper/src/http_router.h +++ b/app/wxhelper/src/http_router.h @@ -1,7 +1,7 @@ #ifndef WXHELPER_HTTP_ROUTER_H_ #define WXHELPER_HTTP_ROUTER_H_ #include -#include +#include #include #include "singleton.h" diff --git a/app/wxhelper/src/misc_controller.cc b/app/wxhelper/src/misc_controller.cc index 9150d90..7e049d8 100644 --- a/app/wxhelper/src/misc_controller.cc +++ b/app/wxhelper/src/misc_controller.cc @@ -38,38 +38,65 @@ std::string MiscController::GetUserInfo(std::string params) { return ret.dump(); } std::string MiscController::GetSNSFirstPage(std::string params) { - nlohmann::json ret = { - {"code", 200}, {"data", {}}, {"msg", "Not Implemented"}}; + int64_t success = wechat::WeChatService::GetInstance().GetSNSFirstPage(); + nlohmann::json ret = {{"code", success}, {"data", {}}, {"msg", "success"}}; return ret.dump(); } std::string MiscController::GetSNSNextPage(std::string params) { - nlohmann::json ret = { - {"code", 200}, {"data", {}}, {"msg", "Not Implemented"}}; + SPDLOG_INFO("GetSNSNextPage params:{}", params); + nlohmann::json jp = nlohmann::json::parse(params); + int64_t sns_id = jsonutils::GetInt64Param(jp, "snsId"); + int64_t success = wechat::WeChatService::GetInstance().GetSNSNextPage(sns_id); + nlohmann::json ret = {{"code", success}, {"data", {}}, {"msg", "success"}}; return ret.dump(); } std::string MiscController::AddFavFromMsg(std::string params) { - nlohmann::json ret = { - {"code", 200}, {"data", {}}, {"msg", "Not Implemented"}}; + SPDLOG_INFO("AddFavFromMsg params:{}", params); + nlohmann::json jp = nlohmann::json::parse(params); + int64_t sns_id = jsonutils::GetInt64Param(jp, "msgId"); + int64_t success = wechat::WeChatService::GetInstance().AddFavFromMsg(sns_id); + nlohmann::json ret = {{"code", success}, {"data", {}}, {"msg", "success"}}; return ret.dump(); } std::string MiscController::AddFavFromImage(std::string params) { - nlohmann::json ret = { - {"code", 200}, {"data", {}}, {"msg", "Not Implemented"}}; + SPDLOG_INFO("AddFavFromImage params:{}", params); + nlohmann::json jp = nlohmann::json::parse(params); + std::wstring wxid = jsonutils::GetWStringParam(jp, "wxid"); + std::wstring image_path = jsonutils::GetWStringParam(jp, "imagePath"); + int64_t success = + wechat::WeChatService::GetInstance().AddFavFromImage(wxid, image_path); + nlohmann::json ret = {{"code", success}, {"data", {}}, {"msg", "success"}}; return ret.dump(); } std::string MiscController::DecodeImage(std::string params) { - nlohmann::json ret = { - {"code", 200}, {"data", {}}, {"msg", "Not Implemented"}}; + SPDLOG_INFO("DecodeImage params:{}", params); + nlohmann::json jp = nlohmann::json::parse(params); + std::wstring file_path = jsonutils::GetWStringParam(jp, "filePath"); + std::wstring store_dir = jsonutils::GetWStringParam(jp, "storeDir"); + int64_t success = + wechat::WeChatService::GetInstance().DecodeImage(file_path, store_dir); + nlohmann::json ret = {{"code", success}, {"data", {}}, {"msg", "success"}}; return ret.dump(); } std::string MiscController::GetVoiceByMsgId(std::string params) { - nlohmann::json ret = { - {"code", 200}, {"data", {}}, {"msg", "Not Implemented"}}; + SPDLOG_INFO("GetVoiceByMsgId params:{}", params); + nlohmann::json jp = nlohmann::json::parse(params); + int64_t msg_id = jsonutils::GetInt64Param(jp, "msgId"); + std::wstring store_dir = jsonutils::GetWStringParam(jp, "storeDir"); + int64_t success = + wechat::WeChatService::GetInstance().GetVoiceByDB(msg_id, store_dir); + nlohmann::json ret = {{"code", success}, {"data", {}}, {"msg", "success"}}; return ret.dump(); } std::string MiscController::DoOcrTask(std::string params) { + SPDLOG_INFO("DoOcrTask params:{}", params); + nlohmann::json jp = nlohmann::json::parse(params); + std::wstring image_path = jsonutils::GetWStringParam(jp, "imagePath"); + std::string text(""); + int64_t success = + wechat::WeChatService::GetInstance().DoOCRTask(image_path, text); nlohmann::json ret = { - {"code", 200}, {"data", {}}, {"msg", "Not Implemented"}}; + {"code", success}, {"data", {{"content", text}}}, {"msg", "success"}}; return ret.dump(); } std::string MiscController::LockWeChat(std::string params) { @@ -94,6 +121,7 @@ std::string MiscController::GetLoginUrl(std::string params) { return ret.dump(); } std::string MiscController::TranslateVoice(std::string params) { + SPDLOG_INFO("TranslateVoice params:{}", params); nlohmann::json jp = nlohmann::json::parse(params); int64_t msg_id = jsonutils::GetInt64Param(jp, "msgId"); int64_t success = wechat::WeChatService::GetInstance().TranslateVoice(msg_id); @@ -110,23 +138,32 @@ std::string MiscController::GetTranslateVoiceText(std::string params) { return ret_data.dump(); } std::string MiscController::OpenUrlByWeChat(std::string params) { + SPDLOG_INFO("OpenUrlByWeChat params:{}", params); nlohmann::json jp = nlohmann::json::parse(params); std::wstring url = jsonutils::GetWStringParam(jp, "url"); int flag = jsonutils::GetIntParam(jp, "flag"); int64_t success = wechat::WeChatService::GetInstance().OpenUrlByWeChatBrowser(url, flag); - nlohmann::json ret = { - {"code", success}, {"data", {}}, {"msg", "Not Implemented"}}; + nlohmann::json ret = {{"code", success}, {"data", {}}, {"msg", "success"}}; return ret.dump(); } std::string MiscController::ConfirmReceipt(std::string params) { - nlohmann::json ret = { - {"code", 200}, {"data", {}}, {"msg", "Not Implemented"}}; + SPDLOG_INFO("ConfirmReceipt params:{}", params); + nlohmann::json jp = nlohmann::json::parse(params); + std::wstring wxid = jsonutils::GetWStringParam(jp, "wxid"); + std::wstring transcationid = jsonutils::GetWStringParam(jp, "transcationId"); + std::wstring transferid = jsonutils::GetWStringParam(jp, "transferId"); + int64_t success = wechat::WeChatService::GetInstance().DoConfirmReceipt( + wxid, transcationid, transferid); + nlohmann::json ret = {{"code", success}, {"data", {}}, {"msg", "success"}}; return ret.dump(); } std::string MiscController::DownloadAttach(std::string params) { - nlohmann::json ret = { - {"code", 200}, {"data", {}}, {"msg", "Not Implemented"}}; + SPDLOG_INFO("DownloadAttach params:{}", params); + nlohmann::json jp = nlohmann::json::parse(params); + int64_t msg_id = jsonutils::GetInt64Param(jp, "msgId"); + int64_t success = wechat::WeChatService::GetInstance().DoDownloadTask(msg_id); + nlohmann::json ret = {{"code", success}, {"data", {}}, {"msg", "success"}}; return ret.dump(); } } // namespace wxhelper diff --git a/app/wxhelper/src/offset.h b/app/wxhelper/src/offset.h index 841b5b0..fa11d3e 100644 --- a/app/wxhelper/src/offset.h +++ b/app/wxhelper/src/offset.h @@ -5,6 +5,7 @@ namespace wechat { #define V_3_9_8_25 39825 #define V_3_9_9_43 39943 #define V_3_9_10_19 391019 +#define V_3_9_11_19 391119 #ifndef WECHAT_VERSION #error " WECHAT_VERSION not defined ." #endif @@ -349,6 +350,113 @@ const uint64_t kFreeWebViewPageConfig = 0x951520; const uint64_t kGetWebViewMgr = 0x9412d0; const uint64_t kShowWebView = 0x1d236b0; const uint64_t kSetUrl = 0x13dd410; +#elif WECHAT_VERSION == V_3_9_11_19 +const uint64_t kGetAccountServiceMgr = 0x1b50d00; +const uint64_t kSyncMsg = 0xc39680; +const uint64_t kSyncMsgNext = 0xc39680; +const uint64_t kGetCurrentDataPath = 0x2248ce0; +const uint64_t kGetAppDataSavePath = 0x25dc0e0; +const uint64_t kGetSendMessageMgr = 0x1b4f500; +const uint64_t kSendTextMsg = 0x22c2010; +const uint64_t kFreeChatMsg = 0x1b50d80; + +const uint64_t kDoAddMsg = 0x230a3e0; +const uint64_t kSendImageMsg = 0x22b77a0; +const uint64_t kChatMsgInstanceCounter = 0x1b59670; +const uint64_t kSendFileMsg = 0x20cb6f0; +const uint64_t kGetAppMsgMgr = 0x1b544a0; +const uint64_t kGetContactMgr = 0x1b3ccd0; +const uint64_t kGetContactList = 0x219a1c0; + +const uint64_t k_sqlite3_exec = 0x3a59b30; +const uint64_t k_sqlite3_prepare = 0x3a617b0; +const uint64_t k_sqlite3_open = 0x3a98fa0; +const uint64_t k_sqlite3_step = 0x3a1db30; +const uint64_t k_sqlite3_column_count = 0x3a1e350; +const uint64_t k_sqlite3_column_name = 0x3a1ed50; +const uint64_t k_sqlite3_column_type = 0x3a1eba0; +const uint64_t k_sqlite3_column_blob = 0x3a1e380; +const uint64_t k_sqlite3_column_bytes = 0x3a1e470; +const uint64_t k_sqlite3_finalize = 0x3a1cbe0; + +const uint64_t kGPInstance = 0x58dd300; +const uint64_t kMultiDBMgr = 0x593abf8; +const uint64_t kPublicMsgMgr = 0x5938198; +const uint64_t kFavoriteStorageMgr = 0x593b790; +const uint64_t kHardLinkMgr = 0x593ab28; + +const uint64_t kChatRoomMgr = 0x1b7f100; +const uint64_t kGetChatRoomDetailInfo = 0x2160bb0; +const uint64_t kNewChatRoomInfo = 0x2505120; +const uint64_t kFreeChatRoomInfo = 0x2505300; +const uint64_t kDoAddMemberToChatRoom = 0x21505b0; +const uint64_t kDoModChatRoomMemberNickName = 0x215a360; +const uint64_t kDelMemberFromChatRoom = 0x2150bf0; +const uint64_t kGetMemberFromChatRoom = 0x2162400; +const uint64_t kNewChatRoom = 0x2502540; +const uint64_t kFreeChatRoom = 0x2502740; + +const uint64_t kTopMsg = 0x1d7d160; +const uint64_t kRemoveTopMsg = 0x2166090; +const uint64_t kInviteMember = 0x214ff90; +const uint64_t kHookLog = 0x1304e60; + +const uint64_t kCreateChatRoom = 0x214fc60; +const uint64_t kQuitChatRoom = 0x215ac00; +const uint64_t kForwardMsg = 0x22c1590; + +const uint64_t kOnSnsTimeLineSceneFinish = 0x1a73150; +const uint64_t kSNSGetFirstPage = 0x2e1bec0; +const uint64_t kSNSGetNextPageScene = 0x2e41a70; +const uint64_t kSNSDataMgr = 0x21dd6b0; +const uint64_t kSNSTimeLineMgr = 0x2dadf20; +const uint64_t kGetMgrByPrefixLocalId = 0x213afb0; +const uint64_t kAddFavFromMsg = 0x2930e40; +const uint64_t kGetChatMgr = 0x1b82bf0; +const uint64_t kGetFavoriteMgr = 0x1b57ba0; +const uint64_t kAddFavFromImage = 0x293d0f0; +const uint64_t kGetContact = 0x21945d0; +const uint64_t kNewContact = 0x2519300; +const uint64_t kFreeContact = 0x25199b0; +const uint64_t kNewMMReaderItem = 0x8c79a0; +const uint64_t kFreeMMReaderItem = 0x8c6da0; +const uint64_t kForwordPublicMsg = 0xddc6c0; +const uint64_t kParseAppMsgXml = 0x11b0a70; +const uint64_t kNewAppMsgInfo = 0x91a550; +const uint64_t kFreeAppMsgInfo = 0x8fd1a0; +const uint64_t kGetPreDownLoadMgr = 0x9996f0; +const uint64_t kPushAttachTask = 0x9c0080; +const uint64_t kGetCustomSmileyMgr = 0x1ca0320; +const uint64_t kSendCustomEmotion = 0x21b04c0; +const uint64_t kNewJsApiShareAppMessage = 0x26cda20; +const uint64_t kInitJsConfig = 0x137bc00; +const uint64_t kSendApplet = 0x13c0920; +const uint64_t kSendAppletSecond = 0x13c1150; +const uint64_t kGetAppInfoByWaid = 0x13c5790; +const uint64_t kCopyShareAppMessageRequest = 0x13c0670; +const uint64_t kNewWAUpdatableMsgInfo = 0x919ca0; +const uint64_t kFreeWAUpdatableMsgInfo = 0x8fc230; +const uint64_t kSendPatMsg = 0x2ca9790; +const uint64_t kGetOCRManager = 0x999780; +const uint64_t kDoOCRTask = 0x2c53910; + +const uint64_t kGetLockWechatMgr = 0x1c85010; +const uint64_t kRequestLockWechat = 0x1c397d0; +const uint64_t kRequestUnLockWechat = 0x1c39a70; + +const uint64_t kOnLoginBtnClick = 0x202bc30; + +const uint64_t kGetQRCodeLoginMgr = 0x201e350; + +const uint64_t kUpdateMsg = 0x21421a0; +const uint64_t kGetVoiceMgr = 0x1e13320; +const uint64_t kChatMsg2NetSceneSendMsg = 0x1b70fd0; +const uint64_t kTranslateVoice = 0x11217e0; +const uint64_t kNewWebViewPageConfig = 0x9512f0; +const uint64_t kFreeWebViewPageConfig = 0x951520; +const uint64_t kGetWebViewMgr = 0x1b43950; +const uint64_t kShowWebView = 0x302ed30; +const uint64_t kSetUrl = 0x13dd410; #else #ifdef WECHAT_VERSION #error "Unsupported WeChat version." diff --git a/app/wxhelper/src/wechat_interface.h b/app/wxhelper/src/wechat_interface.h index 5fc2d8b..c3bdb19 100644 --- a/app/wxhelper/src/wechat_interface.h +++ b/app/wxhelper/src/wechat_interface.h @@ -128,6 +128,31 @@ struct ContactProfileInner { : wxid(""), account(""), v3(""), nickname(""), head_image("") {} }; +struct SearchContactInner { + std::string big_image; + std::string small_image; + std::string city; + std::string nation; + std::string province; + std::string signature; + std::string v2; + std::string v3; + std::string nickname; + int32_t sex; + SearchContactInner() + : big_image(""), + small_image(""), + city(""), + nation(""), + province(""), + signature(""), + sex(-1), + v2(""), + v3(""), + nickname("") {} +}; + + namespace function { //hook typedef uint64_t(*__DoAddMsg)(uint64_t, uint64_t, uint64_t); diff --git a/app/wxhelper/src/wechat_service.cc b/app/wxhelper/src/wechat_service.cc index 649c0fc..9ea5188 100644 --- a/app/wxhelper/src/wechat_service.cc +++ b/app/wxhelper/src/wechat_service.cc @@ -7,6 +7,20 @@ #include "utils.h" #include "wechat_db.h" #include "wxutils.h" + +#define BUFSIZE 1024 +#define JPEG0 0xFF +#define JPEG1 0xD8 +#define JPEG2 0xFF +#define PNG0 0x89 +#define PNG1 0x50 +#define PNG2 0x4E +#define BMP0 0x42 +#define BMP1 0x4D +#define GIF0 0x47 +#define GIF1 0x49 +#define GIF2 0x46 + namespace offset = wechat::offset; namespace prototype = wechat::prototype; namespace func = wechat::function; @@ -269,7 +283,7 @@ int64_t wechat::WeChatService::SendImageMsg(const std::wstring& wxid, uint64_t temp2 = 0; uint64_t temp3 = 1; uint64_t* flag[10] = {}; - flag[0] = reinterpret_cast(temp3); + flag[0] = reinterpret_cast(temp3); flag[8] = &temp1; flag[9] = &temp2; flag[1] = reinterpret_cast(p_chat_msg_temp); @@ -385,27 +399,33 @@ int64_t wechat::WeChatService::GetContacts(std::vector& vec) { int64_t wechat::WeChatService::GetChatRoomDetailInfo( const std::wstring& room_id, ChatRoomInfoInner& room_info) { - int64_t success = -1; + int64_t success = -1; prototype::WeChatString chat_room_id(room_id); int64_t base_addr = wxutils::GetWeChatWinBase(); uint64_t get_chat_room_mgr_addr = base_addr + offset::kChatRoomMgr; - uint64_t get_chat_room_detail_addr = base_addr + offset::kGetChatRoomDetailInfo; + uint64_t get_chat_room_detail_addr = + base_addr + offset::kGetChatRoomDetailInfo; uint64_t create_chat_room_info_addr = base_addr + offset::kNewChatRoomInfo; uint64_t free_chat_room_info_addr = base_addr + offset::kFreeChatRoomInfo; - - func::__GetChatRoomMgr get_chat_room_mgr = (func::__GetChatRoomMgr)get_chat_room_mgr_addr; - func::__NewChatRoomInfo new_chat_room_info = (func::__NewChatRoomInfo)create_chat_room_info_addr; - func::__FreeChatRoomInfo free_chat_room_info = (func::__FreeChatRoomInfo)free_chat_room_info_addr; - func::__GetChatRoomDetailInfo get_chat_room_detail = (func::__GetChatRoomDetailInfo)get_chat_room_detail_addr; + func::__GetChatRoomMgr get_chat_room_mgr = + (func::__GetChatRoomMgr)get_chat_room_mgr_addr; + func::__NewChatRoomInfo new_chat_room_info = + (func::__NewChatRoomInfo)create_chat_room_info_addr; + func::__FreeChatRoomInfo free_chat_room_info = + (func::__FreeChatRoomInfo)free_chat_room_info_addr; + func::__GetChatRoomDetailInfo get_chat_room_detail = + (func::__GetChatRoomDetailInfo)get_chat_room_detail_addr; char chat_room_info[0x144] = {0}; - - uint64_t new_room_info = new_chat_room_info(reinterpret_cast(&chat_room_info)); + + uint64_t new_room_info = + new_chat_room_info(reinterpret_cast(&chat_room_info)); uint64_t mgr = get_chat_room_mgr(); - success = get_chat_room_detail(mgr,reinterpret_cast(&chat_room_id),new_room_info,1); - + success = get_chat_room_detail(mgr, reinterpret_cast(&chat_room_id), + new_room_info, 1); + room_info.chat_room_id = wxutils::ReadWstringThenConvert(new_room_info + 0x8); room_info.notice = wxutils::ReadWstringThenConvert(new_room_info + 0x28); room_info.admin = wxutils::ReadWstringThenConvert(new_room_info + 0x48); @@ -425,10 +445,10 @@ int64_t wechat::WeChatService::AddMemberToChatRoom( func::__DoAddMemberToChatRoom add_members = (func::__DoAddMemberToChatRoom)add_members_addr; - prototype::WeChatString *chat_room_id = (prototype::WeChatString *)HeapAlloc( + prototype::WeChatString* chat_room_id = (prototype::WeChatString*)HeapAlloc( GetProcessHeap(), 0, sizeof(prototype::WeChatString)); - wchar_t *p_chat_room_id = - (wchar_t *)HeapAlloc(GetProcessHeap(), 0, (room_id.size() + 1) * 2); + wchar_t* p_chat_room_id = + (wchar_t*)HeapAlloc(GetProcessHeap(), 0, (room_id.size() + 1) * 2); wmemcpy(p_chat_room_id, room_id.c_str(), room_id.size() + 1); chat_room_id->ptr = p_chat_room_id; chat_room_id->length = static_cast(room_id.size()); @@ -438,7 +458,7 @@ int64_t wechat::WeChatService::AddMemberToChatRoom( std::vector member_list; uint64_t temp[2] = {0}; - wechat::VectorInner *list = (wechat::VectorInner *)&member_list; + wechat::VectorInner* list = (wechat::VectorInner*)&member_list; int64_t members_ptr = (int64_t)&list->start; for (int i = 0; i < members.size(); i++) { prototype::WeChatString member(members[i]); @@ -454,7 +474,18 @@ int64_t wechat::WeChatService::AddMemberToChatRoom( int64_t wechat::WeChatService::ModChatRoomMemberNickName( const std::wstring& room_id, const std::wstring& wxid, const std::wstring& nickname) { - return 0; + int64_t success = -1; + uint64_t mod_addr = base_addr_ + offset::kDoModChatRoomMemberNickName; + func::__DoModChatRoomMemberNickName modify = + (func::__DoModChatRoomMemberNickName)mod_addr; + const wchar_t* p = room_id.c_str(); + prototype::WeChatString* chat_room_id = BuildWechatString(room_id); + prototype::WeChatString* self_id = BuildWechatString(wxid); + prototype::WeChatString* name = BuildWechatString(nickname); + success = modify( + reinterpret_cast(p), reinterpret_cast(chat_room_id), + reinterpret_cast(self_id), reinterpret_cast(name)); + return success; } int64_t wechat::WeChatService::DelMemberFromChatRoom( @@ -499,7 +530,7 @@ int64_t wechat::WeChatService::GetMemberFromChatRoom( prototype::WeChatString chat_room_id(room_id); char chat_room_info[0x308] = {0}; - uint64_t addr = new_chat_room(reinterpret_cast(&chat_room_info)); + uint64_t addr = new_chat_room(reinterpret_cast(&chat_room_info)); uint64_t mgr = get_chat_room_mgr(); success = get_members(mgr, reinterpret_cast(&chat_room_id), addr); member.chat_room_id = wxutils::ReadWstringThenConvert(addr + 0x10); @@ -511,25 +542,96 @@ int64_t wechat::WeChatService::GetMemberFromChatRoom( return success; } -int64_t wechat::WeChatService::SetTopMsg(uint64_t msg_id) { return 0; } +int64_t wechat::WeChatService::SetTopMsg(uint64_t msg_id) { + int64_t success = -1; + uint64_t top_addr = base_addr_ + offset::kTopMsg; + func::__DoTopMsg top_msg = (func::__DoTopMsg)top_addr; + int64_t index = 0; + int64_t local_id = + wechat::WeChatDb::GetInstance().GetLocalIdByMsgId(msg_id, index); + if (local_id <= 0 || index >> 32 == 0) { + success = -2; + return success; + } + LARGE_INTEGER l; + l.HighPart = index >> 32; + l.LowPart = (DWORD)local_id; + uint64_t ptr = reinterpret_cast(&l); + success = top_msg(ptr, 1); + + return success; +} int64_t wechat::WeChatService::RemoveTopMsg(const std::wstring& room_id, - ULONG64 msg_id) { - return 0; + uint64_t msg_id) { + int64_t success = -1; + uint64_t remove_addr = base_addr_ + offset::kRemoveTopMsg; + func::__RemoveTopMsg remove_top_msg = (func::__RemoveTopMsg)remove_addr; + prototype::WeChatString* chat_room_id = BuildWechatString(room_id); + const wchar_t* w_room = room_id.c_str(); + success = remove_top_msg(reinterpret_cast(w_room), msg_id, + reinterpret_cast(chat_room_id)); + return success; } - +TODO("InviteMemberToChatRoom") int64_t wechat::WeChatService::InviteMemberToChatRoom( const std::wstring& room_id, const std::vector& wxids) { - return 0; + int64_t success = -1; + uint64_t invite_addr = base_addr_ + offset::kInviteMember; + func::__InviteMemberToChatRoom invite = + (func::__InviteMemberToChatRoom)invite_addr; + const wchar_t* w_room = room_id.c_str(); + prototype::WeChatString* chat_room_id = BuildWechatString(room_id); + std::vector wxid_list; + wechat::VectorInner* list = (wechat::VectorInner*)&wxid_list; + int64_t head = (int64_t)&list->start; + for (int i = 0; i < wxids.size(); i++) { + prototype::WeChatString id(wxids[i]); + wxid_list.push_back(id); + } + uint64_t temp[2] = {0}; + success = invite(reinterpret_cast(w_room), head, + reinterpret_cast(chat_room_id), + reinterpret_cast(&temp)); + return success; } +TODO("CreateChatRoom") int64_t wechat::WeChatService::CreateChatRoom( const std::vector& wxids) { - return 0; + int64_t success = -1; + uint64_t get_chat_room_mgr_addr = base_addr_ + offset::kChatRoomMgr; + uint64_t create_chat_room_addr = base_addr_ + offset::kCreateChatRoom; + func::__GetChatRoomMgr get_chat_room_mgr = + (func::__GetChatRoomMgr)get_chat_room_mgr_addr; + func::__CreateChatRoom create_chat_room = + (func::__CreateChatRoom)create_chat_room_addr; + std::vector wxid_list; + wechat::VectorInner* list = (wechat::VectorInner*)&wxid_list; + int64_t head = (int64_t)&list->start; + for (int i = 0; i < wxids.size(); i++) { + prototype::WeChatString id(wxids[i]); + wxid_list.push_back(id); + } + int64_t end = list->end; + uint64_t mgr = get_chat_room_mgr(); + success = create_chat_room(mgr, head, end); + return success; } +TODO("QuitChatRoom") int64_t wechat::WeChatService::QuitChatRoom(const std::wstring& room_id) { - return 0; + int64_t success = -1; + uint64_t get_chat_room_mgr_addr = base_addr_ + offset::kChatRoomMgr; + uint64_t quit_chat_room_addr = base_addr_ + offset::kQuitChatRoom; + func::__GetChatRoomMgr get_chat_room_mgr = + (func::__GetChatRoomMgr)get_chat_room_mgr_addr; + func::__QuitChatRoom quit_chat_room = + (func::__QuitChatRoom)quit_chat_room_addr; + uint64_t mgr = get_chat_room_mgr(); + prototype::WeChatString chat_room_id(room_id); + success = quit_chat_room(mgr, reinterpret_cast(&chat_room_id), 0); + return success; } int64_t wechat::WeChatService::ForwardMsg(uint64_t msg_id, @@ -553,17 +655,92 @@ int64_t wechat::WeChatService::ForwardMsg(uint64_t msg_id, return success; } -int64_t wechat::WeChatService::GetSNSFirstPage() { return 0; } - -int64_t wechat::WeChatService::GetSNSNextPage(uint64_t sns_id) { return 0; } - -int64_t wechat::WeChatService::AddFavFromMsg(uint64_t msg_id) { return 0; } - -int64_t wechat::WeChatService::AddFavFromImage(const std::wstring& wxid, - const std::wstring& image_path) { - return 0; +TODO("GetSNSFirstPage") +int64_t wechat::WeChatService::GetSNSFirstPage() { + int64_t success = -1; + uint64_t sns_data_mgr_addr = base_addr_ + offset::kSNSDataMgr; + uint64_t sns_first_page_addr = base_addr_ + offset::kSNSGetFirstPage; + func::__GetSNSDataMgr sns_data_mgr = (func::__GetSNSDataMgr)sns_data_mgr_addr; + func::__GetSNSFirstPage sns_first_page = + (func::__GetSNSFirstPage)sns_first_page_addr; + uint64_t mgr = sns_data_mgr(); + int64_t buff[16] = {0}; + success = sns_first_page(mgr, reinterpret_cast(&buff), 1); + return success; } +TODO("GetSNSNextPage") +int64_t wechat::WeChatService::GetSNSNextPage(uint64_t sns_id) { + int64_t success = -1; + uint64_t time_line_mgr_addr = base_addr_ + offset::kSNSTimeLineMgr; + uint64_t sns_next_page_addr = base_addr_ + offset::kSNSGetNextPageScene; + func::__GetSnsTimeLineMgr time_line_mgr = + (func::__GetSnsTimeLineMgr)time_line_mgr_addr; + func::__GetSNSNextPageScene sns_next_page = + (func::__GetSNSNextPageScene)sns_next_page_addr; + uint64_t mgr = time_line_mgr(); + success = sns_next_page(mgr, sns_id); + return success; +} + +TODO("AddFavFromMsg") +int64_t wechat::WeChatService::AddFavFromMsg(uint64_t msg_id) { + int64_t success = -1; + uint64_t get_chat_mgr_addr = base_addr_ + offset::kGetChatMgr; + uint64_t get_by_local_id_addr = base_addr_ + offset::kGetMgrByPrefixLocalId; + uint64_t add_fav_addr = base_addr_ + offset::kAddFavFromMsg; + uint64_t get_favorite_mgr_addr = base_addr_ + offset::kGetFavoriteMgr; + uint64_t free_chat_msg_addr = base_addr_ + offset::kFreeChatMsg; + func::__GetMgrByPrefixLocalId get_by_local_id = + (func::__GetMgrByPrefixLocalId)get_by_local_id_addr; + uint64_t new_chat_msg_addr = base_addr_ + offset::kChatMsgInstanceCounter; + + func::__AddFavFromMsg add_fav = (func::__AddFavFromMsg)add_fav_addr; + func::__GetChatMgr get_chat_mgr = (func::__GetChatMgr)get_chat_mgr_addr; + func::__GetFavoriteMgr get_favorite_mgr = + (func::__GetFavoriteMgr)get_favorite_mgr_addr; + func::__FreeChatMsg free_chat_msg = (func::__FreeChatMsg)free_chat_msg_addr; + func::__NewChatMsg new_chat_msg = (func::__NewChatMsg)new_chat_msg_addr; + + int64_t index = 0; + int64_t local_id = + wechat::WeChatDb::GetInstance().GetLocalIdByMsgId(msg_id, index); + if (local_id <= 0 || index >> 32 == 0) { + success = -2; + return success; + } + char chat_msg[0x460] = {0}; + LARGE_INTEGER l; + l.HighPart = index >> 32; + l.LowPart = (DWORD)local_id; + uint64_t p_chat_msg = new_chat_msg(reinterpret_cast(&chat_msg)); + + get_chat_mgr(); + get_by_local_id(l.QuadPart, p_chat_msg); + uint64_t mgr = get_favorite_mgr(); + success = add_fav(mgr, p_chat_msg); + free_chat_msg(p_chat_msg); + return success; +} + +TODO("AddFavFromImage") +int64_t wechat::WeChatService::AddFavFromImage(const std::wstring& wxid, + const std::wstring& image_path) { + int64_t success = -1; + uint64_t get_favorite_mgr_addr = base_addr_ + offset::kGetFavoriteMgr; + uint64_t add_fav_from_image_addr = base_addr_ + offset::kAddFavFromImage; + prototype::WeChatString* send_id = BuildWechatString(wxid); + prototype::WeChatString* path = BuildWechatString(image_path); + func::__GetFavoriteMgr get_favorite_mgr = + (func::__GetFavoriteMgr)get_favorite_mgr_addr; + func::__AddFavFromImage add_fav_from_image = + (func::__AddFavFromImage)add_fav_from_image_addr; + uint64_t mgr = get_favorite_mgr(); + success = add_fav_from_image(mgr, reinterpret_cast(path), + reinterpret_cast(send_id)); + return success; +} +TODO("SendAtText") int64_t wechat::WeChatService::SendAtText( const std::wstring& room_id, const std::vector& wxids, const std::wstring& msg) { @@ -612,7 +789,7 @@ int64_t wechat::WeChatService::SendAtText( free(reinterpret_cast(&chat_msg)); return 0; } - +TODO("GetContactOrChatRoomNickname") std::wstring wechat::WeChatService::GetContactOrChatRoomNickname( const std::wstring& wxid) { int64_t success = -1; @@ -641,13 +818,169 @@ std::wstring wechat::WeChatService::GetContactOrChatRoomNickname( } } +TODO("GetContactByWxid") int64_t wechat::WeChatService::GetContactByWxid(const std::wstring& wxid, ContactProfileInner& profile) { - return 0; + int64_t success = -1; + prototype::WeChatString to_user(wxid); + uint64_t get_contact_mgr_addr = base_addr_ + offset::kGetContactMgr; + uint64_t new_contact_addr = base_addr_ + offset::kNewContact; + uint64_t get_contact_addr = base_addr_ + offset::kGetContact; + uint64_t free_contact_addr = base_addr_ + offset::kFreeContact; + func::__GetContactMgr get_contact_mgr = + (func::__GetContactMgr)get_contact_mgr_addr; + func::__GetContact get_contact = (func::__GetContact)get_contact_addr; + func::__NewContact new_contact = (func::__NewContact)new_contact_addr; + func::__FreeContact free_contact = (func::__FreeContact)free_contact_addr; + char buff[0x6A9] = {0}; + uint64_t contact = new_contact(reinterpret_cast(&buff)); + uint64_t mgr = get_contact_mgr(); + success = get_contact(mgr, reinterpret_cast(&to_user), contact); + profile.wxid = wxutils::ReadWstringThenConvert(contact + 0x10); + profile.account = wxutils::ReadWstringThenConvert(contact + 0x30); + profile.v3 = wxutils::ReadWstringThenConvert(contact + 0x50); + profile.nickname = wxutils::ReadWstringThenConvert(contact + 0xA0); + profile.head_image = wxutils::ReadWstringThenConvert(contact + 0x188); + free_contact(contact); + return success; } -int64_t wechat::WeChatService::DoDownloadTask(uint64_t msg_id) { return 0; } +TODO("DoDownloadTask") +int64_t wechat::WeChatService::DoDownloadTask(uint64_t msg_id) { + int64_t success = -1; + uint64_t get_by_local_id_addr = base_addr_ + offset::kGetMgrByPrefixLocalId; + func::__GetMgrByPrefixLocalId get_by_local_id = + (func::__GetMgrByPrefixLocalId)get_by_local_id_addr; + uint64_t get_chat_mgr_addr = base_addr_ + offset::kGetChatMgr; + func::__GetChatMgr get_chat_mgr = (func::__GetChatMgr)get_chat_mgr_addr; + + uint64_t free_chat_msg_addr = base_addr_ + offset::kFreeChatMsg; + func::__FreeChatMsg free_chat_msg = (func::__FreeChatMsg)free_chat_msg_addr; + + uint64_t new_chat_msg_addr = base_addr_ + offset::kChatMsgInstanceCounter; + func::__NewChatMsg new_chat_msg = (func::__NewChatMsg)new_chat_msg_addr; + + uint64_t get_current_data_path_addr = + base_addr_ + offset::kGetCurrentDataPath; + func::__GetCurrentDataPath GetCurrentDataPath = + (func::__GetCurrentDataPath)get_current_data_path_addr; + + uint64_t new_app_msg_info_addr = base_addr_ + offset::kNewAppMsgInfo; + func::__NewAppMsgInfo new_app_msg_info = + (func::__NewAppMsgInfo)new_app_msg_info_addr; + + uint64_t free_app_msg_info_addr = base_addr_ + offset::kFreeAppMsgInfo; + func::__FreeAppMsgInfo free_app_msg_info = + (func::__NewAppMsgInfo)free_app_msg_info_addr; + + uint64_t xml_to_app_info_addr = base_addr_ + offset::kParseAppMsgXml; + func::__ParseAppMsgXml xml_to_app_info = + (func::__ParseAppMsgXml)xml_to_app_info_addr; + + uint64_t get_pre_download_mgr_addr = base_addr_ + offset::kGetPreDownLoadMgr; + func::__GetPreDownLoadMgr get_pre_download_mgr = + (func::__GetPreDownLoadMgr)get_pre_download_mgr_addr; + + uint64_t push_attach_task_addr = base_addr_ + offset::kPushAttachTask; + func::__PushAttachTask push_attach_task = + (func::__PushAttachTask)push_attach_task_addr; + + int64_t index = 0; + int64_t local_id = + wechat::WeChatDb::GetInstance().GetLocalIdByMsgId(msg_id, index); + if (local_id <= 0 || index >> 32 == 0) { + success = -2; + return success; + } + char* chat_msg = base::utils::WxHeapAlloc(0x460); + LARGE_INTEGER l; + l.HighPart = index >> 32; + l.LowPart = (DWORD)local_id; + uint64_t p_chat_msg = new_chat_msg(reinterpret_cast(chat_msg)); + + get_chat_mgr(); + get_by_local_id(l.QuadPart, p_chat_msg); + + std::wstring save_path = L""; + std::wstring thumb_path = L""; + + prototype::WeChatString current_data_path; + GetCurrentDataPath(reinterpret_cast(¤t_data_path)); + + if (current_data_path.length > 0) { + save_path += current_data_path.ptr; + save_path += L"wxhelper"; + } else { + return -1; + } + + if (!wxutils::FindOrCreateDirectory(save_path)) { + return -3; + } + int64_t type = *(int64_t*)(chat_msg + 0x38); + wchar_t* content = *(wchar_t**)(chat_msg + 0x88); + DWORD len = *(DWORD*)(chat_msg + 0x94); + std::wstring tmp_content(content, len); + prototype::WeChatString* we_content = BuildWechatString(tmp_content); + + switch (type) { + case 0x3: { + save_path += L"\\image"; + if (!wxutils::FindOrCreateDirectory(save_path)) { + return -3; + } + thumb_path = save_path + L"\\" + std::to_wstring(msg_id) + L"_t.dat"; + save_path = save_path + L"\\" + std::to_wstring(msg_id) + L".dat"; + break; + } + case 0x3E: + case 0x2B: { + save_path += L"\\video"; + if (!wxutils::FindOrCreateDirectory(save_path)) { + return -3; + } + thumb_path = save_path + L"\\" + std::to_wstring(msg_id) + L".jpg"; + save_path = save_path + L"\\" + std::to_wstring(msg_id) + L".mp4"; + + break; + } + case 0x31: { + save_path += L"\\file"; + if (!wxutils::FindOrCreateDirectory(save_path)) { + return -3; + } + char* p_xml_app_msg = base::utils::WxHeapAlloc(0x3000); + uint64_t xml_msg = + new_app_msg_info(reinterpret_cast(p_xml_app_msg)); + uint64_t result = + xml_to_app_info(xml_msg, reinterpret_cast(we_content), 1); + if (result != 1) { + return -4; + } + std::wstring file_name = wxutils::ReadWstring(xml_msg + 0x70); + save_path = + save_path + L"\\" + std::to_wstring(msg_id) + L"_" + file_name; + free_app_msg_info(xml_msg); + break; + } + default: + break; + } + prototype::WeChatString* we_save_path = BuildWechatString(save_path); + prototype::WeChatString* we_thumb_path = BuildWechatString(thumb_path); + int temp = 1; + memcpy(chat_msg + 0x280, we_thumb_path, sizeof(prototype::WeChatString)); + memcpy(chat_msg + 0x2A0, we_save_path, sizeof(prototype::WeChatString)); + memcpy(chat_msg + 0x40C, &temp, sizeof(temp)); + UINT64 mgr = get_pre_download_mgr(); + success = push_attach_task(mgr, p_chat_msg, 0, 1); + free_chat_msg(p_chat_msg); + + return success; +} + +TODO("ForwardPublicMsg") int64_t wechat::WeChatService::ForwardPublicMsg(const std::wstring& wxid, const std::wstring& title, const std::wstring& url, @@ -658,33 +991,218 @@ int64_t wechat::WeChatService::ForwardPublicMsg(const std::wstring& wxid, return 0; } +TODO("ForwardPublicMsgByMsgId") int64_t wechat::WeChatService::ForwardPublicMsgByMsgId(const std::wstring& wxid, uint64_t msg_id) { return 0; } - +TODO("DecodeImage") int64_t wechat::WeChatService::DecodeImage(const std::wstring& file_path, const std::wstring& save_dir) { - return 0; -} + if (!wxutils::FindOrCreateDirectory(save_dir)) { + return 0; + } + int64_t pos_begin = file_path.find_last_of(L"\\") + 1; + int64_t pos_end = file_path.find_last_of(L"."); + std::wstring file_name = file_path.substr(pos_begin, pos_end - pos_begin); + HANDLE h_origin_file = + CreateFileW(file_path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, NULL); + char buffer[BUFSIZE] = {0}; + DWORD bytes_read = 0; + DWORD bytes_write = 0; + unsigned char magic_head[4] = {0}; + std::wstring suffix; + short key = 0; + if (ReadFile(h_origin_file, buffer, BUFSIZE, &bytes_read, NULL)) { + memcpy(magic_head, buffer, 3); + } else { + CloseHandle(h_origin_file); + return 0; + } + if ((magic_head[0] ^ JPEG0) == (magic_head[1] ^ JPEG1)) { + key = magic_head[0] ^ JPEG0; + suffix = L".jpg"; + } else if ((magic_head[0] ^ PNG1) == (magic_head[1] ^ PNG2)) { + key = magic_head[0] ^ PNG1; + suffix = L".png"; + } else if ((magic_head[0] ^ GIF0) == (magic_head[1] ^ GIF1)) { + key = magic_head[0] ^ GIF0; + suffix = L".gif"; + } else if ((magic_head[0] ^ BMP0) == (magic_head[1] ^ BMP1)) { + key = magic_head[0] ^ BMP0; + suffix = L".bmp"; + } else { + key = -1; + suffix = L".dat"; + } + std::wstring save_img_path = save_dir + L"\\" + file_name + suffix; + HANDLE save_img = CreateFileW(save_img_path.c_str(), GENERIC_ALL, 0, NULL, + CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (save_img == INVALID_HANDLE_VALUE) { + return 0; + } + if (key > 0) { + for (unsigned int i = 0; i < bytes_read; i++) { + buffer[i] ^= key; + } + } + if (!WriteFile(save_img, (LPCVOID)buffer, bytes_read, &bytes_write, 0)) { + CloseHandle(h_origin_file); + CloseHandle(save_img); + return 0; + } + + do { + if (ReadFile(h_origin_file, buffer, BUFSIZE, &bytes_read, NULL)) { + if (key > 0) { + for (unsigned int i = 0; i < bytes_read; i++) { + buffer[i] ^= key; + } + } + if (!WriteFile(save_img, (LPCVOID)buffer, bytes_read, &bytes_write, 0)) { + CloseHandle(h_origin_file); + CloseHandle(save_img); + return 0; + } + } + } while (bytes_read == BUFSIZE); + CloseHandle(h_origin_file); + CloseHandle(save_img); + return 1; +} +TODO("GetVoiceByDB") int64_t wechat::WeChatService::GetVoiceByDB(ULONG64 msg_id, const std::wstring& dir) { return 0; } - +TODO("SendCustomEmotion") int64_t wechat::WeChatService::SendCustomEmotion(const std::wstring& file_path, const std::wstring& wxid) { - return 0; + int64_t success = -1; + uint64_t get_custom_smiley_mgr_addr = + base_addr_ + offset::kGetCustomSmileyMgr; + func::__GetCustomSmileyMgr get_custom_smiley_mgr = + (func::__GetCustomSmileyMgr)get_custom_smiley_mgr_addr; + uint64_t send_custom_emotion_addr = base_addr_ + offset::kSendCustomEmotion; + func::__SendCustomEmotion send_custom_emotion = + (func::__SendCustomEmotion)send_custom_emotion_addr; + prototype::WeChatString* path = BuildWechatString(file_path); + prototype::WeChatString* recv = BuildWechatString(wxid); + int64_t* temp = base::utils::WxHeapAlloc(0x20); + memset(temp, 0, 0x20); + uint64_t mgr = get_custom_smiley_mgr(); + success = send_custom_emotion( + mgr, reinterpret_cast(path), reinterpret_cast(temp), + reinterpret_cast(recv), 2, reinterpret_cast(temp), 0, + reinterpret_cast(temp)); + return success; } +TODO("SendApplet") int64_t wechat::WeChatService::SendApplet( const std::wstring& recv_wxid, const std::wstring& waid_suff, - const std::wstring& waid_w, const std::string& waid_s, - const std::string& wa_wxid, const std::string& json_param, - const std::string& head_image, const std::string& big_image, - const std::string& index_page) { - return 0; + const std::wstring& waid_w, const std::wstring& waid_s, + const std::wstring& wa_wxid, const std::wstring& json_param, + const std::wstring& head_image, const std::wstring& big_image, + const std::wstring& index_page) { + int64_t success = -1; + if (js_api_addr_ == 0) { + auto vec2 = + base::memory::ScanAndMatchValue(base_addr_ + 0x32D1318, 0x1000, 0x8); + for (int i = 0; i < vec2.size(); i++) { + int64_t ptr = vec2.at(i); + if (*(int64_t*)ptr == base_addr_ + 0x32D1318) { + js_api_addr_ = ptr; + break; + } + } + } + if (js_api_addr_ == 0) { + success = -2; + return success; + } + + uint64_t share_app_msg_addr = base_addr_ + offset::kNewJsApiShareAppMessage; + func::__JsApiShareAppMessage share_app_msg = + (func::__JsApiShareAppMessage)share_app_msg_addr; + + uint64_t init_addr = base_addr_ + offset::kInitJsConfig; + func::__InitJsConfig init = (func::__InitJsConfig)init_addr; + + uint64_t send_applet_addr = base_addr_ + offset::kSendApplet; + func::__SendApplet send_applet = (func::__SendApplet)send_applet_addr; + + uint64_t get_by_waid_addr = base_addr_ + offset::kGetAppInfoByWaid; + func::__GetAppInfoByWaid get_app_info = + (func::__GetAppInfoByWaid)get_by_waid_addr; + + uint64_t copy_app_req_addr = base_addr_ + offset::kCopyShareAppMessageRequest; + func::__CopyShareAppMessageRequest copy_app_req = + (func::__CopyShareAppMessageRequest)copy_app_req_addr; + + uint64_t new_wa_msg_addr = base_addr_ + offset::kNewWAUpdatableMsgInfo; + func::__NewWAUpdatableMsgInfo new_wa_msg = + (func::__NewWAUpdatableMsgInfo)new_wa_msg_addr; + + uint64_t free_wa_msg_addr = base_addr_ + offset::kFreeWAUpdatableMsgInfo; + func::__FreeWAUpdatableMsgInfo free_wa_msg = + (func::__FreeWAUpdatableMsgInfo)free_wa_msg_addr; + + std::vector* temp = + base::utils::WxHeapAlloc>(0x20); + // std::vector* temp = new + // std::vector(); + wechat::VectorInner* list = (wechat::VectorInner*)temp; + + prototype::WeChatString* member = BuildWechatString(recv_wxid); +#ifdef _DEBUG + list->head = reinterpret_cast(member); +#endif + list->start = reinterpret_cast(member); + list->finsh = reinterpret_cast(member) + 0x20; + list->end = reinterpret_cast(member) + 0x20; + + uint64_t head = reinterpret_cast(&(list->start)); + + prototype::WeChatString* waid_cat = BuildWechatString(waid_suff); + prototype::WeChatString* waid = BuildWechatString(waid_w); + + prototype::WeChatString* waid_2 = BuildWechatString(waid_suff); + + prototype::WeChatString* waid_str = BuildWechatString(waid_s); + prototype::WeChatString* app_wxid = BuildWechatString(wa_wxid); + prototype::WeChatString* json_str = BuildWechatString(json_param); + prototype::WeChatString* head_image_url = BuildWechatString(head_image); + prototype::WeChatString* image = BuildWechatString(big_image); + prototype::WeChatString* index = BuildWechatString(index_page); + + uint64_t app_msg = js_api_addr_; + + uint64_t data = *(uint64_t*)(app_msg + 0x8); + char* share_req = base::utils::WxHeapAlloc(0x2000); + + char* mid_ptr = base::utils::WxHeapAlloc(0x18); + memcpy(mid_ptr, &share_req, sizeof(INT64)); + memcpy(mid_ptr + 0x8, &share_req, sizeof(INT64)); + memcpy(mid_ptr + 0x10, &share_req, sizeof(INT64)); + + memcpy((void*)data, mid_ptr, 0x18); + + memcpy(share_req, (void*)(app_msg + 0x8), sizeof(uint64_t)); + memcpy(share_req + 0x8, (void*)(app_msg + 0x8), sizeof(uint64_t)); + memcpy(share_req + 0x10, (void*)(app_msg + 0x8), sizeof(uint64_t)); + memcpy(share_req + 0x20, waid_2, sizeof(prototype::WeChatString)); + memcpy(share_req + 0x48, waid_str, sizeof(prototype::WeChatStr)); + memcpy(share_req + 0x98, app_wxid, sizeof(prototype::WeChatStr)); + memcpy(share_req + 0xF8, json_str, sizeof(prototype::WeChatStr)); + memcpy(share_req + 0x178, head_image_url, sizeof(prototype::WeChatStr)); + memcpy(share_req + 0x198, image, sizeof(prototype::WeChatStr)); + memcpy(share_req + 0x1c0, index, sizeof(prototype::WeChatStr)); + + success = send_applet(app_msg, reinterpret_cast(waid_cat), head, 0); + return success; } int64_t wechat::WeChatService::SendPatMsg(const std::wstring& room_id, @@ -699,9 +1217,40 @@ int64_t wechat::WeChatService::SendPatMsg(const std::wstring& room_id, return success; } +TODO("DoOCRTask") int64_t wechat::WeChatService::DoOCRTask(const std::wstring& img_path, std::string& result) { - return 0; + int64_t success = -1; + uint64_t ocr_manager_addr = base_addr_ + offset::kGetOCRManager; + func::__GetOCRManager ocr_manager = (func::__GetOCRManager)ocr_manager_addr; + + uint64_t do_ocr_task_addr = base_addr_ + offset::kDoOCRTask; + func::__DoOCRTask do_ocr_task = (func::__DoOCRTask)do_ocr_task_addr; + + prototype::WeChatString img(img_path); + std::vector* temp = + base::utils::WxHeapAlloc>(0x20); + int64_t unkonwn = 0; + wechat::VectorInner* list = (wechat::VectorInner*)temp; + list->start = reinterpret_cast(&list->start); + list->finsh = list->start; + char buff[0x28] = {0}; + memcpy(buff, &list->start, sizeof(INT64)); + uint64_t mgr = ocr_manager(); + success = do_ocr_task(mgr, reinterpret_cast(&img), 1, + reinterpret_cast(buff), + reinterpret_cast(&unkonwn)); + int64_t number = *(int64_t*)(buff + 0x8); + if (number > 0) { + int64_t header = *(int64_t*)(buff); + for (unsigned int i = 0; i < number; i++) { + int64_t content = *(int64_t*)header; + result += wxutils::ReadWstringThenConvert(content + 0x28); + result += "\r\n"; + header = content; + } + } + return success; } int64_t wechat::WeChatService::LockWeChat() { @@ -737,10 +1286,10 @@ int64_t wechat::WeChatService::EnterWeChat() { uint64_t click_cb_addr = base_addr + offset::kOnLoginBtnClick; func::__OnLoginBtnClick cb = (func::__OnLoginBtnClick)click_cb_addr; auto vec = - base::memory::ScanAndMatchValue(base_addr + 0x34e0c18, 0x1000, 0x8); + base::memory::ScanAndMatchValue(base_addr + 0x4ecedf8, 0x1000, 0x8); for (int i = 0; i < vec.size(); i++) { int64_t ptr = vec.at(i); - if (*(int64_t*)ptr == base_addr + 0x34e0c18) { + if (*(int64_t*)ptr == base_addr + 0x4ecedf8) { int64_t login_wnd = ptr; success = cb(ptr); break; @@ -749,6 +1298,7 @@ int64_t wechat::WeChatService::EnterWeChat() { return success; } +TODO("SendMultiAtText") int64_t wechat::WeChatService::SendMultiAtText( const std::wstring& room_id, const std::vector>& at) { @@ -805,10 +1355,15 @@ std::string wechat::WeChatService::GetLoginUrl() { return "http://weixin.qq.com/x/" + login_url; } -void wechat::WeChatService::SetBaseAddr(uint64_t addr) {} +void wechat::WeChatService::SetBaseAddr(uint64_t addr) { + this->base_addr_ = addr; +} -void wechat::WeChatService::SetJsApiAddr(uint64_t addr) {} +void wechat::WeChatService::SetJsApiAddr(uint64_t addr) { + this->js_api_addr_ = addr; +} +TODO("TranslateVoice") int64_t wechat::WeChatService::TranslateVoice(uint64_t msg_id) { int64_t success = -1; uint64_t get_by_local_id_addr = base_addr_ + offset::kGetMgrByPrefixLocalId; @@ -865,6 +1420,7 @@ int64_t wechat::WeChatService::TranslateVoice(uint64_t msg_id) { return success; } +TODO("GetTranslateVoiceText") std::string wechat::WeChatService::GetTranslateVoiceText(uint64_t msg_id) { std::string content = wechat::WeChatDb::GetInstance().GetChatMsgStrContentByMsgId(msg_id); @@ -888,6 +1444,7 @@ std::string wechat::WeChatService::GetTranslateVoiceText(uint64_t msg_id) { return ""; } +TODO("OpenUrlByWeChatBrowser") int64_t wechat::WeChatService::OpenUrlByWeChatBrowser(const std::wstring& url, int flag) { int64_t success = -1; @@ -922,3 +1479,52 @@ int64_t wechat::WeChatService::OpenUrlByWeChatBrowser(const std::wstring& url, free_config(ptr); return success; } + +TODO("GetChatRoomMemberNickname") +std::wstring wechat::WeChatService::GetChatRoomMemberNickname( + const std::wstring& room_id, const std::wstring& member_id) { + return std::wstring(); +} + +TODO("DelContact") +int64_t wechat::WeChatService::DelContact(const std::wstring& wxid) { + return 0; +} + +TODO("SearchContact") +int64_t wechat::WeChatService::SearchContact( + const std::wstring& keyword, wechat::SearchContactInner& contact) { + return 0; +} + +TODO("AddFriendByWxid") +int64_t wechat::WeChatService::AddFriendByWxid(const std::wstring& wxid, + const std::wstring& msg) { + return 0; +} + +TODO("VerifyApply") +int64_t wechat::WeChatService::VerifyApply(const std::wstring& v3, + const std::wstring& v4, + int32_t permission) { + return 0; +} + +TODO("DoConfirmReceipt") +int64_t wechat::WeChatService::DoConfirmReceipt( + const std::wstring& wxid, const std::wstring& transcationid, + const std::wstring& transferid) { + int success = -1; + prototype::WeChatString recv_id(wxid); + prototype::WeChatString transcation_id(transcationid); + prototype::WeChatString transfer_id(transferid); + + return success; +} + +TODO("DoRefuseReceipt") +int64_t wechat::WeChatService::DoRefuseReceipt( + const std::wstring& wxid, const std::wstring& transcationid, + const std::wstring& transferid) { + return 0; +} diff --git a/app/wxhelper/src/wechat_service.h b/app/wxhelper/src/wechat_service.h index 0262eae..3a677fc 100644 --- a/app/wxhelper/src/wechat_service.h +++ b/app/wxhelper/src/wechat_service.h @@ -37,7 +37,7 @@ class WeChatService : public base::Singleton { int64_t GetMemberFromChatRoom(const std::wstring& room_id, ChatRoomMemberInner& member); int64_t SetTopMsg(uint64_t msg_id); - int64_t RemoveTopMsg(const std::wstring& room_id, ULONG64 msg_id); + int64_t RemoveTopMsg(const std::wstring& room_id, uint64_t msg_id); int64_t InviteMemberToChatRoom(const std::wstring& room_id, const std::vector& wxids); int64_t CreateChatRoom(const std::vector& wxids); @@ -70,11 +70,11 @@ class WeChatService : public base::Singleton { const std::wstring& wxid); int64_t SendApplet(const std::wstring& recv_wxid, const std::wstring& waid_suff, const std::wstring& waid_w, - const std::string& waid_s, const std::string& wa_wxid, - const std::string& json_param, - const std::string& head_image, - const std::string& big_image, - const std::string& index_page); + const std::wstring& waid_s, const std::wstring& wa_wxid, + const std::wstring& json_param, + const std::wstring& head_image, + const std::wstring& big_image, + const std::wstring& index_page); int64_t SendPatMsg(const std::wstring& room_id, const std::wstring& wxid); int64_t DoOCRTask(const std::wstring& img_path, std::string& result); int64_t LockWeChat(); @@ -88,6 +88,24 @@ class WeChatService : public base::Singleton { int64_t TranslateVoice(uint64_t msg_id); std::string GetTranslateVoiceText(uint64_t msg_id); int64_t OpenUrlByWeChatBrowser(const std::wstring& url, int flag); + std::wstring GetChatRoomMemberNickname(const std::wstring& room_id, + const std::wstring& member_id); + int64_t DelContact(const std::wstring& wxid); + + int64_t SearchContact(const std::wstring& keyword, + wechat::SearchContactInner& contact); + + int64_t AddFriendByWxid(const std::wstring& wxid, const std::wstring& msg); + + int64_t VerifyApply(const std::wstring& v3, const std::wstring& v4, + int32_t permission); + int64_t DoConfirmReceipt(const std::wstring& wxid, + const std::wstring& transcationid, + const std::wstring& transferid); + + int64_t DoRefuseReceipt(const std::wstring& wxid, + const std::wstring& transcationid, + const std::wstring& transferid); private: uint64_t base_addr_; diff --git a/app/wxhelper/src/wxutils.cc b/app/wxhelper/src/wxutils.cc index 2ca2a33..d50b67b 100644 --- a/app/wxhelper/src/wxutils.cc +++ b/app/wxhelper/src/wxutils.cc @@ -105,6 +105,20 @@ int DecodeImage(const wchar_t *file_path, const wchar_t *save_dir) { return -1; } +bool FindOrCreateDirectory(const std::wstring &path) { + WIN32_FIND_DATAW fd; + HANDLE found = ::FindFirstFileW(path.c_str(), &fd); + if (found != INVALID_HANDLE_VALUE && + (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { + FindClose(found); + return true; + } + + if (!::CreateDirectoryW(path.c_str(), NULL)) { + return false; + } + return true; +} } // namespace wxutils } // namespace wxhelper diff --git a/app/wxhelper/src/wxutils.h b/app/wxhelper/src/wxutils.h index bad00e0..581d537 100644 --- a/app/wxhelper/src/wxutils.h +++ b/app/wxhelper/src/wxutils.h @@ -5,6 +5,11 @@ #include namespace wxhelper { namespace wxutils { + + + + + #ifdef _WIN64 int64_t GetWeChatWinBase(); #else @@ -18,6 +23,7 @@ std::string ImageXor(std::string buf); std::wstring ReadWstring(INT64 addr); std::string ReadWstringThenConvert(INT64 addr); int DecodeImage(const wchar_t* file_path, const wchar_t* save_dir); + bool FindOrCreateDirectory(const std::wstring &path); } // namespace wxutils } // namespace wxhelper diff --git a/script/ghidra_script/NamedScript.java b/script/ghidra_script/NamedScript.java new file mode 100644 index 0000000..a9317c4 --- /dev/null +++ b/script/ghidra_script/NamedScript.java @@ -0,0 +1,129 @@ +import java.util.Iterator; +import ghidra.app.decompiler.DecompInterface; +import ghidra.app.decompiler.DecompileOptions; +import ghidra.app.decompiler.DecompileResults; +import ghidra.app.script.GhidraScript; +import ghidra.program.model.address.Address; +import ghidra.program.model.address.AddressFactory; +import ghidra.program.model.address.AddressSpace; +import ghidra.program.model.listing.CodeUnit; +import ghidra.program.model.listing.Data; +import ghidra.program.model.listing.Function; +import ghidra.program.model.listing.FunctionManager; +import ghidra.program.model.listing.Listing; +import ghidra.program.model.pcode.HighFunction; +import ghidra.program.model.pcode.PcodeOp; +import ghidra.program.model.pcode.PcodeOpAST; +import ghidra.program.model.pcode.Varnode; +import ghidra.program.model.symbol.Reference; +import ghidra.program.model.symbol.ReferenceIterator; +import ghidra.program.model.symbol.ReferenceManager; +import ghidra.program.model.symbol.SourceType; +import ghidra.util.exception.DuplicateNameException; +import ghidra.util.exception.InvalidInputException; + +public class NamedScript extends GhidraScript { + + @Override + protected void run() throws Exception { + Address selectAddress = askAddress("选择log地址", "wechat log地址:"); + Listing listing = currentProgram.getListing(); + FunctionManager functionManager = currentProgram.getFunctionManager(); + ReferenceManager referenceManager = currentProgram.getReferenceManager(); + AddressFactory addressFactory = currentProgram.getAddressFactory(); + + AddressSpace space = addressFactory.getDefaultAddressSpace(); + AddressSpace[] addressSpaces = addressFactory.getAddressSpaces(); + + DecompInterface decompiler = new DecompInterface(); + DecompileOptions decompileOptions = new DecompileOptions(); + decompiler.setOptions(decompileOptions); + decompiler.openProgram(currentProgram); + + + Address funcAddress = selectAddress; + Function logFunction = functionManager.getFunctionAt(funcAddress); +// for (AddressSpace sp : addressSpaces) { +// funcAddress = sp.getAddress(selectAddress.getOffset()); +// logFunction = functionManager.getFunctionAt(funcAddress); +// space = sp; +// if (null != logFunction) { +// break; +// } +// } + + ReferenceIterator referenceIterator = referenceManager.getReferencesTo(logFunction.getEntryPoint()); + for (Reference ref : referenceIterator) { + Address fromAddress = ref.getFromAddress(); +// if (fromAddress.getOffset() != 0x18284bb19L) { +// continue; +// } + handle(fromAddress, functionManager, decompiler, space, listing,selectAddress); + println("caller address: " + fromAddress); + } + + } + + private void handle(Address address, FunctionManager functionManager, DecompInterface decompiler, + AddressSpace space, Listing listing,Address selectAddress) { + Function functionContaining = functionManager.getFunctionContaining(address); + if (null == functionContaining) { + println("no found function: " + address); + return; + } + DecompileResults res = decompiler.decompileFunction(functionContaining, 20, null); + if (!res.decompileCompleted()) { + println("Symbol " + res.getErrorMessage()); + return; + } + HighFunction highFunction = res.getHighFunction(); + Iterator pcodeOps = highFunction.getPcodeOps(); + while (pcodeOps.hasNext()) { + PcodeOpAST next = pcodeOps.next(); + int opcode = next.getOpcode(); + int numInputs = next.getNumInputs(); + if (PcodeOp.CALL == opcode || PcodeOp.CALLIND == opcode || PcodeOp.CALLOTHER == opcode) { + Varnode input0 = next.getInput(0); + boolean contains = input0.contains(selectAddress); + + if (contains) { + Varnode input4 = next.getInput(4); + if (input4 == null) { + continue; + } + PcodeOp def4 = input4.getDef(); + if (null != def4) { + Address param4Address = null; + + if (def4.getOpcode() == PcodeOp.COPY) { + Varnode vn0 = def4.getInput(0); + param4Address = space.getAddress(vn0.getAddress().getOffset()); + + Data dataAt = listing.getDataAt(param4Address); + if (dataAt.hasStringValue()) { + Object value = dataAt.getValue(); + String funcStr = value.toString(); + println("func:" + funcStr); + try { + functionContaining.setName(funcStr, SourceType.USER_DEFINED); + listing.setComment(functionContaining.getEntryPoint(), CodeUnit.EOL_COMMENT, + "auto define:" + funcStr); + } catch (DuplicateNameException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InvalidInputException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + } + + } + + } + } + } + +} diff --git a/script/ghidra_script/Sqllite3Script.java b/script/ghidra_script/Sqllite3Script.java new file mode 100644 index 0000000..00f99ab --- /dev/null +++ b/script/ghidra_script/Sqllite3Script.java @@ -0,0 +1,328 @@ +// sqlite function +//@author +//@category _NEW_ +//@keybinding +//@menupath +//@toolbar + +import java.util.regex.Pattern; + +import ghidra.app.script.GhidraScript; +import ghidra.program.model.lang.*; +import ghidra.util.exception.DuplicateNameException; +import ghidra.util.exception.InvalidInputException; +import ghidra.program.model.symbol.*; +import ghidra.program.model.listing.*; +import ghidra.program.model.address.*; + +public class Sqllite3Script extends GhidraScript { + + public void run() throws Exception { + + run2(); + + } + + private void run2() { + Listing listing = currentProgram.getListing(); + AddressSpace defaultAddressSpace = currentProgram.getAddressFactory().getDefaultAddressSpace(); + SymbolTable symbolTable = currentProgram.getSymbolTable(); + FunctionManager functionManager = currentProgram.getFunctionManager(); + Language language = currentProgram.getLanguage(); + LanguageDescription languageDescription = language.getLanguageDescription(); + int size = languageDescription.getSize() / 8; + + try { + Address selectAddress = askAddress("选择地址", "选择一个sqlite3_api_routines结构体中的函数指针的地址"); + String xRefLabelName = getXRefLabelName(listing, functionManager, selectAddress); + if (null != xRefLabelName) { + Sqllite3Script.EnumSql byCode = EnumSql.getByCode(xRefLabelName); + if (null != byCode) { + Integer code = byCode.getCode(); + long offset = selectAddress.getOffset(); + long first = offset - code * size; + for (EnumSql item : EnumSql.values()) { + long addr = item.getCode() * size + first; + setFuncName(listing, functionManager, defaultAddressSpace.getAddress(addr), symbolTable, + item.getDesc()); + printf("sqlite3 function :{%s} \n", item.getDesc()); + + } + } + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + private String getXRefLabelName(Listing listing, FunctionManager functionManager, Address selectAddress) { + String label = null; + Data dataAt = listing.getDataAt(selectAddress); + if (null == dataAt) { + printerr("not found data from selectAddress"); + return label; + } + if (dataAt.isPointer()) { + Reference[] referencesFrom = dataAt.getReferencesFrom(); + if (null == referencesFrom) { + printerr("not found references"); + return label; + } + + for (Reference reference : referencesFrom) { + Address toAddress = reference.getToAddress(); + Function functionAt = functionManager.getFunctionAt(toAddress); + + if (null == functionAt) { + CodeUnit codeUnitAt = listing.getCodeUnitAt(toAddress); + if (null == codeUnitAt) { + label = listing.getComment(CodeUnit.POST_COMMENT, toAddress); + if (label == null) { + label = listing.getComment(CodeUnit.PRE_COMMENT, toAddress); + } + if (label == null) { + label = listing.getComment(CodeUnit.EOL_COMMENT, toAddress); + } + } + label = codeUnitAt.getLabel(); + + } else { + label = functionAt.getName(); + } + return label; + } + } + return label; + + } + + private void setFuncName(Listing listing, FunctionManager functionManager, Address selectAddress, + SymbolTable symbolTable, String name) throws DuplicateNameException, InvalidInputException { + Data dataAt = listing.getDataAt(selectAddress); + if (null == dataAt) { + printerr("not found data from selectAddress"); + return; + } + if (dataAt.isPointer()) { + Reference[] referencesFrom = dataAt.getReferencesFrom(); + if (null == referencesFrom) { + printerr("not found references"); + return; + } + + for (Reference reference : referencesFrom) { + Address toAddress = reference.getToAddress(); + Function functionAt = functionManager.getFunctionAt(toAddress); + + if (null == functionAt) { + CodeUnit codeUnitAt = listing.getCodeUnitAt(toAddress); + if (null != codeUnitAt) { + codeUnitAt.setComment(CodeUnit.POST_COMMENT, name); + } + symbolTable.createLabel(toAddress, name, SourceType.USER_DEFINED); + } else { + functionAt.setName(name, SourceType.USER_DEFINED); + } + } + } + + } + + public enum EnumSql { + + SQLITE3_AGGREGATE_CONTEXT(0, "sqlite3_aggregate_context"), + SQLITE3_AGGREGATE_COUNT(1, "sqlite3_aggregate_count"), SQLITE3_BIND_BLOB(2, "sqlite3_bind_blob"), + SQLITE3_BIND_DOUBLE(3, "sqlite3_bind_double"), SQLITE3_BIND_INT(4, "sqlite3_bind_int"), + SQLITE3_BIND_INT64(5, "sqlite3_bind_int64"), SQLITE3_BIND_NULL(6, "sqlite3_bind_null"), + SQLITE3_BIND_PARAMETER_COUNT(7, "sqlite3_bind_parameter_count"), + SQLITE3_BIND_PARAMETER_INDEX(8, "sqlite3_bind_parameter_index"), + SQLITE3_BIND_PARAMETER_NAME(9, "sqlite3_bind_parameter_name"), SQLITE3_BIND_TEXT(10, "sqlite3_bind_text"), + SQLITE3_BIND_TEXT16(11, "sqlite3_bind_text16"), SQLITE3_BIND_VALUE(12, "sqlite3_bind_value"), + SQLITE3_BUSY_HANDLER(13, "sqlite3_busy_handler"), SQLITE3_BUSY_TIMEOUT(14, "sqlite3_busy_timeout"), + SQLITE3_CHANGES(15, "sqlite3_changes"), SQLITE3_CLOSE(16, "sqlite3_close"), + SQLITE3_COLLATION_NEEDED(17, "sqlite3_collation_needed"), + SQLITE3_COLLATION_NEEDED16(18, "sqlite3_collation_needed16"), SQLITE3_COLUMN_BLOB(19, "sqlite3_column_blob"), + SQLITE3_COLUMN_BYTES(20, "sqlite3_column_bytes"), SQLITE3_COLUMN_BYTES16(21, "sqlite3_column_bytes16"), + SQLITE3_COLUMN_COUNT(22, "sqlite3_column_count"), + SQLITE3_COLUMN_DATABASE_NAME(23, "sqlite3_column_database_name"), + SQLITE3_COLUMN_DATABASE_NAME16(24, "sqlite3_column_database_name16"), + SQLITE3_COLUMN_DECLTYPE(25, "sqlite3_column_decltype"), + SQLITE3_COLUMN_DECLTYPE16(26, "sqlite3_column_decltype16"), SQLITE3_COLUMN_DOUBLE(27, "sqlite3_column_double"), + SQLITE3_COLUMN_INT(28, "sqlite3_column_int"), SQLITE3_COLUMN_INT64(29, "sqlite3_column_int64"), + SQLITE3_COLUMN_NAME(30, "sqlite3_column_name"), SQLITE3_COLUMN_NAME16(31, "sqlite3_column_name16"), + SQLITE3_COLUMN_ORIGIN_NAME(32, "sqlite3_column_origin_name"), + SQLITE3_COLUMN_ORIGIN_NAME16(33, "sqlite3_column_origin_name16"), + SQLITE3_COLUMN_TABLE_NAME(34, "sqlite3_column_table_name"), + SQLITE3_COLUMN_TABLE_NAME16(35, "sqlite3_column_table_name16"), SQLITE3_COLUMN_TEXT(36, "sqlite3_column_text"), + SQLITE3_COLUMN_TEXT16(37, "sqlite3_column_text16"), SQLITE3_COLUMN_TYPE(38, "sqlite3_column_type"), + SQLITE3_COLUMN_VALUE(39, "sqlite3_column_value"), SQLITE3_COMMIT_HOOK(40, "sqlite3_commit_hook"), + SQLITE3_COMPLETE(41, "sqlite3_complete"), SQLITE3_COMPLETE16(42, "sqlite3_complete16"), + SQLITE3_CREATE_COLLATION(43, "sqlite3_create_collation"), + SQLITE3_CREATE_COLLATION16(44, "sqlite3_create_collation16"), + SQLITE3_CREATE_FUNCTION(45, "sqlite3_create_function"), + SQLITE3_CREATE_FUNCTION16(46, "sqlite3_create_function16"), SQLITE3_CREATE_MODULE(47, "sqlite3_create_module"), + SQLITE3_DATA_COUNT(48, "sqlite3_data_count"), SQLITE3_DB_HANDLE(49, "sqlite3_db_handle"), + SQLITE3_DECLARE_VTAB(50, "sqlite3_declare_vtab"), + SQLITE3_ENABLE_SHARED_CACHE(51, "sqlite3_enable_shared_cache"), SQLITE3_ERRCODE(52, "sqlite3_errcode"), + SQLITE3_ERRMSG(53, "sqlite3_errmsg"), SQLITE3_ERRMSG16(54, "sqlite3_errmsg16"), + SQLITE3_EXEC(55, "sqlite3_exec"), SQLITE3_EXPIRED(56, "sqlite3_expired"), + SQLITE3_FINALIZE(57, "sqlite3_finalize"), SQLITE3_FREE(58, "sqlite3_free"), + SQLITE3_FREE_TABLE(59, "sqlite3_free_table"), SQLITE3_GET_AUTOCOMMIT(60, "sqlite3_get_autocommit"), + SQLITE3_GET_AUXDATA(61, "sqlite3_get_auxdata"), SQLITE3_GET_TABLE(62, "sqlite3_get_table"), NULL(63, "0"), + SQLITE3_INTERRUPT(64, "sqlite3_interrupt"), SQLITE3_LAST_INSERT_ROWID(65, "sqlite3_last_insert_rowid"), + SQLITE3_LIBVERSION(66, "sqlite3_libversion"), SQLITE3_LIBVERSION_NUMBER(67, "sqlite3_libversion_number"), + SQLITE3_MALLOC(68, "sqlite3_malloc"), SQLITE3_MPRINTF(69, "sqlite3_mprintf"), SQLITE3_OPEN(70, "sqlite3_open"), + SQLITE3_OPEN16(71, "sqlite3_open16"), SQLITE3_PREPARE(72, "sqlite3_prepare"), + SQLITE3_PREPARE16(73, "sqlite3_prepare16"), SQLITE3_PROFILE(74, "sqlite3_profile"), + SQLITE3_PROGRESS_HANDLER(75, "sqlite3_progress_handler"), SQLITE3_REALLOC(76, "sqlite3_realloc"), + SQLITE3_RESET(77, "sqlite3_reset"), SQLITE3_RESULT_BLOB(78, "sqlite3_result_blob"), + SQLITE3_RESULT_DOUBLE(79, "sqlite3_result_double"), SQLITE3_RESULT_ERROR(80, "sqlite3_result_error"), + SQLITE3_RESULT_ERROR16(81, "sqlite3_result_error16"), SQLITE3_RESULT_INT(82, "sqlite3_result_int"), + SQLITE3_RESULT_INT64(83, "sqlite3_result_int64"), SQLITE3_RESULT_NULL(84, "sqlite3_result_null"), + SQLITE3_RESULT_TEXT(85, "sqlite3_result_text"), SQLITE3_RESULT_TEXT16(86, "sqlite3_result_text16"), + SQLITE3_RESULT_TEXT16BE(87, "sqlite3_result_text16be"), SQLITE3_RESULT_TEXT16LE(88, "sqlite3_result_text16le"), + SQLITE3_RESULT_VALUE(89, "sqlite3_result_value"), SQLITE3_ROLLBACK_HOOK(90, "sqlite3_rollback_hook"), + SQLITE3_SET_AUTHORIZER(91, "sqlite3_set_authorizer"), SQLITE3_SET_AUXDATA(92, "sqlite3_set_auxdata"), + SQLITE3_SNPRINTF(93, "sqlite3_snprintf"), SQLITE3_STEP(94, "sqlite3_step"), + SQLITE3_TABLE_COLUMN_METADATA(95, "sqlite3_table_column_metadata"), + SQLITE3_THREAD_CLEANUP(96, "sqlite3_thread_cleanup"), SQLITE3_TOTAL_CHANGES(97, "sqlite3_total_changes"), + SQLITE3_TRACE(98, "sqlite3_trace"), SQLITE3_TRANSFER_BINDINGS(99, "sqlite3_transfer_bindings"), + SQLITE3_UPDATE_HOOK(100, "sqlite3_update_hook"), SQLITE3_USER_DATA(101, "sqlite3_user_data"), + SQLITE3_VALUE_BLOB(102, "sqlite3_value_blob"), SQLITE3_VALUE_BYTES(103, "sqlite3_value_bytes"), + SQLITE3_VALUE_BYTES16(104, "sqlite3_value_bytes16"), SQLITE3_VALUE_DOUBLE(105, "sqlite3_value_double"), + SQLITE3_VALUE_INT(106, "sqlite3_value_int"), SQLITE3_VALUE_INT64(107, "sqlite3_value_int64"), + SQLITE3_VALUE_NUMERIC_TYPE(108, "sqlite3_value_numeric_type"), SQLITE3_VALUE_TEXT(109, "sqlite3_value_text"), + SQLITE3_VALUE_TEXT16(110, "sqlite3_value_text16"), SQLITE3_VALUE_TEXT16BE(111, "sqlite3_value_text16be"), + SQLITE3_VALUE_TEXT16LE(112, "sqlite3_value_text16le"), SQLITE3_VALUE_TYPE(113, "sqlite3_value_type"), + SQLITE3_VMPRINTF(114, "sqlite3_vmprintf"), SQLITE3_OVERLOAD_FUNCTION(115, "sqlite3_overload_function"), + SQLITE3_PREPARE_V2(116, "sqlite3_prepare_v2"), SQLITE3_PREPARE16_V2(117, "sqlite3_prepare16_v2"), + SQLITE3_CLEAR_BINDINGS(118, "sqlite3_clear_bindings"), + SQLITE3_CREATE_MODULE_V2(119, "sqlite3_create_module_v2"), SQLITE3_BIND_ZEROBLOB(120, "sqlite3_bind_zeroblob"), + SQLITE3_BLOB_BYTES(121, "sqlite3_blob_bytes"), SQLITE3_BLOB_CLOSE(122, "sqlite3_blob_close"), + SQLITE3_BLOB_OPEN(123, "sqlite3_blob_open"), SQLITE3_BLOB_READ(124, "sqlite3_blob_read"), + SQLITE3_BLOB_WRITE(125, "sqlite3_blob_write"), SQLITE3_CREATE_COLLATION_V2(126, "sqlite3_create_collation_v2"), + SQLITE3_FILE_CONTROL(127, "sqlite3_file_control"), SQLITE3_MEMORY_HIGHWATER(128, "sqlite3_memory_highwater"), + SQLITE3_MEMORY_USED(129, "sqlite3_memory_used"), SQLITE3_MUTEX_ALLOC(130, "sqlite3_mutex_alloc"), + SQLITE3_MUTEX_ENTER(131, "sqlite3_mutex_enter"), SQLITE3_MUTEX_FREE(132, "sqlite3_mutex_free"), + SQLITE3_MUTEX_LEAVE(133, "sqlite3_mutex_leave"), SQLITE3_MUTEX_TRY(134, "sqlite3_mutex_try"), + SQLITE3_OPEN_V2(135, "sqlite3_open_v2"), SQLITE3_RELEASE_MEMORY(136, "sqlite3_release_memory"), + SQLITE3_RESULT_ERROR_NOMEM(137, "sqlite3_result_error_nomem"), + SQLITE3_RESULT_ERROR_TOOBIG(138, "sqlite3_result_error_toobig"), SQLITE3_SLEEP(139, "sqlite3_sleep"), + SQLITE3_SOFT_HEAP_LIMIT(140, "sqlite3_soft_heap_limit"), SQLITE3_VFS_FIND(141, "sqlite3_vfs_find"), + SQLITE3_VFS_REGISTER(142, "sqlite3_vfs_register"), SQLITE3_VFS_UNREGISTER(143, "sqlite3_vfs_unregister"), + SQLITE3_THREADSAFE(144, "sqlite3_threadsafe"), SQLITE3_RESULT_ZEROBLOB(145, "sqlite3_result_zeroblob"), + SQLITE3_RESULT_ERROR_CODE(146, "sqlite3_result_error_code"), SQLITE3_TEST_CONTROL(147, "sqlite3_test_control"), + SQLITE3_RANDOMNESS(148, "sqlite3_randomness"), SQLITE3_CONTEXT_DB_HANDLE(149, "sqlite3_context_db_handle"), + SQLITE3_EXTENDED_RESULT_CODES(150, "sqlite3_extended_result_codes"), SQLITE3_LIMIT(151, "sqlite3_limit"), + SQLITE3_NEXT_STMT(152, "sqlite3_next_stmt"), SQLITE3_SQL(153, "sqlite3_sql"), + SQLITE3_STATUS(154, "sqlite3_status"), SQLITE3_BACKUP_FINISH(155, "sqlite3_backup_finish"), + SQLITE3_BACKUP_INIT(156, "sqlite3_backup_init"), SQLITE3_BACKUP_PAGECOUNT(157, "sqlite3_backup_pagecount"), + SQLITE3_BACKUP_REMAINING(158, "sqlite3_backup_remaining"), SQLITE3_BACKUP_STEP(159, "sqlite3_backup_step"), + SQLITE3_COMPILEOPTION_GET(160, "sqlite3_compileoption_get"), + SQLITE3_COMPILEOPTION_USED(161, "sqlite3_compileoption_used"), + SQLITE3_CREATE_FUNCTION_V2(162, "sqlite3_create_function_v2"), SQLITE3_DB_CONFIG(163, "sqlite3_db_config"), + SQLITE3_DB_MUTEX(164, "sqlite3_db_mutex"), SQLITE3_DB_STATUS(165, "sqlite3_db_status"), + SQLITE3_EXTENDED_ERRCODE(166, "sqlite3_extended_errcode"), SQLITE3_LOG(167, "sqlite3_log"), + SQLITE3_SOFT_HEAP_LIMIT64(168, "sqlite3_soft_heap_limit64"), SQLITE3_SOURCEID(169, "sqlite3_sourceid"), + SQLITE3_STMT_STATUS(170, "sqlite3_stmt_status"), SQLITE3_STRNICMP(171, "sqlite3_strnicmp"), + SQLITE3_UNLOCK_NOTIFY(172, "sqlite3_unlock_notify"), + SQLITE3_WAL_AUTOCHECKPOINT(173, "sqlite3_wal_autocheckpoint"), + SQLITE3_WAL_CHECKPOINT(174, "sqlite3_wal_checkpoint"), SQLITE3_WAL_HOOK(175, "sqlite3_wal_hook"), + SQLITE3_BLOB_REOPEN(176, "sqlite3_blob_reopen"), SQLITE3_VTAB_CONFIG(177, "sqlite3_vtab_config"), + SQLITE3_VTAB_ON_CONFLICT(178, "sqlite3_vtab_on_conflict"), SQLITE3_CLOSE_V2(179, "sqlite3_close_v2"), + SQLITE3_DB_FILENAME(180, "sqlite3_db_filename"), SQLITE3_DB_READONLY(181, "sqlite3_db_readonly"), + SQLITE3_DB_RELEASE_MEMORY(182, "sqlite3_db_release_memory"), SQLITE3_ERRSTR(183, "sqlite3_errstr"), + SQLITE3_STMT_BUSY(184, "sqlite3_stmt_busy"), SQLITE3_STMT_READONLY(185, "sqlite3_stmt_readonly"), + SQLITE3_STRICMP(186, "sqlite3_stricmp"), SQLITE3_URI_BOOLEAN(187, "sqlite3_uri_boolean"), + SQLITE3_URI_INT64(188, "sqlite3_uri_int64"), SQLITE3_URI_PARAMETER(189, "sqlite3_uri_parameter"), + SQLITE3_VSNPRINTF(190, "sqlite3_vsnprintf"), SQLITE3_WAL_CHECKPOINT_V2(191, "sqlite3_wal_checkpoint_v2"), + SQLITE3_AUTO_EXTENSION(192, "sqlite3_auto_extension"), SQLITE3_BIND_BLOB64(193, "sqlite3_bind_blob64"), + SQLITE3_BIND_TEXT64(194, "sqlite3_bind_text64"), + SQLITE3_CANCEL_AUTO_EXTENSION(195, "sqlite3_cancel_auto_extension"), + SQLITE3_LOAD_EXTENSION(196, "sqlite3_load_extension"), SQLITE3_MALLOC64(197, "sqlite3_malloc64"), + SQLITE3_MSIZE(198, "sqlite3_msize"), SQLITE3_REALLOC64(199, "sqlite3_realloc64"), + SQLITE3_RESET_AUTO_EXTENSION(200, "sqlite3_reset_auto_extension"), + SQLITE3_RESULT_BLOB64(201, "sqlite3_result_blob64"), SQLITE3_RESULT_TEXT64(202, "sqlite3_result_text64"), + SQLITE3_STRGLOB(203, "sqlite3_strglob"), SQLITE3_VALUE_DUP(204, "sqlite3_value_dup"), + SQLITE3_VALUE_FREE(205, "sqlite3_value_free"), SQLITE3_RESULT_ZEROBLOB64(206, "sqlite3_result_zeroblob64"), + SQLITE3_BIND_ZEROBLOB64(207, "sqlite3_bind_zeroblob64"), SQLITE3_VALUE_SUBTYPE(208, "sqlite3_value_subtype"), + SQLITE3_RESULT_SUBTYPE(209, "sqlite3_result_subtype"), SQLITE3_STATUS64(210, "sqlite3_status64"), + SQLITE3_STRLIKE(211, "sqlite3_strlike"), SQLITE3_DB_CACHEFLUSH(212, "sqlite3_db_cacheflush"), + SQLITE3_SYSTEM_ERRNO(213, "sqlite3_system_errno"), SQLITE3_TRACE_V2(214, "sqlite3_trace_v2"), + SQLITE3_EXPANDED_SQL(215, "sqlite3_expanded_sql"), + SQLITE3_SET_LAST_INSERT_ROWID(216, "sqlite3_set_last_insert_rowid"), + SQLITE3_PREPARE_V3(217, "sqlite3_prepare_v3"), SQLITE3_PREPARE16_V3(218, "sqlite3_prepare16_v3"), + SQLITE3_BIND_POINTER(219, "sqlite3_bind_pointer"), SQLITE3_RESULT_POINTER(220, "sqlite3_result_pointer"), + SQLITE3_VALUE_POINTER(221, "sqlite3_value_pointer"), SQLITE3_VTAB_NOCHANGE(222, "sqlite3_vtab_nochange"), + SQLITE3_VALUE_NOCHANGE(223, "sqlite3_value_nochange"), SQLITE3_VTAB_COLLATION(224, "sqlite3_vtab_collation"), + SQLITE3_KEYWORD_COUNT(225, "sqlite3_keyword_count"), SQLITE3_KEYWORD_NAME(226, "sqlite3_keyword_name"), + SQLITE3_KEYWORD_CHECK(227, "sqlite3_keyword_check"), SQLITE3_STR_NEW(228, "sqlite3_str_new"), + SQLITE3_STR_FINISH(229, "sqlite3_str_finish"), SQLITE3_STR_APPENDF(230, "sqlite3_str_appendf"), + SQLITE3_STR_VAPPENDF(231, "sqlite3_str_vappendf"), SQLITE3_STR_APPEND(232, "sqlite3_str_append"), + SQLITE3_STR_APPENDALL(233, "sqlite3_str_appendall"), SQLITE3_STR_APPENDCHAR(234, "sqlite3_str_appendchar"), + SQLITE3_STR_RESET(235, "sqlite3_str_reset"), SQLITE3_STR_ERRCODE(236, "sqlite3_str_errcode"), + SQLITE3_STR_LENGTH(237, "sqlite3_str_length"), SQLITE3_STR_VALUE(238, "sqlite3_str_value"), + SQLITE3_CREATE_WINDOW_FUNCTION(239, "sqlite3_create_window_function"), + SQLITE3_NORMALIZED_SQL(240, "sqlite3_normalized_sql"), SQLITE3_STMT_ISEXPLAIN(241, "sqlite3_stmt_isexplain"), + SQLITE3_VALUE_FROMBIND(242, "sqlite3_value_frombind"), SQLITE3_DROP_MODULES(243, "sqlite3_drop_modules"), + SQLITE3_HARD_HEAP_LIMIT64(244, "sqlite3_hard_heap_limit64"), SQLITE3_URI_KEY(245, "sqlite3_uri_key"), + SQLITE3_FILENAME_DATABASE(246, "sqlite3_filename_database"), + SQLITE3_FILENAME_JOURNAL(247, "sqlite3_filename_journal"), SQLITE3_FILENAME_WAL(248, "sqlite3_filename_wal"), + SQLITE3_CREATE_FILENAME(249, "sqlite3_create_filename"), SQLITE3_FREE_FILENAME(250, "sqlite3_free_filename"), + SQLITE3_DATABASE_FILE_OBJECT(251, "sqlite3_database_file_object"), SQLITE3_TXN_STATE(252, "sqlite3_txn_state"), + SQLITE3_CHANGES64(253, "sqlite3_changes64"), SQLITE3_TOTAL_CHANGES64(254, "sqlite3_total_changes64"), + SQLITE3_AUTOVACUUM_PAGES(255, "sqlite3_autovacuum_pages"), SQLITE3_ERROR_OFFSET(256, "sqlite3_error_offset"), + SQLITE3_VTAB_RHS_VALUE(257, "sqlite3_vtab_rhs_value"), SQLITE3_VTAB_DISTINCT(258, "sqlite3_vtab_distinct"), + SQLITE3_VTAB_IN(259, "sqlite3_vtab_in"), SQLITE3_VTAB_IN_FIRST(260, "sqlite3_vtab_in_first"), + SQLITE3_VTAB_IN_NEXT(261, "sqlite3_vtab_in_next"), SQLITE3_DESERIALIZE(262, "sqlite3_deserialize"), + SQLITE3_SERIALIZE(263, "sqlite3_serialize"), SQLITE3_DB_NAME(264, "sqlite3_db_name"), + SQLITE3_VALUE_TYPE_3_40(265, "sqlite3_value_type"); + + private EnumSql(Integer code, String desc) { + this.code = code; + this.desc = desc; + } + + private Integer code; + private String desc; + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public static EnumSql getByCode(Integer code) { + for (EnumSql item : EnumSql.values()) { + if (item.getCode().equals(code)) { + return item; + } + } + return null; + } + + public static EnumSql getByCode(String desc) { + for (EnumSql item : EnumSql.values()) { + if (item.getDesc().equals(desc)) { + return item; + } + } + return null; + } + + } + +}