mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 14:25:38 +03:00
Fixed engine and dll bases screwing up.
This commit is contained in:
parent
323341f67a
commit
472613d973
@ -14,5 +14,3 @@ void OnAmxxAttach()
|
|||||||
MF_AddNatives(write_natives);
|
MF_AddNatives(write_natives);
|
||||||
MF_AddNatives(misc_natives);
|
MF_AddNatives(misc_natives);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
#include "MemConst.h"
|
#include "MemConst.h"
|
||||||
|
|
||||||
// Game memory addresses
|
// Game memory addresses
|
||||||
maddress gameDllAddress;
|
maddress gameDllAddress = NULL;
|
||||||
maddress gameEngAddress;
|
maddress gameEngAddress = NULL;
|
||||||
|
|
||||||
bool GetBaseAddress(void *pAddr, maddress &pBaseAddr)
|
bool GetBaseAddress(void *pAddr, maddress &pBaseAddr/*, size_t *memLength*/)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
MEMORY_BASIC_INFORMATION mem;
|
MEMORY_BASIC_INFORMATION mem;
|
||||||
if (!VirtualQuery(pAddr, &mem, sizeof(mem)))
|
if (!VirtualQuery(pAddr, &mem, sizeof(mem)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (pBaseAddr)
|
|
||||||
pBaseAddr = (maddress)mem.AllocationBase;
|
pBaseAddr = (maddress)mem.AllocationBase;
|
||||||
|
|
||||||
IMAGE_DOS_HEADER *dos = (IMAGE_DOS_HEADER *)(mem.AllocationBase);
|
IMAGE_DOS_HEADER *dos = (IMAGE_DOS_HEADER *)(mem.AllocationBase);
|
||||||
@ -19,6 +18,8 @@ bool GetBaseAddress(void *pAddr, maddress &pBaseAddr)
|
|||||||
if (pe->Signature != IMAGE_NT_SIGNATURE)
|
if (pe->Signature != IMAGE_NT_SIGNATURE)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
//if (memLength)
|
||||||
|
//*memLength = (size_t)(pe->OptionalHeader.SizeOfImage);
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
Dl_info info;
|
Dl_info info;
|
||||||
@ -34,9 +35,9 @@ bool GetBaseAddress(void *pAddr, maddress &pBaseAddr)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (pBaseAddr)
|
if (pBaseAddr)
|
||||||
pBaseAddr = (maddress)info.dli_fbase;
|
*pBaseAddr = (unsigned char *)info.dli_fbase;
|
||||||
if (memLength)
|
//if (memLength)
|
||||||
*memLength = buf.st_size;
|
//*memLength = buf.st_size;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
@ -75,6 +76,15 @@ int MemoryProtect(void *addr, size_t len, unsigned long newProt, unsigned long *
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Linux won't work till I fix it for MEMTYPE_DATA
|
||||||
|
#ifdef __linux__
|
||||||
|
// Data section stuff
|
||||||
|
maddress dataSectionStart;
|
||||||
|
maddress dataSectionOffset;
|
||||||
|
|
||||||
|
int pageSize = sysconf(_SC_PAGESIZE);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Gets real memory address */
|
/* Gets real memory address */
|
||||||
maddress GetRealMemoryAddress(maddress baseaddress, maddress address, char memType)
|
maddress GetRealMemoryAddress(maddress baseaddress, maddress address, char memType)
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "MemConst.h"
|
#include "MemConst.h"
|
||||||
|
|
||||||
#define SAMPLE_DLLFUNC reinterpret_cast<void*>(gpGamedllFuncs->dllapi_table->pfnThink)
|
#define SAMPLE_DLLFUNC reinterpret_cast<void*>(gpGamedllFuncs->dllapi_table->pfnThink)
|
||||||
#define SAMPLE_ENGFUNC reinterpret_cast<void*>(*g_engfuncs.pfnChangeLevel)
|
#define SAMPLE_ENGFUNC reinterpret_cast<void*>(g_engfuncs.pfnChangeLevel)
|
||||||
|
|
||||||
extern maddress gameDllAddress;
|
extern maddress gameDllAddress;
|
||||||
extern maddress gameEngAddress;
|
extern maddress gameEngAddress;
|
||||||
|
@ -20,8 +20,14 @@ static cell AMX_NATIVE_CALL memhack_get_realaddr(AMX *amx, cell *params)
|
|||||||
return (cell)GetRealMemoryAddress(NATIVE_MISC_ADDRESS,NATIVE_MISC_BASEADDRESS,NATIVE_MISC_FLAGS);
|
return (cell)GetRealMemoryAddress(NATIVE_MISC_ADDRESS,NATIVE_MISC_BASEADDRESS,NATIVE_MISC_FLAGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL memhack_return_addr(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
return (cell)PickBaseAddress(params[1]);
|
||||||
|
}
|
||||||
|
|
||||||
AMX_NATIVE_INFO misc_natives[] = {
|
AMX_NATIVE_INFO misc_natives[] = {
|
||||||
{ "memhack_get_base", memhack_get_base },
|
{ "memhack_get_base", memhack_get_base },
|
||||||
{ "memhack_get_realaddr", memhack_get_realaddr },
|
{ "memhack_get_realaddr", memhack_get_realaddr },
|
||||||
|
{ "memhack_return_addr", memhack_return_addr },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user