Beispiel #1
0
        /// <summary>
        /// Liest die Argumente ein.
        /// </summary>
        /// <param name="xe"></param>
        /// <returns></returns>
        protected static string ParseArgs(XElement xe, ExecutableContainer container)
        {
            string args = null;

            var attrArgs = xe.Attribute("Args");

            if (attrArgs != null)
            {
                args = container.ParseParameters(attrArgs.Value);
            }

            var xeArgs = xe.Element("Args");

            if (xeArgs != null)
            {
                var elementArgs = FSUtils.EscapeCommandLineArgs(xeArgs.Elements("Arg")
                                                                .Select(xeArg => container.ParseParameters(xeArg.Value)));
                if (!string.IsNullOrWhiteSpace(elementArgs))
                {
                    if (!string.IsNullOrWhiteSpace(args))
                    {
                        args += " " + elementArgs;
                    }
                    else
                    {
                        args = elementArgs;
                    }
                }
            }

            return(args);
        }
        internal static CommandProcessorOutput ParseCommandLine(string[] args)
        {
            List <string> cliParserOutput = argsParser.Parse(args, InitAllCLIArgs(), parsedArguments);
            string        procMonExePath = null, inputFilePath = null;

            if (cliParserOutput.Count == 0)
            {
                List <string> tempList;
                if (parsedArguments.TryGetValue(ProcMonExe.Name, out tempList))
                {
                    procMonExePath = tempList.First();
                }
                FSUtils.FileExists(procMonExePath, "Not able to, either find or access the ProcMon executable (file).");
                if (parsedArguments.TryGetValue(InFilePath.Name, out tempList))
                {
                    inputFilePath = tempList.First();
                }
                FSUtils.FileExists(inputFilePath, "Not able to, either find or access the ProcMon Logs file.");
                if (parsedArguments.TryGetValue(Config.Name, out tempList))
                {
                    AppConfigFilePath = tempList.First();
                }
                FSUtils.FileExists(AppConfigFilePath, "Application Configuration File was not found.");
            }
            return(Tuple.Create(cliParserOutput, procMonExePath, inputFilePath, AppConfigFilePath));
        }
Beispiel #3
0
        public ExportDoc(XElement xe, ExecutableContainer container, int indent)
            : base(xe, container, indent)
        {
            this.Package        = container.ParseParameters(xe.Attribute("Package").Value);
            this.Version        = container.ParseParameters(xe.Attribute("Version").Value);
            this.Iso            = container.ParseParameters(xe.Attribute("Iso").Value);
            this.ExportDBTables = (string)xe.Attribute("ExportDBTables") == "1";
            this.UseLicense     = (string)xe.Attribute("UseLicense") == "1";
            this.Setting        = container.ParseParameters(xe.Attribute("Setting")?.Value);

            var xaDir = xe.Attribute("Dir");

            if (xaDir != null)
            {
                Dir = container.ParseParameters(xaDir.Value);
            }
            else
            {
                Dir = container.ParseParameters("{" + this.ExportDirParameter + "}");
            }

            string folder = Path.Combine(this.Dir, container.CreateExportFileName(this.Package, this.Version) + "_Help_" + this.Iso);

            var args = new List <string>()
            {
                @"\DOCUMENTATION",
                @"\PACKAGE", this.Package,
                @"\VERSION", this.Version,
                @"\ISO", this.Iso,
                @"\OUTPUT", folder
            };

            if (UseLicense)
            {
                args.Add(@"\USELICENSE");
                args.Add(@"\SETTING");
                args.Add(this.Setting);
            }

            if (ExportDBTables)
            {
                args.Add(@"\ExportDBTables");
            }

            this.Arguments = FSUtils.EscapeCommandLineArgs(args)
                             // ggf. manuelle "Args" aus dem Basis-Konstruktor übernehmen
                             + (!string.IsNullOrEmpty(this.Arguments) ? " " + this.Arguments : "");
        }
Beispiel #4
0
        internal static bool ProcessPMLFile()
        {
            var fileToParse        = inputFilePath;
            var didCoversionHappen = false;

            if (inputFilePath.EndsWith(".pml", System.StringComparison.CurrentCultureIgnoreCase))
            {
                didCoversionHappen = Convert(inputFilePath, out var outputXmlFile) && !string.IsNullOrWhiteSpace(outputXmlFile);
                fileToParse        = outputXmlFile;
            }
            parsedPMLFile = ConvertedXMLProcessor.PopulateProcessesAndEvents(fileToParse, appConfigFilePath);
            if (didCoversionHappen)
            {
                FSUtils.FileDelete(fileToParse);
            }
            return(parsedPMLFile == null);
        }
