public override bool Execute(List <string> args)
        {
            if (args.Count != 2)
            {
                return(false);
            }
            var outDir = args[1];
            ITagLayoutWriter writer;

            switch (args[0])
            {
            case "csharp":
                writer = new CSharpClassWriter(_stringIds, outDir);
                break;

            case "cpp":
                writer = new CppStructWriter(_stringIds, outDir);
                break;

            default:
                return(false);
            }
            Directory.CreateDirectory(outDir);
            var count = 0;

            using (var stream = _fileInfo.OpenRead())
            {
                foreach (var tagClass in _cache.TagClasses)
                {
                    TagLayoutGuess layout  = null;
                    HaloTag        lastTag = null;
                    foreach (var tag in _cache.Tags.FindAllByClass(tagClass))
                    {
                        Console.Write("Analyzing ");
                        TagPrinter.PrintTagShort(tag);

                        lastTag = tag;
                        var analyzer  = new TagAnalyzer(_cache, tag);
                        var data      = _cache.ExtractTag(stream, tag);
                        var tagLayout = analyzer.Analyze(data);
                        if (layout != null)
                        {
                            layout.Merge(tagLayout);
                        }
                        else
                        {
                            layout = tagLayout;
                        }
                    }
                    if (layout != null && lastTag != null)
                    {
                        Console.WriteLine("Writing {0} layout", tagClass);
                        LayoutGuessWriter.Write(lastTag, layout, writer);
                        count++;
                    }
                }
            }
            Console.WriteLine("Successfully generated {0} layouts!", count);
            return(true);
        }
