Skip to content

Commit

Permalink
Added Uplay R1 platform
Browse files Browse the repository at this point in the history
  • Loading branch information
acidicoala committed Mar 18, 2021
1 parent 5e41525 commit 85e4c85
Show file tree
Hide file tree
Showing 27 changed files with 279 additions and 183 deletions.
4 changes: 3 additions & 1 deletion Common/src/constants.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

constexpr auto VERSION = "1.0.1";
constexpr auto VERSION = "1.1.0";
constexpr auto WORKING_DIR = L"WORKING_DIR";

constexpr auto INTEGRATION_64 = L"Integration64.dll";
Expand All @@ -10,12 +10,14 @@ constexpr auto INTEGRATION_32 = L"Integration32.dll";

constexpr auto EOSSDK = L"EOSSDK-Win64-Shipping.dll";
constexpr auto STEAMAPI = L"steam_api64.dll";
constexpr auto UPLAY_R1 = L"uplay_r1_loader64.dll";
constexpr auto UPLAY_R2 = L"uplay_r2_loader64.dll";

#else

constexpr auto EOSSDK = L"EOSSDK-Win32-Shipping.dll";
constexpr auto STEAMAPI = L"steam_api.dll";
constexpr auto UPLAY_R1 = L"uplay_r1_loader.dll";
constexpr auto UPLAY_R2 = L"uplay_r2_loader.dll";

#endif
Expand Down
4 changes: 2 additions & 2 deletions Common/src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ wstring getProcessName(DWORD pid)
return wstring(buffer);
}

wstring getCurrentModuleName()
wstring getCurrentProcessName()
{
wchar_t name[MAX_PATH];
auto result = GetModuleFileName(NULL, name, MAX_PATH);

if(result == NULL)
logger->error("Failed to get current module's file name. Error code: {}", GetLastError());
logger->error("Failed to get current process file name. Error code: {}", GetLastError());

return wstring(name);
}
Expand Down
2 changes: 1 addition & 1 deletion Common/src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ constexpr auto UNLOCKER_NAME = "Unlocker32";

