Merge pull request #393 from CoderTyn/master

chore: add CMake support for MinGW-w64 environment
This commit is contained in:
Changhua 2025-04-24 22:39:48 +08:00 committed by GitHub
commit b8cb4fafc5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
24 changed files with 289 additions and 64 deletions

View File

@ -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)

View File

@ -13,6 +13,7 @@
#include <spdlog/sinks/rotating_file_sink.h>
#include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/spdlog.h>
#include "framework.h"
#define LOG_DEBUG(...) SPDLOG_DEBUG(__VA_ARGS__)
#define LOG_INFO(...) SPDLOG_INFO(__VA_ARGS__)

View File

@ -7,7 +7,6 @@
#include <strsafe.h>
#include <wchar.h>
#include "framework.h"
#include <Shlwapi.h>
#include <tlhelp32.h>
@ -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;

View File

@ -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);

View File

@ -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)

View File

@ -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
# $<TARGET_FILE:sdk>
# ${CMAKE_SOURCE_DIR}/Out
# COMMAND ${CMAKE_COMMAND} -E copy
# $<TARGET_FILE:sdk>
# ${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
# )

View File

@ -142,7 +142,7 @@ xcopy /y $(OutDir)$(TargetFileName) $(SolutionDir)..\clients\python\wcferry</Com
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\com\util.h" />
<ClInclude Include="framework.h" />
<ClInclude Include="..\com\framework.h" />
<ClInclude Include="injector.h" />
<ClInclude Include="sdk.h" />
</ItemGroup>

View File

@ -15,7 +15,7 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework.h">
<ClInclude Include="..\com\framework.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="sdk.h">

View File

@ -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<LPVOID>(GetProcAddress(dll, func_name.c_str()));
uint64_t offset = reinterpret_cast<uint64_t>(absAddr) - reinterpret_cast<uint64_t>(dll);
FreeLibrary(dll);

View File

@ -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;
}
}

View File

@ -1,3 +1,3 @@
EXPORTS
EXPORTS
WxInitSDK
WxDestroySDK

View File

@ -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();
}

BIN
WeChatFerry/smc/libCodec.a Normal file

Binary file not shown.

Binary file not shown.

View File

@ -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
# $<TARGET_FILE:spy>
# ${CMAKE_SOURCE_DIR}/Out
# COMMAND ${CMAKE_COMMAND} -E copy
# $<TARGET_FILE:spy>
# ${CMAKE_SOURCE_DIR}/../clients/python/wcferry
# )

View File

@ -250,7 +250,7 @@ xcopy /y $(SolutionDir)DISCLAIMER.md $(SolutionDir)..\clients\python\wcferry</Co
<ClInclude Include="chatroom_manager.h" />
<ClInclude Include="misc_manager.h" />
<ClInclude Include="database_executor.h" />
<ClInclude Include="framework.h" />
<ClInclude Include="..\com\framework.h" />
<ClInclude Include="contact_manager.h" />
<ClInclude Include="message_handler.h" />
<ClInclude Include="resource.h" />

View File

@ -18,7 +18,7 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework.h">
<ClInclude Include="..\com\framework.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="rpc_server.h">

View File

@ -1,5 +0,0 @@
#pragma once
#define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容
// Windows 头文件
#include <windows.h>

View File

@ -5,8 +5,6 @@
#include <mutex>
#include <queue>
#include "framework.h"
#include "account_manager.h"
#include "log.hpp"
#include "offsets.h"
@ -192,8 +190,8 @@ int Handler::EnableLog()
funcWxLog = Spy::getFunction<funcWxLog_t>(OsLog::CALL);
if (InitializeHook() != MH_OK) return -1;
if (MH_CreateHook(funcWxLog, &PrintWxLog, reinterpret_cast<LPVOID *>(&realWxLog)) != MH_OK) return -2;
if (MH_EnableHook(funcWxLog) != MH_OK) return -3;
if (MH_CreateHook(reinterpret_cast<LPVOID>(funcWxLog), reinterpret_cast<LPVOID>(&PrintWxLog), reinterpret_cast<LPVOID *>(&realWxLog)) != MH_OK) return -2;
if (MH_EnableHook(reinterpret_cast<LPVOID>(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<LPVOID>(funcWxLog)) != MH_OK) return -1;
if (MH_RemoveHook(reinterpret_cast<LPVOID>(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<funcRecvMsg_t>(OsRecv::CALL);
if (InitializeHook() != MH_OK) return -1;
if (MH_CreateHook(funcRecvMsg, &DispatchMsg, reinterpret_cast<LPVOID *>(&realRecvMsg)) != MH_OK) return -2;
if (MH_EnableHook(funcRecvMsg) != MH_OK) return -3;
if (MH_CreateHook(reinterpret_cast<LPVOID>(funcRecvMsg), reinterpret_cast<LPVOID>(&DispatchMsg), reinterpret_cast<LPVOID *>(&realRecvMsg)) != MH_OK) return -2;
if (MH_EnableHook(reinterpret_cast<LPVOID>(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<LPVOID>(funcRecvMsg)) != MH_OK) return -1;
if (MH_RemoveHook(reinterpret_cast<LPVOID>(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<funcRecvPyq_t>(OsRecv::PYQ_CALL);
if (InitializeHook() != MH_OK) return -1;
if (MH_CreateHook(funcRecvPyq, &DispatchPyq, reinterpret_cast<LPVOID *>(&realRecvPyq)) != MH_OK) return -1;
if (MH_EnableHook(funcRecvPyq) != MH_OK) return -1;
if (MH_CreateHook(reinterpret_cast<LPVOID>(funcRecvPyq), reinterpret_cast<LPVOID>(&DispatchPyq), reinterpret_cast<LPVOID *>(&realRecvPyq)) != MH_OK) return -1;
if (MH_EnableHook(reinterpret_cast<LPVOID>(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<LPVOID>(funcRecvPyq)) != MH_OK) return -1;
if (MH_RemoveHook(reinterpret_cast<LPVOID>(funcRecvPyq)) != MH_OK) return -2;
if (UninitializeHook() != MH_OK) return -3;
isListeningPyq = false;
return 0;

View File

@ -4,8 +4,6 @@
#include <filesystem>
#include <fstream>
#include "framework.h"
#include "codec.h"
#include "database_executor.h"
#include "log.hpp"

View File

@ -14,7 +14,7 @@ int Init(void *args)
auto *pp = static_cast<util::PortPath *>(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<uint64_t>(dll_addr));
} else {
LOG_ERROR("获取 WeChatWin.dll 模块地址失败");

View File

@ -1,3 +1,3 @@
EXPORTS
EXPORTS
InitSpy
CleanupSpy

View File

@ -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"
}