From 7a8ee474738a81728b1b33c90105d6c8b410a339 Mon Sep 17 00:00:00 2001 From: Changhua Date: Sun, 16 Jun 2024 15:28:34 +0800 Subject: [PATCH] Support MediaMsgi.db --- WeChatFerry/spy/exec_sql.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/WeChatFerry/spy/exec_sql.cpp b/WeChatFerry/spy/exec_sql.cpp index 9f30f2c..cd25f04 100644 --- a/WeChatFerry/spy/exec_sql.cpp +++ b/WeChatFerry/spy/exec_sql.cpp @@ -2,6 +2,7 @@ #include "exec_sql.h" #include "load_calls.h" +#include "log.h" #include "sqlite3.h" #include "util.h" @@ -40,9 +41,9 @@ static void GetMsgDbHandle(QWORD msgMgrAddr) dbMap[dbname] = GET_QWORD(dbAddr + 0x78); // MediaMsgi.db - // QWORD mmdbAddr = GET_QWORD(dbAddr + 0x14); - // string mmdbname = Wstring2String(GET_WSTRING(mmdbAddr + 0x4C)); - // dbMap[mmdbname] = GET_QWORD(mmdbAddr + 0x38); + QWORD mmdbAddr = GET_QWORD(dbAddr + 0x20); + string mmdbname = Wstring2String(GET_WSTRING(mmdbAddr + 0x78)); + dbMap[mmdbname] = GET_QWORD(mmdbAddr + 0x50); } } } @@ -133,6 +134,12 @@ DbRows_t ExecDbQuery(const string db, const string sql) } QWORD *stmt; + QWORD handle = dbMap[db]; + if (handle == 0){ + LOG_WARN("Empty handle, retrying..."); + dbMap = GetDbHandles(); + } + int rc = func_prepare(dbMap[db], sql.c_str(), -1, &stmt, 0); if (rc != SQLITE_OK) { return rows; @@ -200,7 +207,7 @@ vector GetAudioData(uint64_t id) QWORD msgMgrAddr = GET_QWORD(g_WeChatWinDllAddr + OFFSET_DB_MSG_MGR); QWORD dbIndex = GET_QWORD(msgMgrAddr + 0x68); - string sql = "SELECT Buf from Media WHERE Reserved0=" + to_string(id) + ";"; + string sql = "SELECT Buf FROM Media WHERE Reserved0=" + to_string(id) + ";"; for (int i = dbIndex - 1; i >= 0; i--) { string dbname = "MediaMSG" + to_string(i) + ".db"; DbRows_t rows = ExecDbQuery(dbname, sql);