Exemple #2
0
        private static int Main(string[] args)
        {
            if (Environment.Is64BitProcess)
            {
                Environment.SetEnvironmentVariable("_NT_DEBUGGER_EXTENSION_PATH", @"C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\WINXP;C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\winext;C:\Program Files (x86)\Windows Kits\10\Debuggers\x64;");
            }
            else
            {
                Environment.SetEnvironmentVariable("_NT_DEBUGGER_EXTENSION_PATH", @"C:\Program Files (x86)\Windows Kits\10\Debuggers\x86\WINXP;C:\Program Files (x86)\Windows Kits\10\Debuggers\x86\winext;C:\Program Files (x86)\Windows Kits\10\Debuggers\x86;");
            }
            using (context = new DumpContext()) {
                Console.WriteLine("SuperDump - Windows dump analysis tool");
                Console.WriteLine("--------------------------");
                //check if symbol path is set
                if (string.IsNullOrEmpty(SYMBOL_PATH))
                {
                    Console.WriteLine("WARNING: Environment variable _NT_SYMBOL_PATH is not set!");
                }

                if (args.Length < 1)
                {
                    Console.WriteLine("no dump file was specified! Please enter dump path: ");
                    DUMP_LOC = Console.ReadLine();
                }
                else
                {
                    DUMP_LOC = args[0];
                }

                if (args.Length < 2)
                {
                    Console.WriteLine("no output file was specified! Please enter output file: ");
                    OUTPUT_LOC = Console.ReadLine();
                }
                else
                {
                    OUTPUT_LOC = args[1];
                }

                string absoluteDumpFile = Path.GetFullPath(DUMP_LOC);
                Console.WriteLine(absoluteDumpFile);

                var logfile = new FileInfo(Path.Combine(Path.GetDirectoryName(OUTPUT_LOC), "superdump.log"));
                context.Printer = new FilePrinter(logfile.FullName);

                try {
                    if (File.Exists(absoluteDumpFile))
                    {
                        LoadDump(absoluteDumpFile);

                        // do this as early as possible, as some WinDbg commands help us get the right DAC files
                        var windbgAnalyzer = new WinDbgAnalyzer(context, Path.Combine(context.DumpDirectory, "windbg.log"));
                        windbgAnalyzer.Analyze();

                        // start analysis
                        var analysisResult = new SDResult();
                        analysisResult.IsManagedProcess = context.Target.ClrVersions.Count > 0;

                        if (analysisResult.IsManagedProcess)
                        {
                            SetupCLRRuntime();
                        }

                        var sysInfo = new SystemAnalyzer(context);
                        analysisResult.SystemContext = sysInfo.systemInfo;

                        var exceptionAnalyzer = new ExceptionAnalyzer(context, analysisResult);

                        context.WriteInfo("--- Thread analysis ---");
                        ThreadAnalyzer threadAnalyzer = new ThreadAnalyzer(context);
                        analysisResult.ExceptionRecord     = threadAnalyzer.exceptions;
                        analysisResult.ThreadInformation   = threadAnalyzer.threads;
                        analysisResult.DeadlockInformation = threadAnalyzer.deadlocks;
                        analysisResult.LastExecutedThread  = threadAnalyzer.GetLastExecutedThreadOSId();
                        context.WriteInfo("Last executed thread (engine id): " + threadAnalyzer.GetLastExecutedThreadEngineId().ToString());

                        var analyzer = new MemoryAnalyzer(context);
                        analysisResult.MemoryInformation = analyzer.memDict;
                        analysisResult.BlockingObjects   = analyzer.blockingObjects;

                        // this analyzer runs after all others to put tags onto taggableitems
                        var tagAnalyzer = new TagAnalyzer(analysisResult);
                        tagAnalyzer.Analyze();

                        //get non loaded symbols
                        List <string> notLoadedSymbols = new List <string>();
                        foreach (var item in sysInfo.systemInfo.Modules)
                        {
                            if (item.PdbInfo == null || string.IsNullOrEmpty(item.PdbInfo.FileName) || string.IsNullOrEmpty(item.PdbInfo.Guid))
                            {
                                notLoadedSymbols.Add(item.FileName);
                            }
                        }
                        analysisResult.NotLoadedSymbols = notLoadedSymbols;

                        // print to log
                        sysInfo.PrintArchitecture();
                        sysInfo.PrintCLRVersions();
                        sysInfo.PrintAppDomains();
                        sysInfo.PrintModuleList();
                        threadAnalyzer.PrintManagedExceptions();
                        threadAnalyzer.PrintCompleteStackTrace();
                        analyzer.PrintExceptionsObjects();

                        // write to json
                        analysisResult.WriteResultToJSONFile(OUTPUT_LOC);

                        context.WriteInfo("--- End of output ---");
                        Console.WriteLine("done.");
                    }
                    else
                    {
                        throw new FileNotFoundException("File can not be found!");
                    }
                } catch (Exception e) {
                    context.WriteError($"Exception happened: {e}");
                    return(1);
                }
            }
            return(0);
        }
