Add debug build

This commit is contained in:
Changhua 2023-02-25 01:53:02 +08:00
parent 6b94c3d6aa
commit b6b38376f8
9 changed files with 98 additions and 37 deletions

View File

@ -17,13 +17,18 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "launcher", "launcher\launch
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4DE80B82-5F6A-4C4C-9D16-1574308110FA}.Debug|x86.ActiveCfg = Debug|Win32
{4DE80B82-5F6A-4C4C-9D16-1574308110FA}.Debug|x86.Build.0 = Debug|Win32
{4DE80B82-5F6A-4C4C-9D16-1574308110FA}.Release|x86.ActiveCfg = Release|Win32
{4DE80B82-5F6A-4C4C-9D16-1574308110FA}.Release|x86.Build.0 = Release|Win32
{ABFCB647-137F-478B-A73E-F0B1E3ADC215}.Debug|x86.ActiveCfg = Debug|x64
{ABFCB647-137F-478B-A73E-F0B1E3ADC215}.Release|x86.ActiveCfg = Release|Win32
{ABFCB647-137F-478B-A73E-F0B1E3ADC215}.Release|x86.Build.0 = Release|Win32
{B11ADC6F-20DA-4DEF-A8A0-60374427D4C6}.Debug|x86.ActiveCfg = Debug|x64
{B11ADC6F-20DA-4DEF-A8A0-60374427D4C6}.Release|x86.ActiveCfg = Release|Win32
{B11ADC6F-20DA-4DEF-A8A0-60374427D4C6}.Release|x86.Build.0 = Release|Win32
EndGlobalSection

View File

@ -107,7 +107,7 @@ namespace launcher {
private: System::Void Start_Click(System::Object^ sender, System::EventArgs^ e) {
this->Start->Enabled = false;
this->Stop->Enabled = true;
WxInitSDK();
WxInitSDK(true);
}
private: System::Void Stop_Click(System::Object^ sender, System::EventArgs^ e) {
this->Stop->Enabled = false;

View File

@ -85,7 +85,7 @@
<EntryPointSymbol>main</EntryPointSymbol>
</Link>
<PostBuildEvent>
<Command>xcopy /y $(OutDir)launcher.exe $(OutDir)out\launcher</Command>
<Command>xcopy /y $(OutDir)launcher.exe $(SolutionDir)Out</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Copy files</Message>

View File

@ -126,8 +126,7 @@
<ModuleDefinitionFile>sdk.def</ModuleDefinitionFile>
</Link>
<PostBuildEvent>
<Command>xcopy /y $(OutDir)sdk.dll $(OutDir)out\launcher
xcopy /y $(OutDir)sdk.dll $(SolutionDir)python\wcferry</Command>
<Command>xcopy /y $(OutDir)sdk.dll $(SolutionDir)Out</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Copy files</Message>

27
sdk/main.cpp Normal file
View File

@ -0,0 +1,27 @@
#include <stdio.h>
#include <string.h>
#include "sdk.h"
void help() { printf("Usage: sdk.exe start|stop [debug]"); }
int main(int argc, char *argv[])
{
int ret = -1;
bool debug = false;
if ((argc < 2) || (argc > 3)) {
help();
} else if (argc == 3) {
debug = (strcmp(argv[2], "debug") == 0);
}
if (strcmp(argv[1], "start") == 0) {
ret = WxInitSDK(debug);
} else if (strcmp(argv[1], "stop") == 0) {
ret = WxDestroySDK();
} else {
help();
}
return ret;
}

View File

@ -1,4 +1,4 @@
#include "Shlwapi.h"
#include "Shlwapi.h"
#include "framework.h"
#include <process.h>
#include <tlhelp32.h>
@ -13,17 +13,21 @@ static HANDLE wcProcess = NULL;
static HMODULE spyBase = NULL;
static WCHAR spyDllPath[MAX_PATH] = { 0 };
int WxInitSDK()
int WxInitSDK(bool debug)
{
int status = 0;
InitLogger();
LOG_INFO("WxInitSDK.");
GetModuleFileName(GetModuleHandle(WECHATSDKDLL), spyDllPath, MAX_PATH);
PathRemoveFileSpec(spyDllPath);
PathAppend(spyDllPath, WECHATINJECTDLL);
if (debug) {
PathAppend(spyDllPath, WECHATINJECTDLL_DEBUG);
} else {
PathAppend(spyDllPath, WECHATINJECTDLL);
}
if (!PathFileExists(spyDllPath)) {
LOG_ERROR("DLL does not exists.");
LOG_ERROR("DLL does not exists: {}.", Wstring2String(spyDllPath));
return ERROR_FILE_NOT_FOUND;
}

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
int WxInitSDK();
int WxInitSDK(bool debug);
int WxDestroySDK();

View File

@ -74,6 +74,7 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<TargetName>$(ProjectName)_debug</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
@ -90,28 +91,9 @@
</PropertyGroup>
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<VcpkgUseStatic>true</VcpkgUseStatic>
<VcpkgConfiguration>Release</VcpkgConfiguration>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;SPY_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalIncludeDirectories>$(SolutionDir)rpc;$(SolutionDir)rpc\nanopb;$(SolutionDir)rpc\proto;$(SolutionDir)spy;C:\Tools\vcpkg\installed\x86-windows-static\include</AdditionalIncludeDirectories>
<PrecompiledHeaderOutputFile />
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<ModuleDefinitionFile>spy.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
@ -138,9 +120,52 @@
<ModuleDefinitionFile>spy.def</ModuleDefinitionFile>
</Link>
<PostBuildEvent>
<Command>cd $(OutDir)
md out\launcher
xcopy /y $(OutDir)spy.dll $(SolutionDir)python\wcferry</Command>
<Command>cd $(SolutionDir)
md Out
xcopy /y $(OutDir)$(TargetFileName) Out</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Copy spy.dll</Message>
</PostBuildEvent>
<PreBuildEvent>
<Command>cd $(SolutionDir)rpc\proto
C:\Tools\nanopb\protoc --nanopb_out=. wcf.proto
</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Generating PB files</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;SPY_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(SolutionDir)rpc;$(SolutionDir)rpc\nanopb;$(SolutionDir)rpc\proto;$(SolutionDir)spy;C:\Tools\vcpkg\installed\x86-windows-static\include</AdditionalIncludeDirectories>
<PrecompiledHeaderOutputFile />
<DisableSpecificWarnings>4251;4819</DisableSpecificWarnings>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>iphlpapi.lib;wsock32.lib;ws2_32.lib;crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>spy.def</ModuleDefinitionFile>
</Link>
<PostBuildEvent>
<Command>cd $(SolutionDir)
md Out
xcopy /y $(OutDir)$(TargetFileName) Out</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Copy spy.dll</Message>

View File

@ -2,10 +2,11 @@
#include <string>
#define WECHAREXE L"WeChat.exe"
#define WECHATWINDLL L"WeChatWin.dll"
#define WECHATSDKDLL L"sdk.dll"
#define WECHATINJECTDLL L"spy.dll"
#define WECHAREXE L"WeChat.exe"
#define WECHATWINDLL L"WeChatWin.dll"
#define WECHATSDKDLL L"sdk.dll"
#define WECHATINJECTDLL L"spy.dll"
#define WECHATINJECTDLL_DEBUG L"spy_debug.dll"
#define GET_DWORD(addr) ((DWORD) * (DWORD *)(addr))
#define GET_STRING(addr) ((CHAR *)(*(DWORD *)(addr)))