Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DynAppSysFactory
- {
- struct InterfaceLinkedList_t
- {
- void* (*Function)();
- const char* pName;
- InterfaceLinkedList_t* pNext;
- };
- InterfaceLinkedList_t* m_pList;
- public:
- DynAppSysFactory ( const std::string& module );
- void* Get ( const std::string& name );
- };
- DynAppSysFactory::DynAppSysFactory ( const std::string& module )
- {
- void* create_interface = GetProcAddress ( GetModuleHandleA ( module.c_str () ), "CreateInterface" );
- size_t jmp_instruction = (size_t)create_interface + 4;
- size_t jmp_target = jmp_instruction + *(size_t*)( jmp_instruction + 1 ) + 5;
- m_pList = **(InterfaceLinkedList_t***)( jmp_target + 6 );
- }
- void* DynAppSysFactory::Get ( const std::string& name )
- {
- InterfaceLinkedList_t* pList = m_pList;
- size_t nLength = name.length ();
- while ( pList )
- {
- if ( !std::strncmp ( pList->pName, name.c_str (), nLength ) )
- {
- int nVersion = atoi ( pList->pName + nLength );
- if ( nVersion > 0 )
- return pList->Function ();
- }
- pList = pList->pNext;
- }
- return nullptr;
- }
- DynAppSysFactory ClientFactory ( "client.dll" );
- DynAppSysFactory EngineFactory ( "engine.dll" );
- DynAppSysFactory VGuiFactory ( "vguimatsurface.dll" );
- DynAppSysFactory VGui2Factory ( "vgui2.dll" );
- m_pClient = (Source::IBaseClientDLL*) ClientFactory.Get ( "VClient" );
- m_pEngine = (Source::IVEngineClient*) EngineFactory.Get ( "VEngineClient" );
- m_pPanel = (Source::IPanel*) VGui2Factory.Get ( "VGUI_Panel" );
- m_pSurface = (Source::ISurface*) VGuiFactory.Get ( "VGUI_Surface" );
- m_pModelInfo = (Source::IVModelInfo*) EngineFactory.Get ( "VModelInfoClient" );
- m_pEntList = (Source::IClientEntityList*) ClientFactory.Get ( "VClientEntityList" );
- m_pEngineTrace = (Source::IEngineTrace*) EngineFactory.Get ( "EngineTraceClient" );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement