added windows support

This commit is contained in:
BotoX 2016-08-04 16:08:20 +02:00
parent a827da64eb
commit c303af4d9d
2 changed files with 48 additions and 3 deletions

View File

@ -64,14 +64,36 @@ public:
CEventAction *m_pNext; CEventAction *m_pNext;
DECLARE_SIMPLE_DATADESC(); DECLARE_SIMPLE_DATADESC();
#ifdef PLATFORM_WINDOWS
static int *s_pBlocksAllocated;
static void **s_ppHeadOfFreeList;
#else
static void (*s_pOperatorDeleteFunc)(void *pMem); static void (*s_pOperatorDeleteFunc)(void *pMem);
#endif
static void operator delete(void *pMem); static void operator delete(void *pMem);
}; };
#ifdef PLATFORM_WINDOWS
int *CEventAction::s_pBlocksAllocated;
void **CEventAction::s_ppHeadOfFreeList;
#else
void (*CEventAction::s_pOperatorDeleteFunc)(void *pMem); void (*CEventAction::s_pOperatorDeleteFunc)(void *pMem);
#endif
void CEventAction::operator delete(void *pMem) void CEventAction::operator delete(void *pMem)
{ {
#ifdef PLATFORM_WINDOWS
(*s_pBlocksAllocated)--;
// make the block point to the first item in the list
*((void **)pMem) = *s_ppHeadOfFreeList;
// the list head is now the new block
*s_ppHeadOfFreeList = pMem;
#else
s_pOperatorDeleteFunc(pMem); s_pOperatorDeleteFunc(pMem);
#endif
} }
class CBaseEntityOutput class CBaseEntityOutput
@ -418,11 +440,34 @@ bool Outputinfo::SDK_OnLoad(char *error, size_t maxlen, bool late)
return false; return false;
} }
#ifdef PLATFORM_WINDOWS
char path[PLATFORM_MAX_PATH];
g_pSM->BuildPath(Path_Game, path, sizeof(path), "bin/server.dll");
HMODULE hModule = GetModuleHandle(path);
uintptr_t pCode = (uintptr_t)memutils->FindPattern(hModule,
"\x8B\x4C\x24\x28\x89\x41\x14\x8B\x4F\x18\xA1****\xFF\x0D****\x89\x07\x89\x3D****\x8B\xF9\xEB\x07",
33);
if(!pCode)
{
snprintf(error, maxlen, "Failed to find windows signature.\n");
return false;
}
uintptr_t ppHeadOfFreeList = *(uintptr_t *)(pCode + 11);
uintptr_t pBlocksAllocated = *(uintptr_t *)(pCode + 17);
CEventAction::s_pBlocksAllocated = (int *)pBlocksAllocated;
CEventAction::s_ppHeadOfFreeList = (void **)ppHeadOfFreeList;
#else
if(!g_pGameConf->GetMemSig("CEventAction__operator_delete", (void **)(&CEventAction::s_pOperatorDeleteFunc)) || !CEventAction::s_pOperatorDeleteFunc) if(!g_pGameConf->GetMemSig("CEventAction__operator_delete", (void **)(&CEventAction::s_pOperatorDeleteFunc)) || !CEventAction::s_pOperatorDeleteFunc)
{ {
snprintf(error, maxlen, "Failed to find CEventAction__operator_delete function.\n"); snprintf(error, maxlen, "Failed to find CEventAction__operator_delete function.\n");
return false; return false;
} }
#endif
return true; return true;
} }

View File

@ -40,7 +40,7 @@
/* Basic information exposed publicly */ /* Basic information exposed publicly */
#define SMEXT_CONF_NAME "OutputInfo" #define SMEXT_CONF_NAME "OutputInfo"
#define SMEXT_CONF_DESCRIPTION "Read entity outputs" #define SMEXT_CONF_DESCRIPTION "Read entity outputs"
#define SMEXT_CONF_VERSION "1.0" #define SMEXT_CONF_VERSION "1.1"
#define SMEXT_CONF_AUTHOR "BotoX" #define SMEXT_CONF_AUTHOR "BotoX"
#define SMEXT_CONF_URL "" #define SMEXT_CONF_URL ""
#define SMEXT_CONF_LOGTAG "OUTPUTINFO" #define SMEXT_CONF_LOGTAG "OUTPUTINFO"
@ -64,7 +64,7 @@
//#define SMEXT_ENABLE_PLAYERHELPERS //#define SMEXT_ENABLE_PLAYERHELPERS
//#define SMEXT_ENABLE_DBMANAGER //#define SMEXT_ENABLE_DBMANAGER
#define SMEXT_ENABLE_GAMECONF #define SMEXT_ENABLE_GAMECONF
//#define SMEXT_ENABLE_MEMUTILS #define SMEXT_ENABLE_MEMUTILS
#define SMEXT_ENABLE_GAMEHELPERS #define SMEXT_ENABLE_GAMEHELPERS
//#define SMEXT_ENABLE_TIMERSYS //#define SMEXT_ENABLE_TIMERSYS
//#define SMEXT_ENABLE_THREADER //#define SMEXT_ENABLE_THREADER