Exemplo n.º 1
0
        /// <summary>
        ///     根据地址获取模块ID
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public int GetModuleIdByPage(string path)
        {
            var moduleID = 0;

            if (ModuleInfos == null || DisplayModuleInfo == null)
            {
                return(moduleID);
            }
            var entity = new BfModuleInfo();

            foreach (var module in DisplayModuleInfo)
            {
                if (module.Items == null)
                {
                    continue;
                }
                entity = module.Items.FindLast(a => a.URL == path.Trim('~'));
                if (entity != null && entity.ID > 0)
                {
                    break;
                }
            }

            if (entity != null && entity.ID > 0)
            {
                var info = ModuleInfos.FindLast(a => a.MODULE_CODE == entity.CODE);
                if (info != null && info.SystemID.GetValueOrDefault() > 0)
                {
                    moduleID = info.SystemID.GetValueOrDefault();
                }
            }
            return(moduleID);
        }
Exemplo n.º 2
0
        public Main(RemoteHooking.IContext context, string channelName, VisualRenderType visualRenderType)
        {
            _visualRenderType = visualRenderType;
            // Connect to server object using provided channel name
            var @interface = RemoteHooking.IpcConnectClient <InjectorInterface>(channelName);

            Process = Process.GetProcessById(RemoteHooking.GetCurrentProcessId());
            foreach (ProcessModule processModule in Process.Modules)
            {
                try
                {
                    ModuleInfos.Add(processModule.ModuleName,
                                    new ModuleInfo
                    {
                        Name       = processModule.ModuleName,
                        MemorySize = processModule.ModuleMemorySize,
                        Address    = processModule.BaseAddress
                    });
                }
                catch
                {
                    // ignored
                }
            }

            // If Ping fails then the Run method will be not be called
            @interface.Ping();
        }
Exemplo n.º 3
0
        /// <summary>
        /// This method is bound to the AppDomain.CurrentDomain.AssemblyResolve event so that when the appDomain
        /// requests to resolve an assembly, the plugin assemblies are resolved from the already loaded plugin cache managed by the PluginManager class.
        /// </summary>
        /// <param name="sender">not used.</param>
        /// <param name="args">contains the assembly named requested and optioanlly the assemby itself.</param>
        /// <returns>The resolved assembly, the cached plugin assembly</returns>
        /// <remarks>Exceptions are managed nby the callaing code.</remarks>
        public static Assembly ResolveCurrentDomainAssembly(object sender, ResolveEventArgs args)
        {
            if (args.RequestingAssembly != null)
            {
                return(args.RequestingAssembly);
            }
            // At this point, the catalog may be checked to see if the requested assembly belongs to a disabled module, the resolution should fail.
            //ModuleBase module = pluginManager.ModuleInfos.
            //    SingleOrDefault(x => (x.EntryType.Assembly.FullName == args.Name) && (x.Manifest.IsEnabled == true)).Plugin;

            string asmName = new AssemblyName(args.Name).Name;

            var moduleInfo = ModuleInfos
                             .Where(x => (x.EntryType.Assembly.GetName().Name.Equals(asmName, StringComparison.InvariantCultureIgnoreCase))
                                    //&& (x.Manifest.IsEnabled == true) // check the catalog
                                    )
                             .FirstOrDefault();

            if (moduleInfo != null && IsActive(moduleInfo.Id) && IsLoaded(moduleInfo.Id))
            {
                return(moduleInfo.EntryType.Assembly);
            }

            // check the module cache for assemblies that are registered by the modules' manifests.
            if (moduleAssemblyCache.ContainsKey(asmName))
            {
                return(moduleAssemblyCache[asmName]);
            }

            string message = string.Format("Unable to resolve assembly '{0}'.", asmName);

            LoggerFactory.GetFileLogger().LogCustom(message);
            //throw new Exception(message);
            return(null);
        }
Exemplo n.º 4
0
        IEnumerable <ModuleInfo> IPermissionConfig.GetGuildModuleWhitelist(IGuild guild)
        {
            var wl = QueryGuildModules()
                     .Where(g => g.Guild.GuildId == guild.Id)
                     .Select(m => m.Module.ModuleName)
                     .ToList();

            return(ModuleInfos.Where(m => wl.Contains(m.Key)).Select(m => m.Value));
        }
Exemplo n.º 5
0
        IEnumerable <ModuleInfo> IPermissionConfig.GetChannelModuleWhitelist(ITextChannel channel)
        {
            var wl = QueryChannelModules()
                     .Where(c => c.Channel.ChannelId == channel.Id)
                     .Select(m => m.Module.ModuleName)
                     .ToList();

            return(ModuleInfos.Where(m => wl.Contains(m.Key)).Select(m => m.Value));
        }
Exemplo n.º 6
0
    public bool Execute(ISerializable parameters, out ISerializable result)
    {
        var  moduleInfos = new ModuleInfos();
        var  domain      = AppDomain.CurrentDomain;
        uint domainId    = (uint)domain.Id;
        var  domainName  = domain.FriendlyName;

        foreach (var assembly in domain.GetAssemblies())
        {
            var assemblyName = assembly.GetName().Name;
            foreach (var module in assembly.GetLoadedModules())
            {
                var moduleInfo = new ModuleInfo {
                    Name         = module.ScopeName,
                    AssemblyName = assemblyName,
                    DomainId     = domainId,
                    DomainName   = domainName
                };
                moduleInfos.Add(moduleInfo);
            }
        }
        result = moduleInfos;
        return(true);
    }
Exemplo n.º 7
0
        IEnumerable <ModuleInfo> IPermissionConfig.GetGuildModuleWhitelist(IGuild guild)
        {
            var wl = QueryGuild(guild).WhiteListedModules;

            return(ModuleInfos.Where(m => wl.Any(w => w.ModuleName == m.Key)).Select(m => m.Value));
        }
Exemplo n.º 8
0
        IEnumerable <ModuleInfo> IPermissionConfig.GetChannelModuleWhitelist(ITextChannel channel)
        {
            var wl = QueryChannel(channel).WhiteListedModules;

            return(ModuleInfos.Where(m => wl.Any(w => w.ModuleName == m.Key)).Select(m => m.Value));
        }