Beispiel #1
0
        private async Task RefreshModule(int modulenumber)
        {
            try
            {
                ModuleInformation moduleInformation = await _moduleManager.ReadModuleInformation(_deviceSpecification,
                                                                                                 Convert.ToByte(_deviceNumberTextBox.Text), modulenumber);

                if (_deviceSpecification.ControlType == ControlType.MRTYPE)
                {
                    MrModuleControl control = _panelControl.Controls[modulenumber] as MrModuleControl;
                    control.Information = moduleInformation;
                }
                else
                {
                    ModuleControl control = _panelControl.Controls[modulenumber] as ModuleControl;
                    control.Information = moduleInformation;
                }
            }
            catch (Exception e)
            {
                MessageErrorBox message = new MessageErrorBox(e.Message, "Не удалось прочитать информацию о модуле");
                message.ShowErrorMessageForm();
                _panelControl.Controls.Remove(_panelControl.Controls[modulenumber]);
            }
        }
Beispiel #2
0
 internal TypeInformation(
     TypeReference type, ModuleInformation module,
     Func <MemberReference, bool> memberFilter)
     : base(type, module)
 {
     this.memberFilter = memberFilter;
 }
        private ModuleImage CompileInternal(ICodeSource source)
        {
            RegisterScopeIfNeeded();

            var parser = new PreprocessingLexer();

            foreach (var variable in _preprocessorVariables)
            {
                parser.Define(variable);
            }
            parser.UnknownDirective += (sender, args) =>
            {
                // все неизвестные директивы возвращать назад и обрабатывать старым кодом
                args.IsHandled = true;
            };
            parser.Code = source.Code;

            var compiler = new Compiler.Compiler();

            compiler.ProduceExtraCode = ProduceExtraCode;
            compiler.DirectiveHandler = ResolveDirective;

            if (DirectiveResolver != null)
            {
                DirectiveResolver.Source = source;
            }

            ModuleImage compiledImage;

            try
            {
                compiledImage = compiler.Compile(parser, _currentContext);
            }
            catch (ScriptException e)
            {
                if (e.ModuleName == null)
                {
                    e.ModuleName = source.SourceDescription;
                }

                throw;
            }
            finally
            {
                if (DirectiveResolver != null)
                {
                    DirectiveResolver.Source = null;
                }
            }

            var mi = new ModuleInformation();

            mi.CodeIndexer = parser.Iterator;
            // пока у модулей нет собственных имен, будет совпадать с источником модуля
            mi.ModuleName            = source.SourceDescription;
            mi.Origin                = source.SourceDescription;
            compiledImage.ModuleInfo = mi;

            return(compiledImage);
        }
Beispiel #4
0
        private async Task SetMrModuleControl()
        {
            _panelControl.Controls.Clear();
            int y = 0;

            try
            {
                for (int i = 0; i < _deviceSpecification.ModulesCount; i++)
                {
                    MrModuleControl   control           = new MrModuleControl();
                    ModuleInformation moduleInformation = await _moduleManager.ReadModuleInformation(_deviceSpecification, Convert.ToByte(_deviceNumberTextBox.Text), i);

                    control.Information = moduleInformation;
                    control.Anchor      = (AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top);
                    control.TypeModule  = _deviceSpecification.ModuleTypes[i];
                    control.Location    = new Point(0, y);
                    control.Width       = _panelControl.Width;
                    _panelControl.Controls.Add(control);
                    y = y + control.Height;
                    (control as IModuleControlInerface).NeedRefreshAction += (j) =>
                    {
                        RefreshModule(j);
                    };
                }
            }
            catch (Exception e)
            {
                MessageErrorBox message = new MessageErrorBox(e.Message, "Не удалось прочитать информацию о модулях");
                message.ShowErrorMessageForm();
            }
        }
        public static bool TryGetSubmodules
        (
            this TypeDefinition module,
            ModuleInformation parentModule,
            [NotNullWhen(true)] out ModuleInformation[]?submodules
        )
        {
            submodules = null;

            if (!module.HasNestedTypes)
            {
                return(false);
            }

            submodules = module.NestedTypes.Where(t => t.IsProbablyCommandModule()).Select
                         (
                t =>
            {
                var wasParsed = ModuleInformation.TryCreate(t, out var submodule, parentModule);
                return(wasParsed, submodule);
            }
                         )
                         .Where(mr => mr.wasParsed)
                         .Select(mr => mr.submodule !)
                         .ToArray();

            return(true);
        }
