Add dev console
This commit is contained in:
@@ -1,12 +1,16 @@
|
|||||||
#include "Memory.hpp";
|
|
||||||
#include "Maths.hpp";
|
|
||||||
#include "ObfuscateString.h"
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
#include <spdlog/sinks/rotating_file_sink.h>
|
#include <spdlog/sinks/rotating_file_sink.h>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <safetyhook.hpp>
|
#include <safetyhook.hpp>
|
||||||
|
#include "Memory.hpp";
|
||||||
|
#include "Maths.hpp";
|
||||||
|
#include "UEngine.hpp";
|
||||||
|
#include "SDK/Basic.hpp"
|
||||||
|
#include "SDK/Engine_classes.hpp"
|
||||||
|
#include "ObfuscateString.h"
|
||||||
|
|
||||||
|
using namespace SDK;
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
const std::string PLUGIN_NAME = "HellIsUs";
|
const std::string PLUGIN_NAME = "HellIsUs";
|
||||||
@@ -38,6 +42,13 @@ static int g_AdditionalFOVValue = 0;
|
|||||||
static float g_FOV_In = 0;
|
static float g_FOV_In = 0;
|
||||||
static float g_Compensated_FOV = 0;
|
static float g_Compensated_FOV = 0;
|
||||||
static float g_FOV_Out = 0;
|
static float g_FOV_Out = 0;
|
||||||
|
static bool g_Console_Enabled = false;
|
||||||
|
|
||||||
|
// AOB Unreal Engine offsets addresses
|
||||||
|
static uint8_t* GObjectsaddress = nullptr;
|
||||||
|
static uint8_t* GNamesaddress = nullptr;
|
||||||
|
static uint8_t* AppendStringaddress = nullptr;
|
||||||
|
static uint8_t* ProcessEventaddress = nullptr;
|
||||||
|
|
||||||
// AOB Scan pointers
|
// AOB Scan pointers
|
||||||
static uint8_t* FOVaddress = nullptr;
|
static uint8_t* FOVaddress = nullptr;
|
||||||
@@ -60,6 +71,7 @@ static void DOFFixEnabled(bool fix_enabled);
|
|||||||
static void CAFixEnabled(bool fix_enabled);
|
static void CAFixEnabled(bool fix_enabled);
|
||||||
static void VignettingFixEnabled(bool fix_enabled);
|
static void VignettingFixEnabled(bool fix_enabled);
|
||||||
static void FogFixEnabled(bool fix_enabled);
|
static void FogFixEnabled(bool fix_enabled);
|
||||||
|
static void EnableConsole();
|
||||||
|
|
||||||
extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
|
extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
@@ -174,7 +186,56 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
|
|||||||
AOBScanDone = true;
|
AOBScanDone = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger->info("--------------- AOB scan finished ---------------");
|
if (!GObjectsaddress || !AppendStringaddress || !ProcessEventaddress) {
|
||||||
|
logger->info("------------ UEngine offsets search ------------");
|
||||||
|
|
||||||
|
constexpr auto GObjetcsStringObfuscated = make_obfuscated<0x4A>("48 8B ?? ?? ?? ?? ?? 48 8B ?? ?? 48 8D ?? ?? EB ?? 33");
|
||||||
|
GObjectsaddress = Memory::AOBScan(gameExecutable, GObjetcsStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||||
|
constexpr auto GNamesStringObfuscated = make_obfuscated<0x4A>("48 8D ?? ?? ?? ?? ?? EB ?? 48 8D ?? ?? ?? ?? ?? E8 ?? ?? ?? ?? C6 05 ?? ?? ?? ?? ?? 0F ?? ?? 4C");
|
||||||
|
GNamesaddress = Memory::AOBScan(gameExecutable, GNamesStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||||
|
constexpr auto AppendStringStringObfuscated = make_obfuscated<0x4A>("48 89 ?? ?? ?? 48 89 ?? ?? ?? 57 48 83 ?? ?? 80 3D ?? ?? ?? ?? ?? 48 8B F2 8B ?? 48");
|
||||||
|
AppendStringaddress = Memory::AOBScan(gameExecutable, AppendStringStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||||
|
constexpr auto ProcessEventStringObfuscated = make_obfuscated<0x4A>("40 ?? 56 57 41 ?? 41 ?? 41 ?? 41 ?? 48 81 ?? ?? ?? ?? ?? 48 8D ?? ?? ?? 48 89 ?? ?? ?? ?? ?? 48 8B ?? ?? ?? ?? ?? 48 33 ?? 48 89 ?? ?? ?? ?? ?? 4D ?? ?? 48");
|
||||||
|
ProcessEventaddress = Memory::AOBScan(gameExecutable, ProcessEventStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||||
|
|
||||||
|
if (!GObjectsaddress)
|
||||||
|
logger->warn("GObjects signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
||||||
|
else {
|
||||||
|
uint32_t gObjectsOffset = static_cast<uint32_t>(Memory::GetOffsetFromOpcode(GObjectsaddress + 0x3) -
|
||||||
|
reinterpret_cast<uint8_t*>(GetModuleHandleA(gameExecutable.c_str())));
|
||||||
|
logger->info("GObjects offset is: 0x{:X}.", gObjectsOffset);
|
||||||
|
Offsets::GObjects = static_cast<UC::uint32>(gObjectsOffset); // Update GObjects offset
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!GNamesaddress)
|
||||||
|
logger->warn("GNames signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
||||||
|
else {
|
||||||
|
uint32_t gNamesOffset = static_cast<uint32_t>(Memory::GetOffsetFromOpcode(GNamesaddress + 0x3) -
|
||||||
|
reinterpret_cast<uint8_t*>(GetModuleHandleA(gameExecutable.c_str())));
|
||||||
|
logger->info("GNames offset is: 0x{:X}.", gNamesOffset);
|
||||||
|
Offsets::GNames = static_cast<UC::uint32>(gNamesOffset); // Update GNames offset
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!AppendStringaddress)
|
||||||
|
logger->warn("AppendString signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
||||||
|
else {
|
||||||
|
std::optional<uint32_t> gAppendStringOffsetOpt = UE::CalculateOffset(gameExecutable, AppendStringaddress); // Get Offset from opcode
|
||||||
|
uint32_t gAppendStringOffset = *gAppendStringOffsetOpt;
|
||||||
|
logger->info("AppendString offset is: 0x{:X}.", gAppendStringOffset);
|
||||||
|
Offsets::AppendString = static_cast<UC::uint32>(gAppendStringOffset); // Update AppendString offset
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ProcessEventaddress)
|
||||||
|
logger->warn("Process Event signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
||||||
|
else {
|
||||||
|
std::optional<uint32_t> gProcessEventOffsetOpt = UE::CalculateOffset(gameExecutable, ProcessEventaddress);
|
||||||
|
uint32_t gProcessEventOffset = *gProcessEventOffsetOpt;
|
||||||
|
logger->info("Process Event offset is: 0x{:X}.", gProcessEventOffset);
|
||||||
|
Offsets::ProcessEvent = static_cast<UC::uint32>(gProcessEventOffset);// Update ProcessEvent offset
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger->info("-------------- Fixes initialisation -------------");
|
||||||
}
|
}
|
||||||
if (g_fix_enabled) {
|
if (g_fix_enabled) {
|
||||||
if (FOVaddress) FOVFixEnabled(g_fov_fix_enabled || g_aspect_fix_enabled);
|
if (FOVaddress) FOVFixEnabled(g_fov_fix_enabled || g_aspect_fix_enabled);
|
||||||
@@ -237,6 +298,11 @@ extern "C" __declspec(dllexport) void SetFOV(int fov)
|
|||||||
g_AdditionalFOVValue = fov;
|
g_AdditionalFOVValue = fov;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" __declspec(dllexport) void SetConsole()
|
||||||
|
{
|
||||||
|
EnableConsole();
|
||||||
|
}
|
||||||
|
|
||||||
// Getters for Reshade addon call
|
// Getters for Reshade addon call
|
||||||
extern "C" __declspec(dllexport) float GetFOVIn() {
|
extern "C" __declspec(dllexport) float GetFOVIn() {
|
||||||
return g_FOV_In;
|
return g_FOV_In;
|
||||||
@@ -250,6 +316,10 @@ extern "C" __declspec(dllexport) float GetFOVOut() {
|
|||||||
return g_FOV_Out;
|
return g_FOV_Out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" __declspec(dllexport) bool GetConsoleEnabled() {
|
||||||
|
return g_Console_Enabled;
|
||||||
|
}
|
||||||
|
|
||||||
// Code injection functions
|
// Code injection functions
|
||||||
static void FOVFixEnabled(bool fix_enabled) {
|
static void FOVFixEnabled(bool fix_enabled) {
|
||||||
if (g_fix_enabled && fix_enabled && FOVaddress != nullptr) {
|
if (g_fix_enabled && fix_enabled && FOVaddress != nullptr) {
|
||||||
@@ -338,6 +408,60 @@ static void FogFixEnabled(bool fix_enabled) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UE Console creation
|
||||||
|
static void EnableConsole()
|
||||||
|
{
|
||||||
|
logger->info("-------------- Console re-enabling --------------");
|
||||||
|
if (!GObjectsaddress || !AppendStringaddress || !ProcessEventaddress) {
|
||||||
|
logger->warn("Could not re-enable console");
|
||||||
|
logger->info("------------------ User inputs ------------------");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::thread([&]() {
|
||||||
|
auto start = std::chrono::high_resolution_clock::now(); // Measure the time to renable console
|
||||||
|
UEngine* Engine = nullptr;
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; ++i) { // gives 10 seconds to find UE Engine
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
|
Engine = UEngine::GetEngine();
|
||||||
|
|
||||||
|
if (Engine && Engine->ConsoleClass && Engine->GameViewport)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Engine || !Engine->ConsoleClass || !Engine->GameViewport) {
|
||||||
|
logger->error("Console could not be found in engine.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
logger->info("Console found in engine");
|
||||||
|
|
||||||
|
/* Creates a new UObject of class-type specified by Engine->ConsoleClass */
|
||||||
|
UObject* NewObject = UGameplayStatics::SpawnObject(Engine->ConsoleClass, Engine->GameViewport);
|
||||||
|
if (NewObject)
|
||||||
|
{
|
||||||
|
logger->info("Successfully spawned console object");
|
||||||
|
// Set the console viewport so that it will be displayed
|
||||||
|
Engine->GameViewport->ViewportConsole = static_cast<UConsole*>(NewObject);
|
||||||
|
auto end = std::chrono::high_resolution_clock::now();
|
||||||
|
std::chrono::duration<double> elapsed = end - start;
|
||||||
|
|
||||||
|
// Set the all the console shortkey to F2
|
||||||
|
for (int i = 0; i < UInputSettings::GetDefaultObj()->ConsoleKeys.Num(); i++)
|
||||||
|
{
|
||||||
|
UInputSettings::GetDefaultObj()->ConsoleKeys[i].KeyName = UKismetStringLibrary::Conv_StringToName(L"F2");
|
||||||
|
}
|
||||||
|
logger->info("Console fully reactivated in {:.3f}s and bound to key F2", elapsed.count());
|
||||||
|
logger->info("------------------ User inputs ------------------");
|
||||||
|
|
||||||
|
g_Console_Enabled = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
logger->error("Could not spawn console object");
|
||||||
|
}
|
||||||
|
}).detach();
|
||||||
|
}
|
||||||
|
|
||||||
static void InitializeLogger()
|
static void InitializeLogger()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
Reference in New Issue
Block a user