diff --git a/cyberpunk_patch/src/Options.cpp b/cyberpunk_patch/src/Options.cpp index bb2bad67..a60f587b 100644 --- a/cyberpunk_patch/src/Options.cpp +++ b/cyberpunk_patch/src/Options.cpp @@ -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; @@ -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; diff --git a/cyberpunk_patch/src/Options.h b/cyberpunk_patch/src/Options.h index 2e395b0a..dbe7250c 100644 --- a/cyberpunk_patch/src/Options.h +++ b/cyberpunk_patch/src/Options.h @@ -13,5 +13,6 @@ struct Options bool PatchAVX{ false }; bool PatchVirtualInput{ true }; bool PatchMemoryPool{ true }; + bool PatchUnlockMenu{ true }; std::filesystem::path Path; }; \ No newline at end of file diff --git a/cyberpunk_patch/src/dllmain.cpp b/cyberpunk_patch/src/dllmain.cpp index dabdb508..c34049bc 100644 --- a/cyberpunk_patch/src/dllmain.cpp +++ b/cyberpunk_patch/src/dllmain.cpp @@ -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); @@ -39,6 +40,9 @@ void Initialize(HMODULE mod) if (options.PatchVirtualInput) VirtualInputPatch(&image); + if (options.PatchUnlockMenu) + UnlockMenuPatch(&image); + spdlog::default_logger()->flush(); } diff --git a/cyberpunk_patch/src/pool_patch.cpp b/cyberpunk_patch/src/pool_patch.cpp index 9648c165..e3be3d2f 100644 --- a/cyberpunk_patch/src/pool_patch.cpp +++ b/cyberpunk_patch/src/pool_patch.cpp @@ -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) { @@ -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) @@ -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); diff --git a/cyberpunk_patch/src/unlock_menu_patch.cpp b/cyberpunk_patch/src/unlock_menu_patch.cpp new file mode 100644 index 00000000..405d5490 --- /dev/null +++ b/cyberpunk_patch/src/unlock_menu_patch.cpp @@ -0,0 +1,25 @@ +#include "Image.h" +#include + + +void UnlockMenuPatch(Image* apImage) +{ + uint8_t* pAddress = nullptr; + + if (apImage->version == Image::MakeVersion(1, 4)) + { + pAddress = reinterpret_cast(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"); +}