示例#1
0
文件: Modules.cpp 项目: luser/znc
// Why MODHALTCHK works only with functions returning EModRet ? :(
bool CModules::OnServerCapAvailable(const CString& sCap) {
	bool bResult = false;
	for (unsigned int a = 0; a < size(); ++a) {
		try {
			CModule* pMod = (*this)[a];
			CClient* pOldClient = pMod->GetClient();
			pMod->SetClient(m_pClient);
			if (m_pUser) {
				CUser* pOldUser = pMod->GetUser();
				pMod->SetUser(m_pUser);
				bResult |= pMod->OnServerCapAvailable(sCap);
				pMod->SetUser(pOldUser);
			} else {
				// WTF? Is that possible?
				bResult |= pMod->OnServerCapAvailable(sCap);
			}
			pMod->SetClient(pOldClient);
		} catch (CModule::EModException e) {
			if (CModule::UNLOAD == e) {
				UnloadModule((*this)[a]->GetModName());
			}
		}
	}
	return bResult;
}
示例#2
0
文件: Modules.cpp 项目: luser/znc
void CModules::UnloadAll() {
	while (size()) {
		CString sRetMsg;
		CString sModName = back()->GetModName();
		UnloadModule(sModName, sRetMsg);
	}
}
示例#3
0
// Maybe create new macro for this?
bool CGlobalModules::IsClientCapSupported(const CString& sCap, bool bState) {
	bool bResult = false;
	for (unsigned int a = 0; a < size(); ++a) {
		try {
			CGlobalModule* pMod = (CGlobalModule*) (*this)[a];
			CClient* pOldClient = pMod->GetClient();
			pMod->SetClient(m_pClient);
			if (m_pUser) {
				CUser* pOldUser = pMod->GetUser();
				pMod->SetUser(m_pUser);
				bResult |= pMod->IsClientCapSupported(sCap, bState);
				pMod->SetUser(pOldUser);
			} else {
				// WTF? Is that possible?
				bResult |= pMod->IsClientCapSupported(sCap, bState);
			}
			pMod->SetClient(pOldClient);
		} catch (CModule::EModException e) {
			if (CModule::UNLOAD == e) {
				UnloadModule((*this)[a]->GetModName());
			}
		}
	}
	return bResult;
}
SubModuleLoader::~SubModuleLoader() {
  String msg;
  while (modules.empty() == false) {
    bool ret = UnloadModule((*modules.begin())->GetModName(), msg);
    TermUtils::PrintStatus(ret, msg);
  };
};
示例#5
0
void
xf86DeleteInputDriver(int drvIndex)
{
    if (xf86InputDriverList[drvIndex] && xf86InputDriverList[drvIndex]->module)
	UnloadModule(xf86InputDriverList[drvIndex]->module);
    free(xf86InputDriverList[drvIndex]);
    xf86InputDriverList[drvIndex] = NULL;
}
示例#6
0
CTSProcessor::~CTSProcessor()
{
	UnloadModule();
	m_pTSPacket->Release();
	SafeRelease(&m_pFilterModule);
	SafeRelease(&m_pFilterManager);
	m_pTSProcessor->Release();
}
//--------------------------------------------------------------
static int Hook_UnloadModule(int id)
{
	DPRINTF("Hook_UnloadModule() id=%d\n", id);

	if (id == FAKEMOD_ID)
		return 0;

	return UnloadModule(id);
}
示例#8
0
void
xf86DeleteDriver(int drvIndex)
{
    if (xf86DriverList[drvIndex]
	&& (!xf86DriverHasEntities(xf86DriverList[drvIndex]))) {
	if (xf86DriverList[drvIndex]->module)
	    UnloadModule(xf86DriverList[drvIndex]->module);
	free(xf86DriverList[drvIndex]);
	xf86DriverList[drvIndex] = NULL;
    }
}
示例#9
0
bool CModules::ReloadModule(const CString& sModule, const CString& sArgs, CUser* pUser, CString& sRetMsg) {
	CString sMod = sModule;  // Make a copy incase the reference passed in is from CModule::GetModName()
	sRetMsg = "";
	if (!UnloadModule(sMod, sRetMsg)) {
		return false;
	}

	if (!LoadModule(sMod, sArgs, pUser, sRetMsg)) {
		return false;
	}

	sRetMsg = "Reloaded module [" + sMod + "]";
	return true;
}
示例#10
0
void
xf86DeleteScreen(int scrnIndex, int flags)
{
    ScrnInfoPtr pScrn;
    int i;

    /* First check if the screen is valid */
    if (xf86NumScreens == 0 || xf86Screens == NULL)
	return;

    if (scrnIndex > xf86NumScreens - 1)
	return;

    if (!(pScrn = xf86Screens[scrnIndex]))
	return;

    /* If a FreeScreen function is defined, call it here */
    if (pScrn->FreeScreen != NULL)
	pScrn->FreeScreen(scrnIndex, 0);

    while (pScrn->modes)
	xf86DeleteMode(&pScrn->modes, pScrn->modes);

    while (pScrn->modePool)
	xf86DeleteMode(&pScrn->modePool, pScrn->modePool);

    xf86OptionListFree(pScrn->options);

    if (pScrn->module)
	UnloadModule(pScrn->module);

    if (pScrn->drv)
	pScrn->drv->refCount--;

    free(pScrn->privates);

    xf86ClearEntityListForScreen(scrnIndex);

    free(pScrn);

    /* Move the other entries down, updating their scrnIndex fields */

    xf86NumScreens--;

    for (i = scrnIndex; i < xf86NumScreens; i++) {
	xf86Screens[i] = xf86Screens[i + 1];
	xf86Screens[i]->scrnIndex = i;
	/* Also need to take care of the screen layout settings */
    }
}
示例#11
0
bool Warden::LoadModuleAndExecute(uint32 accountId, uint32 modLen, uint8* module, uint8* sessionKey, uint8* packet, ByteBuffer* returnPacket)
{
    sLog->outStaticDebug("Warden::LoadModuleAndExecute()");

    uint32 m_signature = *(uint32*)(module + modLen - 4);   // - sizeof(uint32)
    if (m_signature != 0x5349474E)   // NGIS->SIGN string
    {
        sLog->outError("Warden module seams damaged, cannot find signature data.");
        return false;
    }
    // Now inflate the module after removing uint32 size at the beginning and last 4 "SIGN"
    uint32 m_InflateSize = *(uint32*)module;
    uint8* moduleCode = (uint8*)malloc(m_InflateSize);
    uint32 currentSize = modLen - 4 - 4;   // - sizeof(uint32) for inflateSize and - sizeof(uint32) for signature
    uLongf finalSize = m_InflateSize;
    if (uncompress(moduleCode, &finalSize, module+4, currentSize) != Z_OK)
    {
        sLog->outError("Warden module could not be inflated.");
        free(moduleCode);
        return false;
    }

    InstanceS instance;
    instance.loader = new CWardenLoader();

    instance.loader->PrintHeader((PDWORD)moduleCode);
    instance.loader->LoadWarden((PDWORD)moduleCode, finalSize);
    instance.list = instance.loader->InitializeWarden(&instance);

    instance.pointers.f1 = &*(*instance.list)->fpGenerateRC4Keys;
    instance.pointers.f2 = &*(*instance.list)->fpUnload;
    instance.pointers.f3 = &*(*instance.list)->fpPacketHandler;
    instance.pointers.f4 = &*(*instance.list)->fpTick;

    uint8* keyAddr = GenerateNewKeys(&instance, sessionKey, packet);

    *returnPacket << uint8(WMSG_WARDEN_KEYS);
    *returnPacket << uint32(accountId);
    returnPacket->append(((KeyPair*)keyAddr)->server, 0x102);
    returnPacket->append(((KeyPair*)keyAddr)->client, 0x102);
    returnPacket->append(&((WardenInitData*)(instance.list))->seed[0], 16);

    // Unload the module
    UnloadModule(&instance);
    instance.loader->UnloadWarden();
    delete instance.loader;
    free(moduleCode);
    return true;
}
示例#12
0
bool CModules::OnBoot() {
	for (unsigned int a = 0; a < size(); a++) {
		try {
			if (!(*this)[a]->OnBoot()) {
				return true;
			}
		} catch (CModule::EModException e) {
			if (e == CModule::UNLOAD) {
				UnloadModule((*this)[a]->GetModName());
			}
		}
	}

	return false;
}
示例#13
0
/** Unloading all modules except the protocol module.
 */