Beispiel #6
0
        protected virtual MarkdownSection GenerateSummarySection([NotNull] ModuleInformation module)
        {
            string modulePrefixText;

            if (!module.HasPrefix)
            {
                modulePrefixText = "These commands have no prefix.";
            }
            else
            {
                var moduleAliasChains = module.GetAliasChains().ToList();

                var compiledAliases = moduleAliasChains
                                      .Skip(1)
                                      .Select(a => new MarkdownInlineCode(a).Compile())
                                      .Humanize("or");

                var moduleExtraAliases = moduleAliasChains.Skip(1).Any()
                    ? $"You can also use {compiledAliases} instead of `{module.GetNameChain(true)}`."
                    : string.Empty;

                modulePrefixText = $"These commands are prefixed with `{module.GetNameChain(true)}`. {moduleExtraAliases}";
            }

            var summarySection = new MarkdownSection("Summary", 2).AppendContent
                                 (
                new MarkdownParagraph()
                .AppendLine(modulePrefixText)
                .AppendLine(module.Summary)
                                 );

            return(summarySection);
        }
Beispiel #7
0
        protected virtual MarkdownSection GenerateCommandsSection([NotNull] ModuleInformation module)
        {
            var moduleCommandsSection = new MarkdownSection("Commands", 2);
            var commandGroups         = module.Commands.GroupBy(c => c.Name).ToList();

            foreach (var commandGroup in commandGroups)
            {
                if (commandGroup != commandGroups.First())
                {
                    moduleCommandsSection.AppendContent(new MarkdownHorizontalRule());
                }

                var commandOverloads = new MarkdownSection("Overloads", 4);
                foreach (var command in commandGroup)
                {
                    commandOverloads.AppendContentRange(GenerateCommandOverloadContent(command));
                }

                // Filter out commands without names (we use the module's name chain instead)
                var commandGroupName = commandGroup.Key.IsNullOrWhitespace()
                    ? commandGroup.First().Module.GetNameChain(true)
                    : commandGroup.Key;

                var commandSection = new MarkdownSection(commandGroupName, 3).AppendContent(commandOverloads);
                commandSection.Header.Title.Emphasis = Italic;

                moduleCommandsSection.AppendContent(commandSection);
            }

            return(moduleCommandsSection);
        }
        public static bool TryGetCommands
        (
            this TypeDefinition module,
            ModuleInformation parentModule,
            [NotNullWhen(true)] out CommandInformation[]?commands
        )
        {
            commands = null;

            if (!module.HasMethods)
            {
                return(false);
            }

            commands = module.Methods.Select
                       (
                m =>
            {
                var wasParsed = CommandInformation.TryCreate(m, parentModule, out var command);
                return(wasParsed, command);
            }
                       )
                       .Where(cr => cr.wasParsed)
                       .Select(cr => cr.command !)
                       .ToArray();

            return(true);
        }
Beispiel #9
0
        /// <inheritdoc />
        public async Task GenerateDocumentationAsync()
        {
            var types = _commandAssemblyModules.SelectMany(c => c.Types)
                        .Where(t => t.IsProbablyCommandModule());

            var modules = types.Select(t =>
            {
                var wasCreated = ModuleInformation.TryCreate(t, out var info);
                return(wasCreated, info);
            })
                          .Where(wi => wi.wasCreated)
                          .Select(wi => wi.info)
                          .OrderBy(i => i.Name)
                          .ToList();

            var modulePages = GenerateDocumentationPages(modules);

            await Task.WhenAll(modulePages.Values.Select(p => SavePageAsync(p, Path.Combine("docs", "modules"))));

            var indexPage = GenerateDocumentationIndex
                            (
                modulePages.Where(p => !p.Key.IsSubmodule).Select(kvp => kvp.Value)
                            );

            await SavePageAsync(indexPage, "docs");
        }
