core-legacy/CSmmAPI.cpp
author David Anderson <dvander@alliedmods.net>
Thu Oct 29 00:52:39 2009 -0700 (2009-10-29)
changeset 666 acab40e6dbd7
parent 665 c2ed9ba7f74c
child 667 938f7325d919
permissions -rw-r--r--
Backported GetVSPInfo from new API to legacy API (bug 4079, r=ds).
     1 /* ======== SourceMM ========
     2  * Copyright (C) 2004-2008 Metamod:Source Development Team
     3  * No warranties of any kind
     4  *
     5  * License: zlib/libpng
     6  *
     7  * Author(s): David "BAILOPAN" Anderson
     8  * ============================
     9  */
    10 
    11 #include "convar_smm.h"
    12 #include "CSmmAPI.h"
    13 #include "sourcemm.h"
    14 #include "concommands.h"
    15 #include "CPlugin.h"
    16 #include "vsp_listener.h"
    17 #include "util.h"
    18 
    19 /**
    20  * @brief Implementation of main API interface
    21  * @file CSmmAPI.cpp
    22  */
    23 
    24 using namespace SourceMM;
    25 
    26 CSmmAPI g_SmmAPI;
    27 
    28 CSmmAPI::CSmmAPI()
    29 {
    30 	m_ConPrintf = NULL;
    31 	m_CmdCache = false;
    32 	m_MsgCount = -1;
    33 	m_VSP = false;
    34 }
    35 
    36 CSmmAPI::~CSmmAPI()
    37 {
    38 	m_UserMessages.RemoveAll();
    39 }
    40 
    41 void CSmmAPI::LogMsg(ISmmPlugin *pl, const char *msg, ...)
    42 {
    43 	va_list ap;
    44 	static char buffer[2048];
    45 
    46 	va_start(ap, msg);
    47 	UTIL_FormatArgs(buffer, sizeof(buffer), msg, ap);
    48 	va_end(ap);
    49 
    50 	LogMessage("[%s] %s", pl->GetLogTag(), buffer);
    51 }
    52 
    53 CreateInterfaceFn CSmmAPI::engineFactory(bool syn)
    54 {
    55 	if (syn)
    56 		return EngineFactory;
    57 	return g_Engine.engineFactory;
    58 }
    59 
    60 CreateInterfaceFn CSmmAPI::physicsFactory(bool syn)
    61 {
    62 	if (syn)
    63 		return PhysicsFactory;
    64 	return g_Engine.physicsFactory;
    65 }
    66 
    67 CreateInterfaceFn CSmmAPI::fileSystemFactory(bool syn)
    68 {
    69 	if (syn)
    70 		return FileSystemFactory;
    71 	return g_Engine.fileSystemFactory;
    72 }
    73 
    74 CreateInterfaceFn CSmmAPI::serverFactory(bool syn)
    75 {
    76 	if (syn)
    77 		return ServerFactory;
    78 	return g_GameDll.factory;
    79 }
    80 
    81 CGlobalVars *CSmmAPI::pGlobals()
    82 {
    83 	return g_Engine.pGlobals;
    84 }
    85 
    86 void CSmmAPI::SetLastMetaReturn(META_RES res)
    87 {
    88 	m_Res = res;
    89 }
    90 
    91 META_RES CSmmAPI::GetLastMetaReturn()
    92 {
    93 	return m_Res;
    94 }
    95 
    96 IConCommandBaseAccessor *CSmmAPI::GetCvarBaseAccessor()
    97 {
    98 	return static_cast<IConCommandBaseAccessor *>(&g_SMConVarAccessor);
    99 }
   100 
   101 bool CSmmAPI::RegisterConCmdBase(ISmmPlugin *plugin, ConCommandBase *pCommand)
   102 {
   103 	if (pCommand->IsCommand())
   104 	{
   105 		g_PluginMngr.AddPluginCmd(plugin, pCommand);
   106 	} else {
   107 		g_PluginMngr.AddPluginCvar(plugin, pCommand);
   108 	}
   109 
   110 	return g_SMConVarAccessor.Register(pCommand);
   111 }
   112 
   113 void CSmmAPI::UnregisterConCmdBase(ISmmPlugin *plugin, ConCommandBase *pCommand)
   114 {
   115 	if (pCommand->IsCommand())
   116 	{
   117 		g_PluginMngr.RemovePluginCmd(plugin, pCommand);
   118 	} else {
   119 		g_PluginMngr.RemovePluginCvar(plugin, pCommand);
   120 	}
   121 
   122 	CPluginManager::CPlugin *pPlugin = g_PluginMngr.FindByAPI(plugin);
   123 	PluginId id = (pPlugin != NULL) ? pPlugin->m_Id : Pl_BadLoad;
   124 
   125 	NotifyConCommandBaseDrop(id, pCommand);
   126 
   127 	g_SMConVarAccessor.Unregister(pCommand);
   128 }
   129 
   130 void CSmmAPI::ConPrint(const char *fmt)
   131 {
   132 	(m_ConPrintf)("%s", fmt);
   133 }
   134 
   135 void CSmmAPI::ConPrintf(const char *fmt, ...)
   136 {
   137 	va_list ap;
   138 	static char buffer[4096];
   139 
   140 	va_start(ap, fmt);
   141 	UTIL_FormatArgs(buffer, sizeof(buffer), fmt, ap);
   142 	va_end(ap);
   143 
   144 	(m_ConPrintf)("%s", buffer);
   145 }
   146 
   147 void CSmmAPI::AddListener(ISmmPlugin *plugin, IMetamodListener *pListener)
   148 {
   149 	CPluginManager::CPlugin *pl = g_PluginMngr.FindByAPI(plugin);
   150 	CPluginEventHandler cpeh;
   151 
   152 	cpeh.event = pListener;
   153 	cpeh.got_vsp = false;
   154 
   155 	pl->m_Events.push_back(cpeh);
   156 }
   157 
   158 void *CSmmAPI::MetaFactory(const char *iface, int *_ret, PluginId *id)
   159 {
   160 	if (id)
   161 	{
   162 		*id = 0;
   163 	}
   164 
   165 	if (!iface)
   166 	{
   167 		return NULL;
   168 	}
   169 
   170 	//first check ours... we get first chance!
   171 	if (strcmp(iface, MMIFACE_SOURCEHOOK) == 0)
   172 	{
   173 		if (_ret)
   174 		{
   175 			*_ret = IFACE_OK;
   176 		}
   177 		return static_cast<void *>(static_cast<SourceHook::ISourceHook *>(&g_SourceHook));
   178 	} else if (strcmp(iface, MMIFACE_PLMANAGER) == 0) {
   179 		if (_ret)
   180 		{
   181 			*_ret = IFACE_OK;
   182 		}
   183 		return static_cast<void *>(static_cast<ISmmPluginManager *>(&g_PluginMngr));
   184 	}
   185 
   186 	CPluginManager::CPlugin *pl;
   187 	SourceHook::List<CPluginEventHandler>::iterator event;
   188 	IMetamodListener *api;
   189 	int ret = 0;
   190 	void *val = NULL;
   191 
   192 	for (PluginIter iter = g_PluginMngr._begin(); iter != g_PluginMngr._end(); iter++)
   193 	{
   194 		pl = (*iter);
   195 		for (event=pl->m_Events.begin(); event!=pl->m_Events.end(); event++)
   196 		{
   197 			api = (*event).event;
   198 			ret = IFACE_FAILED;
   199 			if ( (val=api->OnMetamodQuery(iface, &ret)) != NULL )
   200 			{
   201 				if (_ret)
   202 					*_ret = ret;
   203 				if (id)
   204 					*id = pl->m_Id;
   205 				return val;
   206 			}
   207 		}
   208 	}
   209 
   210 	if (_ret)
   211 		*_ret = IFACE_FAILED;
   212 
   213 	return NULL;
   214 }
   215 
   216 //////////////////////////////////////////////////////////////////////////
   217 //THERE BE HAX HERE!!!! DON'T TELL ALFRED, BUT GABE WANTED IT THAT WAY. //
   218 // (note: you can find the offset by looking for the text               //
   219 //   "Echo text to console", you'll find the callback cmd pushed on the //
   220 //   stack.)                                                            //
   221 //////////////////////////////////////////////////////////////////////////
   222 
   223 #define SIGLEN			8
   224 #define ENGINE486_SIG	"\x55\x89\xE5\x53\x83\xEC\x14\xBB"
   225 #define ENGINE486_OFFS	40
   226 #define ENGINE686_SIG	"\x53\x83\xEC\x08\xBB\x01\x00\x00"
   227 #define ENGINE686_OFFS	50
   228 #define	ENGINEAMD_SIG	"\x53\x51\xBB\x01\x00\x00\x00\x51"
   229 #define	ENGINEAMD_OFFS	47
   230 #define ENGINEW32_SIG	"\xA1\x2A\x2A\x2A\x2A\x56\xBE\x01"
   231 #define ENGINEW32_OFFS	38
   232 #define IA32_CALL		0xE8
   233 
   234 //Thanks to fysh for the idea of extracting info from "echo" and for
   235 // having the original offsets at hand!
   236 bool CSmmAPI::CacheCmds()
   237 {
   238 	ICvar *pCvar = g_Engine.icvar;
   239 
   240 	ConCommandBase *pBase = pCvar->GetCommands();
   241 	unsigned char *ptr = NULL;
   242 	FnCommandCallback callback = NULL;
   243 	int offs = 0;
   244 
   245 	while (pBase)
   246 	{
   247 		if ( strcmp(pBase->GetName(), "echo") == 0 )
   248 		{
   249 			//callback = //*((FnCommandCallback *)((char *)pBase + offsetof(ConCommand, m_fnCommandCallback)));
   250 			callback = ((ConCommand *)pBase)->GetCallback();
   251 			ptr = (unsigned char *)callback;
   252 		#ifdef OS_LINUX
   253 			if (UTIL_VerifySignature(ptr, ENGINE486_SIG, SIGLEN))
   254 			{
   255 				offs = ENGINE486_OFFS;
   256 			}
   257 			else if (UTIL_VerifySignature(ptr, ENGINE686_SIG, SIGLEN))
   258 			{
   259 				offs = ENGINE686_OFFS;
   260 			}
   261 			else if (UTIL_VerifySignature(ptr, ENGINEAMD_SIG, SIGLEN))
   262 			{
   263 				offs = ENGINEAMD_OFFS;
   264 			}
   265 		#elif defined OS_WIN32 // Only one Windows engine binary so far...
   266 			if (UTIL_VerifySignature(ptr, ENGINEW32_SIG, SIGLEN))
   267 			{
   268 				offs = ENGINEW32_OFFS;
   269 			}
   270 		#endif
   271 
   272 			if (!offs || ptr[offs - 1] != IA32_CALL)
   273 			{
   274 				m_ConPrintf = (CONPRINTF_FUNC)Msg;
   275 				return false;
   276 			}
   277 			//get the relative offset
   278 			m_ConPrintf = *((CONPRINTF_FUNC *)(ptr + offs));
   279 			//add the base offset, to the ip (which is the address+offset + 4 bytes for next instruction)
   280 			m_ConPrintf = (CONPRINTF_FUNC)((unsigned long)m_ConPrintf + (unsigned long)(ptr + offs) + 4);
   281 
   282 			m_CmdCache = true;
   283 
   284 			return true;
   285 		}
   286 		pBase = const_cast<ConCommandBase *>(pBase->GetNext());
   287 	}
   288 
   289 	m_ConPrintf = (CONPRINTF_FUNC)Msg;
   290 
   291 	return false;
   292 }
   293 
   294 bool CSmmAPI::CmdCacheSuccessful()
   295 {
   296 	return m_CmdCache;
   297 }
   298 
   299 void CSmmAPI::GetApiVersions(int &major, int &minor, int &plvers, int &plmin)
   300 {
   301 	major = SM_VERS_API_MAJOR;
   302 	minor = SM_VERS_API_MINOR;
   303 	plvers = PLAPI_VERSION;
   304 	plmin = PLAPI_MIN_VERSION;
   305 }
   306 
   307 void CSmmAPI::GetShVersions(int &shvers, int &shimpl)
   308 {
   309 	shvers = SH_IFACE_VERSION;
   310 	shimpl = SH_IMPL_VERSION;
   311 }
   312 
   313 int CSmmAPI::FormatIface(char iface[], unsigned int maxlength)
   314 {
   315 	int length = (int)strlen(iface);
   316 	int i;
   317 	int num = 0;
   318 
   319 	for (i = length - 1; i >= 0; i--)
   320 	{
   321 		if (!isdigit(iface[i]))
   322 		{
   323 			if (i != length - 1)
   324 			{
   325 				num = 1;
   326 			}
   327 			break;
   328 		}
   329 	}
   330 
   331 	if ( (num && ((int)maxlength <= length)) || (!num && ((int)maxlength <= length + 3)) )
   332 	{
   333 		return -1;
   334 	}
   335 
   336 	if (i != length - 1)
   337 		num = atoi(&(iface[++i]));
   338 
   339 	num++;
   340 
   341 	snprintf(&(iface[i]), 4, "%03d", num);
   342 
   343 	return num;
   344 }
   345 
   346 void *CSmmAPI::InterfaceSearch(CreateInterfaceFn fn, const char *iface, int max, int *ret)
   347 {
   348 	char _if[256];	/* assume no interface goes beyond this */
   349 	size_t len = strlen(iface);
   350 	int num = 0;
   351 	void *pf = NULL;
   352 
   353 	if (max > 999)
   354 		max = 999;
   355 
   356 	if (len + 4 > sizeof(_if))
   357 	{
   358 		if (ret)
   359 		{
   360 			*ret = IFACE_FAILED;
   361 		}
   362 		return NULL;
   363 	}
   364 
   365 	strcpy(_if, iface);
   366 
   367 	do
   368 	{
   369 		if ( (pf = (fn)(_if, ret)) != NULL )
   370 			break;
   371 		if (num > max)
   372 			break;
   373 	} while (( num = FormatIface(_if, len+1) ));
   374 
   375 	return pf;
   376 }
   377 
   378 void *CSmmAPI::VInterfaceMatch(CreateInterfaceFn fn, const char *iface, int min)
   379 {
   380 	char buffer[256];	/* assume no interface will go beyond this */
   381 	size_t len = strlen(iface);
   382 	int ret;			/* just in case something doesn't handle NULL properly */
   383 
   384 	if (len > sizeof(buffer) - 4)
   385 	{
   386 		return NULL;
   387 	}
   388 
   389 	strcpy(buffer, iface);
   390 
   391 	if (min != -1)
   392 	{
   393 		char *ptr = &buffer[len - 1];
   394 		int digits = 0;
   395 		while (isdigit(*ptr) && digits <=3)
   396 		{
   397 			*ptr = '\0';
   398 			digits++;
   399 			ptr--;
   400 		}
   401 		if (digits != 3)
   402 		{
   403 			/* for now, assume this is an error */
   404 			strcpy(buffer, iface);
   405 		} else {
   406 			char num[4];
   407 			min = (min == 0) ? 1 : min;
   408 			snprintf(num, sizeof(num), "%03d", min);
   409 			strcat(buffer, num);
   410 		}
   411 	}
   412 
   413 	return InterfaceSearch(fn, buffer, IFACE_MAXNUM, &ret);
   414 }
   415 
   416 const char *CSmmAPI::GetBaseDir()
   417 {
   418 	return g_ModPath.c_str();
   419 }
   420 
   421 void CSmmAPI::PathFormat(char *buffer, size_t len, const char *fmt, ...)
   422 {
   423 	va_list ap;
   424 	va_start(ap, fmt);
   425 	size_t mylen = UTIL_FormatArgs(buffer, len, fmt, ap);
   426 	va_end(ap);
   427 
   428 	for (size_t i = 0; i < mylen; i++)
   429 	{
   430 		if (buffer[i] == ALT_SEP_CHAR)
   431 		{
   432 			buffer[i] = PATH_SEP_CHAR;
   433 		}
   434 	}
   435 }
   436 
   437 void CSmmAPI::ClientConPrintf(edict_t *client, const char *fmt, ...)
   438 {
   439 	va_list ap;
   440 	static char buffer[4096];
   441 
   442 	va_start(ap, fmt);
   443 	UTIL_FormatArgs(buffer, sizeof(buffer), fmt, ap);
   444 	va_end(ap);
   445 
   446 	g_Engine.engine->ClientPrintf(client, buffer);
   447 }
   448 
   449 void CSmmAPI::LoadAsVSP()
   450 {
   451 	size_t len;
   452 	char engine_file[PATH_SIZE];
   453 	char rel_path[PATH_SIZE * 2];
   454 
   455 	GetFileOfAddress(g_Engine.engine, engine_file, sizeof(engine_file));
   456 
   457 	/* Chop off the "engine" file part */
   458 	len = strlen(engine_file);
   459 	for (size_t i = len - 1; i >= 0 && i < len; i--)
   460 	{
   461 		if (engine_file[i] == '/'
   462 			|| engine_file[i] == '\\')
   463 		{
   464 			engine_file[i] = '\0';
   465 			break;
   466 		}
   467 	}
   468 
   469 	char our_path[PATH_SIZE];
   470 	GetFileOfAddress((void*)LoadAsGameDLL, our_path, sizeof(our_path));
   471 
   472 	const char *usepath = our_path;
   473 	if (UTIL_Relatize(rel_path, sizeof(rel_path), engine_file, our_path))
   474 		usepath = rel_path;
   475 	
   476 	char command[PATH_SIZE * 2];
   477 	g_VspListener.SetLoadable(true);
   478 	UTIL_Format(command, sizeof(command), "plugin_load \"%s\"\n", usepath);
   479 	g_Engine.engine->ServerCommand(command);
   480 }
   481 
   482 void CSmmAPI::EnableVSPListener()
   483 {
   484 	/* If GameInit already passed and we're not already enabled or loaded, go ahead and LoadAsVSP load */
   485 	if (g_bGameInit && !m_VSP && !g_VspListener.IsLoaded() && !g_bIsBridgedAsVsp)
   486 	{
   487 		LoadAsVSP();
   488 	}
   489 	m_VSP = true;
   490 }
   491 
   492 int CSmmAPI::GetGameDLLVersion()
   493 {
   494 	return g_GameDllVersion;
   495 }
   496 
   497 //////////////////////////////////////////////////////////////////////
   498 // EVEN MORE HACKS HERE! YOU HAVE BEEN WARNED!                      //
   499 // Signatures necessary in finding the pointer to the CUtlDict that //
   500 //   stores user message information.                               //
   501 // IServerGameDLL::GetUserMessageInfo() normally crashes with bad   //
   502 //   message indices. This is our answer to it. Yuck! <:-(          //
   503 //////////////////////////////////////////////////////////////////////
   504 #ifdef OS_WIN32
   505 	/* General Windows sig */
   506 	#define MSGCLASS_SIGLEN		7
   507 	#define MSGCLASS_SIG		"\x8B\x0D\x2A\x2A\x2A\x2A\x56"
   508 	#define MSGCLASS_OFFS		2
   509 
   510 	/* Dystopia Wimdows hack */
   511 	#define MSGCLASS2_SIGLEN	16
   512 	#define MSGCLASS2_SIG		"\x56\x8B\x74\x24\x2A\x85\xF6\x7C\x2A\x3B\x35\x2A\x2A\x2A\x2A\x7D"
   513 	#define MSGCLASS2_OFFS		11
   514 
   515 	/* Windows frame pointer sig */
   516 	#define MSGCLASS3_SIGLEN	18
   517 	#define MSGCLASS3_SIG		"\x55\x8B\xEC\x51\x89\x2A\x2A\x8B\x2A\x2A\x50\x8B\x0D\x2A\x2A\x2A\x2A\xE8"
   518 	#define MSGCLASS3_OFFS		13
   519 #elif defined OS_LINUX
   520 	/* No frame pointer sig */
   521 	#define MSGCLASS_SIGLEN		14
   522 	#define MSGCLASS_SIG		"\x53\x83\xEC\x2A\x8B\x2A\x2A\x2A\xA1\x2A\x2A\x2A\x2A\x89"
   523 	#define MSGCLASS_OFFS		9
   524 
   525 	/* Frame pointer sig */
   526 	#define MSGCLASS2_SIGLEN	16
   527 	#define MSGCLASS2_SIG		"\x55\x89\xE5\x53\x83\xEC\x2A\x8B\x2A\x2A\xA1\x2A\x2A\x2A\x2A\x89"
   528 	#define MSGCLASS2_OFFS		11
   529 #endif
   530 
   531 /* This is the ugliest function in all of SourceMM */
   532 /* :TODO: Make this prettier */
   533 bool CSmmAPI::CacheUserMessages()
   534 {
   535 	UserMsgDict *dict = NULL;
   536 	char *vfunc = UTIL_GetOrigFunction(&IServerGameDLL::GetUserMessageInfo, g_GameDll.pGameDLL);
   537 
   538 	if (!vfunc)
   539 	{
   540 		return false;
   541 	}
   542 
   543 	if (UTIL_VerifySignature(vfunc, MSGCLASS_SIG, MSGCLASS_SIGLEN))
   544 	{
   545 		/* Get address of CUserMessages instance */
   546 		char **userMsgClass = *reinterpret_cast<char ***>(vfunc + MSGCLASS_OFFS);
   547 
   548 		/* Get address of CUserMessages::m_UserMessages */
   549 		dict = reinterpret_cast<UserMsgDict *>(*userMsgClass);
   550 	} else if (UTIL_VerifySignature(vfunc, MSGCLASS2_SIG, MSGCLASS2_SIGLEN)) {
   551 	#ifdef OS_WIN32
   552 		/* If we get here, the code is possibly inlined like in Dystopia */
   553 
   554 		/* Get the address of the CUtlRBTree */
   555 		char *rbtree = *reinterpret_cast<char **>(vfunc + MSGCLASS2_OFFS);
   556 
   557 		/* CUtlDict should be 8 bytes before the CUtlRBTree (hacktacular!) */
   558 		dict = reinterpret_cast<UserMsgDict *>(rbtree - 8);
   559 	#elif defined OS_LINUX
   560 		/* Get address of CUserMessages instance */
   561 		char **userMsgClass = *reinterpret_cast<char ***>(vfunc + MSGCLASS2_OFFS);
   562 
   563 		/* Get address of CUserMessages::m_UserMessages */
   564 		dict = reinterpret_cast<UserMsgDict *>(*userMsgClass);
   565 	#endif
   566 	#ifdef OS_WIN32
   567 	} else if (UTIL_VerifySignature(vfunc, MSGCLASS3_SIG, MSGCLASS3_SIGLEN)) {
   568 		/* Get address of CUserMessages instance */
   569 		char **userMsgClass = *reinterpret_cast<char ***>(vfunc + MSGCLASS3_OFFS);
   570 
   571 		/* Get address of CUserMessages::m_UserMessages */
   572 		dict = reinterpret_cast<UserMsgDict *>(*userMsgClass);
   573 	#endif
   574 	}
   575 
   576 	if (dict)
   577 	{
   578 		m_MsgCount = dict->Count();
   579 
   580 		/* Ensure that count is within bounds of an unsigned byte, because that's what engine supports */
   581 		if (m_MsgCount < 0 || m_MsgCount > 255)
   582 		{
   583 			m_MsgCount = -1;
   584 			return false;
   585 		}
   586 
   587 		UserMessage *msg;
   588 
   589 		/* Cache messages in our CUtlDict */
   590 		for (int i = 0; i < m_MsgCount; i++)
   591 		{
   592 			msg = dict->Element(i);
   593 			m_UserMessages.Insert(msg->name, msg);
   594 		}
   595 
   596 		return true;
   597 	}
   598 
   599 	return false;
   600 }
   601 
   602 bool CSmmAPI::MsgCacheSuccessful()
   603 {
   604 	return m_MsgCount > -1;
   605 }
   606 
   607 int CSmmAPI::GetUserMessageCount()
   608 {
   609 	return m_MsgCount;
   610 }
   611 
   612 int CSmmAPI::FindUserMessage(const char *name, int *size)
   613 {
   614 	int index = m_UserMessages.Find(name);
   615 
   616 	if (size && index > -1)
   617 	{
   618 		UserMessage *msg = m_UserMessages.Element(index);
   619 		*size = msg->size;
   620 	}
   621 
   622 	return index;
   623 }
   624 
   625 const char *CSmmAPI::GetUserMessage(int index, int *size)
   626 {
   627 	if (m_MsgCount <= 0 || index < 0 || index >= m_MsgCount)
   628 	{
   629 		return NULL;
   630 	}
   631 
   632 	UserMessage *msg = m_UserMessages.Element(index);
   633 
   634 	if (size)
   635 	{
   636 		*size = msg->size;
   637 	}
   638 
   639 	return msg->name;
   640 }
   641 
   642 IServerPluginCallbacks *CSmmAPI::GetVSPInfo(int *pVersion)
   643 {
   644 	if (pVersion != NULL)
   645 		*pVersion = g_vsp_version;
   646 
   647 	return g_pRealVspCallbacks;
   648 }