From 52dc88a121b4afb9e9975b69fd669bfa81b5e49c Mon Sep 17 00:00:00 2001 From: dillon520 Date: Sat, 4 Jan 2025 18:17:44 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A6=82=E6=9E=9C=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=8C=87=E5=AE=9A=E7=9A=84=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E4=B8=8D=E5=AD=98=E5=9C=A8=EF=BC=8C=E4=BC=9A?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改:检测输出目录是否存在,如果不存在就创建该目录。 --- WeChatFerry/spy/funcs.cpp | 75 +++++++++++++++++++++++++++++++++++++++ WeChatFerry/spy/funcs.h | 1 + 2 files changed, 76 insertions(+) diff --git a/WeChatFerry/spy/funcs.cpp b/WeChatFerry/spy/funcs.cpp index bdd1d56..601fbf6 100644 --- a/WeChatFerry/spy/funcs.cpp +++ b/WeChatFerry/spy/funcs.cpp @@ -3,6 +3,8 @@ #include "framework.h" #include #include +#include +#include #include "codec.h" #include "exec_sql.h" @@ -75,6 +77,37 @@ static string get_key(uint8_t header1, uint8_t header2, uint8_t *key) return ""; // 错误 } +// 创建多级目录 +bool CreateDir(const char* dir) +{ + int m = 0, n; + string str1, str2; + str1 = dir; + str2 = str1.substr(0, 2); + str1 = str1.substr(3, str1.size()); + while (m >= 0) + { + m = str1.find('/'); + + str2 += '/' + str1.substr(0, m); + //判断该目录是否存在 + n = _access(str2.c_str(), 0); + if (n == -1) + { + //创建目录文件 + int flag = _mkdir(str2.c_str()); + if (flag != 0) { //创建失败 + LOG_ERROR("Failed to CreateDir:{}", dir); + return false; + } + } + + str1 = str1.substr(m + 1, str1.size()); + } + LOG_DEBUG("CreateDir {} success.", dir); + return true; +} + string DecryptImage(string src, string dir) { if (!fs::exists(src)) { @@ -116,6 +149,17 @@ string DecryptImage(string src, string dir) dst = fs::path(src).replace_extension(ext).string(); } else { dst = (dir.back() == '\\' || dir.back() == '/') ? dir : (dir + "/"); + replace(dst.begin(), dst.end(), '\\', '/'); + + // 判断dir文件夹是否存在,若不存在则创建(否则将无法创建出文件) + if (_access(dst.c_str(), 0) == -1) {//判断该文件夹是否存在 + bool success = CreateDir(dst.c_str()); //Windows创建文件夹 + if (!success) { //创建失败 + LOG_ERROR("Failed to mkdir:{}", dst); + return ""; + } + } + dst += fs::path(src).stem().string() + ext; } @@ -292,6 +336,37 @@ string GetAudio(QWORD id, string dir) return mp3path; } +string GetPCMAudio(uint64_t id, string dir, int32_t sr) +{ + string pcmpath = (dir.back() == '\\' || dir.back() == '/') ? dir : (dir + "/"); + pcmpath += to_string(id) + ".pcm"; + replace(pcmpath.begin(), pcmpath.end(), '\\', '/'); + if (fs::exists(pcmpath)) { // 不重复下载 + return pcmpath; + } + vector pcm; + vector silk = GetAudioData(id); + if (silk.size() == 0) { + LOG_ERROR("Empty audio data."); + return ""; + } + + SilkDecode(silk, pcm, sr); + errno_t err; + FILE* fPCM; + err = fopen_s(&fPCM, pcmpath.c_str(), "wb"); + if (err != 0) { + printf("Error: could not open input file %s\n", pcmpath.c_str()); + exit(0); + } + + fwrite(pcm.data(), sizeof(uint8_t), pcm.size(), fPCM); + fclose(fPCM); + + return pcmpath; +} + + OcrResult_t GetOcrResult(string path) { OcrResult_t ret = { -1, "" }; diff --git a/WeChatFerry/spy/funcs.h b/WeChatFerry/spy/funcs.h index a41a77b..cc0f89d 100644 --- a/WeChatFerry/spy/funcs.h +++ b/WeChatFerry/spy/funcs.h @@ -5,6 +5,7 @@ int IsLogin(void); std::string GetAudio(uint64_t id, std::string dir); +std::string GetPCMAudio(uint64_t id, std::string dir, int32_t sr); std::string DecryptImage(std::string src, std::string dst); int RefreshPyq(uint64_t id); int DownloadAttach(uint64_t id, std::string thumb, std::string extra); From b339c526f69c4e72377a877721a2d16979ccbdbd Mon Sep 17 00:00:00 2001 From: Changhua Date: Sun, 5 Jan 2025 22:22:22 +0800 Subject: [PATCH 2/2] Bump to v39.3.5 --- WeChatFerry/spy/spy.rc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WeChatFerry/spy/spy.rc b/WeChatFerry/spy/spy.rc index 5f87428..daf9908 100644 --- a/WeChatFerry/spy/spy.rc +++ b/WeChatFerry/spy/spy.rc @@ -51,7 +51,7 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 39,3,4,0 + FILEVERSION 39,3,5,0 PRODUCTVERSION 3,9,11,25 FILEFLAGSMASK 0x3fL #ifdef _DEBUG @@ -69,7 +69,7 @@ BEGIN BEGIN VALUE "CompanyName", "WeChatFerry" VALUE "FileDescription", "WeChatFerry" - VALUE "FileVersion", "39.3.4.0" + VALUE "FileVersion", "39.3.5.0" VALUE "InternalName", "spy.dll" VALUE "LegalCopyright", "Copyright (C) 2023" VALUE "OriginalFilename", "spy.dll"