Beispiel #10
0
        /// <summary>
        /// Gets all modules in the opened process.
        /// </summary>
        /// <returns>A collection of modules in the process.</returns>
        public IEnumerable <NormalizedModule> GetModules(Process process)
        {
            // Query all modules in the target process
            IntPtr[] modulePointers         = new IntPtr[0];
            Int32    bytesNeeded            = 0;
            List <NormalizedModule> modules = new List <NormalizedModule>();

            if (process == null)
            {
                return(modules);
            }

            if (this.ModuleCache.Contains(process.Id) && this.ModuleCache.TryGetValue(process.Id, out modules))
            {
                return(modules);
            }

            try
            {
                // Determine number of modules
                if (!NativeMethods.EnumProcessModulesEx(process.Handle, modulePointers, 0, out bytesNeeded, (UInt32)Enumerations.ModuleFilter.ListModulesAll))
                {
                    // Failure, return our current empty list
                    return(modules);
                }

                Int32 totalNumberofModules = bytesNeeded / IntPtr.Size;
                modulePointers = new IntPtr[totalNumberofModules];

                if (NativeMethods.EnumProcessModulesEx(process.Handle, modulePointers, bytesNeeded, out bytesNeeded, (UInt32)Enumerations.ModuleFilter.ListModulesAll))
                {
                    for (Int32 index = 0; index < totalNumberofModules; index++)
                    {
                        StringBuilder moduleFilePath = new StringBuilder(1024);
                        NativeMethods.GetModuleFileNameEx(process.Handle, modulePointers[index], moduleFilePath, (UInt32)moduleFilePath.Capacity);

                        ModuleInformation moduleInformation = new ModuleInformation();
                        NativeMethods.GetModuleInformation(process.Handle, modulePointers[index], out moduleInformation, (UInt32)(IntPtr.Size * modulePointers.Length));

                        // Ignore modules in 64-bit address space for WoW64 processes
                        if (process.Is32Bit() && moduleInformation.ModuleBase.ToUInt64() > Int32.MaxValue)
                        {
                            continue;
                        }

                        // Convert to a normalized module and add it to our list
                        NormalizedModule module = new NormalizedModule(moduleFilePath.ToString(), moduleInformation.ModuleBase.ToUInt64(), (Int32)moduleInformation.SizeOfImage);
                        modules.Add(module);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, "Unable to fetch modules from selected process", ex);
            }

            this.ModuleCache.Add(process.Id, modules);

            return(modules);
        }
Beispiel #11
0
	public static bool LoadDataFromFile()
	{
		FileModuleInformation[] modInfo;
		string path = Path.Combine(Application.persistentDataPath, usersSavePath);
		try
		{
			DebugHelper.Log($"Loading Module information data from file: {path}");
			modInfo = SettingsConverter.Deserialize<FileModuleInformation[]>(File.ReadAllText(path));
			lastRead = modInfo;
		}
		catch (FileNotFoundException)
		{
			DebugHelper.LogWarning($"File {path} was not found.");
			return false;
		}
		catch (Exception ex)
		{
			DebugHelper.LogException(ex);
			return false;
		}

		foreach (var fileInfo in modInfo)
		{
			ModuleInformation defaultInfo = null;
			if (fileInfo.moduleID != null)
			{
				defaultInfo = ComponentSolverFactory.GetDefaultInformation(fileInfo.moduleID);
			}

			var info = new ModuleInformation();
			foreach (FieldInfo fileFieldInfo in fileInfoFields)
			{
				if (fileFieldInfo.DeclaringType == typeof(ModuleInformation)) {
					if (fileInfoFields.Any(field => field.DeclaringType == typeof(FileModuleInformation) && field.Name == fileFieldInfo.Name))
						continue;

					fileFieldInfo.SetValue(info, fileFieldInfo.GetValue(fileInfo));
				}
				else
				{
					var baseFieldInfo = Array.Find(infoFields, field => field.Name == fileFieldInfo.Name);
					if (baseFieldInfo == null)
						throw new NotSupportedException("Superclass isn't overriding only base fields.");

					var value = fileFieldInfo.GetValue(fileInfo);
					if (value == null && defaultInfo != null)
					{
						value = baseFieldInfo.GetValue(defaultInfo);
					}

					baseFieldInfo.SetValue(info, value);
				}
			}

			ComponentSolverFactory.AddModuleInformation(info);
		}
		return true;
	}
Beispiel #12
0
    public ButtonComponentSolver(BombCommander bombCommander, ButtonComponent bombComponent) :
        base(bombCommander, bombComponent)
    {
        ModuleInformation buttonInfo         = ComponentSolverFactory.GetModuleInfo("ButtonComponentSolver", "!{0} tap [tap the button] | !{0} hold [hold the button] | !{0} release 7 [release when the digit shows 7]");
        ModuleInformation buttonInfoModified = ComponentSolverFactory.GetModuleInfo("ButtonComponentModifiedSolver", "Click the button with !{0} tap. Click the button at time with !{0} tap 8:55 8:44 8:33. Hold the button with !{0} hold. Release the button with !{0} release 9:58 9:49 9:30.");

        bombComponent.GetComponent <Selectable>().OnCancel += bombComponent.OnButtonCancel;
        _button = bombComponent.button;
        modInfo = VanillaRuleModifier.IsSeedVanilla() ? buttonInfo : buttonInfoModified;
    }
Beispiel #13
0
        /// <summary>
        /// Gets all modules in the opened process.
        /// </summary>
        /// <returns>A collection of modules in the process.</returns>
        public IEnumerable <NormalizedModule> GetModules()
        {
            // Query all modules in the target process
            IntPtr[] modulePointers = new IntPtr[0];
            Int32    bytesNeeded    = 0;

            List <NormalizedModule> modules = new List <NormalizedModule>();

            if (this.SystemProcess == null)
            {
                return(modules);
            }

            try
            {
                // Determine number of modules
                if (!NativeMethods.EnumProcessModulesEx(this.SystemProcess.Handle, modulePointers, 0, out bytesNeeded, (UInt32)Enumerations.ModuleFilter.ListModulesAll))
                {
                    return(modules);
                }

                Int32 totalNumberofModules = bytesNeeded / IntPtr.Size;
                modulePointers = new IntPtr[totalNumberofModules];

                if (NativeMethods.EnumProcessModulesEx(this.SystemProcess.Handle, modulePointers, bytesNeeded, out bytesNeeded, (UInt32)Enumerations.ModuleFilter.ListModulesAll))
                {
                    for (Int32 index = 0; index < totalNumberofModules; index++)
                    {
                        StringBuilder moduleFilePath = new StringBuilder(1024);
                        NativeMethods.GetModuleFileNameEx(this.SystemProcess.Handle, modulePointers[index], moduleFilePath, (UInt32)moduleFilePath.Capacity);

                        String            moduleName        = Path.GetFileName(moduleFilePath.ToString());
                        ModuleInformation moduleInformation = new ModuleInformation();
                        NativeMethods.GetModuleInformation(this.SystemProcess.Handle, modulePointers[index], out moduleInformation, (UInt32)(IntPtr.Size * modulePointers.Length));

                        // Ignore modules in 64-bit address space for WoW64 processes
                        if (EngineCore.GetInstance().Processes.IsOpenedProcess32Bit() && moduleInformation.ModuleBase.ToUInt64() > Int32.MaxValue)
                        {
                            continue;
                        }

                        // Convert to a normalized module and add it to our list
                        NormalizedModule module = new NormalizedModule(moduleName, moduleInformation.ModuleBase, (Int32)moduleInformation.SizeOfImage);
                        modules.Add(module);
                    }
                }
            }
            catch (Exception ex)
            {
                OutputViewModel.GetInstance().Log(OutputViewModel.LogLevel.Error, "Unable to fetch modules from selected process", ex);
                AnalyticsService.GetInstance().SendEvent(AnalyticsService.AnalyticsAction.General, ex);
            }

            return(modules);
        }
Beispiel #14
0
    public void Initialize()
    {
        var moduleInfo = new ModuleInformation {
            ModuleName = "ClassNameHere"
        };

        splashScreenService.ModuleLoadStart(moduleInfo);

        _subject.Initialize();

        splashScreenService.ModuleLoadEnd(moduleInfo);
    }
Beispiel #15
0
        public static List <ModuleInformation> ParseModulesFromDirStream(byte[] dirStream)
        {
            // 2.3.4.2 dir Stream: Version Independent Project Information
            // https://msdn.microsoft.com/en-us/library/dd906362(v=office.12).aspx
            // Dir stream is ALWAYS in little endian

            List <ModuleInformation> modules = new List <ModuleInformation>();

            int               offset = 0;
            UInt16            tag;
            UInt32            wLength;
            ModuleInformation currentModule = new ModuleInformation {
                moduleName = "", textOffset = 0
            };

            while (offset < dirStream.Length)
            {
                tag     = GetWord(dirStream, offset);
                wLength = GetDoubleWord(dirStream, offset + 2);

                // taken from Pcodedmp
                if (tag == 9)
                {
                    wLength = 6;
                }
                else if (tag == 3)
                {
                    wLength = 2;
                }

                switch (tag)
                {
                // MODULESTREAMNAME Record
                case 26:
                    currentModule.moduleName = System.Text.Encoding.UTF8.GetString(dirStream, (int)offset + 6, (int)wLength);
                    break;

                // MODULEOFFSET Record
                case 49:
                    currentModule.textOffset = GetDoubleWord(dirStream, offset + 6);
                    modules.Add(currentModule);
                    currentModule = new ModuleInformation {
                        moduleName = "", textOffset = 0
                    };
                    break;
                }

                offset += 6;
                offset += (int)wLength;
            }

            return(modules);
        }
Beispiel #16
0
        private ScriptModuleHandle Compile(ICodeSource source)
        {
            RegisterScopeIfNeeded();

            var parser = new Parser();

            parser.Code = source.Code;

            var compiler = new Compiler.Compiler();

            compiler.DirectiveHandler = ResolveDirective;
            ModuleImage compiledImage;

            try
            {
                compiledImage = compiler.Compile(parser, _currentContext);
            }
            catch (ScriptException e)
            {
                if (e.ModuleName == null)
                {
                    e.ModuleName = source.SourceDescription;
                }

                throw;
            }

            foreach (var item in _predefinedVariables)
            {
                var varDef = _scope.GetVariable(item);
                if (varDef.Type == SymbolType.ContextProperty)
                {
                    compiledImage.ExportedProperties.Add(new ExportedSymbol()
                    {
                        SymbolicName = varDef.Identifier,
                        Index        = varDef.Index
                    });
                }
            }

            var mi = new ModuleInformation();

            mi.CodeIndexer = parser.GetCodeIndexer();
            // пока у модулей нет собственных имен, будет совпадать с источником модуля
            mi.ModuleName            = source.SourceDescription;
            mi.Origin                = source.SourceDescription;
            compiledImage.ModuleInfo = mi;

            return(new ScriptModuleHandle()
            {
                Module = compiledImage
            });
        }
    public ButtonComponentSolver(TwitchModule module) :
        base(module)
    {
        ModuleInformation buttonInfo         = ComponentSolverFactory.GetModuleInfo("ButtonComponentSolver", "!{0} tap [tap the button] | !{0} hold [hold the button] | !{0} release 7 [release when the digit shows 7]");
        ModuleInformation buttonInfoModified = ComponentSolverFactory.GetModuleInfo("ButtonComponentModifiedSolver", "Click the button with !{0} tap. Click the button at a time with !{0} tap 8:55 8:44 8:33. Hold the button with !{0} hold. Release the button with !{0} release 9:58 9:49 9:30.");

        var buttonModule = (ButtonComponent)module.BombComponent;

        buttonModule.GetComponent <Selectable>().OnCancel += buttonModule.OnButtonCancel;
        _button = buttonModule.button;
        ModInfo = VanillaRuleModifier.IsSeedVanilla() ? buttonInfo : buttonInfoModified;
    }
 public FormidableBehaviour() : base()
 {
     this.nextPlayerCacheTime   = 0f;
     this.nextLootItemCacheTime = 0f;
     this.gamePlayers           = new List <GamePlayer>();
     this.gameLootItems         = new List <GameLootItem>();
     this.moduleInformation     = new ModuleInformation(this.gamePlayers, this.gameLootItems);
     this.playerBoxModule       = new PlayerBoxModule(this.moduleInformation);
     this.playerLabelModule     = new PlayerLabelModule(this.moduleInformation);
     this.lootItemLabelModule   = new LootItemLabelModule(this.moduleInformation);
     this.shader = null;
     this.nextShaderUpdateTime = 0f;
 }
Beispiel #19
0
        private ModuleImage CompileInternal(ICodeSource source)
        {
            RegisterScopeIfNeeded();

            var parser = new Parser();

            parser.Code = source.Code;

            var compiler = new Compiler.Compiler();

            compiler.ProduceExtraCode = ProduceExtraCode;
            compiler.DirectiveHandler = ResolveDirective;

            if (DirectiveResolver != null)
            {
                DirectiveResolver.Source = source;
            }

            ModuleImage compiledImage;

            try
            {
                compiledImage = compiler.Compile(parser, _currentContext);
            }
            catch (ScriptException e)
            {
                if (e.ModuleName == null)
                {
                    e.ModuleName = source.SourceDescription;
                }

                throw;
            }
            finally
            {
                if (DirectiveResolver != null)
                {
                    DirectiveResolver.Source = null;
                }
            }

            var mi = new ModuleInformation();

            mi.CodeIndexer = parser.GetCodeIndexer();
            // пока у модулей нет собственных имен, будет совпадать с источником модуля
            mi.ModuleName            = source.SourceDescription;
            mi.Origin                = source.SourceDescription;
            compiledImage.ModuleInfo = mi;

            return(compiledImage);
        }
Beispiel #20
0
        private void getTitlePage()
        {
            try
            {
                JsonReader        reader     = new JsonTextReader(new StringReader(WebRequestHelper.getData("http://mbbsweb.azurewebsites.net/api/Module/GetModuleInfo?moduleID=" + data.ModuleName, data.Token)));
                string            text       = WebRequestHelper.getData("http://mbbsweb.azurewebsites.net/api/Module/GetModuleInfo?moduleID=" + data.ModuleName, data.Token);
                ModuleInformation moduleInfo = JsonConvert.DeserializeObject <ModuleInformation>(text);
                XFont             titleFont  = new XFont("Verdana", 15, XFontStyle.Bold);

                using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(new Bitmap(1, 1)))
                {
                    SizeF  size      = graphics.MeasureString(moduleInfo.ModuleName, new Font("Verdana", 15, FontStyle.Bold, GraphicsUnit.Point));
                    Double textWidth = (double)size.Width / 2;
                    XRect  titleRect = new XRect((pdfPage.Width / 2) - textWidth / 1.4, 100, someWidth, 200);
                    tf.DrawString(moduleInfo.ModuleName, titleFont, XBrushes.Black, titleRect, XStringFormats.TopLeft);
                    size      = graphics.MeasureString(data.ModuleName, new Font("Verdana", 15, FontStyle.Bold, GraphicsUnit.Point));
                    textWidth = (double)size.Width / 2;
                    titleRect = new XRect(pdfPage.Width / 2 - textWidth / 1.4, 120, someWidth, 200);
                    tf.DrawString(data.ModuleName, titleFont, XBrushes.Black, titleRect, XStringFormats.TopLeft);
                }



                XFont infoText = new XFont("Verdana", 10, XFontStyle.Regular);
                XRect infoRect = new XRect(myX, pdfPage.Height - 200, someWidth, 200);
                tf.DrawString(moduleInfo.LocationName, infoText, XBrushes.Black, infoRect, XStringFormats.TopLeft);

                infoRect = new XRect(myX, pdfPage.Height - 190, someWidth, 200);
                tf.DrawString(moduleInfo.Sector, infoText, XBrushes.Black, infoRect, XStringFormats.TopLeft);

                infoRect = new XRect(myX, pdfPage.Height - 180, someWidth, 200);
                tf.DrawString(moduleInfo.POBox, infoText, XBrushes.Black, infoRect, XStringFormats.TopLeft);

                infoRect = new XRect(myX, pdfPage.Height - 170, someWidth, 200);
                tf.DrawString(moduleInfo.PostalCode, infoText, XBrushes.Black, infoRect, XStringFormats.TopLeft);

                infoRect = new XRect(myX, pdfPage.Height - 160, someWidth, 200);
                tf.DrawString(moduleInfo.Phone, infoText, XBrushes.Black, infoRect, XStringFormats.TopLeft);

                infoRect = new XRect(myX, pdfPage.Height - 150, someWidth, 200);
                tf.DrawString(moduleInfo.Website, infoText, XBrushes.Black, infoRect, XStringFormats.TopLeft);

                pdfPage = pdf.AddPage();
                graph   = XGraphics.FromPdfPage(pdfPage);
                tf      = new XTextFormatter(graph);
            }
            catch
            {
                getTitlePage();
            }
        }
