2006-01-12 03:55:49 +00:00
|
|
|
#ifndef __MEMMISC_H__
|
|
|
|
#define __MEMMISC_H__
|
|
|
|
|
|
|
|
#include "MemConst.h"
|
|
|
|
|
|
|
|
#define SAMPLE_DLLFUNC reinterpret_cast<void*>(gpGamedllFuncs->dllapi_table->pfnThink)
|
2006-02-13 19:31:46 +00:00
|
|
|
#define SAMPLE_ENGFUNC reinterpret_cast<void*>(g_engfuncs.pfnChangeLevel)
|
2006-01-12 03:55:49 +00:00
|
|
|
|
|
|
|
extern maddress gameDllAddress;
|
|
|
|
extern maddress gameEngAddress;
|
|
|
|
|
|
|
|
inline maddress PickBaseAddress(long num)
|
|
|
|
{
|
|
|
|
if(num == 0) return gameDllAddress;
|
|
|
|
else if(num == 1) return gameEngAddress;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern int MemoryProtect(void *addr, size_t len, unsigned long newProt, unsigned long *oldProt, char memType = MEMTYPE_CODE);
|
|
|
|
extern maddress GetRealMemoryAddress(maddress baseaddress,maddress address, char memType);
|
|
|
|
|
|
|
|
extern bool GetBaseAddress(void *pAddr, maddress &pBaseAddr);
|
|
|
|
|
|
|
|
inline bool GetBaseAddresses( void )
|
|
|
|
{
|
|
|
|
bool success = false;
|
|
|
|
|
2006-02-13 19:31:46 +00:00
|
|
|
success = GetBaseAddress(SAMPLE_DLLFUNC, gameDllAddress);
|
2006-01-12 03:55:49 +00:00
|
|
|
if(success == false) return false;
|
|
|
|
|
2006-02-13 19:31:46 +00:00
|
|
|
success = GetBaseAddress(SAMPLE_ENGFUNC, gameEngAddress);
|
2006-01-12 03:55:49 +00:00
|
|
|
if(success == false) return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|