Beispiel #5
0
        internal PMLToXMLConverter(string procMonExeLocation, string pmlFile, bool shouldRetryOnceOnFailure = false)
        {
            if (!AuthentiCodeTools.IsTrusted(procMonExeLocation))
            {
                throw new ArgumentException(string.Format("ProcessMonitor (ProcMon) executable at location {0} is not a trusted binary.", procMonExeLocation));
            }
            if (!SignerInfo.IsSignedBy(procMonExeLocation, "CN=Microsoft Code Signing PCA, O=Microsoft Corporation, L=Redmond, S=Washington, C=US", true))
            {
                throw new ArgumentException(string.Format("ProcessMonitor (ProcMon) executable at location {0} does not meet expected digital signing requirements.", procMonExeLocation));
            }
            this.shouldRetryOnceOnFailure = shouldRetryOnceOnFailure;
            PMLFile = pmlFile;
            XMLFile = FSUtils.CreateOuputFileNameFromInput(pmlFile, ".xml");

            StringBuilder sbArgs = new StringBuilder("/quiet /minimized /saveas2 ");

            sbArgs.Append(XMLFile);
            sbArgs.Append(" /openlog ");
            sbArgs.Append(PMLFile);
            // [BIB]:  http://forum.sysinternals.com/forum_posts.asp?TID=13843&PID=74632&title=producing-csv-from-process-monitor-via-script#74632
            procMon = new ProcessEx(procMonExeLocation, sbArgs.ToString());
        }
Beispiel #6
0
        void Install(IReadOnlyList <string> args)
        {
            if (args.Count < 2)
            {
                Console.Error.WriteLine("install command requires a name and path");
            }

            var(name, path) = (args[0], args[1]);
            var installPath = $"{path}/ReShade/Repositories/{name}";

            if (FSUtils.GetItem(installPath, out var kind))
            {
                if (InteractUtils.RequestInput(
                        $"Installation path {installPath} already exists, remove?",
                        allowDefault: false,
                        (ConsoleKey.Y, "Yes"),
                        (ConsoleKey.N, "No")) == ConsoleKey.Y)
                {
                    switch (kind)
                    {
                    case FSItemKind.File:
                    case FSItemKind.Link:
                        File.Delete(path);
                        break;

                    case FSItemKind.Directory:
                        Directory.Delete(path, true);
                        break;
                    }
                }
            }

            FSUtils.CreateSymbolicLink(
                installPath,
                Path.GetFullPath($"{Runtime.RepositoriesPath}/{name}"));

            Console.WriteLine("Repository installed.");
        }
Beispiel #7
0
        private static void Require(Evaluator eval, StackFrame frame)
        {
            Context context = frame.context.value as Context;

            var(name, path, command, rest) = ReadArguments(frame.args);

            Module module   = null;
            Module current  = CurrentModule;
            string fullPath = FSUtils.LookupModuleFile(programPath, current.currentPath, Names.MODULES_FOLDER, name);

            if (eval.HaveReturn())
            {
                Atom result = eval.TakeReturn();
                ImportSymbols(context, result, path, command, rest);
                eval.SetReturn(null);
            }
            else
            {
                if (fullPath != null)
                {
                    // По указанному абсолютному пути есть файл
                    // Значит можно пробовать загрузить модуль
                    if (_modules.TryGetValue(fullPath, out module))
                    {
                        // Модуль уже есть в памяти
                        if (module.loading)
                        {
                            // Циклический импорт
                            eval.SetError($"Module already in loading state: {fullPath}! Check for cyclical require!");
                            return;
                        }

                        // Модуль загружен и готов к использованию
                        // Импортим символы
                        ImportSymbols(context, module.Result, path, command, rest);
                        eval.SetReturn(null);
                        eval.CloseFrame();
                    }
                    else
                    {
                        // Модуля нет в памяти
                        var content = File.ReadAllText(fullPath);
                        var atoms   = BombardoLang.Parse(content);

                        module = new Module(fullPath, baseContext);
                        // Простое исполнение, без поддержки семантики препроцессинга
                        eval.CreateFrame("-eval-block-", atoms, module.ModuleContext);
                    }
                }
                else
                {
                    // Такого файла нет - значит по данному пути МОЖЕТ быть загружен встроенный модуль
                    if (!_modules.TryGetValue(fullPath, out module))
                    {
                        module = GetBuildInModule(name);
                        if (module != null)
                        {
                            // Кэшируем ссылку на модуль
                            _modules.Add(fullPath, module);
                        }
                    }

                    ImportSymbols(context, module.Result, path, command, rest);
                    eval.SetReturn(null);
                    eval.CloseFrame();
                }
            }
        }