mirror of
https://github.com/laomms/wxhelper.git
synced 2024-12-22 16:19:21 +08:00
up
This commit is contained in:
parent
fa450a6887
commit
b9c1370bfe
1598
enc_temp_folder/bd4455ec16623a51f931c98552ba1e28/wechat_service.cc
Normal file
1598
enc_temp_folder/bd4455ec16623a51f931c98552ba1e28/wechat_service.cc
Normal file
File diff suppressed because it is too large
Load Diff
@ -54,7 +54,7 @@ class WeChatService : public base::Singleton<WeChatService> {
|
||||
std::wstring GetContactOrChatRoomNickname(const std::wstring& wxid);
|
||||
int64_t GetContactByWxid(const std::wstring& wxid,
|
||||
ContactProfileInner& profile);
|
||||
int64_t DoDownloadTask(uint64_t msg_id);
|
||||
std::wstring DoDownloadTask(uint64_t msg_id);
|
||||
int64_t ForwardPublicMsg(const std::wstring& wxid, const std::wstring& title,
|
||||
const std::wstring& url,
|
||||
const std::wstring& thumb_url,
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "misc_controller.h"
|
||||
|
||||
#include <locale>
|
||||
#include <codecvt>
|
||||
#include "json_utils.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "spdlog/spdlog.h"
|
||||
@ -162,8 +163,10 @@ std::string MiscController::DownloadAttach(std::string params) {
|
||||
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"}};
|
||||
std::wstring result = wechat::WeChatService::GetInstance().DoDownloadTask(msg_id);
|
||||
std::string result_str = std::wstring_convert<std::codecvt_utf8<wchar_t>>().to_bytes(result);
|
||||
nlohmann::json ret = {
|
||||
{"code", 1}, {"data", {"result", result_str}}, {"msg", "success"} };
|
||||
return ret.dump();
|
||||
}
|
||||
} // namespace wxhelper
|
||||
|
@ -844,9 +844,23 @@ int64_t wechat::WeChatService::GetContactByWxid(const std::wstring& wxid,
|
||||
return success;
|
||||
}
|
||||
|
||||
std::wstring combineAndRemoveDuplicate(const std::wstring& basePath, const std::wstring& resultPath) {
|
||||
std::wstring cleanedBasePath = basePath;
|
||||
if (cleanedBasePath.back() == L'\\') {
|
||||
cleanedBasePath.pop_back();
|
||||
}
|
||||
size_t pos = resultPath.find(cleanedBasePath);
|
||||
if (pos != std::wstring::npos) {
|
||||
std::wstring adjustedResultPath = resultPath.substr(pos + cleanedBasePath.length());
|
||||
return cleanedBasePath + L'\\' + adjustedResultPath;
|
||||
}
|
||||
|
||||
return basePath + L'\\' + resultPath;
|
||||
}
|
||||
TODO("DoDownloadTask")
|
||||
int64_t wechat::WeChatService::DoDownloadTask(uint64_t msg_id) {
|
||||
int64_t success = -1;
|
||||
|
||||
std::wstring wechat::WeChatService::DoDownloadTask(uint64_t msg_id) {
|
||||
|
||||
uint64_t get_by_local_id_addr = base_addr_ + offset::kGetMgrByPrefixLocalId;
|
||||
func::__GetMgrByPrefixLocalId get_by_local_id =
|
||||
(func::__GetMgrByPrefixLocalId)get_by_local_id_addr;
|
||||
@ -889,8 +903,7 @@ int64_t wechat::WeChatService::DoDownloadTask(uint64_t msg_id) {
|
||||
int64_t local_id =
|
||||
wechat::WeChatDb::GetInstance().GetLocalIdByMsgId(msg_id, index);
|
||||
if (local_id <= 0 || index >> 32 == 0) {
|
||||
success = -2;
|
||||
return success;
|
||||
return L"-2";
|
||||
}
|
||||
char* chat_msg = base::utils::WxHeapAlloc<char>(0x460);
|
||||
LARGE_INTEGER l;
|
||||
@ -909,45 +922,42 @@ int64_t wechat::WeChatService::DoDownloadTask(uint64_t msg_id) {
|
||||
|
||||
if (current_data_path.length > 0) {
|
||||
save_path += current_data_path.ptr;
|
||||
save_path += L"wxhelper";
|
||||
} else {
|
||||
return -1;
|
||||
return L"-1";
|
||||
}
|
||||
|
||||
if (!wxutils::FindOrCreateDirectory(save_path)) {
|
||||
return -3;
|
||||
}
|
||||
int64_t type = *(int64_t*)(chat_msg + 0x38);
|
||||
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;
|
||||
case 0x3: {
|
||||
if (!save_path.empty() && save_path.back() == L'\\') {
|
||||
save_path.pop_back();
|
||||
}
|
||||
size_t pos = save_path.find_last_of(L'\\');
|
||||
if (pos != std::wstring::npos) {
|
||||
save_path = save_path.substr(0, pos + 1); // 保留最后一个反斜杠
|
||||
}
|
||||
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: {
|
||||
}
|
||||
case 0x3E:
|
||||
case 0x2B: {
|
||||
save_path += L"\\video";
|
||||
if (!wxutils::FindOrCreateDirectory(save_path)) {
|
||||
return -3;
|
||||
return L"-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: {
|
||||
}
|
||||
case 0x31: {
|
||||
save_path += L"\\file";
|
||||
if (!wxutils::FindOrCreateDirectory(save_path)) {
|
||||
return -3;
|
||||
return L"-3";
|
||||
}
|
||||
char* p_xml_app_msg = base::utils::WxHeapAlloc<char>(0x3000);
|
||||
uint64_t xml_msg =
|
||||
@ -955,28 +965,25 @@ int64_t wechat::WeChatService::DoDownloadTask(uint64_t msg_id) {
|
||||
uint64_t result =
|
||||
xml_to_app_info(xml_msg, reinterpret_cast<uint64_t>(we_content), 1);
|
||||
if (result != 1) {
|
||||
return -4;
|
||||
return L"-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:
|
||||
}
|
||||
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);
|
||||
INT64 success = push_attach_task(mgr, p_chat_msg, 0, 1);
|
||||
std::wstring result = *(wchar_t**)(chat_msg + 0x2A0);
|
||||
free_chat_msg(p_chat_msg);
|
||||
|
||||
return success;
|
||||
return save_path + result;
|
||||
}
|
||||
|
||||
TODO("ForwardPublicMsg")
|
||||
|
@ -118,7 +118,7 @@
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<AdditionalIncludeDirectories>inc\nlohmann;inc\tinyxml2;inc\mongoose;inc\lz4;inc\Detours;inc\include;inc\base64;inc;inc\spdlog;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
|
Loading…
Reference in New Issue
Block a user