Skip to content

Commit

Permalink
Unlock the debug menu
Browse files Browse the repository at this point in the history
  • Loading branch information
maximegmd committed Dec 14, 2020
1 parent f8baaad commit 064dc14
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
2 changes: 2 additions & 0 deletions cyberpunk_patch/src/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Options::Options(HMODULE aModule)
this->PatchSpectre = config.value("spectre", this->PatchSpectre);
this->PatchMemoryPool = config.value("memory_pool", this->PatchMemoryPool);
this->PatchVirtualInput = config.value("virtual_input", this->PatchVirtualInput);
this->PatchUnlockMenu = config.value("unlock_menu", this->PatchUnlockMenu);
}

nlohmann::json config;
Expand All @@ -41,6 +42,7 @@ Options::Options(HMODULE aModule)
config["spectre"] = this->PatchSpectre;
config["memory_pool"] = this->PatchMemoryPool;
config["virtual_input"] = this->PatchVirtualInput;
config["unlock_menu"] = this->PatchUnlockMenu;

std::ofstream o(configPath);
o << config.dump(4) << std::endl;
Expand Down
1 change: 1 addition & 0 deletions cyberpunk_patch/src/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ struct Options
bool PatchAVX{ false };
bool PatchVirtualInput{ true };
bool PatchMemoryPool{ true };
bool PatchUnlockMenu{ true };
std::filesystem::path Path;
};
4 changes: 4 additions & 0 deletions cyberpunk_patch/src/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#pragma comment(linker, "/DLL")

void PoolPatch(Image* apImage);
void UnlockMenuPatch(Image* apImage);
void VirtualInputPatch(Image* apImage);
void SmtAmdPatch(Image* apImage);
void PatchAvx(Image* apImage);
Expand Down Expand Up @@ -39,6 +40,9 @@ void Initialize(HMODULE mod)
if (options.PatchVirtualInput)
VirtualInputPatch(&image);

if (options.PatchUnlockMenu)
UnlockMenuPatch(&image);

spdlog::default_logger()->flush();
}

Expand Down
6 changes: 3 additions & 3 deletions cyberpunk_patch/src/pool_patch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ uint64_t GetGPUMemory()

void RegisterPoolOptions(void* apThis, const char* acpName, uint64_t aSize)
{
const uint64_t kScaler = 1000 * 1000 * 1000;
const uint64_t kScaler = 1024 * 1024 * 1024;

if (strcmp(acpName, "PoolCPU") == 0)
{
Expand All @@ -59,7 +59,7 @@ void RegisterPoolOptions(void* apThis, const char* acpName, uint64_t aSize)
const auto gigsInstalled = statex.ullTotalPhys / kScaler;
aSize = (gigsInstalled - 4) * kScaler;

spdlog::info("\t\tDetected RAM: {}GB, using {}GB", gigsInstalled, aSize / kScaler);
spdlog::info("\t\tDetected RAM: {}GB, using {}GB", gigsInstalled, float(aSize) / kScaler);
}
}
else if (strcmp(acpName, "PoolGPU") == 0)
Expand All @@ -69,7 +69,7 @@ void RegisterPoolOptions(void* apThis, const char* acpName, uint64_t aSize)
const auto detectedGpuMemory = std::max(returnedGpuMemory, defaultMemory);
aSize = std::max(aSize, detectedGpuMemory);

spdlog::info("\t\tUsing {}GB of VRAM", aSize / kScaler);
spdlog::info("\t\tUsing {}GB of VRAM", float(aSize) / kScaler);
}

RealRegisterPoolOptions(apThis, acpName, aSize);
Expand Down
25 changes: 25 additions & 0 deletions cyberpunk_patch/src/unlock_menu_patch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "Image.h"
#include <spdlog/spdlog.h>


void UnlockMenuPatch(Image* apImage)
{
uint8_t* pAddress = nullptr;

if (apImage->version == Image::MakeVersion(1, 4))
{
pAddress = reinterpret_cast<uint8_t*>(apImage->base_address + 0x207c4b);
}
else
{
spdlog::warn("\tUnlock menu patch: failed, unknown version");
return;
}

DWORD oldProtect = 0;
VirtualProtect(pAddress, 8, PAGE_EXECUTE_WRITECOPY, &oldProtect);
*pAddress = 0;
VirtualProtect(pAddress, 8, oldProtect, nullptr);

spdlog::info("\tUnlock menu patch: success");
}

0 comments on commit 064dc14

Please sign in to comment.