fixed a serious potential bug with swapping plugins to debug mode, leaving stale function pointers without plugin removal
2 * ===============================================================
3 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
4 * ===============================================================
6 * This file is not open source and may not be copied without explicit
7 * written permission of AlliedModders LLC. This file may not be redistributed
8 * in whole or significant part.
9 * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
14 #ifndef _INCLUDE_SOURCEMOD_EXTENSION_SYSTEM_H_
15 #define _INCLUDE_SOURCEMOD_EXTENSION_SYSTEM_H_
17 #include <IExtensionSys.h>
18 #include <ILibrarySys.h>
20 #include <sh_string.h>
21 #include "sm_globals.h"
24 #include <IPluginSys.h>
25 #include <IRootConsoleMenu.h>
27 using namespace SourceMod;
28 using namespace SourceHook;
30 class CExtension : public IExtension
32 friend class CExtensionManager;
34 CExtension(const char *filename, char *error, size_t maxlen);
37 IExtensionInterface *GetAPI();
38 const char *GetFilename();
39 IdentityToken_t *GetIdentity();
41 ITERATOR *FindFirstDependency(IExtension **pOwner, SMInterface **pInterface);
42 bool FindNextDependency(ITERATOR *iter, IExtension **pOwner, SMInterface **pInterface);
43 void FreeDependencyIterator(ITERATOR *iter);
44 bool IsRunning(char *error, size_t maxlength);
46 void SetError(const char *error);
47 void AddDependency(IfaceInfo *pInfo);
48 void AddInterface(SMInterface *pInterface);
49 void AddPlugin(IPlugin *pPlugin);
50 void RemovePlugin(IPlugin *pPlugin);
53 IdentityToken_t *m_pIdentToken;
54 IExtensionInterface *m_pAPI;
58 List<IfaceInfo> m_Deps;
59 List<SMInterface *> m_Interfaces;
60 List<IPlugin *> m_Plugins;
61 List<const sp_nativeinfo_t *> m_Natives;
63 unsigned int unload_code;
67 class CExtensionManager :
68 public IExtensionManager,
70 public IPluginsListener,
71 public IRootConsoleCommand
73 public: //SMGlobalClass
74 void OnSourceModAllInitialized();
75 void OnSourceModShutdown();
76 public: //IExtensionManager
77 IExtension *LoadExtension(const char *path,
78 ExtensionLifetime lifetime,
81 bool UnloadExtension(IExtension *pExt);
82 IExtension *FindExtensionByFile(const char *file);
83 IExtension *FindExtensionByName(const char *ext);
84 public: //IPluginsListener
85 void OnPluginDestroyed(IPlugin *plugin);
86 public: //IRootConsoleCommand
87 void OnRootConsoleCommand(const char *cmd, unsigned int argcount);
89 IExtension *LoadAutoExtension(const char *path);
90 void BindDependency(IExtension *pOwner, IfaceInfo *pInfo);
91 void AddInterface(IExtension *pOwner, SMInterface *pInterface);
92 void BindChildPlugin(IExtension *pParent, IPlugin *pPlugin);
93 void AddNatives(IExtension *pOwner, const sp_nativeinfo_t *natives);
94 void BindAllNativesToPlugin(IPlugin *pPlugin);
96 void AddDependency(IExtension *pSource, const char *file, bool required, bool autoload);
99 CExtension *FindByOrder(unsigned int num);
101 List<CExtension *> m_Libs;
104 extern CExtensionManager g_Extensions;
106 #endif //_INCLUDE_SOURCEMOD_EXTENSION_SYSTEM_H_