// Process info
wstring getProcessName(DWORD pid);
wstring getCurrentModuleName();
wstring getCurrentProcessName();
path getProcessPath(HANDLE handle = NULL);
bool is32bit(DWORD PID);
bool is32bit(HANDLE hProcess);
Expand Down
11 changes: 4 additions & 7 deletions IntegrationWizard/Config.jsonc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"config_version": 1, // DO NOT EDIT THIS VALUE
"config_version": 2, // DO NOT EDIT THIS VALUE
"log_level": "debug",
"platforms": {
"Steam": {
Expand Down Expand Up @@ -45,8 +45,8 @@
// "SIMS4.OFF.SOLP.0x0000000000030553" // Sims 4: Get Famous [Better stay anonymous]
]
},
"Ubisoft Connect": {
"enabled": false, // Ubisoft games unload the Unlocker DLL :(
"Uplay R1": {
"enabled": true,
"process": "upc.exe",
"replicate": true,
"ignore": [
Expand All @@ -60,10 +60,7 @@
// Unreal Engine
"CrashReportClient.exe",
// Origin integration with other stores
"EALink.exe",
// Ubisoft integration with other stores
"UbisoftGameLauncher.exe",
"UbisoftGameLauncher64.exe"
"EALink.exe"
],
"terminate": [
// Steam
Expand Down
12 changes: 8 additions & 4 deletions Unlocker/Unlocker.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,15 @@
<ClInclude Include="src\platforms\steam\steamtypes.h" />
<ClInclude Include="src\platforms\steam\steam_hooks.h" />
<ClInclude Include="src\platforms\steam\steam_ordinals.h" />
<ClInclude Include="src\platforms\ubisoft\ubisoft_hooks.h" />
<ClInclude Include="src\platforms\uplay_r1\UplayR1.h" />
<ClInclude Include="src\platforms\uplay_r1\uplay_r1_hooks.h" />
<ClInclude Include="src\platforms\uplay_r2\uplay_r2_hooks.h" />
<ClInclude Include="src\Unlocker.h" />
<ClInclude Include="src\ntapi.h" />
<ClInclude Include="src\pch.h" />
<ClInclude Include="src\ProcessHooker.h" />
<ClInclude Include="src\platforms\steam\Steam.h" />
<ClInclude Include="src\platforms\ubisoft\Ubisoft.h" />
<ClInclude Include="src\platforms\uplay_r2\UplayR2.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\platforms\origin\Origin.cpp" />
Expand All @@ -237,7 +239,9 @@
<ClCompile Include="src\platforms\epic\Epic.cpp" />
<ClCompile Include="src\platforms\origin\origin_hooks.cpp" />
<ClCompile Include="src\platforms\steam\steam_hooks.cpp" />
<ClCompile Include="src\platforms\ubisoft\ubisoft_hooks.cpp" />
<ClCompile Include="src\platforms\uplay_r1\UplayR1.cpp" />
<ClCompile Include="src\platforms\uplay_r1\uplay_r1_hooks.cpp" />
<ClCompile Include="src\platforms\uplay_r2\uplay_r2_hooks.cpp" />
<ClCompile Include="src\Unlocker.cpp" />
<ClCompile Include="src\pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
Expand All @@ -247,7 +251,7 @@
</ClCompile>
<ClCompile Include="src\ProcessHooker.cpp" />
<ClCompile Include="src\platforms\steam\Steam.cpp" />
<ClCompile Include="src\platforms\ubisoft\Ubisoft.cpp" />
<ClCompile Include="src\platforms\uplay_r2\UplayR2.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.vcxproj">
Expand Down
42 changes: 30 additions & 12 deletions Unlocker/Unlocker.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,21 @@
<Filter Include="Header Files\platforms\origin">
<UniqueIdentifier>{a09035ba-a888-4765-86c3-5d1df17bdf5a}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\platforms\ubisoft">
<UniqueIdentifier>{3fa38e81-3df5-4991-ab87-30a327edacfe}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\platforms\origin">
<UniqueIdentifier>{e6dd8cef-5536-4417-88af-da4931ab890d}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\platforms\ubisoft">
<Filter Include="Source Files\platforms\uplay_r2">
<UniqueIdentifier>{dead7396-6b35-46bc-9107-d06731daa0cc}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\platforms\uplay_r2">
<UniqueIdentifier>{3fa38e81-3df5-4991-ab87-30a327edacfe}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\platforms\uplay_r1">
<UniqueIdentifier>{5fe452a7-3c29-4ce1-a4b2-1bf90c6b15ee}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\platforms\uplay_r1">
<UniqueIdentifier>{e1f0bb2b-4cf4-4a3b-8c4c-d5e216cd5eba}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\DLLMonitor.h">
Expand Down Expand Up @@ -101,11 +107,17 @@
<ClInclude Include="src\platforms\origin\Origin.h">
<Filter>Header Files\platforms\origin</Filter>
</ClInclude>
<ClInclude Include="src\platforms\ubisoft\Ubisoft.h">
<Filter>Header Files\platforms\ubisoft</Filter>
<ClInclude Include="src\platforms\uplay_r2\UplayR2.h">
<Filter>Header Files\platforms\uplay_r2</Filter>
</ClInclude>
<ClInclude Include="src\platforms\ubisoft\ubisoft_hooks.h">
<Filter>Header Files\platforms\ubisoft</Filter>
<ClInclude Include="src\platforms\uplay_r2\uplay_r2_hooks.h">
<Filter>Header Files\platforms\uplay_r2</Filter>
</ClInclude>
<ClInclude Include="src\platforms\uplay_r1\UplayR1.h">
<Filter>Header Files\platforms\uplay_r1</Filter>
</ClInclude>
<ClInclude Include="src\platforms\uplay_r1\uplay_r1_hooks.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -148,11 +160,17 @@
<ClCompile Include="src\platforms\origin\origin_hooks.cpp">
<Filter>Source Files\platforms\origin</Filter>
</ClCompile>
<ClCompile Include="src\platforms\ubisoft\ubisoft_hooks.cpp">
<Filter>Source Files\platforms\ubisoft</Filter>
<ClCompile Include="src\platforms\uplay_r2\uplay_r2_hooks.cpp">
<Filter>Source Files\platforms\uplay_r2</Filter>
</ClCompile>
<ClCompile Include="src\platforms\ubisoft\Ubisoft.cpp">
<Filter>Source Files\platforms\ubisoft</Filter>
<ClCompile Include="src\platforms\uplay_r2\UplayR2.cpp">
<Filter>Source Files\platforms\uplay_r2</Filter>
</ClCompile>
<ClCompile Include="src\platforms\uplay_r1\UplayR1.cpp">
<Filter>Source Files\platforms\uplay_r1</Filter>
</ClCompile>
<ClCompile Include="src\platforms\uplay_r1\uplay_r1_hooks.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
30 changes: 23 additions & 7 deletions Unlocker/src/DLLMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#include "platforms/epic/Epic.h"
#include "platforms/steam/Steam.h"
#include <platforms/origin/Origin.h>
#include <platforms/ubisoft/Ubisoft.h>
#include <platforms/uplay_r1/UplayR1.h>
#include <platforms/uplay_r2/UplayR2.h>


_LdrRegisterDllNotification LdrRegisterDllNotification = NULL;
Expand Down Expand Up @@ -48,6 +49,7 @@ void CALLBACK dllCallback(ULONG NotificationReason, PLDR_DLL_NOTIFICATION_DATA N
logger->info(L"Epic Games DLL has been detected");
platforms.push_back(make_unique<Epic>(NotificationData->Loaded.FullDllName->Buffer));
platforms.back()->init();

}
else if(dllName == STEAMAPI)
{
Expand All @@ -61,12 +63,18 @@ void CALLBACK dllCallback(ULONG NotificationReason, PLDR_DLL_NOTIFICATION_DATA N
platforms.push_back(make_unique<Origin>(NotificationData->Loaded.FullDllName->Buffer));
platforms.back()->init();
}
else if(dllName == UPLAY_R2)
else if(dllName == UPLAY_R1)
{
logger->info(L"Ubisoft DLL has been detected");
platforms.push_back(make_unique<Ubisoft>(NotificationData->Loaded.FullDllName->Buffer));
logger->info(L"UplayR1 DLL has been detected");
platforms.push_back(make_unique<UplayR1>(NotificationData->Loaded.FullDllName->Buffer));
platforms.back()->init();
}
/*else if(dllName == UPLAY_R2)
{
logger->info(L"UplayR2 DLL has been detected");
platforms.push_back(make_unique<UplayR2>(NotificationData->Loaded.FullDllName->Buffer));
platforms.back()->init();
}*/
}
}

Expand Down Expand Up @@ -95,12 +103,18 @@ void checkLoadedDlls()
platforms.push_back(make_unique<Origin>(handle));
platforms.back()->init();
}
else if(handle = GetModuleHandle(UPLAY_R2))
else if(handle = GetModuleHandle(UPLAY_R1))
{
logger->info(L"Ubisoft DLL is already loaded");
platforms.push_back(make_unique<Ubisoft>(handle));
logger->info(L"UplayR1 DLL is already loaded");
platforms.push_back(make_unique<UplayR1>(handle));
platforms.back()->init();
}
/*else if(handle = GetModuleHandle(UPLAY_R2))
{
logger->info(L"UplayR2 DLL is already loaded");
platforms.push_back(make_unique<UplayR2>(handle));
platforms.back()->init();
}*/
else
{
return;
Expand Down Expand Up @@ -139,11 +153,13 @@ void DLLMonitor::shutdown()
{
logger->debug("Shutting down DLL monitor");


for(auto& platform : platforms)
{
platform->shutdown();
}

// Deconstructor of each platform will do the unhooking
platforms.clear();

LdrUnregisterDllNotification(cookie);
Expand Down
2 changes: 1 addition & 1 deletion Unlocker/src/Unlocker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void Unlocker::init(HMODULE hModule)
Logger::init(UNLOCKER_NAME, true);

logger->info("Unlocker v{}", VERSION);
logger->info(L"Hooking into \"{}\"", getCurrentModuleName());
logger->info(L"Hooking into \"{}\"", getCurrentProcessName());

DLLMonitor::init();
ProcessHooker::init();
Expand Down
56 changes: 47 additions & 9 deletions Unlocker/src/platforms/BasePlatform.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
#include "pch.h"
#include "BasePlatform.h"

// TODO: Make constructor?
void BasePlatform::init()
{
if(initialized || handle == NULL)
return;

logger->debug("Initializing {} platform", getPlatformName());

platformInit();

logger->info("{} platform was initialized", getPlatformName());
initialized = true;
}

BasePlatform::BasePlatform(const HMODULE handle)
{
this->handle = handle;

auto buffer = new WCHAR[MAX_PATH];
GetModuleBaseName(GetCurrentProcess(), handle, buffer, MAX_PATH);
this->moduleName = wtos(wstring(buffer));
this->moduleName = wtos(buffer);
delete[] buffer;
}

BasePlatform::BasePlatform(const wstring& fullDllName)
{
moduleName = wtos(fullDllName);
this->moduleName = wtos(fullDllName);

auto handle = GetModuleHandle(fullDllName.c_str());
if(handle == NULL)
Expand All @@ -25,10 +39,30 @@ BasePlatform::BasePlatform(const wstring& fullDllName)
this->handle = handle;
}

void BasePlatform::installDetourHook(Hooks& hooks, void* hookedFunc, const char* funcName)
// Destructor
void BasePlatform::shutdown()
{
if(!initialized)
return;

logger->debug("Shutting down {} platform", getPlatformName());

auto& hooks = getPlatformHooks();

for(auto& hook : hooks)
{
hook->unHook();
}
hooks.clear();

logger->debug("{} platform was shut down", getPlatformName());
}


void BasePlatform::installDetourHook(void* hookedFunc, const char* funcName)
{
static std::mutex mutex;
const std::lock_guard lock(mutex);

auto& hooks = getPlatformHooks();

if(auto original_func_address = GetProcAddress(handle, funcName))
{
Expand All @@ -44,13 +78,15 @@ void BasePlatform::installDetourHook(Hooks& hooks, void* hookedFunc, const char*
{
hooks.pop_back();
logger->warn("Failed to hook \"{}\" via Detour. Trying with IAT.", funcName);
installIatHook(hooks, hookedFunc, funcName);
installIatHook(hookedFunc, funcName);
}
}
}

void BasePlatform::installIatHook(Hooks& hooks, void* hookedFunc, const char* funcName)
void BasePlatform::installIatHook(void* hookedFunc, const char* funcName)
{
auto& hooks = getPlatformHooks();

hooks.push_back(make_unique<PLH::IatHook>
(moduleName, funcName, (char*) hookedFunc, &trampolineMap[funcName], L"")
);
Expand All @@ -63,12 +99,14 @@ void BasePlatform::installIatHook(Hooks& hooks, void* hookedFunc, const char* fu
{
hooks.pop_back();
logger->warn("Failed to hook \"{}\" via IAT. Trying with EAT.", funcName);
installEatHook(hooks, hookedFunc, funcName);
installEatHook(hookedFunc, funcName);
}
}

void BasePlatform::installEatHook(Hooks& hooks, void* hookedFunc, const char* funcName)
void BasePlatform::installEatHook(void* hookedFunc, const char* funcName)
{
auto& hooks = getPlatformHooks();

hooks.push_back(make_unique<PLH::EatHook>
(funcName, stow(moduleName), (char*) hookedFunc, &trampolineMap[funcName])
);
Expand Down

0 comments on commit 85e4c85

Please sign in to comment.