Beispiel #21
0
        /// <summary>
        /// Gets the name chain of a module, that is, the name of its parent followed by the module's name.
        /// </summary>
        /// <param name="this">The module to get the chain of.</param>
        /// <param name="onlyPrefixes">Whether to only include prefixes in the chain.</param>
        /// <returns>A name chain in the form of "[parentName] [childName]".</returns>
        public static string GetNameChain(this ModuleInformation @this, bool onlyPrefixes = false)
        {
            string thisPrefix;

            if (onlyPrefixes)
            {
                thisPrefix = @this.HasPrefix ? @this.Name : string.Empty;
            }
            else
            {
                thisPrefix = @this.Name;
            }

            return(@this.IsSubmodule ? $"{GetNameChain(@this.Parent!)} {thisPrefix}" : thisPrefix);
        }
Beispiel #22
0
        /// <summary>
        /// Gets all modules in the opened process
        /// </summary>
        /// <returns>A collection of modules in the process</returns>
        public IEnumerable <NormalizedModule> GetModules()
        {
            List <NormalizedModule> normalizedModules = new List <NormalizedModule>();

            if (this.SystemProcess == null)
            {
                return(normalizedModules);
            }

            // Query all modules in the target process
            IntPtr[] modulePointers = new IntPtr[0];
            Int32    bytesNeeded    = 0;

            try
            {
                // Determine number of modules
                if (!Native.NativeMethods.EnumProcessModulesEx(this.SystemProcess.Handle, modulePointers, 0, out bytesNeeded, (UInt32)Enumerations.ModuleFilter.ListModulesAll))
                {
                    return(normalizedModules);
                }

                Int32 totalNumberofModules = bytesNeeded / IntPtr.Size;
                modulePointers = new IntPtr[totalNumberofModules];

                if (Native.NativeMethods.EnumProcessModulesEx(this.SystemProcess.Handle, modulePointers, bytesNeeded, out bytesNeeded, (UInt32)Enumerations.ModuleFilter.ListModulesAll))
                {
                    for (Int32 index = 0; index < totalNumberofModules; index++)
                    {
                        StringBuilder moduleFilePath = new StringBuilder(1024);
                        Native.NativeMethods.GetModuleFileNameEx(this.SystemProcess.Handle, modulePointers[index], moduleFilePath, (UInt32)moduleFilePath.Capacity);

                        String            moduleName        = Path.GetFileName(moduleFilePath.ToString());
                        ModuleInformation moduleInformation = new ModuleInformation();
                        Native.NativeMethods.GetModuleInformation(this.SystemProcess.Handle, modulePointers[index], out moduleInformation, (UInt32)(IntPtr.Size * modulePointers.Length));

                        // Convert to a normalized module and add it to our list
                        NormalizedModule module = new NormalizedModule(moduleName, moduleInformation.ModuleBase, unchecked ((Int32)moduleInformation.SizeOfImage));
                        normalizedModules.Add(module);
                    }
                }
            }
            catch (Exception ex)
            {
                OutputViewModel.GetInstance().Log(OutputViewModel.LogLevel.Error, "Error fetching modules from selected process: " + ex.ToString());
            }

            return(normalizedModules);
        }
