コード例 #1
0
ファイル: sp_main.cpp プロジェクト: Doldol/Source.Python
//-----------------------------------------------------------------------------
// Purpose: called when the plugin is unloaded (turned off)
//-----------------------------------------------------------------------------
void CSourcePython::Unload( void )
{
	Msg(MSG_PREFIX "Unloading...\n");
	
	DevMsg(1, MSG_PREFIX "Unhooking all functions...\n");
	GetHookManager()->UnhookAllFunctions();
	
	DevMsg(1, MSG_PREFIX "Shutting down python...\n");
	g_PythonManager.Shutdown();

	DevMsg(1, MSG_PREFIX "Clearing all commands...\n");
	ClearAllCommands();

	DevMsg(1, MSG_PREFIX "Unregistering ConVar...\n");
	ConVar_Unregister( );

	// New in CSGO...
#ifdef ENGINE_CSGO
	DevMsg(1, MSG_PREFIX "Disconnecting interfaces...\n");
	DisconnectInterfaces();
#else
	DevMsg(1, MSG_PREFIX "Disconnecting tier2 libraries...\n");
	DisconnectTier2Libraries( );

	DevMsg(1, MSG_PREFIX "Disconnecting tier1 libraries...\n");
	DisconnectTier1Libraries( );
#endif

	DevMsg(1, MSG_PREFIX "Resetting cache notifier...\n");
	modelcache->SetCacheNotify(m_pOldMDLCacheNotifier);

	Msg(MSG_PREFIX "Unloaded successfully.\n");
}
コード例 #2
0
ファイル: ms_stdcall2.cpp プロジェクト: Ayuto/DynamicHooks
// ============================================================================
// >> main
// ============================================================================
int main()
{
	CHookManager* pHookMngr = GetHookManager();

	// Prepare calling convention
	std::vector<DataType_t> vecArgTypes;
	vecArgTypes.push_back(DATA_TYPE_INT);

	// Hook the function
	CHook* pHook = pHookMngr->HookFunction(
		(void *) &MyFunc,
		new x86MsStdcall(vecArgTypes, DATA_TYPE_INT)
	);

	pHook->AddCallback(HOOKTYPE_PRE, (HookHandlerFn *) (void *) &PreMyFunc);
	pHook->AddCallback(HOOKTYPE_POST, (HookHandlerFn *) (void *) &PostMyFunc);

	// Call the function
	int return_value = MyFunc(0);
	
	assert(g_iMyFuncCallCount == 4);
	assert(g_iPreMyFuncCallCount == 4);
	assert(g_iPostMyFuncCallCount == 4);
	assert(return_value == 3);

	//pHookMngr->UnhookAllFunctions();
	return 0;
}