Beispiel #1
0
        async Task <MessageResponse> ProcessModuleLoadedMessage(ModuleLoadedMessage msg)
        {
            await Task.Run(() => {
                try
                {
                    ModuleLoaded?.Invoke(this, msg.ModuleName);
                } catch (Exception e)
                {
                    Log.WriteLine("ModuleLoadedMessageHandler event lambda exception {0}", e.ToString());
                }
            });

            return(MessageResponse.Completed);
        }
        /// <summary>
        /// Load all modules in the Module Directory
        /// </summary>
        public static void LoadAll()
        {
            ModuleLoadOrder = ModuleLoadOrder ?? new Dictionary <int, UserModule>();
            ModuleLoadOrder?.Clear();

            var sysModule = UserModule.FromType(typeof(SystemCommands));

            ModuleLoadOrder.Add(ModuleLoadOrder.Count, sysModule);

            var directories = Directory.GetDirectories(ModuleDirectory, "*", SearchOption.TopDirectoryOnly);

            LoadingStarted?.Invoke(directories.Length);

            // Search through all directories and add user modules
            directories.ToList().ForEach(dir => {
                var um = GetModuleFromDirectory(dir);

                // If a module is detected, add it to the ModuleLoadOrder dictionary
                if (um != null)
                {
                    var index  = ModuleLoadOrder.Count + 1;
                    var canUse = false;
                    do
                    {
                        if (!ModuleLoadOrder.ContainsKey(index))
                        {
                            canUse = true;
                            ModuleLoadOrder.Add(index, um);
                            ModuleLoaded?.Invoke(um);
                        }
                        else
                        {
                            index++;
                        }
                    } while(canUse == false);
                }
            });

            LoadingEnded?.Invoke();
        }
        public static async Task LoadAllAsync()
        {
            ModuleLoadOrder = ModuleLoadOrder ?? new Dictionary <int, UserModule>();
            ModuleLoadOrder?.Clear();

            var sysModule = await UserModule.FromTypeAsync(typeof(SystemCommands));

            ModuleLoadOrder.Add(ModuleLoadOrder.Count, sysModule);

            var directories = Directory.GetDirectories(ModuleDirectory, "*", SearchOption.TopDirectoryOnly);

            LoadingStarted?.Invoke(directories.Length);

            var foundModules = await GetModulesFromDirectoriesAsync(directories);

            foundModules.ForEach(um => {
                var index  = ModuleLoadOrder.Count + 1;
                var canUse = false;

                do
                {
                    if (!ModuleLoadOrder.ContainsKey(index))
                    {
                        canUse = true;
                        ModuleLoadOrder.Add(index, um);
                        ModuleLoaded?.Invoke(um);
                    }
                    else
                    {
                        index++;
                    }
                } while(canUse == false);
            });

            LoadingEnded?.Invoke();
        }
Beispiel #4
0
 /// <summary>
 /// Allows you to perform an action once your module has finished loading (once
 /// <see cref="LoadAsync"/> has completed).  You must call "base.OnModuleLoaded(e)" at the
 /// end for the <see cref="Module.ModuleLoaded"/> event to fire.
 /// </summary>
 protected virtual void OnModuleLoaded(EventArgs e)
 {
     ModuleLoaded?.Invoke(this, e);
 }
 void OnModuleLoaded(ModuleEventArgs e)
 {
     ModuleLoaded?.Invoke(this, e);
 }
Beispiel #6
0
 private void OnModuleLoaded(string moduleName, Assembly assembly)
 {
     ModuleLoaded?.Invoke(this, new ModuleLoadedEventArgs(moduleName, assembly));
 }
Beispiel #7
0
 protected void OnModuleLoaded(ModuleInfo module, object value)
 {
     ModuleLoaded?.Invoke(this, new ModuleIntanceEventArgs(module, value));
 }
        public virtual int LoadModule(ulong ImageFileHandle, ulong BaseOffset, uint ModuleSize, string ModuleName, string ImageName, uint CheckSum, uint TimeDateStamp)
        {
            ModuleLoaded?.Invoke(this, new ModuleEventArgs(ImageFileHandle, BaseOffset, ModuleSize, ModuleName, ImageName, CheckSum, TimeDateStamp));

            return((int)DEBUG_STATUS.NO_CHANGE);
        }