bool CModules::UnloadModule(const CString& sModule, CString& sRetMsg) {
    // Make a copy incase the reference passed in is from CModule::GetModName()
    CString sMod = sModule;

    CModule* pModule = FindModule(sMod);
    sRetMsg = "";

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

    bool bSuccess;
    bool bHandled = false;
    _GLOBALMODULECALL(OnModuleUnloading(pModule, bSuccess, sRetMsg),
                      pModule->GetUser(), pModule->GetNetwork(), nullptr,
                      &bHandled);
    if (bHandled) return bSuccess;

    ModHandle p = pModule->GetDLL();

    if (p) {
        delete pModule;

        for (iterator it = begin(); it != end(); ++it) {
            if (*it == pModule) {
                erase(it);
                break;
            }
        }

        dlclose(p);
        sRetMsg = t_f("Module {1} unloaded.")(sMod);

        return true;
    }

    sRetMsg = t_f("Unable to unload module {1}.")(sMod);
    return false;
}
bool CModules::UnloadModule(const CString& sModule, CString& sRetMsg) {
     
    CString sMod = sModule;

    CModule* pModule = FindModule(sMod);
    sRetMsg = "";

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

    bool bSuccess;
    bool bHandled = false;
    _GLOBALMODULECALL(OnModuleUnloading(pModule, bSuccess, sRetMsg),
                      pModule->GetUser(), pModule->GetNetwork(), nullptr,
                      &bHandled);
    if (bHandled) return bSuccess;

    ModHandle p = pModule->GetDLL();

    if (p) {
        delete pModule;

        for (iterator it = begin(); it != end(); ++it) {
            if (*it == pModule) {
                erase(it);
                break;
            }
        }

        dlclose(p);
        sRetMsg = t_f("Module {1} unloaded.")(sMod);

        return true;
    }

    sRetMsg = t_f("Unable to unload module {1}.")(sMod);
    return false;
}