Add DLL to modify PlayFab url
This commit is contained in:
@@ -47,13 +47,21 @@
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(ProjectDir)bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<OutDir>$(SolutionDir)Prospect.Launcher\Libs</OutDir>
|
||||
<IntDir>$(ProjectDir)bin\intermediate\$(Platform)\$(Configuration)\</IntDir>
|
||||
<LibraryPath>$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(ProjectDir)bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<OutDir>$(SolutionDir)Prospect.Launcher\Libs</OutDir>
|
||||
<IntDir>$(ProjectDir)bin\intermediate\$(Platform)\$(Configuration)\</IntDir>
|
||||
<LibraryPath>$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<VcpkgUseStatic>true</VcpkgUseStatic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<VcpkgUseStatic>true</VcpkgUseStatic>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
@@ -63,13 +71,13 @@
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)libs\detours\;$(UESDK);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>detours.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@@ -82,7 +90,8 @@
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)libs\detours\;$(UESDK);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -90,12 +99,14 @@
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>detours.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="hooks.h" />
|
||||
<ClInclude Include="logger.h" />
|
||||
<ClInclude Include="main.h" />
|
||||
<ClInclude Include="SDK.h" />
|
||||
<ClInclude Include="SDK_Memory.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="logger.cpp" />
|
||||
|
||||
@@ -15,10 +15,16 @@
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="main.h">
|
||||
<ClInclude Include="logger.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="logger.h">
|
||||
<ClInclude Include="SDK.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="hooks.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SDK_Memory.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <locale>
|
||||
#include <string>
|
||||
#include "SDK_Memory.h"
|
||||
|
||||
namespace SDK
|
||||
{
|
||||
template<class T>
|
||||
struct TArray
|
||||
{
|
||||
friend struct FString;
|
||||
|
||||
TArray()
|
||||
{
|
||||
Data = nullptr;
|
||||
Count = Max = 0;
|
||||
}
|
||||
|
||||
int Num() const
|
||||
{
|
||||
return Count;
|
||||
}
|
||||
|
||||
T& operator[](int i)
|
||||
{
|
||||
return Data[i];
|
||||
}
|
||||
|
||||
const T& operator[](int i) const
|
||||
{
|
||||
return Data[i];
|
||||
}
|
||||
|
||||
bool IsValidIndex(int i) const
|
||||
{
|
||||
return i < Num();
|
||||
}
|
||||
|
||||
private:
|
||||
T* Data;
|
||||
int32_t Count;
|
||||
int32_t Max;
|
||||
};
|
||||
|
||||
struct FString : private TArray<wchar_t>
|
||||
{
|
||||
FString(const wchar_t* other)
|
||||
{
|
||||
Max = Count = *other ? std::wcslen(other) + 1 : 0;
|
||||
|
||||
if (Count)
|
||||
{
|
||||
Data = static_cast<wchar_t*>(GMalloc->Malloc(Count));
|
||||
|
||||
wcscpy_s(Data, Count, other);
|
||||
}
|
||||
}
|
||||
|
||||
FString(const std::wstring& other) : FString(other.c_str())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool IsValid() const
|
||||
{
|
||||
return Data != nullptr;
|
||||
}
|
||||
|
||||
const wchar_t* c_str() const
|
||||
{
|
||||
return Data;
|
||||
}
|
||||
|
||||
std::string ToString() const
|
||||
{
|
||||
const auto length = std::wcslen(Data);
|
||||
|
||||
std::string str(length, '\0');
|
||||
std::use_facet<std::ctype<wchar_t>>(std::locale()).narrow(Data, Data + length, '?', &str[0]);
|
||||
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
struct UPlayFabAPISettings
|
||||
{
|
||||
FString VerticalName;
|
||||
FString BaseServiceHost;
|
||||
FString TitleId;
|
||||
FString AdvertisingIdType;
|
||||
FString AdvertisingIdValue;
|
||||
bool DisableAdvertising = false;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#define DEFAULT_ALIGNMENT 0
|
||||
|
||||
namespace SDK
|
||||
{
|
||||
class FExec
|
||||
{
|
||||
public:
|
||||
virtual ~FExec() = default;
|
||||
private:
|
||||
virtual bool Exec(void* world, void* cmd, void* ar) = 0;
|
||||
};
|
||||
|
||||
class FMalloc : FExec
|
||||
{
|
||||
public:
|
||||
virtual void* Malloc(SIZE_T Count, uint32_t Alignment = DEFAULT_ALIGNMENT) = 0;
|
||||
|
||||
virtual void* TryMalloc(SIZE_T Count, uint32_t Alignment = DEFAULT_ALIGNMENT) = 0;
|
||||
|
||||
virtual void* Realloc(void* Original, SIZE_T Count, uint32_t Alignment = DEFAULT_ALIGNMENT) = 0;
|
||||
|
||||
virtual void* TryRealloc(void* Original, SIZE_T Count, uint32_t Alignment = DEFAULT_ALIGNMENT) = 0;
|
||||
|
||||
virtual void Free(void* Original) = 0;
|
||||
|
||||
virtual SIZE_T QuantizeSize(SIZE_T Count, uint32_t Alignment)
|
||||
{
|
||||
return Count;
|
||||
}
|
||||
|
||||
virtual bool GetAllocationSize(void* Original, SIZE_T& SizeOut)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void Trim(bool bTrimThreadCaches)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void SetupTLSCachesOnCurrentThread()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void ClearAndDisableTLSCachesOnCurrentThread()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void InitializeStatsMetadata();
|
||||
|
||||
virtual bool Exec(void* InWorld, void* Cmd, void* Ar) override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void UpdateStats() = 0;
|
||||
|
||||
virtual void GetAllocatorStats(void* out_Stats) = 0;
|
||||
|
||||
virtual void DumpAllocatorStats(class FOutputDevice& Ar) = 0;
|
||||
|
||||
virtual bool IsInternallyThreadSafe() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool ValidateHeap()
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
|
||||
virtual const TCHAR* GetDescriptiveName() = 0;
|
||||
};
|
||||
|
||||
FMalloc* GMalloc;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "SDK.h"
|
||||
@@ -1,5 +1,8 @@
|
||||
#include "logger.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <Windows.h>
|
||||
|
||||
HANDLE h_out = nullptr, h_old_out = nullptr;
|
||||
HANDLE h_err = nullptr, h_old_err = nullptr;
|
||||
HANDLE h_in = nullptr, h_old_in = nullptr;
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdio>
|
||||
#include <Windows.h>
|
||||
|
||||
namespace logger
|
||||
{
|
||||
void Attach();
|
||||
@@ -12,4 +9,4 @@ namespace logger
|
||||
bool Print(const char* fmt, ...);
|
||||
|
||||
char ReadKey();
|
||||
};
|
||||
}
|
||||
@@ -1,17 +1,71 @@
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#include <MinHook.h>
|
||||
#include <cstdio>
|
||||
#include "main.h"
|
||||
#include "logger.h"
|
||||
#include <detours.h>
|
||||
#include "SDK.h"
|
||||
#include "SDK_Memory.h"
|
||||
|
||||
/**
|
||||
* Variable offset, find with "STOPMOVIECAPTURE", scroll up.
|
||||
*/
|
||||
constexpr uintptr_t OffsetGMalloc = 0x5C9A3F8;
|
||||
|
||||
/**
|
||||
* Function offset, find with "?sdk=".
|
||||
*/
|
||||
constexpr uintptr_t OffsetPlayFabApiGetUrl = 0xCA5010;
|
||||
|
||||
/**
|
||||
* Function hooks.
|
||||
*/
|
||||
typedef SDK::FString(__fastcall* tPlayFabApiGetUrl)(SDK::UPlayFabAPISettings*, const SDK::FString&);
|
||||
|
||||
tPlayFabApiGetUrl OldPlayFabApiGetUrl;
|
||||
|
||||
SDK::FString __fastcall PlayFabApiGetUrlProxy(SDK::UPlayFabAPISettings* thiz, const SDK::FString& callPath)
|
||||
{
|
||||
logger::Print("[Agent] GetURL called with callPath %s\n", callPath.ToString().c_str());
|
||||
|
||||
return std::wstring(L"http://127.0.0.1:8888") + std::wstring(callPath.c_str());
|
||||
}
|
||||
|
||||
DWORD WINAPI OnDllAttach(LPVOID base)
|
||||
{
|
||||
logger::Attach();
|
||||
logger::Print("[Agent] DLL Attached\n");
|
||||
|
||||
// TODO: Patch.
|
||||
const auto hModule = GetModuleHandleW(nullptr);
|
||||
const auto hModulePtr = reinterpret_cast<uintptr_t>(hModule);
|
||||
|
||||
logger::Print("[Agent] DLL Exit\n");
|
||||
FreeLibraryAndExitThread(static_cast<HMODULE>(base), 1);
|
||||
// Initialize GMalloc.
|
||||
SDK::GMalloc = *reinterpret_cast<SDK::FMalloc**>(hModulePtr + OffsetGMalloc);
|
||||
|
||||
// Initialize MinHook.
|
||||
if (MH_Initialize() != MH_OK)
|
||||
{
|
||||
logger::Print("[Agent] Failed to initialize MinHook\n");
|
||||
FreeLibraryAndExitThread(hModule, 1);
|
||||
}
|
||||
|
||||
// Hook UPlayFabAPISettings::GetUrl.
|
||||
const auto pTarget = reinterpret_cast<LPVOID>(hModulePtr + OffsetPlayFabApiGetUrl);
|
||||
const auto ppOriginal = reinterpret_cast<LPVOID*>(&OldPlayFabApiGetUrl);
|
||||
const auto mhStatus = MH_CreateHook(pTarget, &PlayFabApiGetUrlProxy, ppOriginal);
|
||||
|
||||
if (mhStatus != MH_OK)
|
||||
{
|
||||
logger::Print("[Agent] Failed to create PlayFabAPIGetUrl hook (%d)\n", mhStatus);
|
||||
FreeLibraryAndExitThread(hModule, 1);
|
||||
}
|
||||
|
||||
if (MH_EnableHook(pTarget) != MH_OK)
|
||||
{
|
||||
logger::Print("[Agent] Failed to enable PlayFabAPIGetUrl hook\n");
|
||||
FreeLibraryAndExitThread(hModule, 1);
|
||||
}
|
||||
|
||||
logger::Print("[Agent] DLL Initialized\n");
|
||||
ExitThread(1);
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain(
|
||||
@@ -27,10 +81,18 @@ BOOL WINAPI DllMain(
|
||||
// Allocate a console.
|
||||
AllocConsole();
|
||||
freopen_s(reinterpret_cast<FILE**>(stdout), "CONOUT$", "w", stdout);
|
||||
|
||||
// Attach logger.
|
||||
logger::Attach();
|
||||
|
||||
// Spawn thread.
|
||||
CreateThread(nullptr, 0, OnDllAttach, hinstDll, 0, nullptr);
|
||||
}
|
||||
else if (fdwReason == DLL_PROCESS_DETACH)
|
||||
{
|
||||
// Detach logger.
|
||||
logger::Detach();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
Reference in New Issue
Block a user