bool TransactionUnloader::RevertTransaction(Transaction* T) { bool Successful = true; if (getExecutor() && T->getModule()) { Successful = getExecutor()->unloadFromJIT(T->getModule(), T->getExeUnloadHandle()) && Successful; // Cleanup the module from unused global values. // if (T->getModule()) { // llvm::ModulePass* globalDCE = llvm::createGlobalDCEPass(); // globalDCE->runOnModule(*T->getModule()); // } Successful = unloadModule(T->getModule()) && Successful; } // Clean up the pending instantiations m_Sema->PendingInstantiations.clear(); m_Sema->PendingLocalImplicitInstantiations.clear(); DeclUnloader DeclU(m_Sema, m_CodeGen, T); Successful = unloadDeclarations(T, DeclU) && Successful; Successful = unloadDeserializedDeclarations(T, DeclU) && Successful; Successful = unloadFromPreprocessor(T, DeclU) && Successful; #ifndef NDEBUG //FIXME: Move the nested transaction marker out of the decl lists and // reenable this assertion. //size_t DeclSize = std::distance(T->decls_begin(), T->decls_end()); //if (T->getCompilationOpts().CodeGenerationForModule) // assert (!DeclSize && "No parsed decls must happen in parse for module"); #endif if (Successful) T->setState(Transaction::kRolledBack); else T->setState(Transaction::kRolledBackWithErrors); // Release the input_line_X file unless verifying diagnostics. if (!m_Interp->getCI()->getDiagnosticOpts().VerifyDiagnostics) m_Sema->getSourceManager().invalidateCache(T->getBufferFID()); return Successful; }
AcRx::AppRetCode acrxEntryPoint(AcRx::AppMsgCode msg, void* pkt) { switch (msg) { case AcRx::kInitAppMsg: if (!acrxClassDictionary->at("AcBrEntity")) acrxDynamicLinker->loadModule("acbr16.dbx", 1); initModule(); acrxUnlockApplication(pkt); // try to allow unloading acrxRegisterAppMDIAware(pkt); break ; case AcRx::kUnloadAppMsg: unloadModule(); break ; default: break ; } return AcRx::kRetOK; }
bool Module::replaceModule() { if (_newModule.empty()) return true; _console->hide(); Common::UString newModule = _newModule; unloadAreas(); unloadHAKs(); unloadModule(); _exit = true; if (!loadModule(newModule)) return false; return enter(); }
// ___ acrxEntryPoint ______________________________________________________________________ // // description: Locally defined entry point invoked by Rx. // // parameter: msg The first parameter, a data member of class AcRx called msg, // represents the message sent from the ARX kernel to the application. // pkt The second parameter is an opaque handle to data passed to // the lock and unlock functions for the application. // // return value: The function returns a status code, such as RSRSLT and RSERR. // problems: . AcRx::AppRetCode acrxEntryPoint(AcRx::AppMsgCode msg, void* pkt) { switch(msg) { case AcRx::kInitAppMsg: acrxDynamicLinker->unlockApplication(pkt); // register as MDI aware acrxDynamicLinker->registerAppMDIAware(pkt); loadModule(); break; case AcRx::kUnloadAppMsg: unloadModule(); break; case AcRx::kLoadDwgMsg: case AcRx::kUnloadDwgMsg: case AcRx::kInvkSubrMsg: default: break; } return AcRx::kRetOK; }
std::string ModuleManager::callMethod(const std::string& sender, const std::string& reciver, const std::string& action, const std::string& jsonString, IrcConnection* connection) { if(reciver=="IRCCONNECTION") { JSONNode n; if(!jsonString.empty()) { n = libjson::parse(jsonString); } if(action == "joinChan") { connection->joinChan(n["channel"].as_string()); } else if(action == "partChan") { connection->partChan(n["channel"].as_string()); } else if(action == "sendQuit") { connection->sendQuit(n["msg"].as_string()); } else if(action == "sendMessage") { connection->sendMessage(n["target"].as_string(), n["message"].as_string()); } else if(action == "sendNotice") { connection->sendNotice(n["target"].as_string(), n["message"].as_string()); } else if(action == "sendAction") { connection->sendNotice(n["target"].as_string(), n["message"].as_string()); } else if(action == "sendCTCP") { connection->sendNotice(n["target"].as_string(), n["message"].as_string()); } else if(action == "changeNick") { connection->changeNick(n["nick"].as_string()); } else if(action == "setUserMode") { connection->setUserMode(n["mode"].as_string()); } else if(action == "setMode") { connection->setMode(n["nick"].as_string(), n["mode"].as_string()); } else if(action == "getChannels") { JSONNode n(JSON_NODE); std::map<std::string, IrcChannel>& channelList = connection->getChannels(); std::map<std::string, IrcChannel>::iterator iter; for(iter=channelList.begin(); iter!=channelList.end(); ++iter) { JSONNode n2(JSON_ARRAY); n2.set_name(iter->first); n2.push_back(convertIrcChannelToJSONString(iter->second)); n.push_back(n2); } return n.write(); } else if(action == "getServer") { return connection->getServer(); } else if(action == "getPort") { return Base::StringUtils::toString(connection->getPort()); } else if(action == "getNick") { return connection->getNick(); } else if(action == "getID") { return connection->getID(); } } else if(reciver=="IRC") { JSONNode n; if(!jsonString.empty()) { n = libjson::parse(jsonString); } if(action == "disconect") { mIRC->disconect(n["id"].as_string()); } else if(action == "disconectAll") { mIRC->disconectAll(); } } else if(reciver=="MODULEMANAGER") { JSONNode n; if(!jsonString.empty()) { n = libjson::parse(jsonString); } if(action == "reloadModule") { return Base::StringUtils::toString(reloadModule(n["id"].as_string())); } else if(action == "loadModuleBinary" || action == "loadModuleScript") { std::map<std::string, std::string> tmpParams; JSONNode n2 = n["params"]; JSONNode::iterator i = n2.begin(); for(; i!=n2.end(); ++i) { tmpParams[(*i).name()] = (*i).as_string(); } if(action == "loadModuleBinary") { return Base::StringUtils::toString(loadModuleBinary(n["id"].as_string(), n["file"].as_string(), tmpParams)); } else { return Base::StringUtils::toString(loadModuleScript(n["id"].as_string(), n["file"].as_string(), tmpParams)); } } else if(action == "unloadModule") { unloadModule(n["id"].as_string()); } } else { Module* module = getModule(reciver); if(!module) { return ""; } if(module->type == Module::BINARY) { if(!module->binaryModule.onInternalMessage) { return ""; } return module->binaryModule.onInternalMessage(sender.c_str(), action.c_str(), jsonString.c_str(), connection); } } return ""; }
void ModuleManager::unloadModule(const std::string& id) { unloadModule(getModule(id)); }
RBOOL processMessage ( rSequence seq ) { RBOOL isSuccess = FALSE; RU8 command = 0; rSequence idSeq = NULL; rpHCPId tmpId = { 0 }; rpHCPId emptyId = { 0 }; RU64 tmpTime = 0; rThread hQuitThread = 0; rpHCPIdentStore identStore = {0}; RPU8 token = NULL; RU32 tokenSize = 0; OBFUSCATIONLIB_DECLARE( store, RP_HCP_CONFIG_IDENT_STORE ); if( NULL != seq ) { if( rSequence_getRU8( seq, RP_TAGS_OPERATION, &command ) ) { rpal_debug_info( "Received command 0x%0X.", command ); switch( command ) { case RP_HCP_COMMAND_LOAD_MODULE: isSuccess = loadModule( &g_hcpContext, seq ); break; case RP_HCP_COMMAND_UNLOAD_MODULE: isSuccess = unloadModule( &g_hcpContext, seq ); break; case RP_HCP_COMMAND_SET_HCP_ID: if( rSequence_getSEQUENCE( seq, RP_TAGS_HCP_IDENT, &idSeq ) ) { tmpId = seqToHcpId( idSeq ); if( 0 != rpal_memory_memcmp( &emptyId, &tmpId, sizeof( emptyId ) ) ) { g_hcpContext.currentId = tmpId; OBFUSCATIONLIB_TOGGLE( store ); if( rSequence_getBUFFER( seq, RP_TAGS_HCP_ENROLLMENT_TOKEN, &token, &tokenSize ) ) { identStore.agentId = tmpId; if( saveHcpId( (RPNCHAR)store, &identStore, token, tokenSize ) ) { isSuccess = TRUE; } if( NULL != g_hcpContext.enrollmentToken ) { rpal_memory_free( g_hcpContext.enrollmentToken ); g_hcpContext.enrollmentToken = NULL; } if( NULL != ( g_hcpContext.enrollmentToken = rpal_memory_alloc( tokenSize ) ) ) { rpal_memory_memcpy( g_hcpContext.enrollmentToken, token, tokenSize ); g_hcpContext.enrollmentTokenSize = tokenSize; isSuccess = TRUE; } } else { rpal_debug_warning( "hcp id is missing token" ); } OBFUSCATIONLIB_TOGGLE( store ); } } break; case RP_HCP_COMMAND_SET_GLOBAL_TIME: if( rSequence_getTIMESTAMP( seq, RP_TAGS_TIMESTAMP, &tmpTime ) ) { rpal_time_setGlobalOffset( tmpTime - rpal_time_getLocal() ); isSuccess = TRUE; } break; case RP_HCP_COMMAND_QUIT: if( 0 != ( hQuitThread = rpal_thread_new( thread_quitAndCleanup, NULL ) ) ) { rpal_thread_free( hQuitThread ); isSuccess = TRUE; } break; case RP_HCP_COMMAND_UPGRADE: isSuccess = upgradeHcp( seq ); break; default: break; } if( isSuccess ) { rpal_debug_info( "Command was successful." ); } else { rpal_debug_warning( "Command was not successful." ); } } } return isSuccess; }
bool KviModuleManager::unloadModule(const QString &modName) { return unloadModule(findModule(modName)); }
~SP_ModulePriv(void) { unloadModule(); }
void loadModuleInterfaces(const char *dll, void **rmodule) // loads the interface from a dll and populates it's internal list { #if defined(WIN32) UINT errorMode = 0; if ( gSuppressLoadError ) errorMode = SEM_FAILCRITICALERRORS; UINT oldErrorMode = SetErrorMode(errorMode); HMODULE module = LoadLibraryA(dll); SetErrorMode(oldErrorMode); #else std::string mname(dll); mname.assign(mname.substr(0, mname.rfind(DLL_IN_EXT))); mname.insert(0,"lib"); mname.append(".so"); HMODULE module = (HMODULE)dlopen(mname.c_str(), RTLD_LAZY); #endif bool found_exports = (module != 0); if ( module ) { #if defined(WIN32) void *proc = GetProcAddress(module,"getInterfaceList"); #else void *proc = dlsym(module, "getInterfaceList"); #endif if ( proc ) { const INTERFACE_EXPORT *interfaces; NxI32 num = ((PLUGIN_INTERFACE_LIST_FUNC)proc)(&interfaces); for (NxI32 i = 0; i < num; i++) { getHash()[interfaces[i].name] = interfaces[i].func; found_exports = true; } } //LEGACY SUPPORT else // DO it the old way { #if defined(WIN32) void *proc = GetProcAddress(module,"getInterface"); #else void *proc = dlsym(module, "getInterface"); #endif if ( proc ) { // store the name of the dll sans extension as the classname lookup std::string cname(dll); getHash()[cname.substr(0, cname.rfind(DLL_IN_EXT))] = (PLUGIN_INTERFACE_FUNC)proc; found_exports = true; } } //END LEGACY } if (found_exports) { if (rmodule) *rmodule = module; } else { unloadModule(module); if (rmodule) *rmodule = 0; } }
void Module::unload() { unloadAreas(); unloadModule(); }