Beispiel #23
0
        public static string GetNameChain([NotNull] this ModuleInformation @this, bool onlyPrefixes = false)
        {
            string thisPrefix;

            if (onlyPrefixes)
            {
                thisPrefix = @this.HasPrefix ? @this.Name : string.Empty;
            }
            else
            {
                thisPrefix = @this.Name;
            }

            // ReSharper disable once AssignNullToNotNullAttribute
            return(@this.IsSubmodule ? $"{GetNameChain(@this.Parent)} {thisPrefix}" : thisPrefix);
        }
Beispiel #24
0
        private async void SetModuleControl()
        {
            _panelControl.Controls.Clear();
            ModuleControl     control           = new ModuleControl();
            ModuleInformation moduleInformation = await _moduleManager.ReadModuleInformation(_deviceSpecification, Convert.ToByte(_deviceNumberTextBox.Text), 0);

            control.Information = moduleInformation;
            control.Anchor      = (AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top);
            control.Dock        = DockStyle.Top;
            control.TypeModule  = _deviceSpecification.ModuleTypes[0];
            (control as IModuleControlInerface).NeedRefreshAction += (i) =>
            {
                RefreshModule(i);
            };
            _panelControl.Controls.Add(control);
        }
Beispiel #25
0
        private List <ModuleInformation> GetModuleInfos()
        {
            IntPtr[] moduleHandles = new IntPtr[1024];

            WinApi.EnumProcessModules(ParentProcessHandle, moduleHandles, Marshal.SizeOf(typeof(IntPtr)) * moduleHandles.Length, out var needed);

            List <ModuleInformation> moduleInfos = new List <ModuleInformation>();

            for (int i = 0; i < moduleHandles.Length; i++)
            {
                if (moduleHandles[i] != IntPtr.Zero)
                {
                    moduleInfos.Add(ModuleInformation.InitializeFromHandle(ParentProcessHandle, moduleHandles[i]));
                }
            }

            return(moduleInfos);
        }