void ModuleManager::UnloadAll()
{
	std::vector<Anope::string> modules[MT_END];
	for (std::list<Module *>::iterator it = Modules.begin(), it_end = Modules.end(); it != it_end; ++it)
		if ((*it)->type != PROTOCOL)
			modules[(*it)->type].push_back((*it)->name);

	for (size_t i = MT_BEGIN + 1; i != MT_END; ++i)
		for (unsigned j = 0; j < modules[i].size(); ++j)
		{
			Module *m = FindModule(modules[i][j]);
			if (m != NULL)
				UnloadModule(m, NULL);
		}
}
示例#14
0
void ModuleManager::UnloadAll()
{
	std::vector<Anope::string> modules;
	for (size_t i = 1, j = 0; i != MT_END; j |= i, i <<= 1)
		for (std::list<Module *>::iterator it = Modules.begin(), it_end = Modules.end(); it != it_end; ++it)
		{
			Module *m = *it;
			if ((m->type & j) == m->type)
				modules.push_back(m->name);
		}
	
	for (unsigned i = 0; i < modules.size(); ++i)
	{
		Module *m = FindModule(modules[i]);
		if (m != NULL)
			UnloadModule(m, NULL);
	}
}
示例#15
0
文件: pybase.cpp 项目: McAlyster/py
void pybase::Reload()
{
    ThrLock lock;

    PyObject *reg = GetRegistry(REGNAME);

    if(reg) {
        PyObject *key;
        Py_ssize_t pos = 0;
        while(PyDict_Next(reg,&pos,&key,NULL)) {
            pybase *th = (pybase *)PyLong_AsLong(key);
            FLEXT_ASSERT(th);
            th->Unload();
        }

        UnloadModule();
    }

    bool ok = ReloadModule();

    if(ok) {
        LoadModule();

        if(reg) {
            SetRegistry(REGNAME,reg);

            PyObject *key;
            Py_ssize_t pos = 0;
            while(PyDict_Next(reg,&pos,&key,NULL)) {
                pybase *th = (pybase *)PyLong_AsLong(key);
                FLEXT_ASSERT(th);
                th->Load();
            }
        }
        else
            Load();
    }

    Report();
}
示例#16
0
void Module::unloadInternal()
{
	WXMP_Error error;

	//
	// terminate plugin
	//
	if( mPluginAPIs != NULL )
	{
		if( mPluginAPIs->mTerminatePluginProc ) 
		{
			mPluginAPIs->mTerminatePluginProc( &error );
		}
		delete mPluginAPIs;
		mPluginAPIs = NULL;
	}

	//
	// unload plugin module
	//
	if( mLoaded != kModuleNotLoaded )
	{
		UnloadModule(mHandle, false);
		mHandle = NULL;
		if( mLoaded == kModuleLoaded )
		{
			//
			// Reset mLoaded to kModuleNotLoaded, if the module was loaded successfully.
			// Otherwise let it remain kModuleErrorOnLoad so that we won't try to load 
			// it again if some other handler ask to do so.
			//
			mLoaded = kModuleNotLoaded;
		}
	}

	CheckError( error );
}
示例#17
0
ModuleManager::~ModuleManager()
{
   size_t cnt = mModules.GetCount();

   for (size_t ndx = 0; ndx < cnt; ndx++) {
      delete (Module *) mModules[ndx];
   }
   mModules.Clear();

   ModuleMap::iterator iter = mDynModules.begin();
   while (iter != mDynModules.end())
   {
      UnloadModule(iter->second);

      mDynModules.erase(iter->first);

      iter = mDynModules.begin();
   }

   if (pBuiltinModuleList != NULL)
   {
      delete pBuiltinModuleList;
   }
}
示例#18
0
文件: Modules.cpp 项目: sorbits/znc
bool CModules::ReloadModule(const CString& sModule, const CString& sArgs, CUser* pUser, CIRCNetwork* pNetwork, CString& sRetMsg) {
	CString sMod = sModule;  // Make a copy incase the reference passed in is from CModule::GetModName()
	CModule *pModule = FindModule(sMod);

	if (!pModule) {
		sRetMsg = "Module [" + sMod + "] not loaded";
		return false;
	}

	CModInfo::EModuleType eType = pModule->GetType();
	pModule = NULL;

	sRetMsg = "";
	if (!UnloadModule(sMod, sRetMsg)) {
		return false;
	}

	if (!LoadModule(sMod, sArgs, eType, pUser, pNetwork, sRetMsg)) {
		return false;
	}

	sRetMsg = "Reloaded module [" + sMod + "]";
	return true;
}
示例#19
0
void HModuleRoster::MessageReceived( BMessage *message )
{
	switch( message->what )
	{
		case B_NODE_MONITOR:
		{
			int32		opcode;
			
			opcode = message->FindInt32( "opcode" );
			switch( opcode )
			{
				case B_ENTRY_CREATED:
				{
					entry_ref ref;
					const char *name;
					message->FindInt32( "device", &ref.device );
					message->FindInt64( "directory", &ref.directory );
					message->FindString( "name", &name );
					ref.set_name( name );
					
					BEntry		entry( &ref, true );
					BPath		modulePath;
					entry.GetPath( &modulePath );
					LoadModule( &modulePath );
					break;
				}	
				case B_ENTRY_REMOVED:
				{
					node_ref 	nref;
					message->FindInt32( "device", &nref.device );
					message->FindInt64( "node", &nref.node );
					UnloadModule( &nref );
					break;
				}
				case B_ENTRY_MOVED:
				{
					node_ref dirRef;
					message->FindInt32( "device", &dirRef.device );
					message->FindInt64( "to directory", &dirRef.node );
					
					if( dirRef != watchedRef )
					{
						entry_ref ref;
						const char *name;
						message->FindInt32( "device", &ref.device );
						message->FindInt64( "to directory", &ref.directory );
						message->FindString( "name", &name );
						ref.set_name( name );
						
						BEntry		entry( &ref, true );
						BNode		node( &entry );
						
						node_ref nref;
						node.GetNodeRef( &nref );
						UnloadModule( &nref );
					}
					else
					{
						entry_ref ref;
						const char *name;
						message->FindInt32( "device", &ref.device );
						message->FindInt64( "to directory", &ref.directory );
						message->FindString( "name", &name );
						ref.set_name( name );
						
						BEntry		entry( &ref, true );
						BPath		modulePath;
						entry.GetPath( &modulePath );
						LoadModule( &modulePath );
					}
					break;
				}
			}
			break;
		}
		default:
			BHandler::MessageReceived( message );
			break;
	}
}
示例#20
0
bool CModules::UnloadModule(const CString& sModule) {
	CString s;
	return UnloadModule(sModule, s);
}
示例#21
0
bool CModules::LoadModule(const CString& sModule, const CString& sArgs, CUser* pUser, CString& sRetMsg) {
	sRetMsg = "";

	if (FindModule(sModule) != NULL) {
		sRetMsg = "Module [" + sModule + "] already loaded.";
		return false;
	}

	bool bSuccess;
	GLOBALMODULECALL(OnModuleLoading(sModule, sArgs, bSuccess, sRetMsg), pUser, NULL, return bSuccess);

	CString sModPath, sDataPath;
	CString sDesc;
	bool bVersionMismatch;
	bool bIsGlobal;

	if (!FindModPath(sModule, sModPath, sDataPath)) {
		sRetMsg = "Unable to find module [" + sModule + "]";
		return false;
	}

	ModHandle p = OpenModule(sModule, sModPath, bVersionMismatch, bIsGlobal, sDesc, sRetMsg);

	if (!p)
		return false;

	if (bVersionMismatch) {
		dlclose(p);
		sRetMsg = "Version mismatch, recompile this module.";
		return false;
	}

	if ((pUser == NULL) != bIsGlobal) {
		dlclose(p);
		sRetMsg = "Module [" + sModule + "] is ";
		sRetMsg += (bIsGlobal) ? "" : "not ";
		sRetMsg += "a global module.";
		return false;
	}

	CModule* pModule = NULL;

	if (pUser) {
		typedef CModule* (*fp)(ModHandle, CUser* pUser,
				const CString& sModName, const CString& sDataPath);
		fp Load = (fp) dlsym(p, "ZNCModLoad");

		if (!Load) {
			dlclose(p);
			sRetMsg = "Could not find ZNCModLoad() in module [" + sModule + "]";
			return false;
		}

		pModule = Load(p, pUser, sModule, sDataPath);
	} else {
		typedef CModule* (*fp)(ModHandle, const CString& sModName,
				const CString& sDataPath);
		fp Load = (fp) dlsym(p, "ZNCModLoad");

		if (!Load) {
			dlclose(p);
			sRetMsg = "Could not find ZNCModLoad() in module [" + sModule + "]";
			return false;
		}

		pModule = Load(p, sModule, sDataPath);
	}

	pModule->SetDescription(sDesc);
	pModule->SetGlobal(bIsGlobal);
	pModule->SetArgs(sArgs);
	pModule->SetModPath(CDir::ChangeDir(CZNC::Get().GetCurPath(), sModPath));
	push_back(pModule);

	bool bLoaded;
	try {
		bLoaded = pModule->OnLoad(sArgs, sRetMsg);
	} catch (CModule::EModException) {
		bLoaded = false;
		sRetMsg = "Caught an exception";
	}

	if (!bLoaded) {
		UnloadModule(sModule, sModPath);
		if (!sRetMsg.empty())
			sRetMsg = "Module [" + sModule + "] aborted: " + sRetMsg;
		else
			sRetMsg = "Module [" + sModule + "] aborted.";
		return false;
	}

	if (!sRetMsg.empty()) {
		sRetMsg = "Loaded module [" + sModule + "] [" + sRetMsg + "] [" + sModPath + "]";
	} else {
		sRetMsg = "Loaded module [" + sModule + "] [" + sModPath + "]";
	}
	return true;
}
示例#22
0
bool CModules::LoadModule(const CString& sModule, const CString& sArgs, CUser* pUser, CString& sRetMsg, bool bFake) {
	sRetMsg = "";

	if (FindModule(sModule) != NULL) {
		sRetMsg = "Module [" + sModule + "] already loaded.";
		return false;
	}

	if (bFake) {
		CModule* pModule = new CModule(NULL, sModule, "");
		pModule->SetArgs(sArgs);
		pModule->SetDescription("<<Fake Module>>");
		pModule->SetFake(true);
		push_back(pModule);
		sRetMsg = "Loaded fake module [" + sModule + "]";
		return true;
	}

	CString sModPath, sDataPath;
	CString sDesc;
	bool bVersionMismatch;
	bool bIsGlobal;

	if (!FindModPath(sModule, sModPath, sDataPath)) {
		sRetMsg = "Unable to find module [" + sModule + "]";
		return false;
	}

	ModHandle p = OpenModule(sModule, sModPath, bVersionMismatch, bIsGlobal, sDesc, sRetMsg);

	if (!p)
		return false;

	if (bVersionMismatch) {
		dlclose(p);
		return false;
	}

	if ((pUser == NULL) != bIsGlobal) {
		dlclose(p);
		sRetMsg = "Module [" + sModule + "] is ";
		sRetMsg += (bIsGlobal) ? "" : "not ";
		sRetMsg += "a global module.";
		return false;
	}

	CModule* pModule = NULL;

	if (pUser) {
		typedef CModule* (*fp)(ModHandle, CUser* pUser,
				const CString& sModName, const CString& sDataPath);
		fp Load = (fp) dlsym(p, "ZNCModLoad");

		if (!Load) {
			dlclose(p);
			sRetMsg = "Could not find ZNCModLoad() in module [" + sModule + "]";
			return false;
		}

		pModule = Load(p, pUser, sModule, sDataPath);
	} else {
		typedef CModule* (*fp)(ModHandle, const CString& sModName,
				const CString& sDataPath);
		fp Load = (fp) dlsym(p, "ZNCModLoad");

		if (!Load) {
			dlclose(p);
			sRetMsg = "Could not find ZNCModLoad() in module [" + sModule + "]";
			return false;
		}

		pModule = Load(p, sModule, sDataPath);
	}

	pModule->SetDescription(sDesc);
	pModule->SetGlobal(bIsGlobal);
	pModule->SetArgs(sArgs);
	push_back(pModule);

	bool bLoaded;
	try {
		bLoaded = pModule->OnLoad(sArgs, sRetMsg);
	} catch (CModule::EModException) {
		bLoaded = false;
		sRetMsg = "Caught an exception";
	}

	if (!bLoaded) {
		UnloadModule(sModule, sModPath);
		if (!sRetMsg.empty())
			sRetMsg = "Module [" + sModule + "] aborted: " + sRetMsg;
		else
			sRetMsg = "Module [" + sModule + "] aborted.";
		return false;
	}

	if (!sRetMsg.empty()) {
		sRetMsg = "Loaded module [" + sModule + "] [" + sRetMsg + "] [" + sModPath + "]";
	} else {
		sRetMsg = "Loaded module [" + sModule + "] [" + sModPath + "]";
	}
	return true;
}
示例#23
0
bool CModules::LoadModule(const CString& sModule, const CString& sArgs, CUser* pUser, CString& sRetMsg) {
    sRetMsg = "";

    if (FindModule(sModule) != NULL) {
        sRetMsg = "Module [" + sModule + "] already loaded.";
        return false;
    }

    bool bSuccess;
    GLOBALMODULECALL(OnModuleLoading(sModule, sArgs, bSuccess, sRetMsg), pUser, NULL, return bSuccess);

    CString sModPath, sDataPath;
    bool bVersionMismatch;
    CModInfo Info;

    if (!FindModPath(sModule, sModPath, sDataPath)) {
        sRetMsg = "Unable to find module [" + sModule + "]";
        return false;
    }

    ModHandle p = OpenModule(sModule, sModPath, bVersionMismatch, Info, sRetMsg);

    if (!p)
        return false;

    if (bVersionMismatch) {
        dlclose(p);
        sRetMsg = "Version mismatch, recompile this module.";
        return false;
    }

    if ((pUser == NULL) != Info.IsGlobal()) {
        dlclose(p);
        sRetMsg = "Module [" + sModule + "] is ";
        sRetMsg += Info.IsGlobal() ? "" : "not ";
        sRetMsg += "a global module.";
        return false;
    }

    CModule* pModule = NULL;

    if (pUser) {
        pModule = Info.GetLoader()(p, pUser, sModule, sDataPath);
    } else {
        pModule = Info.GetGlobalLoader()(p, sModule, sDataPath);
    }

    pModule->SetDescription(Info.GetDescription());
    pModule->SetGlobal(Info.IsGlobal());
    pModule->SetArgs(sArgs);
    pModule->SetModPath(CDir::ChangeDir(CZNC::Get().GetCurPath(), sModPath));
    push_back(pModule);

    bool bLoaded;
    try {
        bLoaded = pModule->OnLoad(sArgs, sRetMsg);
    } catch (CModule::EModException) {
        bLoaded = false;
        sRetMsg = "Caught an exception";
    }

    if (!bLoaded) {
        UnloadModule(sModule, sModPath);
        if (!sRetMsg.empty())
            sRetMsg = "Module [" + sModule + "] aborted: " + sRetMsg;
        else
            sRetMsg = "Module [" + sModule + "] aborted.";
        return false;
    }

    if (!sRetMsg.empty()) {
        sRetMsg += "[" + sRetMsg + "] ";
    }
    sRetMsg += "[" + sModPath + "]";
    return true;
}
示例#24
0
文件: Modules.cpp 项目: sorbits/znc
bool CModules::LoadModule(const CString& sModule, const CString& sArgs, CModInfo::EModuleType eType, CUser* pUser, CIRCNetwork *pNetwork, CString& sRetMsg) {
	sRetMsg = "";

	if (FindModule(sModule) != NULL) {
		sRetMsg = "Module [" + sModule + "] already loaded.";
		return false;
	}

	bool bSuccess;
	_GLOBALMODULECALL(OnModuleLoading(sModule, sArgs, eType, bSuccess, sRetMsg), pUser, pNetwork, NULL, return bSuccess);

	CString sModPath, sDataPath;
	bool bVersionMismatch;
	CModInfo Info;

	if (!FindModPath(sModule, sModPath, sDataPath)) {
		sRetMsg = "Unable to find module [" + sModule + "]";
		return false;
	}

	ModHandle p = OpenModule(sModule, sModPath, bVersionMismatch, Info, sRetMsg);

	if (!p)
		return false;

	if (bVersionMismatch) {
		dlclose(p);
		sRetMsg = "Version mismatch, recompile this module.";
		return false;
	}

	if (!Info.SupportsType(eType)) {
		dlclose(p);
		sRetMsg = "Module [" + sModule + "] does not support module type ["
			+ CModInfo::ModuleTypeToString(eType) + "].";
		return false;
	}

	if (!pUser && eType == CModInfo::UserModule) {
		dlclose(p);
		sRetMsg = "Module [" + sModule + "] requires a user.";
		return false;
	}

	if (!pNetwork && eType == CModInfo::NetworkModule) {
		dlclose(p);
		sRetMsg = "Module [" + sModule + "] requires a network.";
		return false;
	}

	CModule* pModule = Info.GetLoader()(p, pUser, pNetwork, sModule, sDataPath);
	pModule->SetDescription(Info.GetDescription());
	pModule->SetType(eType);
	pModule->SetArgs(sArgs);
	pModule->SetModPath(CDir::ChangeDir(CZNC::Get().GetCurPath(), sModPath));
	push_back(pModule);

	bool bLoaded;
	try {
		bLoaded = pModule->OnLoad(sArgs, sRetMsg);
	} catch (CModule::EModException) {
		bLoaded = false;
		sRetMsg = "Caught an exception";
	}

	if (!bLoaded) {
		UnloadModule(sModule, sModPath);
		if (!sRetMsg.empty())
			sRetMsg = "Module [" + sModule + "] aborted: " + sRetMsg;
		else
			sRetMsg = "Module [" + sModule + "] aborted.";
		return false;
	}

	if (!sRetMsg.empty()) {
		sRetMsg += "[" + sRetMsg + "] ";
	}
	sRetMsg += "[" + sModPath + "]";
	return true;
}
ACLModule::~ACLModule(void)
{
    UnloadModule();
}
DynamicLibraryModule::~DynamicLibraryModule(void)
{
    UnloadModule();
}