void CForwardManager::UnhookRecorder(IDemoRecorder *recorder) { #ifdef WIN32 SH_REMOVE_HOOK(IDemoRecorder, StartRecording, recorder, SH_MEMBER(this, &CForwardManager::OnStartRecording_Post), true); SH_REMOVE_HOOK(IDemoRecorder, StopRecording, recorder, SH_MEMBER(this, &CForwardManager::OnStopRecording), false); #endif }
void HLTVServerWrapper::Unhook() { if (!m_Connected) return; g_pSTVForwards.UnhookServer(this); if (m_DemoRecorder) g_pSTVForwards.UnhookRecorder(m_DemoRecorder); if (g_HLTVServers.HasShutdownOffset()) SH_REMOVE_MANUALHOOK(CHLTVServer_Shutdown, m_HLTVServer->GetBaseServer(), SH_MEMBER(this, &HLTVServerWrapper::OnHLTVServerShutdown), false); if (iserver) { IClient *pClient = iserver->GetClient(m_HLTVServer->GetHLTVSlot()); if (pClient) { SH_REMOVE_HOOK(IClient, ExecuteStringCommand, pClient, SH_MEMBER(this, &HLTVServerWrapper::OnHLTVBotExecuteStringCommand), false); SH_REMOVE_HOOK(IClient, ExecuteStringCommand, pClient, SH_MEMBER(this, &HLTVServerWrapper::OnHLTVBotExecuteStringCommand_Post), true); #if SOURCE_ENGINE != SE_CSGO SH_REMOVE_HOOK(IClient, ClientPrintf, pClient, SH_MEMBER(this, &HLTVServerWrapper::OnIClient_ClientPrintf_Post), false); #ifndef WIN32 // The IClient vtable is +4 from the CBaseClient vtable due to multiple inheritance. void *pGameClient = (void *)((intptr_t)pClient - 4); if (g_HLTVServers.HasClientPrintfOffset()) SH_REMOVE_MANUALHOOK(CGameClient_ClientPrintf, pGameClient, SH_MEMBER(this, &HLTVServerWrapper::OnCGameClient_ClientPrintf_Post), false); #endif // !WIN32 #endif // SOURCE_ENGINE != SE_CSGO } } }
void EventManager::OnSourceModShutdown() { /* Remove hook for IGameEventManager2::FireEvent() */ SH_REMOVE_HOOK(IGameEventManager2, FireEvent, gameevents, SH_MEMBER(this, &EventManager::OnFireEvent), false); SH_REMOVE_HOOK(IGameEventManager2, FireEvent, gameevents, SH_MEMBER(this, &EventManager::OnFireEvent_Post), true); /* Remove the 'GameEvent' handle type */ handlesys->RemoveType(m_EventType, g_pCoreIdent); /* Remove ourselves as listener for events */ gameevents->RemoveListener(this); }
void SourceModBase::ShutdownServices() { /* Unload plugins */ scripts->Shutdown(); /* Unload extensions */ extsys->Shutdown(); if (g_pOnMapEnd) forwardsys->ReleaseForward(g_pOnMapEnd); /* Notify! */ SMGlobalClass *pBase = SMGlobalClass::head; while (pBase) { pBase->OnSourceModShutdown(); pBase = pBase->m_pGlobalClassNext; } /* Delete all data packs */ CStack<CDataPack *>::iterator iter; CDataPack *pd; for (iter=m_freepacks.begin(); iter!=m_freepacks.end(); iter++) { pd = (*iter); delete pd; } m_freepacks.popall(); /* Notify! */ pBase = SMGlobalClass::head; while (pBase) { pBase->OnSourceModAllShutdown(); pBase = pBase->m_pGlobalClassNext; } if (enginePatch) { SH_RELEASE_CALLCLASS(enginePatch); enginePatch = NULL; } if (gamedllPatch) { SH_RELEASE_CALLCLASS(gamedllPatch); gamedllPatch = NULL; } SH_REMOVE_HOOK(IServerGameDLL, LevelShutdown, gamedll, SH_MEMBER(this, &SourceModBase::LevelShutdown), false); SH_REMOVE_HOOK(IServerGameDLL, GameFrame, gamedll, SH_MEMBER(&g_Timers, &TimerSystem::GameFrame), false); }
void SoundHooks::Shutdown() { plsys->RemovePluginsListener(this); if (m_NormalCount) { SH_REMOVE_HOOK(IEngineSound, EmitSound, engsound, SH_MEMBER(this, &SoundHooks::OnEmitSound), false); SH_REMOVE_HOOK(IEngineSound, EmitSound, engsound, SH_MEMBER(this, &SoundHooks::OnEmitSound2), false); } if (m_AmbientCount) { SH_REMOVE_HOOK(IVEngineServer, EmitAmbientSound, engine, SH_MEMBER(this, &SoundHooks::OnEmitAmbientSound), false); } }
void ChatTriggers::OnSourceModShutdown() { if (m_pSayCmd) { SH_REMOVE_HOOK(ConCommand, Dispatch, m_pSayCmd, SH_MEMBER(this, &ChatTriggers::OnSayCommand_Post), true); SH_REMOVE_HOOK(ConCommand, Dispatch, m_pSayCmd, SH_MEMBER(this, &ChatTriggers::OnSayCommand_Pre), false); } if (m_pSayTeamCmd) { SH_REMOVE_HOOK(ConCommand, Dispatch, m_pSayTeamCmd, SH_MEMBER(this, &ChatTriggers::OnSayCommand_Post), true); SH_REMOVE_HOOK(ConCommand, Dispatch, m_pSayTeamCmd, SH_MEMBER(this, &ChatTriggers::OnSayCommand_Pre), false); } #if SOURCE_ENGINE == SE_EPISODEONE if (m_bIsINS && m_pSay2Cmd) { SH_REMOVE_HOOK(ConCommand, Dispatch, m_pSay2Cmd, SH_MEMBER(this, &ChatTriggers::OnSayCommand_Pre), false); SH_REMOVE_HOOK(ConCommand, Dispatch, m_pSay2Cmd, SH_MEMBER(this, &ChatTriggers::OnSayCommand_Post), true); } #elif SOURCE_ENGINE == SE_NUCLEARDAWN if (m_pSaySquadCmd) { SH_REMOVE_HOOK(ConCommand, Dispatch, m_pSaySquadCmd, SH_MEMBER(this, &ChatTriggers::OnSayCommand_Pre), false); SH_REMOVE_HOOK(ConCommand, Dispatch, m_pSaySquadCmd, SH_MEMBER(this, &ChatTriggers::OnSayCommand_Post), true); } #endif forwardsys->ReleaseForward(m_pShouldFloodBlock); forwardsys->ReleaseForward(m_pDidFloodBlock); forwardsys->ReleaseForward(m_pOnClientSayCmd); forwardsys->ReleaseForward(m_pOnClientSayCmd_Post); }
bool SDKTools::SDK_OnMetamodUnload(char *error, size_t maxlen) { #if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_CSGO SH_REMOVE_HOOK(IVEngineServer, ClientCommand, engine, SH_MEMBER(this, &SDKTools::OnSendClientCommand), false); #endif return true; }
void CSteamAPI::ShutdownForwards() { SH_REMOVE_HOOK( ISteamGameServer, WasRestartRequested, g_APIContext.SteamGameServer(), SH_MEMBER( this, &CSteamAPI::WasRestartRequested ), false ); forwards->ReleaseForward( g_pValidatedFwd ); forwards->ReleaseForward( g_pRestartReqFwd ); }
void TempEntHooks::_DecRefCounter() { if (--m_HookCount == 0) { SH_REMOVE_HOOK(IVEngineServer, PlaybackTempEntity, engine, SH_MEMBER(this, &TempEntHooks::OnPlaybackTempEntity), false); } }
void SDKTools::SDK_OnUnload() { SourceHook::List<ValveCall *>::iterator iter; for (iter = g_RegCalls.begin(); iter != g_RegCalls.end(); iter++) { delete (*iter); } g_RegCalls.clear(); ShutdownHelpers(); if (g_pAcceptInput) { g_pAcceptInput->Destroy(); g_pAcceptInput = NULL; } g_TEManager.Shutdown(); s_TempEntHooks.Shutdown(); s_SoundHooks.Shutdown(); g_Hooks.Shutdown(); g_OutputManager.Shutdown(); gameconfs->CloseGameConfigFile(g_pGameConf); playerhelpers->RemoveClientListener(&g_SdkTools); playerhelpers->UnregisterCommandTargetProcessor(this); plsys->RemovePluginsListener(&g_OutputManager); SH_REMOVE_HOOK(IServerGameDLL, LevelInit, gamedll, SH_MEMBER(this, &SDKTools::LevelInit), true); if (enginePatch) { SH_RELEASE_CALLCLASS(enginePatch); enginePatch = NULL; } if (enginesoundPatch) { SH_RELEASE_CALLCLASS(enginesoundPatch); enginesoundPatch = NULL; } bool err; if (g_CallHandle != 0) { if ((err = handlesys->RemoveType(g_CallHandle, myself->GetIdentity())) != true) { g_pSM->LogError(myself, "Could not remove call handle (type=%x, err=%d)", g_CallHandle, err); } } if (g_TraceHandle != 0) { if ((err = handlesys->RemoveType(g_TraceHandle, myself->GetIdentity())) != true) { g_pSM->LogError(myself, "Could not remove trace handle (type=%x, err=%d)", g_TraceHandle, err); } } }
void HolidayManager::OnSDKUnload() { UnhookIfNecessary(); SH_REMOVE_HOOK(IServerGameDLL, LevelShutdown, gamedll, SH_MEMBER(this, &HolidayManager::Hook_LevelShutdown), false); plsys->RemovePluginsListener(this); forwards->ReleaseForward(m_isHolidayForward); }
bool StubPlugin::Unload(char *error, size_t maxlen) { SM_UnloadExtension(); SH_REMOVE_HOOK(IServerGameDLL, ServerActivate, server, SH_STATIC(Hook_ServerActivate), true); return true; }
void SourceModBase::ShutdownServices() { /* Unload plugins */ scripts->Shutdown(); /* Unload extensions */ extsys->Shutdown(); if (g_pOnMapEnd) forwardsys->ReleaseForward(g_pOnMapEnd); /* Notify! */ SMGlobalClass *pBase = SMGlobalClass::head; while (pBase) { pBase->OnSourceModShutdown(); pBase = pBase->m_pGlobalClassNext; } sCoreProviderImpl.ShutdownHooks(); /* Notify! */ pBase = SMGlobalClass::head; while (pBase) { pBase->OnSourceModAllShutdown(); pBase = pBase->m_pGlobalClassNext; } if (enginePatch) { SH_RELEASE_CALLCLASS(enginePatch); enginePatch = NULL; } if (gamedllPatch) { SH_RELEASE_CALLCLASS(gamedllPatch); gamedllPatch = NULL; } SH_REMOVE_HOOK(IServerGameDLL, LevelShutdown, gamedll, SH_MEMBER(this, &SourceModBase::LevelShutdown), false); SH_REMOVE_HOOK(IServerGameDLL, GameFrame, gamedll, SH_MEMBER(&g_Timers, &TimerSystem::GameFrame), false); SH_REMOVE_HOOK(IServerGameDLL, Think, gamedll, SH_MEMBER(logicore.callbacks, &IProviderCallbacks::OnThink), false); }
void SoundHooks::_DecRefCounter(int type) { if (type == NORMAL_SOUND_HOOK) { if (--m_NormalCount == 0) { SH_REMOVE_HOOK(IEngineSound, EmitSound, engsound, SH_MEMBER(this, &SoundHooks::OnEmitSound), false); SH_REMOVE_HOOK(IEngineSound, EmitSound, engsound, SH_MEMBER(this, &SoundHooks::OnEmitSound2), false); } } else if (type == AMBIENT_SOUND_HOOK) { if (--m_AmbientCount == 0) { SH_REMOVE_HOOK(IVEngineServer, EmitAmbientSound, engine, SH_MEMBER(this, &SoundHooks::OnEmitAmbientSound), false); } } }
void SteamWorksGCHooks::RemoveHooks(ISteamGameCoordinator *pGC, bool destroyed) { if (this->uHooked != eHooked || pGC == NULL) { return; } SH_REMOVE_HOOK(ISteamGameCoordinator, SendMessage, pGC, SH_MEMBER(this, &SteamWorksGCHooks::SendMessage), false); SH_REMOVE_HOOK(ISteamGameCoordinator, IsMessageAvailable, pGC, SH_MEMBER(this, &SteamWorksGCHooks::IsMessageAvailable), true); SH_REMOVE_HOOK(ISteamGameCoordinator, RetrieveMessage, pGC, SH_MEMBER(this, &SteamWorksGCHooks::RetrieveMessage), false); if (destroyed) { this->uHooked = eUnhooked; return; } this->uHooked = eHooking; smutils->AddGameFrameHook(OurGCGameFrameHook); }
void NextMapManager::OnSourceModShutdown() { #if SOURCE_ENGINE >= SE_ORANGEBOX SH_REMOVE_HOOK(IVEngineServer, ChangeLevel, engine, SH_MEMBER(this, &NextMapManager::HookChangeLevel), false); #else SH_REMOVE_HOOK(IVEngineServer, ChangeLevel, engine, SH_MEMBER(this, &NextMapManager::HookChangeLevel), false); #endif if (changeLevelCmd != NULL) { SH_REMOVE_HOOK(ConCommand, Dispatch, changeLevelCmd, SH_STATIC(CmdChangeLevelCallback), false); } SourceHook::List<MapChangeData *>::iterator iter; iter = m_mapHistory.begin(); while (iter != m_mapHistory.end()) { delete (MapChangeData *)*iter; iter = m_mapHistory.erase(iter); } }
void CForwardManager::UnhookClient(IClient *client) { // Remove ExecuteStringCommand hook g_pSTVCommonHooks.RemoveSpectatorHook(this, client); void *pGameClient = (void *)((intptr_t)client - 4); if (m_bHasActivatePlayerOffset) SH_REMOVE_MANUALHOOK(CBaseClient_ActivatePlayer, pGameClient, SH_MEMBER(this, &CForwardManager::OnSpectatorPutInServer), true); SH_REMOVE_HOOK(IClient, Disconnect, client, SH_MEMBER(this, &CForwardManager::IClient_OnSpectatorDisconnect), false); #ifndef WIN32 if (m_bHasDisconnectOffset) SH_REMOVE_MANUALHOOK(CBaseClient_Disconnect, pGameClient, SH_MEMBER(this, &CForwardManager::BaseClient_OnSpectatorDisconnect), false); #endif }
void CStrike::SDK_OnUnload() { if (hooked_everything) { gameevents->RemoveListener(&g_TimeLeftEvents); SH_REMOVE_HOOK(IServerGameDLL, LevelInit, gamedll, SH_MEMBER(&g_TimeLeftEvents, &TimeLeftEvents::LevelInit), true); hooked_everything = false; } g_RegNatives.UnregisterAll(); gameconfs->CloseGameConfigFile(g_pGameConf); plsys->RemovePluginsListener(this); playerhelpers->UnregisterCommandTargetProcessor(this); forwards->ReleaseForward(g_pHandleBuyForward); forwards->ReleaseForward(g_pPriceForward); forwards->ReleaseForward(g_pTerminateRoundForward); forwards->ReleaseForward(g_pCSWeaponDropForward); }
void SourceModBase::CloseSourceMod() { if (!sSourceModInitialized) return; SH_REMOVE_HOOK(IServerGameDLL, LevelInit, gamedll, SH_MEMBER(this, &SourceModBase::LevelInit), false); if (g_Loaded) { /* Force a level end */ LevelShutdown(); ShutdownServices(); } /* Rest In Peace */ ShutdownLogicBridge(); ShutdownJIT(); }
void TF2Tools::SDK_OnUnload() { SH_REMOVE_HOOK(IServerGameDLL, ServerActivate, gamedll, SH_STATIC(OnServerActivate), true); g_RegNatives.UnregisterAll(); gameconfs->CloseGameConfigFile(g_pGameConf); playerhelpers->UnregisterCommandTargetProcessor(this); playerhelpers->RemoveClientListener(this); plsys->RemovePluginsListener(this); forwards->ReleaseForward(g_critForward); forwards->ReleaseForward(g_isHolidayForward); forwards->ReleaseForward(g_addCondForward); forwards->ReleaseForward(g_removeCondForward); forwards->ReleaseForward(g_waitingPlayersStartForward); forwards->ReleaseForward(g_waitingPlayersEndForward); forwards->ReleaseForward(g_teleportForward); }
void UserMessages::_DecRefCounter() { if (--m_HookCount == 0) { #if SOURCE_ENGINE == SE_CSGO SH_REMOVE_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Pre), false); SH_REMOVE_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Post), true); #else SH_REMOVE_HOOK(IVEngineServer, UserMessageBegin, engine, SH_MEMBER(this, &UserMessages::OnStartMessage_Pre), false); SH_REMOVE_HOOK(IVEngineServer, UserMessageBegin, engine, SH_MEMBER(this, &UserMessages::OnStartMessage_Post), true); SH_REMOVE_HOOK(IVEngineServer, MessageEnd, engine, SH_MEMBER(this, &UserMessages::OnMessageEnd_Pre), false); SH_REMOVE_HOOK(IVEngineServer, MessageEnd, engine, SH_MEMBER(this, &UserMessages::OnMessageEnd_Post), true); #endif } }
void UserMessages::OnSourceModAllShutdown() { if (m_HookCount) { #if SOURCE_ENGINE == SE_CSGO SH_REMOVE_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Pre), false); SH_REMOVE_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Post), true); #else SH_REMOVE_HOOK(IVEngineServer, UserMessageBegin, engine, SH_MEMBER(this, &UserMessages::OnStartMessage_Pre), false); SH_REMOVE_HOOK(IVEngineServer, UserMessageBegin, engine, SH_MEMBER(this, &UserMessages::OnStartMessage_Post), true); SH_REMOVE_HOOK(IVEngineServer, MessageEnd, engine, SH_MEMBER(this, &UserMessages::OnMessageEnd_Pre), false); SH_REMOVE_HOOK(IVEngineServer, MessageEnd, engine, SH_MEMBER(this, &UserMessages::OnMessageEnd_Post), true); #endif } m_HookCount = 0; }
void CEntityManager::Shutdown() { SH_REMOVE_HOOK(IVEngineServer, RemoveEdict, engine, SH_MEMBER(this, &CEntityManager::RemoveEdict), true); IDetourTracker *pDetourTracker = IDetourTracker::m_Head; while (pDetourTracker) { pDetourTracker->RemoveHook(); pDetourTracker = pDetourTracker->m_Next; } if(RemoveEntity_CDetour) RemoveEntity_CDetour->DisableDetour(); RemoveEntity_CDetour = NULL; if(PostConstructor_CDetour) PostConstructor_CDetour->DisableDetour(); PostConstructor_CDetour = NULL; pFactoryTrie.clear(); pSwapTrie.clear(); pHookedTrie.clear(); pCacheTrie.clear(); }
bool TestReentr(std::string &error) { GET_SHPTR(g_SHPtr); g_PLID = 1337; g_pC1 = &g_C1; g_pC2 = &g_C2; g_pC3 = &g_C3; g_pC4 = &g_C4; g_pC5 = &g_C5; g_pC6 = &g_C6; g_pC7 = &g_C7; g_pC8 = &g_C8; SH_ADD_HOOK(C1, F, g_pC1, SH_STATIC(Handler_C1_F), false); SH_ADD_HOOK(C1, G, g_pC1, SH_STATIC(Handler_C1_G), false); SH_ADD_HOOK(C2, F, g_pC2, SH_STATIC(Handler_C2_F), false); SH_ADD_HOOK(C2, G, g_pC2, SH_STATIC(Handler_C2_G), false); SH_ADD_HOOK(C3, F, g_pC3, SH_STATIC(Handler_C3_F), false); SH_ADD_HOOK(C3, G, g_pC3, SH_STATIC(Handler_C3_G), false); SH_ADD_HOOK(C4, F, g_pC4, SH_STATIC(Handler_C4_F), false); SH_ADD_HOOK(C4, G, g_pC4, SH_STATIC(Handler_C4_G), false); SH_ADD_HOOK(C5, F, g_pC5, SH_STATIC(Handler_C5_F), false); SH_ADD_HOOK(C5, G, g_pC5, SH_STATIC(Handler_C5_G), false); SH_ADD_HOOK(C6, F, g_pC6, SH_STATIC(Handler_C6_F), false); SH_ADD_HOOK(C6, G, g_pC6, SH_STATIC(Handler_C6_G), false); SH_ADD_HOOK(C7, F, g_pC7, SH_STATIC(Handler_C7_F), false); SH_ADD_HOOK(C7, G, g_pC7, SH_STATIC(Handler_C7_G), false); SH_ADD_HOOK(C8, F, g_pC8, SH_STATIC(Handler_C8_F), false); SH_ADD_HOOK(C8, G, g_pC8, SH_STATIC(Handler_C8_G), false); g_pC1->F(); CHECK_STATES((&g_States, new State_H_C1_F(g_pC1), new State_H_C1_G(g_pC1), new State_H_C2_F(g_pC2), new State_H_C2_G(g_pC2), new State_H_C3_F(g_pC3), new State_H_C3_G(g_pC3), new State_H_C4_F(g_pC4), new State_H_C4_G(g_pC4), new State_H_C5_F(g_pC5), new State_H_C5_G(g_pC5), new State_H_C6_F(g_pC6), new State_H_C6_G(g_pC6), new State_H_C7_F(g_pC7), new State_H_C7_G(g_pC7), new State_H_C8_F(g_pC8), new State_H_C8_G(g_pC8), new State_C8_G(g_pC8), new State_C8_F(g_pC8), new State_C7_G(g_pC7), new State_C7_F(g_pC7), new State_C6_G(g_pC6), new State_C6_F(g_pC6), new State_C5_G(g_pC5), new State_C5_F(g_pC5), new State_C4_G(g_pC4), new State_C4_F(g_pC4), new State_C3_G(g_pC3), new State_C3_F(g_pC3), new State_C2_G(g_pC2), new State_C2_F(g_pC2), new State_C1_G(g_pC1), new State_C1_F(g_pC1), NULL), "1"); SH_ADD_HOOK(C4, G, g_pC4, SH_STATIC(Handler2_C4_G), false); g_pC1->F(); CHECK_STATES((&g_States, new State_H_C1_F(g_pC1), new State_H_C1_G(g_pC1), new State_H_C2_F(g_pC2), new State_H_C2_G(g_pC2), new State_H_C3_F(g_pC3), new State_H_C3_G(g_pC3), new State_H_C4_F(g_pC4), new State_H_C4_G(g_pC4), new State_H_C5_F(g_pC5), new State_H_C5_G(g_pC5), new State_H_C6_F(g_pC6), new State_H_C6_G(g_pC6), new State_H_C7_F(g_pC7), new State_H_C7_G(g_pC7), new State_H_C8_F(g_pC8), new State_H_C8_G(g_pC8), new State_C8_G(g_pC8), new State_C8_F(g_pC8), new State_C7_G(g_pC7), new State_C7_F(g_pC7), new State_C6_G(g_pC6), new State_C6_F(g_pC6), new State_C5_G(g_pC5), new State_C5_F(g_pC5), new State_H2_C4_G(g_pC4), new State_C4_G(g_pC4), new State_C4_F(g_pC4), new State_C3_G(g_pC3), new State_C3_F(g_pC3), new State_C2_G(g_pC2), new State_C2_F(g_pC2), new State_C1_G(g_pC1), new State_C1_F(g_pC1), NULL), "2"); g_pC1->F(); CHECK_STATES((&g_States, new State_H_C1_F(g_pC1), new State_H_C1_G(g_pC1), new State_H_C2_F(g_pC2), new State_H_C2_G(g_pC2), new State_H_C3_F(g_pC3), new State_H_C3_G(g_pC3), new State_H_C4_F(g_pC4), new State_H_C4_G(g_pC4), new State_H_C5_F(g_pC5), new State_H_C5_G(g_pC5), new State_H_C6_F(g_pC6), new State_H_C6_G(g_pC6), new State_H_C7_F(g_pC7), new State_H_C7_G(g_pC7), new State_H_C8_F(g_pC8), new State_H_C8_G(g_pC8), new State_C8_G(g_pC8), new State_C8_F(g_pC8), new State_C7_G(g_pC7), new State_C7_F(g_pC7), new State_C6_G(g_pC6), new State_C6_F(g_pC6), new State_C5_G(g_pC5), new State_C5_F(g_pC5), new State_H2_C4_G(g_pC4), new State_C4_G(g_pC4), new State_C4_F(g_pC4), new State_C3_G(g_pC3), new State_C3_F(g_pC3), new State_C2_G(g_pC2), new State_C2_F(g_pC2), new State_C1_G(g_pC1), new State_C1_F(g_pC1), NULL), "3"); g_TestID = 1; g_pC1->F(); CHECK_STATES((&g_States, new State_H_C1_F(g_pC1), new State_H_C1_G(g_pC1), new State_H_C2_F(g_pC2), new State_H_C2_G(g_pC2), new State_H_C3_F(g_pC3), new State_H_C3_G(g_pC3), new State_H_C4_F(g_pC4), new State_H_C4_G(g_pC4), new State_H_C5_F(g_pC5), new State_H_C5_G(g_pC5), new State_H_C6_F(g_pC6), new State_H_C6_G(g_pC6), new State_H_C7_F(g_pC7), new State_H_C7_G(g_pC7), new State_H_C8_F(g_pC8), new State_H_C8_G(g_pC8), new State_C8_G(g_pC8), new State_C8_F(g_pC8), new State_C7_G(g_pC7), new State_C7_F(g_pC7), new State_C6_G(g_pC6), new State_C6_F(g_pC6), new State_C5_G(g_pC5), new State_C5_F(g_pC5), new State_C4_G(g_pC4), new State_C4_F(g_pC4), new State_C3_G(g_pC3), new State_C3_F(g_pC3), new State_C2_G(g_pC2), new State_C2_F(g_pC2), new State_C1_G(g_pC1), new State_C1_F(g_pC1), NULL), "4"); g_pC1->F(); CHECK_STATES((&g_States, new State_H_C1_F(g_pC1), new State_H_C1_G(g_pC1), new State_H_C2_F(g_pC2), new State_H_C2_G(g_pC2), new State_H_C3_F(g_pC3), new State_H_C3_G(g_pC3), new State_H_C4_F(g_pC4), new State_H_C4_G(g_pC4), new State_H_C5_F(g_pC5), new State_H_C5_G(g_pC5), new State_H_C6_F(g_pC6), new State_H_C6_G(g_pC6), new State_H_C7_F(g_pC7), new State_H_C7_G(g_pC7), new State_H_C8_F(g_pC8), new State_H_C8_G(g_pC8), new State_C8_G(g_pC8), new State_C8_F(g_pC8), new State_C7_G(g_pC7), new State_C7_F(g_pC7), new State_C6_G(g_pC6), new State_C6_F(g_pC6), new State_C5_G(g_pC5), new State_C5_F(g_pC5), new State_C4_G(g_pC4), new State_C4_F(g_pC4), new State_C3_G(g_pC3), new State_C3_F(g_pC3), new State_C2_G(g_pC2), new State_C2_F(g_pC2), new State_C1_G(g_pC1), new State_C1_F(g_pC1), NULL), "5"); SH_ADD_HOOK(C4, G, g_pC4, SH_STATIC(Handler2_C4_G), false); g_TestID = 2; g_pC1->F(); CHECK_STATES((&g_States, new State_H_C1_F(g_pC1), new State_H_C1_G(g_pC1), new State_H_C2_F(g_pC2), new State_H_C2_G(g_pC2), new State_H_C3_F(g_pC3), new State_H_C3_G(g_pC3), new State_H_C4_F(g_pC4), new State_H_C4_G(g_pC4), new State_H_C5_F(g_pC5), new State_H_C5_G(g_pC5), new State_H_C6_F(g_pC6), new State_H_C6_G(g_pC6), new State_H_C7_F(g_pC7), new State_H_C7_G(g_pC7), new State_H_C8_F(g_pC8), new State_H_C8_G(g_pC8), new State_C8_G(g_pC8), new State_C8_F(g_pC8), new State_C7_G(g_pC7), new State_C7_F(g_pC7), new State_C6_G(g_pC6), new State_C6_F(g_pC6), new State_C5_G(g_pC5), new State_C5_F(g_pC5), new State_C4_G(g_pC4), new State_C4_F(g_pC4), new State_C3_G(g_pC3), new State_C3_F(g_pC3), new State_C2_G(g_pC2), new State_C2_F(g_pC2), new State_C1_G(g_pC1), new State_C1_F(g_pC1), NULL), "6"); g_pC1->F(); CHECK_STATES((&g_States, new State_H_C1_F(g_pC1), new State_H_C1_G(g_pC1), new State_H_C2_F(g_pC2), new State_H_C2_G(g_pC2), new State_H_C3_F(g_pC3), new State_H_C3_G(g_pC3), new State_H_C4_F(g_pC4), new State_C4_G(g_pC4), new State_C4_F(g_pC4), new State_C3_G(g_pC3), new State_C3_F(g_pC3), new State_C2_G(g_pC2), new State_C2_F(g_pC2), new State_C1_G(g_pC1), new State_C1_F(g_pC1), NULL), "7"); SH_REMOVE_HOOK(C1, F, g_pC1, SH_STATIC(Handler_C1_F), false); SH_REMOVE_HOOK(C1, G, g_pC1, SH_STATIC(Handler_C1_G), false); SH_REMOVE_HOOK(C2, F, g_pC2, SH_STATIC(Handler_C2_F), false); SH_REMOVE_HOOK(C2, G, g_pC2, SH_STATIC(Handler_C2_G), false); SH_REMOVE_HOOK(C3, F, g_pC3, SH_STATIC(Handler_C3_F), false); SH_REMOVE_HOOK(C3, G, g_pC3, SH_STATIC(Handler_C3_G), false); SH_REMOVE_HOOK(C4, F, g_pC4, SH_STATIC(Handler_C4_F), false); SH_REMOVE_HOOK(C4, G, g_pC4, SH_STATIC(Handler_C4_G), false); SH_REMOVE_HOOK(C5, F, g_pC5, SH_STATIC(Handler_C5_F), false); SH_REMOVE_HOOK(C5, G, g_pC5, SH_STATIC(Handler_C5_G), false); SH_REMOVE_HOOK(C6, F, g_pC6, SH_STATIC(Handler_C6_F), false); SH_REMOVE_HOOK(C6, G, g_pC6, SH_STATIC(Handler_C6_G), false); SH_REMOVE_HOOK(C7, F, g_pC7, SH_STATIC(Handler_C7_F), false); SH_REMOVE_HOOK(C7, G, g_pC7, SH_STATIC(Handler_C7_G), false); SH_REMOVE_HOOK(C8, F, g_pC8, SH_STATIC(Handler_C8_F), false); SH_REMOVE_HOOK(C8, G, g_pC8, SH_STATIC(Handler_C8_G), false); return true; }
void LuaEx::ShutdownHooks() { SH_REMOVE_HOOK(IScriptManager, CreateVM, scriptmgr, SH_MEMBER(this, &LuaEx::Hook_CreateVMPost), true); SH_REMOVE_HOOK(IScriptManager, DestroyVM, scriptmgr, SH_MEMBER(this, &LuaEx::Hook_DestroyVM), true); }
bool TestThisPtrOffs(std::string &error) { GET_SHPTR(g_SHPtr); g_PLID = 1337; Derived *pD = MyInstanceFactory(); Base1 *pB1 = pD; Base2 *pB2 = pD; CAutoPtrDestruction<Derived> apd(pD); // It should be: // pB1 = pD // pB2 > pB1 // 1) // Get a callclass for pD // Verify whether the this pointers are correct // Also call them normally to make sure that we aren't messing it up ;) SourceHook::CallClass<Derived> *pD_CC = SH_GET_CALLCLASS(pD); SH_CALL(pD_CC, &Derived::Func1)(); SH_CALL(pD_CC, &Derived::Func2)(); SH_CALL(pD_CC, &Derived::Func3)(); pD->Func1(); pD->Func2(); pD->Func3(); CHECK_STATES((&g_States, new State_Func1_Called(pB1), new State_Func2_Called(pB2), new State_Func3_Called(pD), new State_Func1_Called(pB1), new State_Func2_Called(pB2), new State_Func3_Called(pD), NULL), "Part 1"); SH_CALL(pD_CC, &Base1::Func1)(); SH_CALL(pD_CC, &Base2::Func2)(); CHECK_STATES((&g_States, new State_Func1_Called(pB1), new State_Func2_Called(pB2), NULL), "Part 1.1"); // 2) // Get callclasses for the other ones and verify it as well SourceHook::CallClass<Base1> *pB1_CC = SH_GET_CALLCLASS(pB1); SourceHook::CallClass<Base2> *pB2_CC = SH_GET_CALLCLASS(pB2); SH_CALL(pB1_CC, &Base1::Func1)(); SH_CALL(pB2_CC, &Base2::Func2)(); CHECK_STATES((&g_States, new State_Func1_Called(pB1), new State_Func2_Called(pB2), NULL), "Part 2"); // 3) Add hooks on them (referring to them through pD1 / Derived) // Check whether the hooks are called with the correct this pointer SH_ADD_HOOK(Derived, Func1, pD, SH_STATIC(Handler_Func1), false); SH_ADD_HOOK(Derived, Func2, pD, SH_STATIC(Handler_Func2), false); SH_ADD_HOOK(Derived, Func3, pD, SH_STATIC(Handler_Func3), false); pD->Func1(); pD->Func2(); pD->Func3(); pB1->Func1(); pB2->Func2(); // The handlers should always be called with the pointer to Derived CHECK_STATES((&g_States, new State_Func1H_Called(pD), new State_Func1_Called(pB1), new State_Func2H_Called(pD), new State_Func2_Called(pB2), new State_Func3H_Called(pD), new State_Func3_Called(pD), new State_Func1H_Called(pD), new State_Func1_Called(pB1), new State_Func2H_Called(pD), new State_Func2_Called(pB2), NULL), "Part 3"); SH_REMOVE_HOOK(Derived, Func1, pD, SH_STATIC(Handler_Func1), false); SH_REMOVE_HOOK(Derived, Func2, pD, SH_STATIC(Handler_Func2), false); SH_REMOVE_HOOK(Derived, Func3, pD, SH_STATIC(Handler_Func3), false); // 4) // Now add the hooks on Base1 and Base2 and check again // Note that the new implicit_cast should convert the pD to Base1*/Base2* :) SH_ADD_HOOK(Base1, Func1, pD, SH_STATIC(Handler_Func1), false); SH_ADD_HOOK(Base2, Func2, pD, SH_STATIC(Handler_Func2), false); SH_ADD_HOOK(Derived, Func3, pD, SH_STATIC(Handler_Func3), false); pD->Func1(); pD->Func2(); pD->Func3(); pB1->Func1(); pB2->Func2(); // This time, the handlers for Func1 should be called with pB1 and the handlers // for Func2 should be called with pB2 CHECK_STATES((&g_States, new State_Func1H_Called(pB1), new State_Func1_Called(pB1), new State_Func2H_Called(pB2), new State_Func2_Called(pB2), new State_Func3H_Called(pD), new State_Func3_Called(pD), new State_Func1H_Called(pB1), new State_Func1_Called(pB1), new State_Func2H_Called(pB2), new State_Func2_Called(pB2), NULL), "Part 4"); SH_REMOVE_HOOK(Base1, Func1, pD, SH_STATIC(Handler_Func1), false); SH_REMOVE_HOOK(Base2, Func2, pD, SH_STATIC(Handler_Func2), false); SH_REMOVE_HOOK(Derived, Func3, pD, SH_STATIC(Handler_Func3), false); // 5) // Add some hooks, and use callclasses // 5.1) First off, add all of them on pD SH_ADD_HOOK(Derived, Func1, pD, SH_STATIC(Handler_Func1), false); SH_ADD_HOOK(Derived, Func2, pD, SH_STATIC(Handler_Func2), false); SH_ADD_HOOK(Derived, Func3, pD, SH_STATIC(Handler_Func3), false); pD->Func1(); pD->Func2(); pD->Func3(); CHECK_STATES((&g_States, new State_Func1H_Called(pD), new State_Func1_Called(pB1), new State_Func2H_Called(pD), new State_Func2_Called(pB2), new State_Func3H_Called(pD), new State_Func3_Called(pD), NULL), "Part 5.1"); SH_CALL(pD_CC, &Derived::Func1)(); SH_CALL(pD_CC, &Derived::Func2)(); SH_CALL(pD_CC, &Derived::Func3)(); SH_CALL(pB1_CC, &Base1::Func1)(); SH_CALL(pB2_CC, &Base2::Func2)(); CHECK_STATES((&g_States, new State_Func1_Called(pB1), new State_Func2_Called(pB2), new State_Func3_Called(pD), new State_Func1_Called(pB1), new State_Func2_Called(pB2), NULL), "Part 5.2"); SH_REMOVE_HOOK(Derived, Func1, pD, SH_STATIC(Handler_Func1), false); SH_REMOVE_HOOK(Derived, Func2, pD, SH_STATIC(Handler_Func2), false); SH_REMOVE_HOOK(Derived, Func3, pD, SH_STATIC(Handler_Func3), false); SH_RELEASE_CALLCLASS(pB1_CC); SH_RELEASE_CALLCLASS(pB2_CC); SH_RELEASE_CALLCLASS(pD_CC); return true; }
bool TestVafmtAndOverload(std::string &error) { GET_SHPTR(g_SHPtr); g_PLID = 1337; Whatever gabgab; IGaben *pGab = &gabgab; // Part 1 SH_CALL(pGab, static_cast<void (IGaben::*)()>(&IGaben::EatYams))(); SH_CALL(pGab, static_cast<bool (IGaben::*)(const char *) const>(&IGaben::EatYams))("Here!"); SH_ADD_HOOK(IGaben, EatYams, pGab, EatYams0_Handler, false); SH_ADD_HOOK(IGaben, EatYams, pGab, EatYams1_Handler, false); pGab->EatYams(); pGab->EatYams("Here!"); SH_REMOVE_HOOK(IGaben, EatYams, pGab, EatYams0_Handler, false); SH_REMOVE_HOOK(IGaben, EatYams, pGab, EatYams1_Handler, false); CHECK_STATES((&g_States, new State_EatYams_Called(0), new State_EatYams_Called(1), new State_EatYams_Handler_Called(0), new State_EatYams_Called(0), new State_EatYams_Handler_Called(1), new State_EatYams_Called(1), NULL),"Part 1"); // Part 2 pGab->Vafmt1(true, 55, "Hello %s%d%s", "BA", 1, "L"); SH_CALL(pGab, &IGaben::Vafmt1)(true, 55, "Hello %s%d%s", "BA", 1, "L"); pGab->Vafmt2("Hello %s%d%s", "BA", 1, "LOPAN"); SH_CALL(pGab, &IGaben::Vafmt2)("Hello %s%d%s", "BA", 1, "LOPAN"); CHECK_STATES((&g_States, new State_Vafmt_Called(1, "Hello BA1L"), new State_Vafmt_Called(1, "Hello BA1L"), new State_Vafmt_Called(2, "Hello BA1LOPAN"), new State_Vafmt_Called(2, "Hello BA1LOPAN"), NULL), "Part 2"); // Part 3 SH_ADD_HOOK(IGaben, Vafmt1, pGab, Vafmt1_PreHandler, false); SH_ADD_HOOK(IGaben, Vafmt1, pGab, Vafmt1_PostHandler, true); SH_ADD_HOOK(IGaben, Vafmt2, pGab, Vafmt2_PreHandler, false); SH_ADD_HOOK(IGaben, Vafmt2, pGab, Vafmt2_PostHandler, true); pGab->Vafmt1(true, 55, "Hello %s%d%s", "BA", 1, "L"); pGab->Vafmt2("Hello %s%d%s", "BA", 1, "LOPAN"); CHECK_STATES((&g_States, new State_Vafmt_PreHandler_Called(1, std::string("Hello BA1L")), new State_Vafmt_Called(1, std::string("Hello BA1L")), new State_Vafmt_PostHandler_Called(1, std::string("Hello BA1L")), new State_Vafmt_PreHandler_Called(2, std::string("Hello BA1LOPAN")), new State_Vafmt_Called(2, std::string("Hello BA1LOPAN")), new State_Vafmt_PostHandler_Called(2, std::string("Hello BA1LOPAN")), NULL), "Part 3"); // Part 4 SH_REMOVE_HOOK(IGaben, Vafmt1, pGab, Vafmt1_PreHandler, false); SH_REMOVE_HOOK(IGaben, Vafmt1, pGab, Vafmt1_PostHandler, true); SH_REMOVE_HOOK(IGaben, Vafmt2, pGab, Vafmt2_PreHandler, false); SH_REMOVE_HOOK(IGaben, Vafmt2, pGab, Vafmt2_PostHandler, true); pGab->Vafmt1(true, 55, "Hello %s%d%s", "BA", 1, "L"); pGab->Vafmt2("Hello %s%d%s", "BA", 1, "LOPAN"); CHECK_STATES((&g_States, new State_Vafmt_Called(1, "Hello BA1L"), new State_Vafmt_Called(2, "Hello BA1LOPAN"), NULL), "Part 4"); return true; }
void ConVarManager::OnSimillimumShutdown() { List<ConVarInfo *>::iterator iter = m_ConVars.begin(); HandleSecurity sec(NULL, g_pCoreIdent); /* Iterate list of ConVarInfo structures, remove every one of them */ while (iter != m_ConVars.end()) { ConVarInfo *pInfo = (*iter); iter = m_ConVars.erase(iter); handlesys->FreeHandle(pInfo->handle, &sec); if (pInfo->pChangeForward != NULL) { g_Forwards.ReleaseForward(pInfo->pChangeForward); } if (pInfo->sourceMod) { /* If we created it, we won't be tracking it, therefore it is * safe to remove everything in one go. */ META_UNREGCVAR(pInfo->pVar); delete [] pInfo->pVar->GetName(); delete [] pInfo->pVar->GetHelpText(); delete [] pInfo->pVar->GetDefault(); delete pInfo->pVar; } else { /* If we didn't create it, we might be tracking it. Also, * it could be unreadable. */ UntrackConCommandBase(pInfo->pVar, this); } /* It's not safe to read the name here, so we simply delete the * the info struct and clear the lookup cache at the end. */ delete pInfo; } convar_cache.clear(); #if SOURCE_ENGINE != SE_DARKMESSIAH /* Unhook things */ if (m_bIsDLLQueryHooked) { SH_REMOVE_HOOK(IServerGameDLL, OnQueryCvarValueFinished, gamedll, SH_MEMBER(this, &ConVarManager::OnQueryCvarValueFinished), false); m_bIsDLLQueryHooked = false; } else if (m_bIsVSPQueryHooked) { SH_REMOVE_HOOK(IServerPluginCallbacks, OnQueryCvarValueFinished, vsp_interface, SH_MEMBER(this, &ConVarManager::OnQueryCvarValueFinished), false); m_bIsVSPQueryHooked = false; } #endif #if SOURCE_ENGINE >= SE_ORANGEBOX SH_REMOVE_HOOK(ICvar, CallGlobalChangeCallbacks, icvar, SH_STATIC(OnConVarChanged), false); #else SH_REMOVE_HOOK(ICvar, CallGlobalChangeCallback, icvar, SH_STATIC(OnConVarChanged), false); #endif /* Remove the 'convars' option from the 'sm' console command */ g_RootMenu.RemoveRootConsoleCommand("cvars", this); scripts->RemovePluginsListener(this); /* Remove the 'ConVar' handle type */ handlesys->RemoveType(m_ConVarType, g_pCoreIdent); }