Beispiel #26
0
 /// <summary>
 /// Gets the alias chains of a module, that is, the name of its parent followed by the module's name, for each
 /// alias.
 /// </summary>
 /// <param name="this">The module to get the chain of.</param>
 /// <returns>A name chain in the form of "[parentName] [childName]".</returns>
 public static IEnumerable <string> GetAliasChains(this ModuleInformation @this)
 {
     foreach (var alias in @this.Aliases)
     {
         if (@this.IsSubmodule)
         {
             // ReSharper disable once AssignNullToNotNullAttribute
             foreach (var parentAliasChain in GetAliasChains(@this.Parent !))
             {
                 yield return($"{parentAliasChain} {alias}");
             }
         }
         else
         {
             yield return(alias);
         }
     }
 }
        /// <exception cref="DllInjectorException">Bytes to fill module list returned 0. The process is probably not yet initialized.</exception>
        public static List <Module> CollectModules(Process process)
        {
            List <Module> collectedModules = new List <Module>();

            IntPtr[] modulePointers = new IntPtr[0];
            int      numberOfModules;
            int      bytesNeeded;


            // Determine number of modules.
            if (!EnumProcessModulesEx(process.Handle, modulePointers, 0, out bytesNeeded, (uint)ModuleFilter.ListModulesAll))
            {
                return(collectedModules);
            }

            if (bytesNeeded == 0)
            {
                throw new DllInjectorException("Bytes needed to dump module list returned 0. This means that either the process probably not yet fully initialized.");
            }

            numberOfModules = bytesNeeded / IntPtr.Size;
            modulePointers  = new IntPtr[numberOfModules];

            // Collect modules from the process
            if (EnumProcessModulesEx(process.Handle, modulePointers, bytesNeeded, out bytesNeeded, (uint)ModuleFilter.ListModulesAll))
            {
                for (int x = 0; x < numberOfModules; x++)
                {
                    StringBuilder     modulePathBuilder = new StringBuilder(32767);
                    ModuleInformation moduleInformation = new ModuleInformation();

                    GetModuleFileNameEx(process.Handle, modulePointers[x], modulePathBuilder, (uint)(modulePathBuilder.Capacity));
                    GetModuleInformation(process.Handle, modulePointers[x], out moduleInformation, (uint)sizeof(ModuleInformation));

                    // Convert to a normalized module and add it to our list
                    string modulePath = modulePathBuilder.ToString();
                    Module module     = new Module(modulePath, moduleInformation.lpBaseOfDll, moduleInformation.SizeOfImage, moduleInformation.EntryPoint);
                    collectedModules.Add(module);
                }
            }

            return(collectedModules);
        }
