diff --git a/WeChatFerry/CMakeLists.txt b/WeChatFerry/CMakeLists.txt new file mode 100644 index 0000000..0abeef3 --- /dev/null +++ b/WeChatFerry/CMakeLists.txt @@ -0,0 +1,56 @@ +cmake_minimum_required(VERSION 3.15) + +# Common compiler flags +# 设置 C 语言标准为 C17 +set(CMAKE_C_STANDARD 17) +# 确保要求该标准为必须 +# set(CMAKE_C_STANDARD_REQUIRED ON) +# 默认情况下禁用 GNU 扩展 +set(CMAKE_C_EXTENSIONS OFF) +# 设置 C++ 语言标准为 C++17 +set(CMAKE_CXX_STANDARD 17) +# set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +# 集成vcpkg +set(VCPKG_TARGET_TRIPLET "x64-mingw-static" CACHE STRING "Vcpkg target triplet") +set(VCPKG_HOST_TRIPLET "x64-mingw-static" CACHE STRING "Vcpkg host triplet") +set(VCPKG_MANIFEST_MODE ON CACHE BOOL "Enable manifest mode") + +if(DEFINED ENV{VCPKG_ROOT}) + set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain file") +else() + set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain file") +endif() + +# include(FetchContent) +# include(ExternalProject) + +project(WeChatFerry LANGUAGES C CXX) + +add_compile_options( + -Wall + -Wextra + -fPIC +) + +add_link_options( + -static +) + +# Include directories +include_directories( + ${CMAKE_SOURCE_DIR}/com + ${CMAKE_SOURCE_DIR}/rpc + ${CMAKE_SOURCE_DIR}/rpc/nanopb + ${CMAKE_SOURCE_DIR}/rpc/proto + ${CMAKE_SOURCE_DIR}/sdk + ${CMAKE_SOURCE_DIR}/spy + ${CMAKE_SOURCE_DIR}/smc +) + +# Add subdirectories + +add_subdirectory(sdk) +add_subdirectory(spy) + diff --git a/WeChatFerry/sdk/framework.h b/WeChatFerry/com/framework.h similarity index 100% rename from WeChatFerry/sdk/framework.h rename to WeChatFerry/com/framework.h diff --git a/WeChatFerry/com/log.hpp b/WeChatFerry/com/log.hpp index 4a08c8b..a8fa8f8 100644 --- a/WeChatFerry/com/log.hpp +++ b/WeChatFerry/com/log.hpp @@ -13,6 +13,7 @@ #include #include #include +#include "framework.h" #define LOG_DEBUG(...) SPDLOG_DEBUG(__VA_ARGS__) #define LOG_INFO(...) SPDLOG_INFO(__VA_ARGS__) diff --git a/WeChatFerry/com/util.cpp b/WeChatFerry/com/util.cpp index b82e82f..f5a8376 100644 --- a/WeChatFerry/com/util.cpp +++ b/WeChatFerry/com/util.cpp @@ -7,7 +7,6 @@ #include #include -#include "framework.h" #include #include @@ -64,8 +63,8 @@ static DWORD get_wechat_pid() HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (hSnapshot == INVALID_HANDLE_VALUE) return 0; - PROCESSENTRY32 pe32 = { sizeof(PROCESSENTRY32) }; - while (Process32Next(hSnapshot, &pe32)) { + PROCESSENTRY32W pe32 = { sizeof(PROCESSENTRY32W) }; + while (Process32NextW(hSnapshot, &pe32)) { if (pe32.szExeFile == s2w(WECHATEXE)) { pid = pe32.th32ProcessID; break; diff --git a/WeChatFerry/com/util.h b/WeChatFerry/com/util.h index 1998fbb..6e83b01 100644 --- a/WeChatFerry/com/util.h +++ b/WeChatFerry/com/util.h @@ -14,7 +14,7 @@ struct PortPath { char path[MAX_PATH]; }; -DWORD get_wechat_pid(); +static DWORD get_wechat_pid(); int open_wechat(DWORD &pid); std::string get_wechat_version(); uint32_t get_memory_int_by_address(HANDLE hProcess, uint64_t addr); diff --git a/WeChatFerry/rpc/tool/proto/nanopb_pb2.py b/WeChatFerry/rpc/tool/proto/nanopb_pb2.py index eea6b3e..fe7c505 100644 --- a/WeChatFerry/rpc/tool/proto/nanopb_pb2.py +++ b/WeChatFerry/rpc/tool/proto/nanopb_pb2.py @@ -1,11 +1,22 @@ # -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! +# NO CHECKED-IN PROTOBUF GENCODE # source: nanopb.proto +# Protobuf Python Version: 6.30.2 """Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import runtime_version as _runtime_version from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder +_runtime_version.ValidateProtobufRuntimeVersion( + _runtime_version.Domain.PUBLIC, + 6, + 30, + 2, + '', + 'nanopb.proto' +) # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() @@ -16,24 +27,20 @@ from google.protobuf import descriptor_pb2 as google_dot_protobuf_dot_descriptor DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0cnanopb.proto\x1a google/protobuf/descriptor.proto\"\xa4\x07\n\rNanoPBOptions\x12\x10\n\x08max_size\x18\x01 \x01(\x05\x12\x12\n\nmax_length\x18\x0e \x01(\x05\x12\x11\n\tmax_count\x18\x02 \x01(\x05\x12&\n\x08int_size\x18\x07 \x01(\x0e\x32\x08.IntSize:\nIS_DEFAULT\x12$\n\x04type\x18\x03 \x01(\x0e\x32\n.FieldType:\nFT_DEFAULT\x12\x18\n\nlong_names\x18\x04 \x01(\x08:\x04true\x12\x1c\n\rpacked_struct\x18\x05 \x01(\x08:\x05\x66\x61lse\x12\x1a\n\x0bpacked_enum\x18\n \x01(\x08:\x05\x66\x61lse\x12\x1b\n\x0cskip_message\x18\x06 \x01(\x08:\x05\x66\x61lse\x12\x18\n\tno_unions\x18\x08 \x01(\x08:\x05\x66\x61lse\x12\r\n\x05msgid\x18\t \x01(\r\x12\x1e\n\x0f\x61nonymous_oneof\x18\x0b \x01(\x08:\x05\x66\x61lse\x12\x15\n\x06proto3\x18\x0c \x01(\x08:\x05\x66\x61lse\x12#\n\x14proto3_singular_msgs\x18\x15 \x01(\x08:\x05\x66\x61lse\x12\x1d\n\x0e\x65num_to_string\x18\r \x01(\x08:\x05\x66\x61lse\x12\x1b\n\x0c\x66ixed_length\x18\x0f \x01(\x08:\x05\x66\x61lse\x12\x1a\n\x0b\x66ixed_count\x18\x10 \x01(\x08:\x05\x66\x61lse\x12\x1e\n\x0fsubmsg_callback\x18\x16 \x01(\x08:\x05\x66\x61lse\x12/\n\x0cmangle_names\x18\x11 \x01(\x0e\x32\x11.TypenameMangling:\x06M_NONE\x12(\n\x11\x63\x61llback_datatype\x18\x12 \x01(\t:\rpb_callback_t\x12\x34\n\x11\x63\x61llback_function\x18\x13 \x01(\t:\x19pb_default_field_callback\x12\x30\n\x0e\x64\x65scriptorsize\x18\x14 \x01(\x0e\x32\x0f.DescriptorSize:\x07\x44S_AUTO\x12\x1a\n\x0b\x64\x65\x66\x61ult_has\x18\x17 \x01(\x08:\x05\x66\x61lse\x12\x0f\n\x07include\x18\x18 \x03(\t\x12\x0f\n\x07\x65xclude\x18\x1a \x03(\t\x12\x0f\n\x07package\x18\x19 \x01(\t\x12\x41\n\rtype_override\x18\x1b \x01(\x0e\x32*.google.protobuf.FieldDescriptorProto.Type\x12\x19\n\x0bsort_by_tag\x18\x1c \x01(\x08:\x04true\x12.\n\rfallback_type\x18\x1d \x01(\x0e\x32\n.FieldType:\x0b\x46T_CALLBACK*i\n\tFieldType\x12\x0e\n\nFT_DEFAULT\x10\x00\x12\x0f\n\x0b\x46T_CALLBACK\x10\x01\x12\x0e\n\nFT_POINTER\x10\x04\x12\r\n\tFT_STATIC\x10\x02\x12\r\n\tFT_IGNORE\x10\x03\x12\r\n\tFT_INLINE\x10\x05*D\n\x07IntSize\x12\x0e\n\nIS_DEFAULT\x10\x00\x12\x08\n\x04IS_8\x10\x08\x12\t\n\x05IS_16\x10\x10\x12\t\n\x05IS_32\x10 \x12\t\n\x05IS_64\x10@*Z\n\x10TypenameMangling\x12\n\n\x06M_NONE\x10\x00\x12\x13\n\x0fM_STRIP_PACKAGE\x10\x01\x12\r\n\tM_FLATTEN\x10\x02\x12\x16\n\x12M_PACKAGE_INITIALS\x10\x03*E\n\x0e\x44\x65scriptorSize\x12\x0b\n\x07\x44S_AUTO\x10\x00\x12\x08\n\x04\x44S_1\x10\x01\x12\x08\n\x04\x44S_2\x10\x02\x12\x08\n\x04\x44S_4\x10\x04\x12\x08\n\x04\x44S_8\x10\x08:E\n\x0enanopb_fileopt\x12\x1c.google.protobuf.FileOptions\x18\xf2\x07 \x01(\x0b\x32\x0e.NanoPBOptions:G\n\rnanopb_msgopt\x12\x1f.google.protobuf.MessageOptions\x18\xf2\x07 \x01(\x0b\x32\x0e.NanoPBOptions:E\n\x0enanopb_enumopt\x12\x1c.google.protobuf.EnumOptions\x18\xf2\x07 \x01(\x0b\x32\x0e.NanoPBOptions:>\n\x06nanopb\x12\x1d.google.protobuf.FieldOptions\x18\xf2\x07 \x01(\x0b\x32\x0e.NanoPBOptionsB\x1a\n\x18\x66i.kapsi.koti.jpa.nanopb') -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'nanopb_pb2', globals()) -if _descriptor._USE_C_DESCRIPTORS == False: - google_dot_protobuf_dot_descriptor__pb2.FileOptions.RegisterExtension(nanopb_fileopt) - google_dot_protobuf_dot_descriptor__pb2.MessageOptions.RegisterExtension(nanopb_msgopt) - google_dot_protobuf_dot_descriptor__pb2.EnumOptions.RegisterExtension(nanopb_enumopt) - google_dot_protobuf_dot_descriptor__pb2.FieldOptions.RegisterExtension(nanopb) - - DESCRIPTOR._options = None - DESCRIPTOR._serialized_options = b'\n\030fi.kapsi.koti.jpa.nanopb' - _FIELDTYPE._serialized_start=985 - _FIELDTYPE._serialized_end=1090 - _INTSIZE._serialized_start=1092 - _INTSIZE._serialized_end=1160 - _TYPENAMEMANGLING._serialized_start=1162 - _TYPENAMEMANGLING._serialized_end=1252 - _DESCRIPTORSIZE._serialized_start=1254 - _DESCRIPTORSIZE._serialized_end=1323 - _NANOPBOPTIONS._serialized_start=51 - _NANOPBOPTIONS._serialized_end=983 +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'nanopb_pb2', _globals) +if not _descriptor._USE_C_DESCRIPTORS: + _globals['DESCRIPTOR']._loaded_options = None + _globals['DESCRIPTOR']._serialized_options = b'\n\030fi.kapsi.koti.jpa.nanopb' + _globals['_FIELDTYPE']._serialized_start=985 + _globals['_FIELDTYPE']._serialized_end=1090 + _globals['_INTSIZE']._serialized_start=1092 + _globals['_INTSIZE']._serialized_end=1160 + _globals['_TYPENAMEMANGLING']._serialized_start=1162 + _globals['_TYPENAMEMANGLING']._serialized_end=1252 + _globals['_DESCRIPTORSIZE']._serialized_start=1254 + _globals['_DESCRIPTORSIZE']._serialized_end=1323 + _globals['_NANOPBOPTIONS']._serialized_start=51 + _globals['_NANOPBOPTIONS']._serialized_end=983 # @@protoc_insertion_point(module_scope) diff --git a/WeChatFerry/sdk/CMakeLists.txt b/WeChatFerry/sdk/CMakeLists.txt new file mode 100644 index 0000000..158a441 --- /dev/null +++ b/WeChatFerry/sdk/CMakeLists.txt @@ -0,0 +1,57 @@ +# SDK project - dynamic library +project(SDK LANGUAGES C CXX) + +find_package(spdlog REQUIRED) + +add_library(sdk SHARED + dllmain.cpp + injector.cpp + injector.h + sdk.cpp + sdk.h + sdk.def + + # Common files + ${CMAKE_SOURCE_DIR}/com/util.cpp + ${CMAKE_SOURCE_DIR}/com/util.h +) + +target_link_libraries(sdk PRIVATE + version + shlwapi + spdlog::spdlog + c++ +) + +# Set compiler definitions +target_compile_definitions(sdk PRIVATE + SDK_EXPORTS + _WINDOWS + _USRDLL +) + +# add_compile_options( +# # -Wall +# -fPIC +# # -fms-extensions +# ) +# Set output name for debug builds +set_target_properties(sdk PROPERTIES + DEBUG_POSTFIX "d" +) + +# # Post-build copy commands +# add_custom_command(TARGET sdk POST_BUILD +# COMMAND ${CMAKE_COMMAND} -E copy +# $ +# ${CMAKE_SOURCE_DIR}/Out +# COMMAND ${CMAKE_COMMAND} -E copy +# $ +# ${CMAKE_SOURCE_DIR}/../clients/python/wcferry +# COMMAND ${CMAKE_COMMAND} -E copy +# ${CMAKE_SOURCE_DIR}/DISCLAIMER.md +# ${CMAKE_SOURCE_DIR}/Out +# COMMAND ${CMAKE_COMMAND} -E copy +# ${CMAKE_SOURCE_DIR}/DISCLAIMER.md +# ${CMAKE_SOURCE_DIR}/../clients/python/wcferry +# ) diff --git a/WeChatFerry/sdk/SDK.vcxproj b/WeChatFerry/sdk/SDK.vcxproj index cb0fd9d..0246e85 100644 --- a/WeChatFerry/sdk/SDK.vcxproj +++ b/WeChatFerry/sdk/SDK.vcxproj @@ -142,7 +142,7 @@ xcopy /y $(OutDir)$(TargetFileName) $(SolutionDir)..\clients\python\wcferry - + diff --git a/WeChatFerry/sdk/SDK.vcxproj.filters b/WeChatFerry/sdk/SDK.vcxproj.filters index 5adfeab..ccdeccf 100644 --- a/WeChatFerry/sdk/SDK.vcxproj.filters +++ b/WeChatFerry/sdk/SDK.vcxproj.filters @@ -15,7 +15,7 @@ - + 头文件 diff --git a/WeChatFerry/sdk/injector.cpp b/WeChatFerry/sdk/injector.cpp index 913ba87..6eb935e 100644 --- a/WeChatFerry/sdk/injector.cpp +++ b/WeChatFerry/sdk/injector.cpp @@ -122,7 +122,7 @@ static uint64_t get_func_offset(const string &dll_path, const string &func_name) return 0; } - LPVOID absAddr = GetProcAddress(dll, func_name.c_str()); + LPVOID absAddr = reinterpret_cast(GetProcAddress(dll, func_name.c_str())); uint64_t offset = reinterpret_cast(absAddr) - reinterpret_cast(dll); FreeLibrary(dll); diff --git a/WeChatFerry/sdk/sdk.cpp b/WeChatFerry/sdk/sdk.cpp index 8363414..831a855 100644 --- a/WeChatFerry/sdk/sdk.cpp +++ b/WeChatFerry/sdk/sdk.cpp @@ -21,9 +21,16 @@ static HANDLE wcProcess = NULL; static HMODULE spyBase = NULL; static std::string spyDllPath; +//区分MSVC和MinGW +#ifdef _MSC_VER constexpr char WCFSDKDLL[] = "sdk.dll"; constexpr char WCFSPYDLL[] = "spy.dll"; constexpr char WCFSPYDLL_DEBUG[] = "spy_debug.dll"; +#else +constexpr char WCFSDKDLL[] = "libsdk.dll"; +constexpr char WCFSPYDLL[] = "libspy.dll"; +constexpr char WCFSPYDLL_DEBUG[] = "libspyd.dll"; +#endif constexpr std::string_view DISCLAIMER_FLAG = ".license_accepted.flag"; constexpr std::string_view DISCLAIMER_TEXT_FILE = "DISCLAIMER.md"; @@ -91,8 +98,8 @@ static std::string get_dll_path(bool debug) return path.string(); } - -int WxInitSDK(bool debug, int port) +extern "C" { +__declspec(dllexport) int WxInitSDK(bool debug, int port) { if (!show_disclaimer()) { exit(-1); // 用户拒绝协议,退出程序 @@ -134,7 +141,7 @@ int WxInitSDK(bool debug, int port) return status; } -int WxDestroySDK() +__declspec(dllexport) int WxDestroySDK() { if (!injected) { return 1; // 未注入 @@ -151,3 +158,4 @@ int WxDestroySDK() return 0; } +} \ No newline at end of file diff --git a/WeChatFerry/sdk/sdk.def b/WeChatFerry/sdk/sdk.def index d8c9be9..a5c9746 100644 --- a/WeChatFerry/sdk/sdk.def +++ b/WeChatFerry/sdk/sdk.def @@ -1,3 +1,3 @@ -EXPORTS +EXPORTS WxInitSDK WxDestroySDK diff --git a/WeChatFerry/sdk/sdk.h b/WeChatFerry/sdk/sdk.h index 0ebec29..2002d03 100644 --- a/WeChatFerry/sdk/sdk.h +++ b/WeChatFerry/sdk/sdk.h @@ -1,4 +1,6 @@ #pragma once -int WxInitSDK(bool debug, int port); -int WxDestroySDK(); +extern "C" { +__declspec(dllexport) int WxInitSDK(bool debug, int port); +__declspec(dllexport) int WxDestroySDK(); +} \ No newline at end of file diff --git a/WeChatFerry/smc/libCodec.a b/WeChatFerry/smc/libCodec.a new file mode 100644 index 0000000..1370505 Binary files /dev/null and b/WeChatFerry/smc/libCodec.a differ diff --git a/WeChatFerry/smc/libmp3lame.a b/WeChatFerry/smc/libmp3lame.a new file mode 100644 index 0000000..96e03ae Binary files /dev/null and b/WeChatFerry/smc/libmp3lame.a differ diff --git a/WeChatFerry/spy/CMakeLists.txt b/WeChatFerry/spy/CMakeLists.txt new file mode 100644 index 0000000..986c53b --- /dev/null +++ b/WeChatFerry/spy/CMakeLists.txt @@ -0,0 +1,108 @@ +# Spy project - dynamic library +project(Spy LANGUAGES C CXX) + +find_package(spdlog REQUIRED) +find_package(magic_enum REQUIRED) +find_package(minhook CONFIG REQUIRED) +find_package(nng REQUIRED) + +add_library(spy SHARED + chatroom_manager.cpp + chatroom_manager.h + misc_manager.cpp + misc_manager.h + database_executor.cpp + database_executor.h + contact_manager.cpp + contact_manager.h + message_handler.cpp + message_handler.h + rpc_server.cpp + rpc_server.h + message_sender.cpp + message_sender.h + spy.cpp + spy.h + spy_types.h + account_manager.cpp + account_manager.h + resource.h + rpc_helper.h + sqlite3.h + dllmain.cpp + spy.def + + # Common files + ${CMAKE_SOURCE_DIR}/com/util.cpp + ${CMAKE_SOURCE_DIR}/com/util.h + ${CMAKE_SOURCE_DIR}/com/log.hpp + + # RPC files + ${CMAKE_SOURCE_DIR}/rpc/pb_util.cpp + ${CMAKE_SOURCE_DIR}/rpc/pb_util.h + ${CMAKE_SOURCE_DIR}/rpc/pb_types.h + ${CMAKE_SOURCE_DIR}/rpc/nanopb/pb.h + ${CMAKE_SOURCE_DIR}/rpc/nanopb/pb_common.h + ${CMAKE_SOURCE_DIR}/rpc/nanopb/pb_decode.h + ${CMAKE_SOURCE_DIR}/rpc/nanopb/pb_encode.h + ${CMAKE_SOURCE_DIR}/rpc/nanopb/pb_common.c + ${CMAKE_SOURCE_DIR}/rpc/nanopb/pb_decode.c + ${CMAKE_SOURCE_DIR}/rpc/nanopb/pb_encode.c + ${CMAKE_SOURCE_DIR}/rpc/proto/wcf.pb.c + ${CMAKE_SOURCE_DIR}/rpc/proto/wcf.pb.h +) + +# link directories +target_link_directories(spy PRIVATE + ${CMAKE_SOURCE_DIR}/smc +) + +# Link dependencies +target_link_libraries(spy PRIVATE + Codec + mp3lame + version + shlwapi + iphlpapi + wsock32 + ws2_32 + crypt32 + magic_enum::magic_enum + nng::nng + spdlog::spdlog + minhook::minhook + c++ +) + +add_custom_command( + OUTPUT + ${CMAKE_SOURCE_DIR}/rpc/proto/wcf.pb.c + ${CMAKE_SOURCE_DIR}/rpc/proto/wcf.pb.h + COMMAND ${CMAKE_SOURCE_DIR}/rpc/tool/protoc --nanopb_out=${CMAKE_SOURCE_DIR}/rpc/proto wcf.proto + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/rpc/proto + DEPENDS ${CMAKE_SOURCE_DIR}/rpc/proto/wcf.proto + COMMENT "Generated protobuf files" +) + +# Add generated files as dependencies +add_custom_target(protobuf_generation + DEPENDS + ${CMAKE_SOURCE_DIR}/rpc/proto/wcf.pb.c + ${CMAKE_SOURCE_DIR}/rpc/proto/wcf.pb.h +) +add_dependencies(spy protobuf_generation) + +# Set output name for debug builds +set_target_properties(spy PROPERTIES + DEBUG_POSTFIX "d" +) + +# Post-build copy commands +# add_custom_command(TARGET spy POST_BUILD +# COMMAND ${CMAKE_COMMAND} -E copy +# $ +# ${CMAKE_SOURCE_DIR}/Out +# COMMAND ${CMAKE_COMMAND} -E copy +# $ +# ${CMAKE_SOURCE_DIR}/../clients/python/wcferry +# ) diff --git a/WeChatFerry/spy/Spy.vcxproj b/WeChatFerry/spy/Spy.vcxproj index 0854bf5..cbe58f1 100644 --- a/WeChatFerry/spy/Spy.vcxproj +++ b/WeChatFerry/spy/Spy.vcxproj @@ -250,7 +250,7 @@ xcopy /y $(SolutionDir)DISCLAIMER.md $(SolutionDir)..\clients\python\wcferry - + diff --git a/WeChatFerry/spy/Spy.vcxproj.filters b/WeChatFerry/spy/Spy.vcxproj.filters index a2a537b..313caee 100644 --- a/WeChatFerry/spy/Spy.vcxproj.filters +++ b/WeChatFerry/spy/Spy.vcxproj.filters @@ -18,7 +18,7 @@ - + 头文件 diff --git a/WeChatFerry/spy/framework.h b/WeChatFerry/spy/framework.h deleted file mode 100644 index 80cbbc9..0000000 --- a/WeChatFerry/spy/framework.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容 -// Windows 头文件 -#include diff --git a/WeChatFerry/spy/message_handler.cpp b/WeChatFerry/spy/message_handler.cpp index 8fb2bc8..851584f 100644 --- a/WeChatFerry/spy/message_handler.cpp +++ b/WeChatFerry/spy/message_handler.cpp @@ -5,8 +5,6 @@ #include #include -#include "framework.h" - #include "account_manager.h" #include "log.hpp" #include "offsets.h" @@ -192,8 +190,8 @@ int Handler::EnableLog() funcWxLog = Spy::getFunction(OsLog::CALL); if (InitializeHook() != MH_OK) return -1; - if (MH_CreateHook(funcWxLog, &PrintWxLog, reinterpret_cast(&realWxLog)) != MH_OK) return -2; - if (MH_EnableHook(funcWxLog) != MH_OK) return -3; + if (MH_CreateHook(reinterpret_cast(funcWxLog), reinterpret_cast(&PrintWxLog), reinterpret_cast(&realWxLog)) != MH_OK) return -2; + if (MH_EnableHook(reinterpret_cast(funcWxLog)) != MH_OK) return -3; *pLogLevel = 0; isLogging = true; @@ -203,8 +201,8 @@ int Handler::EnableLog() int Handler::DisableLog() { if (!isLogging) return 1; - if (MH_DisableHook(funcWxLog) != MH_OK) return -1; - if (MH_RemoveHook(funcWxLog) != MH_OK) return -2; + if (MH_DisableHook(reinterpret_cast(funcWxLog)) != MH_OK) return -1; + if (MH_RemoveHook(reinterpret_cast(funcWxLog)) != MH_OK) return -2; if (UninitializeHook() != MH_OK) return -3; *pLogLevel = 6; isLogging = false; @@ -217,8 +215,8 @@ int Handler::ListenMsg() funcRecvMsg = Spy::getFunction(OsRecv::CALL); if (InitializeHook() != MH_OK) return -1; - if (MH_CreateHook(funcRecvMsg, &DispatchMsg, reinterpret_cast(&realRecvMsg)) != MH_OK) return -2; - if (MH_EnableHook(funcRecvMsg) != MH_OK) return -3; + if (MH_CreateHook(reinterpret_cast(funcRecvMsg), reinterpret_cast(&DispatchMsg), reinterpret_cast(&realRecvMsg)) != MH_OK) return -2; + if (MH_EnableHook(reinterpret_cast(funcRecvMsg)) != MH_OK) return -3; isListeningMsg = true; return 0; @@ -227,8 +225,8 @@ int Handler::ListenMsg() int Handler::UnListenMsg() { if (!isListeningMsg) return 1; - if (MH_DisableHook(funcRecvMsg) != MH_OK) return -1; - if (MH_RemoveHook(funcRecvMsg) != MH_OK) return -2; + if (MH_DisableHook(reinterpret_cast(funcRecvMsg)) != MH_OK) return -1; + if (MH_RemoveHook(reinterpret_cast(funcRecvMsg)) != MH_OK) return -2; if (UninitializeHook() != MH_OK) return -3; isListeningMsg = false; return 0; @@ -240,8 +238,8 @@ int Handler::ListenPyq() funcRecvPyq = Spy::getFunction(OsRecv::PYQ_CALL); if (InitializeHook() != MH_OK) return -1; - if (MH_CreateHook(funcRecvPyq, &DispatchPyq, reinterpret_cast(&realRecvPyq)) != MH_OK) return -1; - if (MH_EnableHook(funcRecvPyq) != MH_OK) return -1; + if (MH_CreateHook(reinterpret_cast(funcRecvPyq), reinterpret_cast(&DispatchPyq), reinterpret_cast(&realRecvPyq)) != MH_OK) return -1; + if (MH_EnableHook(reinterpret_cast(funcRecvPyq)) != MH_OK) return -1; isListeningPyq = true; return 0; @@ -250,8 +248,8 @@ int Handler::ListenPyq() int Handler::UnListenPyq() { if (!isListeningPyq) return 1; - if (MH_DisableHook(funcRecvPyq) != MH_OK) return -1; - if (MH_RemoveHook(funcRecvPyq) != MH_OK) return -2; + if (MH_DisableHook(reinterpret_cast(funcRecvPyq)) != MH_OK) return -1; + if (MH_RemoveHook(reinterpret_cast(funcRecvPyq)) != MH_OK) return -2; if (UninitializeHook() != MH_OK) return -3; isListeningPyq = false; return 0; diff --git a/WeChatFerry/spy/misc_manager.cpp b/WeChatFerry/spy/misc_manager.cpp index 5db4fbc..390ba5e 100644 --- a/WeChatFerry/spy/misc_manager.cpp +++ b/WeChatFerry/spy/misc_manager.cpp @@ -4,8 +4,6 @@ #include #include -#include "framework.h" - #include "codec.h" #include "database_executor.h" #include "log.hpp" diff --git a/WeChatFerry/spy/spy.cpp b/WeChatFerry/spy/spy.cpp index dc6a700..14d36f7 100644 --- a/WeChatFerry/spy/spy.cpp +++ b/WeChatFerry/spy/spy.cpp @@ -14,7 +14,7 @@ int Init(void *args) auto *pp = static_cast(args); Log::InitLogger(pp->path); - if (auto dll_addr = GetModuleHandle(L"WeChatWin.dll")) { + if (auto dll_addr = GetModuleHandleW(L"WeChatWin.dll")) { WeChatDll.store(reinterpret_cast(dll_addr)); } else { LOG_ERROR("获取 WeChatWin.dll 模块地址失败"); diff --git a/WeChatFerry/spy/spy.def b/WeChatFerry/spy/spy.def index 7632d5c..3005a19 100644 --- a/WeChatFerry/spy/spy.def +++ b/WeChatFerry/spy/spy.def @@ -1,3 +1,3 @@ -EXPORTS +EXPORTS InitSpy CleanupSpy diff --git a/WeChatFerry/vcpkg.json b/WeChatFerry/vcpkg.json index d735952..5f077e0 100644 --- a/WeChatFerry/vcpkg.json +++ b/WeChatFerry/vcpkg.json @@ -2,14 +2,10 @@ "name": "wcf", "version-string": "1.0.0", "dependencies": [ - { - "name": "protobuf", - "features": [ "zlib" ] - }, "spdlog", "nng", "magic-enum", "minhook" ], - "builtin-baseline": "80d54ff62d528339c626a6fbc3489a7f25956ade" + "builtin-baseline": "d6995a0cf3cafda5e9e52749fad075dd62bfd90c" }