Exemple #3
0
        public override object Execute(List <string> args)
        {
            if (args.Count != 2)
            {
                return(false);
            }

            var type   = args[0];
            var outDir = args[1];

            TagLayoutWriter writer;

            switch (type.ToLower())
            {
            case "c#":
            case "cs":
            case "csharp":
                writer = new CSharpLayoutWriter();
                break;

            case "c++":
            case "cpp":
            case "cplusplus":
                writer = new CppLayoutWriter();
                break;

            default:
                return(false);
            }

            Directory.CreateDirectory(outDir);

            var count = 0;

            using (var stream = CacheContext.OpenTagCacheRead())
            {
                foreach (var groupTag in CacheContext.TagCache.Index.NonNull().Select(t => t.Group.Tag).Distinct())
                {
                    TagLayoutGuess    layout  = null;
                    CachedTagInstance lastTag = null;

                    foreach (var tag in CacheContext.TagCache.Index.FindAllInGroup(groupTag))
                    {
                        Console.Write("Analyzing ");
                        TagPrinter.PrintTagShort(tag);

                        lastTag = tag;

                        var analyzer  = new TagAnalyzer(CacheContext.TagCache);
                        var data      = CacheContext.TagCache.ExtractTag(stream, tag);
                        var tagLayout = analyzer.Analyze(data);

                        if (layout != null)
                        {
                            layout.Merge(tagLayout);
                        }
                        else
                        {
                            layout = tagLayout;
                        }
                    }

                    if (layout != null && lastTag != null)
                    {
                        Console.WriteLine("Writing {0} layout", groupTag);

                        var name      = CacheContext.GetString(lastTag.Group.Name);
                        var tagLayout = LayoutGuessFinalizer.MakeLayout(layout, name, groupTag);
                        var path      = Path.Combine(outDir, writer.GetSuggestedFileName(tagLayout));

                        writer.WriteLayout(tagLayout, path);

                        count++;
                    }
                }
            }

            Console.WriteLine("Successfully generated {0} layouts!", count);

            return(true);
        }
 private void Update()
 {
     if (isStart && !(lbl == null) && text != null && text.Length != 0 && !isComplete && !isPause)
     {
         float num = Time.get_deltaTime();
         if (breakTime > 0f)
         {
             breakTime -= num;
             if (breakTime > 0f)
             {
                 return;
             }
             num = 0f - breakTime;
         }
         textAnimTime += num;
         int num2 = (int)(textAnimTime * speed);
         if (num2 > textCount)
         {
             while (num2 > textCount)
             {
                 if (textCount >= text[textIndex].Length)
                 {
                     if (textIndex == text.Length - 1)
                     {
                         textAnimTime = 0f;
                         if (page < textList.Count)
                         {
                             isPause = true;
                         }
                         else
                         {
                             isComplete = true;
                         }
                         if (pageEndCallback != null)
                         {
                             pageEndCallback();
                         }
                     }
                     else
                     {
                         sb.AppendLine();
                         textCount    = 0;
                         textAnimTime = 0f;
                         textIndex++;
                         breakTime = 1f;
                     }
                     break;
                 }
                 int num3 = textCount;
                 textCount = analyzer.Analyze(text[textIndex], textIndex, textCount);
                 if (!analyzer.IsFindTag())
                 {
                     sb.Append(text[textIndex][textCount++]);
                 }
                 else if (tagCallback != null)
                 {
                     tagCallback(analyzer.findTag, analyzer.findTagText);
                 }
             }
             lbl.text = sb.ToString();
         }
     }
 }
Exemple #5
0
        public override bool Execute(List <string> args)
        {
            if (args.Count != 3)
            {
                return(false);
            }
            var             entry  = args[0];
            var             type   = args[1];
            var             outDir = args[2];
            TagLayoutWriter writer;

            switch (type)
            {
            case "csharp":
                writer = new CSharpLayoutWriter();
                break;

            case "cpp":
                writer = new CppLayoutWriter();
                break;

            default:
                return(false);
            }
            Directory.CreateDirectory(outDir);
            var count = 0;

            using (var stream = _info.OpenCacheRead())
            {
                //foreach (var groupTag in _cache.Tags.NonNull().Select(t => t.Group.Tag).Distinct())
                var groupTag = ArgumentParser.ParseTagIndex(_info, entry).Group.Tag;
                {
                    TagLayoutGuess layout  = null;
                    TagInstance    lastTag = null;
                    foreach (var tag in _cache.Tags.FindAllInGroup(groupTag))
                    {
                        Console.Write("Analyzing ");
                        TagPrinter.PrintTagShort(tag);

                        lastTag = tag;
                        var analyzer  = new TagAnalyzer(_cache);
                        var data      = _cache.ExtractTag(stream, tag);
                        var tagLayout = analyzer.Analyze(data);
                        if (layout != null)
                        {
                            layout.Merge(tagLayout);
                        }
                        else
                        {
                            layout = tagLayout;
                        }
                    }
                    if (layout != null && lastTag != null)
                    {
                        Console.WriteLine("Writing {0} layout", groupTag);
                        var name      = _info.StringIDs.GetString(lastTag.Group.Name);
                        var tagLayout = LayoutGuessFinalizer.MakeLayout(layout, name, groupTag);
                        var path      = Path.Combine(outDir, writer.GetSuggestedFileName(tagLayout));
                        writer.WriteLayout(tagLayout, path);
                        count++;
                    }
                }
            }
            Console.WriteLine("Successfully generated {0} layouts!", count);
            return(true);
        }