mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-12-18 01:28:36 +00:00
Merge pull request #4 from CrazyBloo/Cheats_Patches
Initial Patch Implementation
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "common/alignment.h"
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/memory_patcher.h"
|
||||
#include "common/string_util.h"
|
||||
#include "core/aerolib/aerolib.h"
|
||||
#include "core/cpu_patches.h"
|
||||
@@ -19,8 +20,6 @@ using EntryFunc = PS4_SYSV_ABI int (*)(size_t args, const void* argp, void* para
|
||||
static u64 LoadOffset = CODE_BASE_OFFSET;
|
||||
static constexpr u64 CODE_BASE_INCR = 0x010000000u;
|
||||
|
||||
uintptr_t g_eboot_address;
|
||||
|
||||
static u64 GetAlignedSize(const elf_program_header& phdr) {
|
||||
return (phdr.p_align != 0 ? (phdr.p_memsz + (phdr.p_align - 1)) & ~(phdr.p_align - 1)
|
||||
: phdr.p_memsz);
|
||||
@@ -92,12 +91,6 @@ void Module::LoadModuleToMemory(u32& max_tls_index) {
|
||||
LoadOffset += CODE_BASE_INCR * (1 + aligned_base_size / CODE_BASE_INCR);
|
||||
LOG_INFO(Core_Linker, "Loading module {} to {}", name, fmt::ptr(*out_addr));
|
||||
|
||||
if (g_eboot_address == 0) {
|
||||
if (name == "eboot") {
|
||||
g_eboot_address = base_virtual_addr;
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize trampoline generator.
|
||||
void* trampoline_addr = std::bit_cast<void*>(base_virtual_addr + aligned_base_size);
|
||||
Xbyak::CodeGenerator c(TrampolineSize, trampoline_addr);
|
||||
@@ -200,6 +193,13 @@ void Module::LoadModuleToMemory(u32& max_tls_index) {
|
||||
|
||||
const VAddr entry_addr = base_virtual_addr + elf.GetElfEntry();
|
||||
LOG_INFO(Core_Linker, "program entry addr ..........: {:#018x}", entry_addr);
|
||||
|
||||
if (MemoryPatcher::g_eboot_address == 0) {
|
||||
if (name == "eboot") {
|
||||
MemoryPatcher::g_eboot_address = base_virtual_addr;
|
||||
MemoryPatcher::ApplyPendingPatches();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Module::LoadDynamicInfo() {
|
||||
|
||||
@@ -243,6 +243,4 @@ public:
|
||||
std::vector<u8> rela_bits;
|
||||
};
|
||||
|
||||
extern uintptr_t g_eboot_address;
|
||||
|
||||
} // namespace Core
|
||||
|
||||
Reference in New Issue
Block a user