mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-25 21:03:18 +00:00
47 lines
No EOL
1.2 KiB
C++
47 lines
No EOL
1.2 KiB
C++
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#pragma once
|
|
#include <cstring>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace MemoryPatcher {
|
|
|
|
extern uintptr_t g_eboot_address;
|
|
extern uint64_t g_eboot_image_size;
|
|
extern std::string g_game_serial;
|
|
extern std::string patchFile;
|
|
|
|
enum PatchMask : uint8_t {
|
|
None,
|
|
Mask,
|
|
Mask_Jump32,
|
|
};
|
|
|
|
struct patchInfo {
|
|
std::string gameSerial;
|
|
std::string modNameStr;
|
|
std::string offsetStr;
|
|
std::string valueStr;
|
|
bool isOffset;
|
|
bool littleEndian;
|
|
PatchMask patchMask;
|
|
int maskOffset;
|
|
};
|
|
|
|
extern std::vector<patchInfo> pending_patches;
|
|
|
|
std::string convertValueToHex(const std::string type, const std::string valueStr);
|
|
|
|
void OnGameLoaded();
|
|
void AddPatchToQueue(patchInfo patchToAdd);
|
|
void ApplyPendingPatches();
|
|
|
|
void PatchMemory(std::string modNameStr, std::string offsetStr, std::string valueStr, bool isOffset,
|
|
bool littleEndian, PatchMask patchMask = PatchMask::None, int maskOffset = 0);
|
|
|
|
static std::vector<int32_t> PatternToByte(const std::string& pattern);
|
|
uintptr_t PatternScan(const std::string& signature);
|
|
|
|
} // namespace MemoryPatcher
|