Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions WeChatFerry/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

File renamed without changes.
1 change: 1 addition & 0 deletions WeChatFerry/com/log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
5 changes: 2 additions & 3 deletions WeChatFerry/com/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <strsafe.h>
#include <wchar.h>

#include "framework.h"
#include <Shlwapi.h>
#include <tlhelp32.h>

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion WeChatFerry/com/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
49 changes: 28 additions & 21 deletions WeChatFerry/rpc/tool/proto/nanopb_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions WeChatFerry/sdk/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
# )
2 changes: 1 addition & 1 deletion WeChatFerry/sdk/SDK.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion WeChatFerry/sdk/SDK.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework.h">
<ClInclude Include="..\com\framework.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="sdk.h">
Expand Down
2 changes: 1 addition & 1 deletion WeChatFerry/sdk/injector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
14 changes: 11 additions & 3 deletions WeChatFerry/sdk/sdk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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); // 用户拒绝协议,退出程序
Expand Down Expand Up @@ -134,7 +141,7 @@ int WxInitSDK(bool debug, int port)
return status;
}

int WxDestroySDK()
__declspec(dllexport) int WxDestroySDK()
{
if (!injected) {
return 1; // 未注入
Expand All @@ -151,3 +158,4 @@ int WxDestroySDK()

return 0;
}
}
2 changes: 1 addition & 1 deletion WeChatFerry/sdk/sdk.def
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
EXPORTS
EXPORTS
WxInitSDK
WxDestroySDK
6 changes: 4 additions & 2 deletions WeChatFerry/sdk/sdk.h
Original file line number Diff line number Diff line change
@@ -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();
}
Binary file added WeChatFerry/smc/libCodec.a
Binary file not shown.
Binary file added WeChatFerry/smc/libmp3lame.a
Binary file not shown.
Loading