Exemple #1
0
int EngineInfo::vac_pe_approx( enginefuncs_t* _pFuncs )
{

    if ( NULL == _pFuncs ) return INVALID_ARG;
	
	// There is really no good and easy way to do this. Right now what 
	// we do is assume that Steam listenservers will normally be 
	// up-to-date and hence have all function pointers set correctly.
	// So we just check for some anomality and then set some approximated
	// values.

	// The known addresses at the time of writing all start with 0x01D and
	// this lie in the range between 0x01D00000 and 0x01E00000. What we do
	// is check all functions pointers that are known to be good to start
	// with 0x01D. If that is the case then we know that the loading address
	// of the engine functions hasn't changed and we assume the above stated
	// range to be the range of valid engine function addresses.
	// If we find functions outside this range we can't determine a valid
	// range and have to just give up.

	unsigned long* pengfuncs = (unsigned long*)_pFuncs;
	unsigned int i, invals = 0;
	for ( i = 0, pengfuncs += i; i < 140; i++, pengfuncs++ ) {
		if ( ((*pengfuncs) & c_VacDllEngineFuncsRangeMask) != c_VacDllEngineFuncsRangeMark ) {
			invals++;
			break;
		}
	}

	if ( invals > 0 ) {
		META_DEV( "Found %d engine functions out of range 0x%08lx. "
			      "Unable to determine valid engine code address range.", 
			      invals, c_VacDllEngineFuncsRangeMark );

		strncpy( m_type, "vacdll+?", c_EngineInfo__typeLen );
        m_state = STATE_INVALID;
		return STATE_INVALID;
	}

	m_codeStart = c_VacDllEngineFuncsRangeStart;
	m_codeEnd = c_VacDllEngineFuncsRangeEnd;

	strncpy( m_type, "vacdll", c_EngineInfo__typeLen );

    m_state = STATE_VALID;

	return 0;
}
Exemple #2
0
void WINAPI GiveFnptrsToDll(enginefuncs_t *pengfuncsFromEngine, 
		globalvars_t *pGlobals)
{

	gpGlobals = pGlobals;
	Engine.funcs = &g_engfuncs;
	Engine.globals = pGlobals;
	Engine.info.initialise(pengfuncsFromEngine);

	g_engfuncs.initialise_interface(pengfuncsFromEngine);
	// NOTE!  Have to call logging function _after_ initialising g_engfuncs, so
	// that g_engfuncs.pfnAlertMessage() can be resolved properly, heh. :)
	META_DEV("called: GiveFnptrsToDll");

	// Load plugins, load game dll.
	metamod_startup();

	return;
}
Exemple #3
0
// Receive engine function table from engine.
//
// This appears to be the _first_ DLL routine called by the engine, so this
// is where we hook to load all the other DLLs (game, plugins, etc), which
// is actually all done in meta_startup().
C_DLLEXPORT void WINAPI GiveFnptrsToDll(enginefuncs_t *pengfuncsFromEngine, 
		globalvars_t *pGlobals)
{
#ifdef linux
	metamod_handle = get_module_handle_of_memptr((void*)&g_engfuncs);
#endif
	gpGlobals = pGlobals;
	Engine.funcs = &g_engfuncs;
	Engine.globals = pGlobals;
	Engine.info.initialise(pengfuncsFromEngine);

	g_engfuncs.initialise_interface(pengfuncsFromEngine);
	// NOTE!  Have to call logging function _after_ initialising g_engfuncs, so
	// that g_engfuncs.pfnAlertMessage() can be resolved properly, heh. :)
	META_DEV("called: GiveFnptrsToDll");
	
	// Load plugins, load game dll.
	if(!metamod_startup()) {
		metamod_not_loaded = 1;
	}
	
	return;
}