Beispiel #28
0
        void AddToList(string folder, ModuleInformation module)
        {
            String fileName = Path.GetFullPath(folder) + "/" + module.Name + ".dll";

            if (File.Exists(fileName))
            {
                //add to list if not already added
                if (!list.Where(x => x.ManifestModule.Name.Replace(".dll", "") == module.Name).Any())
                {
                    AssemblyName assemblyName = AssemblyName.GetAssemblyName(fileName);
                    Assembly     assembly     = Assembly.Load(assemblyName);
                    //     var exportedTypes = assembly.ExportedTypes;//.Where(x => x.ReflectedType is IModule);//<IModule>();
                    //     var exportedatts = CustomAttributeExtensions.GetCustomAttributes(assembly);

                    list.Add(assembly);
                }
            }
            else
            {
                Console.WriteLine("Error: VEF.WPF.ModuleLoader.LoadModules - File not found:" + fileName);
            }
        }
Beispiel #29
0
    public UnsupportedModComponentSolver(TwitchModule module, ComponentSolverFields componentSolverFields = null)
        : base(module, componentSolverFields == null || componentSolverFields.HookUpEvents)
    {
        _bombModule  = module.BombComponent.GetComponent <KMBombModule>();
        _needyModule = module.BombComponent.GetComponent <KMNeedyModule>();

        ModInfo = new ModuleInformation {
            moduleScore = 0, builtIntoTwitchPlays = true, DoesTheRightThing = true, helpText = $"Solve this {(_bombModule != null ? "module" : "needy")} with !{{0}} solve", moduleDisplayName = $"Unsupported Twitchplays Module  ({module.BombComponent.GetModuleDisplayName()})", moduleID = "UnsupportedTwitchPlaysModule"
        };

        UnsupportedModule = true;

        Selectable selectable = module.BombComponent.GetComponent <Selectable>();

        Selectable[]         selectables       = module.BombComponent.GetComponentsInChildren <Selectable>();
        HashSet <Selectable> selectableHashSet = new HashSet <Selectable>(selectables)
        {
            selectable
        };

        selectable.OnInteract += () => { if (Module != null && Module.CanvasGroupUnsupported != null)
                                         {
                                             Module.CanvasGroupUnsupported.gameObject.SetActive(false);
                                         }
                                         return(true); };
        selectable.OnDeselect += (x) => { if (Module != null && Module.CanvasGroupUnsupported != null)
                                          {
                                              Module.CanvasGroupUnsupported.gameObject.SetActive(x == null || !selectableHashSet.Contains(x));
                                          }
        };

        if (componentSolverFields == null)
        {
            return;
        }
        CommandComponent  = componentSolverFields.CommandComponent;
        ForcedSolveMethod = componentSolverFields.ForcedSolveMethod;
    }
