mirror of
https://git.rip/DMCA_FUCKER/re3.git
synced 2024-12-23 08:30:00 +00:00
Check if address is used twice
This commit is contained in:
parent
66d83c6470
commit
b6a70ecb31
|
@ -9,6 +9,11 @@
|
||||||
#define NOVMT __declspec(novtable)
|
#define NOVMT __declspec(novtable)
|
||||||
#define SETVMT(a) *((DWORD_PTR*)this) = (DWORD_PTR)a
|
#define SETVMT(a) *((DWORD_PTR*)this) = (DWORD_PTR)a
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PATCH_CALL,
|
PATCH_CALL,
|
||||||
|
@ -28,6 +33,21 @@ enum
|
||||||
|
|
||||||
extern int gtaversion;
|
extern int gtaversion;
|
||||||
|
|
||||||
|
class StaticPatcher
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
using Patcher = void(*)();
|
||||||
|
|
||||||
|
Patcher m_func;
|
||||||
|
StaticPatcher *m_next;
|
||||||
|
static StaticPatcher *ms_head;
|
||||||
|
|
||||||
|
void Run() { m_func(); }
|
||||||
|
public:
|
||||||
|
StaticPatcher(Patcher func);
|
||||||
|
static void Apply();
|
||||||
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline T AddressByVersion(uint32_t addressIII10, uint32_t addressIII11, uint32_t addressIIISteam, uint32_t addressvc10, uint32_t addressvc11, uint32_t addressvcSteam)
|
inline T AddressByVersion(uint32_t addressIII10, uint32_t addressIII11, uint32_t addressIIISteam, uint32_t addressvc10, uint32_t addressvc11, uint32_t addressvcSteam)
|
||||||
{
|
{
|
||||||
|
@ -110,9 +130,18 @@ ClearCC(AT address, unsigned int nCount)
|
||||||
VirtualProtect((void*)address, nCount, dwProtect[0], &dwProtect[1]);
|
VirtualProtect((void*)address, nCount, dwProtect[0], &dwProtect[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern std::vector<int32> usedAddresses;
|
||||||
|
|
||||||
template<typename AT, typename HT> inline void
|
template<typename AT, typename HT> inline void
|
||||||
InjectHook(AT address, HT hook, unsigned int nType=PATCH_NOTHING)
|
InjectHook(AT address, HT hook, unsigned int nType=PATCH_NOTHING)
|
||||||
{
|
{
|
||||||
|
if(std::any_of(usedAddresses.begin(), usedAddresses.end(),
|
||||||
|
[address](AT value) { return (int32)value == address; })) {
|
||||||
|
debug("Used address %#06x twice when injecting hook\n", address);
|
||||||
|
}
|
||||||
|
|
||||||
|
usedAddresses.push_back((int32)address);
|
||||||
|
|
||||||
DWORD dwProtect[2];
|
DWORD dwProtect[2];
|
||||||
switch ( nType )
|
switch ( nType )
|
||||||
{
|
{
|
||||||
|
@ -159,22 +188,5 @@ inline void InterceptVmethod(void *dst, T func, uint32_t a)
|
||||||
Patch(a, func);
|
Patch(a, func);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class StaticPatcher
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
using Patcher = void(*)();
|
|
||||||
|
|
||||||
Patcher m_func;
|
|
||||||
StaticPatcher *m_next;
|
|
||||||
static StaticPatcher *ms_head;
|
|
||||||
|
|
||||||
void Run() { m_func(); }
|
|
||||||
public:
|
|
||||||
StaticPatcher(Patcher func);
|
|
||||||
static void Apply();
|
|
||||||
};
|
|
||||||
|
|
||||||
#define STARTPATCHES static StaticPatcher Patcher([](){
|
#define STARTPATCHES static StaticPatcher Patcher([](){
|
||||||
#define ENDPATCHES });
|
#define ENDPATCHES });
|
||||||
|
|
|
@ -16,6 +16,10 @@
|
||||||
#include "Automobile.h"
|
#include "Automobile.h"
|
||||||
#include "debugmenu_public.h"
|
#include "debugmenu_public.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
std::vector<int32> usedAddresses;
|
||||||
|
|
||||||
void **rwengine = *(void***)0x5A10E1;
|
void **rwengine = *(void***)0x5A10E1;
|
||||||
|
|
||||||
DebugMenuAPI gDebugMenuAPI;
|
DebugMenuAPI gDebugMenuAPI;
|
||||||
|
|
Loading…
Reference in a new issue