Beispiel #30
0
    public UnsupportedModComponentSolver(BombCommander bombCommander, BombComponent bombComponent)
        : base(bombCommander, bombComponent)
    {
        bombModule  = bombComponent.GetComponent <KMBombModule>();
        needyModule = bombComponent.GetComponent <KMNeedyModule>();

        modInfo = new ModuleInformation {
            moduleScore = 0, builtIntoTwitchPlays = true, DoesTheRightThing = true, helpText = $"Solve this {(bombModule != null ? "module" : "needy")} with !{{0}} solve", moduleDisplayName = $"Unsupported Twitchplays Module  ({bombComponent.GetModuleDisplayName()})", moduleID = "UnsupportedTwitchPlaysModule"
        };

        UnsupportedModule = true;

        Selectable selectable = bombComponent.GetComponent <Selectable>();

        Selectable[]         selectables       = bombComponent.GetComponentsInChildren <Selectable>();
        HashSet <Selectable> selectableHashSet = new HashSet <Selectable>(selectables)
        {
            selectable
        };

        selectable.OnInteract += () => { ComponentHandle?.CanvasGroupUnsupported?.gameObject.SetActive(false); return(true); };
        selectable.OnDeselect += (x) => { ComponentHandle?.CanvasGroupUnsupported?.gameObject.SetActive(x == null || !selectableHashSet.Contains(x)); };
    }