Exemplo n.º 1
0
        public void ScriptGenerateNoLines()
        {
            String testScriptName = "Name";

            // Create a script - empty.
            StackHashScript         script         = new StackHashScript();
            StackHashScriptSettings scriptSettings = new StackHashScriptSettings(testScriptName, script);

            String tempFileName   = m_TempPath + "\\GeneratedScript.wds";
            String outputFileName = "c:\\test\\results.log";


            String symPath = null;
            String exePath = null;
            String srcPath = null;

            scriptSettings.GenerateScriptFile(tempFileName, outputFileName, ref symPath, ref exePath, ref srcPath);

            Assert.AreEqual(null, symPath);
            Assert.AreEqual(null, exePath);
            Assert.AreEqual(null, srcPath);

            // Read all of the data in.
            String[] allLines = File.ReadAllLines(tempFileName);

            Assert.AreEqual(true, File.Exists(tempFileName));

            // Should just contain a comment line.
            Assert.AreEqual(4, allLines.Length);
            Assert.AreEqual(true, allLines[0].Contains(outputFileName));
            Assert.AreEqual(true, allLines[1].Contains(testScriptName));
            Assert.AreEqual(true, allLines[1].Contains(scriptSettings.LastModifiedDate.ToString(CultureInfo.InvariantCulture)));
            Assert.AreEqual(true, allLines[2].Contains("Script Complete"));
            Assert.AreEqual(true, allLines[3].Contains(".logclose"));
        }
Exemplo n.º 2
0
        public void RunAllAutoScripts()
        {
            String dumpFileName = m_TempPath + "Cucku.exe.mdmp";

            // First make a copy of the test cab file.
            File.Copy(TestSettings.TestDataFolder + @"Dumps\Cucku.exe.mdmp",
                      dumpFileName, true);
            FileAttributes attributes = File.GetAttributes(dumpFileName);

            File.SetAttributes(dumpFileName, attributes & ~FileAttributes.ReadOnly);

            ScriptManager scriptManager = new ScriptManager(m_TempPath);

            // Now execute the script.
            StackHashDebug.Windbg winDbg = new Windbg();

            try
            {
                Collection <AutoScriptBase> autoScripts = scriptManager.AutoScripts;

                foreach (AutoScriptBase autoScript in autoScripts)
                {
                    // Generate the script settings structure in memory.
                    StackHashScriptSettings scriptSettings = autoScript.GenerateScript();

                    // Those settings are now used to create a WinDbg script file (wds). This file has a command
                    // to create a log file (the resultsFileName).
                    String resultsFileName = String.Format("{0}.log", Path.Combine(m_TempPath, autoScript.ScriptName));
                    String scriptFileName  = String.Format("{0}.wds", Path.Combine(m_TempPath, autoScript.ScriptName));
                    String symPath         = null;
                    String exePath         = null;
                    String srcPath         = null;
                    scriptSettings.GenerateScriptFile(scriptFileName, resultsFileName, ref symPath, ref exePath, ref srcPath);

                    // Run the wds file through the debugger to produce the results.log file.
                    winDbg.RunScript(m_DebuggerSettings, false, scriptFileName, dumpFileName, m_TempPath, symPath, exePath, srcPath);

                    // Load the results.log file.
                    StackHashScriptResult scriptResults = new StackHashScriptResult(resultsFileName);

                    // Analyse the results.
                    StackHashDumpAnalysis analysis = new StackHashDumpAnalysis();
                    analysis = autoScript.AnalyzeScriptResults(analysis, scriptResults);
                }
            }
            finally
            {
                scriptManager.RemoveAutoScripts();
            }
        }
Exemplo n.º 3
0
        public void ScriptGenerate2LinesOtherWayAround()
        {
            String testScriptName = "Name";
            String testCommand2   = @"$$ Command 1";
            String testComment2   = @"Demo Comment 1";
            String testCommand1   = @"$$ Command 2";
            String testComment1   = @"Another comment";

            // Create a script - empty.
            StackHashScript script = new StackHashScript();

            script.Add(new StackHashScriptLine(testCommand1, testComment1));
            script.Add(new StackHashScriptLine(testCommand2, testComment2));
            StackHashScriptSettings scriptSettings = new StackHashScriptSettings(testScriptName, script);

            String tempFileName   = m_TempPath + "\\GeneratedScript.wds";
            String outputFileName = "c:\\test\\results.log";
            String symPath        = null;
            String exePath        = null;
            String srcPath        = null;

            scriptSettings.GenerateScriptFile(tempFileName, outputFileName, ref symPath, ref exePath, ref srcPath);

            Assert.AreEqual(null, symPath);
            Assert.AreEqual(null, exePath);
            Assert.AreEqual(null, srcPath);

            // Read all of the data in.
            String[] allLines = File.ReadAllLines(tempFileName);

            Assert.AreEqual(true, File.Exists(tempFileName));

            // Should contain the script header comment plus one command and one comment line for each command.
            Assert.AreEqual(10, allLines.Length);
            Assert.AreEqual(true, allLines[0].Contains(outputFileName));
            Assert.AreEqual(true, allLines[1].Contains(testScriptName));
            Assert.AreEqual(true, allLines[1].Contains(scriptSettings.LastModifiedDate.ToString(CultureInfo.InvariantCulture)));
            Assert.AreEqual(true, allLines[2].Contains(scriptSettings.Script[0].Comment));
            Assert.AreEqual(true, allLines[3].StartsWith(scriptSettings.Script[0].Command));
            Assert.AreEqual(true, allLines[4].Contains(scriptSettings.Script[0].Comment));
            Assert.AreEqual(true, allLines[5].Contains(scriptSettings.Script[1].Comment));
            Assert.AreEqual(true, allLines[6].StartsWith(scriptSettings.Script[1].Command));
            Assert.AreEqual(true, allLines[7].Contains(scriptSettings.Script[1].Comment));
            Assert.AreEqual(true, allLines[8].Contains("Script Complete"));
            Assert.AreEqual(true, allLines[9].Contains(".logclose"));
        }
Exemplo n.º 4
0
        public void RunAutoScript()
        {
            String dumpFileName    = m_TempPath + "Cucku.exe.mdmp";
            String scriptFileName  = m_TempPath + "AutoScript.wds";
            String resultsFileName = m_TempPath + "AutoScript.log";

            // First make a copy of the test cab file.
            File.Copy(TestSettings.TestDataFolder + @"Dumps\Cucku.exe.mdmp",
                      dumpFileName, true);
            FileAttributes attributes = File.GetAttributes(dumpFileName);

            File.SetAttributes(dumpFileName, attributes & ~FileAttributes.ReadOnly);

            AutoScript autoScript = new AutoScript(m_TempPath);
            StackHashScriptSettings scriptSettings = autoScript.GenerateScript();
            String symPath = null;
            String exePath = null;
            String srcPath = null;

            scriptSettings.GenerateScriptFile(scriptFileName, resultsFileName, ref symPath, ref exePath, ref srcPath);

            Assert.AreEqual(null, symPath);
            Assert.AreEqual(null, exePath);
            Assert.AreEqual(null, srcPath);

            // Now execute the script.
            StackHashDebug.Windbg winDbg = new Windbg();
            winDbg.RunScript(m_DebuggerSettings, false, scriptFileName, dumpFileName, m_TempPath, symPath, exePath, srcPath);

            // Load the results file.
            StackHashScriptResult scriptResults = new StackHashScriptResult(resultsFileName);

            // Analyse the results.
            StackHashDumpAnalysis analysis = new StackHashDumpAnalysis();

            analysis = autoScript.AnalyzeScriptResults(analysis, scriptResults);

            Assert.AreEqual("not available", analysis.SystemUpTime);
            Assert.AreEqual("0 days 0:02:20.000", analysis.ProcessUpTime);

            Assert.AreEqual("2.0.50727.3603", analysis.DotNetVersion);
        }
Exemplo n.º 5
0
        public void ScriptGenerate1Line()
        {
            String testScriptName = "Name";
            String testCommand    = @"$$ This is a simple command";
            String testComment    = @"Just a demo";

            // Create a script - empty.
            StackHashScript script = new StackHashScript();

            script.Add(new StackHashScriptLine(testCommand, testComment));
            StackHashScriptSettings scriptSettings = new StackHashScriptSettings(testScriptName, script);

            String m_TempFileName = m_TempPath + "\\GeneratedScript.wds";
            String outputFileName = "c:\\test\\results.log";
            String symPath        = null;
            String exePath        = null;
            String srcPath        = null;

            scriptSettings.GenerateScriptFile(m_TempFileName, outputFileName, ref symPath, ref exePath, ref srcPath);

            Assert.AreEqual(null, symPath);
            Assert.AreEqual(null, exePath);
            Assert.AreEqual(null, srcPath);


            // Read all of the data in.
            String[] allLines = File.ReadAllLines(m_TempFileName);

            Assert.AreEqual(true, File.Exists(m_TempFileName));

            // Should contain the script header comment, and one command comment and one command.
            Assert.AreEqual(7, allLines.Length);
            Assert.AreEqual(true, allLines[0].Contains(outputFileName));
            Assert.AreEqual(true, allLines[1].Contains(testScriptName));
            Assert.AreEqual(true, allLines[1].Contains(scriptSettings.LastModifiedDate.ToString(CultureInfo.InvariantCulture)));
            Assert.AreEqual(true, allLines[2].Contains(scriptSettings.Script[0].Comment));
            Assert.AreEqual(true, allLines[3].StartsWith(scriptSettings.Script[0].Command));
            Assert.AreEqual(true, allLines[4].Contains(scriptSettings.Script[0].Comment));
            Assert.AreEqual(true, allLines[5].Contains("Script Complete"));
            Assert.AreEqual(true, allLines[6].Contains(".logclose"));
        }
Exemplo n.º 6
0
        public void RunSimpleScript()
        {
            // Create a test script.
            String testScriptName = "ScriptName";
            String testCommand    = @"r";
            String testComment    = @"Just a demo";

            StackHashScript script = new StackHashScript();

            script.Add(new StackHashScriptLine(testCommand, testComment));
            StackHashScriptSettings scriptSettings = new StackHashScriptSettings(testScriptName, script);

            String scriptFileName  = m_TempPath + @"\GeneratedScript.wds";
            String resultsFileName = m_TempPath + @"\Results.log";
            String symPath         = null;
            String exePath         = null;
            String srcPath         = null;

            scriptSettings.GenerateScriptFile(scriptFileName, resultsFileName, ref symPath, ref exePath, ref srcPath);

            Assert.AreEqual(null, symPath);
            Assert.AreEqual(null, exePath);
            Assert.AreEqual(null, srcPath);

            // Run the script with the debugger.
            Windbg debugger     = new Windbg();
            String dumpFileName = TestSettings.TestDataFolder + @"Dumps\Cucku.exe.mdmp";

            StackHashDebuggerSettings debuggerSettings = new StackHashDebuggerSettings();

            debuggerSettings.DebuggerPathAndFileName = StackHashDebuggerSettings.Default32BitDebuggerPathAndFileName;
            debuggerSettings.SymbolPath = StackHashSearchPath.DefaultSymbolPath;
            debugger.RunScript(debuggerSettings, true, scriptFileName, dumpFileName, resultsFileName, symPath, exePath, srcPath);

            Assert.AreEqual(true, File.Exists(resultsFileName));
            String[] allResults = File.ReadAllLines(resultsFileName, Encoding.Unicode);

            Assert.AreEqual(true, allResults.Length > 0);
        }
Exemplo n.º 7
0
        public void simpleScriptNCommands(int numCommands, bool addComment)
        {
            // Create a test script.
            String testScriptName = "ScriptName";
            String testCommand    = @"r";

            String testComment = null;

            if (addComment)
            {
                testComment = @"Just a demo";
            }

            StackHashScript script = new StackHashScript();

            for (int i = 0; i < numCommands; i++)
            {
                script.Add(new StackHashScriptLine(testCommand, testComment + i.ToString()));
            }
            StackHashScriptSettings scriptSettings = new StackHashScriptSettings(testScriptName, script);

            String scriptFileName  = m_TempPath + @"\GeneratedScript.wds";
            String resultsFileName = m_TempPath + @"\Results.log";

            String symPath = null;
            String exePath = null;
            String srcPath = null;

            scriptSettings.GenerateScriptFile(scriptFileName, resultsFileName, ref symPath, ref exePath, ref srcPath);

            Assert.AreEqual(null, symPath);
            Assert.AreEqual(null, exePath);
            Assert.AreEqual(null, srcPath);

            // Run the script with the debugger.
            Windbg debugger = new Windbg();

            String dumpFileName = TestSettings.TestDataFolder + @"Dumps\Cucku.exe.mdmp";

            DateTime startTime = DateTime.Now.ToUniversalTime();

            StackHashDebuggerSettings debuggerSettings = new StackHashDebuggerSettings();

            debuggerSettings.DebuggerPathAndFileName = StackHashDebuggerSettings.Default32BitDebuggerPathAndFileName;
            debuggerSettings.SymbolPath = StackHashSearchPath.DefaultSymbolPath;
            debuggerSettings.BinaryPath = StackHashSearchPath.DefaultBinaryPath;
            debugger.RunScript(debuggerSettings, true, scriptFileName, dumpFileName, resultsFileName, symPath, exePath, srcPath);

            DateTime endTime = DateTime.Now.ToUniversalTime();

            Assert.AreEqual(true, File.Exists(resultsFileName));

            // Now load in the test results.
            StackHashScriptResult result = new StackHashScriptResult(resultsFileName);


            Assert.AreEqual(scriptSettings.Name, result.Name);
            Assert.AreEqual(scriptSettings.LastModifiedDate.Date, result.LastModifiedDate.Date);
            Assert.AreEqual(scriptSettings.LastModifiedDate.Hour, result.LastModifiedDate.Hour);
            Assert.AreEqual(scriptSettings.LastModifiedDate.Minute, result.LastModifiedDate.Minute);
            Assert.AreEqual(scriptSettings.LastModifiedDate.Second, result.LastModifiedDate.Second);


            // Recorded time is only accurate to the second.
            long ticksInASecond = 10000000;

            startTime = new DateTime((startTime.Ticks / ticksInASecond) * ticksInASecond, DateTimeKind.Utc);
            endTime   = new DateTime((endTime.Ticks / ticksInASecond) * ticksInASecond, DateTimeKind.Utc);

            bool isGreaterEqual  = result.RunDate >= startTime;
            bool isLessThanEqual = result.RunDate <= endTime;

            long ticks1 = result.RunDate.Ticks;
            long ticks2 = startTime.Ticks;
            long ticks3 = endTime.Ticks;

            Assert.AreEqual(true, (result.RunDate >= startTime) && (result.RunDate <= endTime));

            Assert.AreEqual(numCommands, scriptSettings.Script.Count);

            for (int i = 0; i < numCommands; i++)
            {
                Assert.AreEqual(scriptSettings.Script[i].Command, result.ScriptResults[i].ScriptLine.Command);
                Assert.AreEqual(scriptSettings.Script[i].Comment, result.ScriptResults[i].ScriptLine.Comment);

                Assert.AreEqual(5, result.ScriptResults[i].ScriptLineOutput.Count);
                Assert.AreEqual(true, result.ScriptResults[i].ScriptLineOutput[0].StartsWith("eax="));
                Assert.AreEqual(true, result.ScriptResults[i].ScriptLineOutput[1].StartsWith("eip="));
                Assert.AreEqual(true, result.ScriptResults[i].ScriptLineOutput[2].StartsWith("cs="));
            }
        }
Exemplo n.º 8
0
        public void ScriptContainsSymPathMultipleCommandsWithReplace()
        {
            String testScriptName = "Name";
            String symbolPath1    = "c:\\test1";
            String symbolPath2    = "c:\\test2";

            String testCommand1 = @".sympath+" + symbolPath1;
            String testComment1 = @"Comment 1";
            String testCommand2 = @".Sympath" + symbolPath2; // No + on this one so should replace all previous symbols.
            String testComment2 = @"Comment 2";

            // Create a script - empty.
            StackHashScript script = new StackHashScript();

            script.Add(new StackHashScriptLine(testCommand1, testComment1));
            script.Add(new StackHashScriptLine(testCommand2, testComment2));
            StackHashScriptSettings scriptSettings = new StackHashScriptSettings(testScriptName, script);

            String tempFileName    = m_TempPath + "\\GeneratedScript.wds";
            String outputFileName  = "c:\\test\\results.log";
            String originalSymPath = "c:\\symbols";
            String originalExePath = "c:\\binary";
            String originalSrcPath = "c:\\source";
            String symPath         = originalSymPath;
            String exePath         = originalExePath;
            String srcPath         = originalSrcPath;

            scriptSettings.GenerateScriptFile(tempFileName, outputFileName, ref symPath, ref exePath, ref srcPath);

            Assert.AreEqual(symbolPath2, symPath);
            Assert.AreEqual(originalExePath, exePath);
            Assert.AreEqual(originalSrcPath, srcPath);

            // Read all of the data in.
            String[] allLines = File.ReadAllLines(tempFileName);

            Assert.AreEqual(true, File.Exists(tempFileName));

            // Should contain the script header comment plus one command and one comment line for each command.
            // Should contain an entry for sympath and exepath.
            Assert.AreEqual(8, allLines.Length);
            Assert.AreEqual(true, allLines[0].Contains(outputFileName));
            Assert.AreEqual(true, allLines[1].Contains(testScriptName));
            Assert.AreEqual(true, allLines[1].Contains(scriptSettings.LastModifiedDate.ToString(CultureInfo.InvariantCulture)));
            Assert.AreEqual(true, allLines[2].Contains("Command"));
            Assert.AreEqual(true, allLines[2].Contains(testCommand1));
            Assert.AreEqual(true, allLines[2].Contains(testComment1));
            Assert.AreEqual(true, allLines[3].Contains("CommandEnd"));
            Assert.AreEqual(true, allLines[3].Contains(testCommand1));
            Assert.AreEqual(true, allLines[3].Contains(testComment1));

            Assert.AreEqual(true, allLines[4].Contains("Command"));
            Assert.AreEqual(true, allLines[4].Contains(testCommand2));
            Assert.AreEqual(true, allLines[4].Contains(testComment2));
            Assert.AreEqual(true, allLines[5].Contains("CommandEnd"));
            Assert.AreEqual(true, allLines[5].Contains(testCommand2));
            Assert.AreEqual(true, allLines[5].Contains(testComment2));

            Assert.AreEqual(true, allLines[6].Contains("Script Complete"));
            Assert.AreEqual(true, allLines[7].Contains(".logclose"));
        }
Exemplo n.º 9
0
        public void ScriptContainsSymAndExePathStatementWithConcat()
        {
            String testScriptName = "Name";
            String symbolPath     = "some symbol path **";
            String binaryPath     = "some exe path **";
            String sourcePath     = "some src path **";
            String testCommand1   = @".exepath+" + binaryPath;
            String testComment1   = @"Another comment";
            String testCommand2   = @" .symPath + " + symbolPath;
            String testComment2   = @"Demo Comment 1";
            String testCommand3   = @" .SrcPath   +" + sourcePath;
            String testComment3   = @"Demo Comment 2";

            // Create a script - empty.
            StackHashScript script = new StackHashScript();

            script.Add(new StackHashScriptLine(testCommand1, testComment1));
            script.Add(new StackHashScriptLine(testCommand2, testComment2));
            script.Add(new StackHashScriptLine(testCommand3, testComment3));
            StackHashScriptSettings scriptSettings = new StackHashScriptSettings(testScriptName, script);

            String tempFileName    = m_TempPath + "\\GeneratedScript.wds";
            String outputFileName  = "c:\\test\\results.log";
            String originalSymPath = "c:\\symbols";
            String originalExePath = "c:\\binary";
            String originalSrcPath = "c:\\source";
            String symPath         = originalSymPath;
            String exePath         = originalExePath;
            String srcPath         = originalSrcPath;

            scriptSettings.GenerateScriptFile(tempFileName, outputFileName, ref symPath, ref exePath, ref srcPath);

            Assert.AreEqual(symPath, originalSymPath + ";" + symbolPath);
            Assert.AreEqual(exePath, originalExePath + ";" + binaryPath);
            Assert.AreEqual(srcPath, originalSrcPath + ";" + sourcePath);

            // Read all of the data in.
            String[] allLines = File.ReadAllLines(tempFileName);

            Assert.AreEqual(true, File.Exists(tempFileName));

            // Should contain the script header comment plus one command and one comment line for each command.
            // Should contain an entry for sympath and exepath.
            Assert.AreEqual(10, allLines.Length);
            Assert.AreEqual(true, allLines[0].Contains(outputFileName));
            Assert.AreEqual(true, allLines[1].Contains(testScriptName));
            Assert.AreEqual(true, allLines[1].Contains(scriptSettings.LastModifiedDate.ToString(CultureInfo.InvariantCulture)));
            Assert.AreEqual(true, allLines[2].Contains("Command"));
            Assert.AreEqual(true, allLines[2].Contains(testCommand1));
            Assert.AreEqual(true, allLines[2].Contains(testComment1));
            Assert.AreEqual(true, allLines[3].Contains("CommandEnd"));
            Assert.AreEqual(true, allLines[3].Contains(testCommand1));
            Assert.AreEqual(true, allLines[3].Contains(testComment1));

            Assert.AreEqual(true, allLines[4].Contains("Command"));
            Assert.AreEqual(true, allLines[4].Contains(testCommand2));
            Assert.AreEqual(true, allLines[4].Contains(testComment2));
            Assert.AreEqual(true, allLines[5].Contains("CommandEnd"));
            Assert.AreEqual(true, allLines[5].Contains(testCommand2));
            Assert.AreEqual(true, allLines[5].Contains(testComment2));

            Assert.AreEqual(true, allLines[6].Contains("Command"));
            Assert.AreEqual(true, allLines[6].Contains(testCommand3));
            Assert.AreEqual(true, allLines[6].Contains(testComment3));
            Assert.AreEqual(true, allLines[7].Contains("CommandEnd"));
            Assert.AreEqual(true, allLines[7].Contains(testCommand3));
            Assert.AreEqual(true, allLines[7].Contains(testComment3));

            Assert.AreEqual(true, allLines[8].Contains("Script Complete"));
            Assert.AreEqual(true, allLines[9].Contains(".logclose"));
        }
Exemplo n.º 10
0
        public StackHashScriptResult RunScript(StackHashProduct product, StackHashFile file, StackHashEvent theEvent, StackHashCab cab,
                                               String dumpFileName, String scriptName, bool extractCab, StackHashClientData clientData, bool forceRun)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }
            if (theEvent == null)
            {
                throw new ArgumentNullException("theEvent");
            }
            if (cab == null)
            {
                throw new ArgumentNullException("cab");
            }
            if (scriptName == null)
            {
                throw new ArgumentNullException("scriptName");
            }


            String machineArchitecture = "x86"; // Default to 32 bit.

            if ((cab.DumpAnalysis != null) && !String.IsNullOrEmpty(cab.DumpAnalysis.MachineArchitecture))
            {
                machineArchitecture = cab.DumpAnalysis.MachineArchitecture;
            }


            StackHashScriptResult result = null;
            bool use32BitDebugger        = true;

            if (machineArchitecture != null)
            {
                if ((String.Compare(machineArchitecture, "x64", StringComparison.OrdinalIgnoreCase) == 0) ||
                    (String.Compare(machineArchitecture, "X64", StringComparison.OrdinalIgnoreCase) == 0))
                {
                    use32BitDebugger = false;
                }
            }


            // Unwrap the cab if necessary.
            String cabFileName   = m_ErrorIndex.GetCabFileName(product, file, theEvent, cab);
            String cabFileFolder = Path.GetDirectoryName(cabFileName);

            if (!File.Exists(cabFileName))
            {
                throw new StackHashException("Cab file does not exist: " + cabFileName, StackHashServiceErrorCode.CabDoesNotExist);
            }

            if (extractCab)
            {
                try
                {
                    Cabs.ExtractCab(cabFileName, cabFileFolder);
                }
                catch (System.Exception ex)
                {
                    if (ex.Message.Contains("The file is not a cabinet") || ex.Message.Contains("corrupt") || ex.Message.Contains("Corrupt"))
                    {
                        // Set the downloaded flag appropriately if different.
                        StackHashCab loadedCab = m_ErrorIndex.GetCab(product, file, theEvent, cab.Id);

                        if (loadedCab != null)
                        {
                            if (loadedCab.CabDownloaded)
                            {
                                loadedCab.CabDownloaded = false;
                                m_ErrorIndex.AddCab(product, file, theEvent, loadedCab, false);
                            }
                        }
                    }

                    throw new StackHashException("Cab file cannot be unpackaged. Try downloading the file from again.", ex, StackHashServiceErrorCode.CabIsCorrupt);
                }
            }

            // Now get the dump filename - mdmp and dmp files should be returned.
            String[] allDumpFiles = Directory.GetFiles(cabFileFolder, "*.*dmp");

            if (allDumpFiles.Length == 0)
            {
                return(null);
            }

            // Choose the largest dump file to process.
            String fullDumpFilePath = null;

            long largestFileSize = 0;

            foreach (String fileName in allDumpFiles)
            {
                FileInfo fileInfo = new FileInfo(fileName);
                if (fileInfo.Length > largestFileSize)
                {
                    largestFileSize  = fileInfo.Length;
                    fullDumpFilePath = fileName;
                }
            }

            if (!String.IsNullOrEmpty(dumpFileName))
            {
                fullDumpFilePath = cabFileFolder + "\\" + dumpFileName;
            }

            // Find the script that the user wants to run.
            StackHashScriptSettings scriptSettings = m_ScriptManager.LoadScript(scriptName);

            // Auto generate the script file.
            String dumpAnalysisFolder = cabFileFolder + "\\Analysis";

            if (!Directory.Exists(dumpAnalysisFolder))
            {
                Directory.CreateDirectory(dumpAnalysisFolder);
            }

            // Check if the file has already been run.
            bool   runScript       = true;
            String resultsFileName = String.Format(CultureInfo.InvariantCulture, "{0}\\{1}.log", dumpAnalysisFolder, scriptSettings.Name);

            if (File.Exists(resultsFileName))
            {
                DateTime lastWriteTime = File.GetLastWriteTimeUtc(resultsFileName);

                if (scriptSettings.LastModifiedDate <= lastWriteTime)
                {
                    runScript = false;
                }
            }

            String installFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

            if (runScript || forceRun)
            {
                String overrideSymbolPath = null;
                String overrideBinaryPath = null;
                String overrideSourcePath = null;

                if (m_Debugger.Use32BitDebugger(use32BitDebugger, m_DebuggerSettings))
                {
                    overrideSymbolPath = m_DebuggerSettings.SymbolPath.FullPath;
                    overrideBinaryPath = m_DebuggerSettings.BinaryPath.FullPath;
                    overrideSourcePath = null;

                    // Check the script for PSSCOR loading.
                    String clrVersion = String.Empty;
                    if ((cab.DumpAnalysis != null) && (!String.IsNullOrEmpty(cab.DumpAnalysis.DotNetVersion)))
                    {
                        clrVersion = cab.DumpAnalysis.DotNetVersion;
                    }
                    scriptSettings.FixUp(StackHashScriptDumpArchitecture.X86, clrVersion, installFolder);
                }
                else
                {
                    overrideSymbolPath = m_DebuggerSettings.SymbolPath64Bit.FullPath;
                    overrideBinaryPath = m_DebuggerSettings.BinaryPath64Bit.FullPath;
                    overrideSourcePath = null;

                    // Check the script for PSSCOR loading.
                    String clrVersion = String.Empty;
                    if ((cab.DumpAnalysis != null) && (!String.IsNullOrEmpty(cab.DumpAnalysis.DotNetVersion)))
                    {
                        clrVersion = cab.DumpAnalysis.DotNetVersion;
                    }
                    scriptSettings.FixUp(StackHashScriptDumpArchitecture.Amd64, clrVersion, installFolder);
                }

                String scriptFileName = Path.GetTempFileName();
                scriptSettings.GenerateScriptFile(scriptFileName, resultsFileName, ref overrideSymbolPath, ref overrideBinaryPath, ref overrideSourcePath);

                DateTime timeOfRun = DateTime.Now.ToUniversalTime();
                try
                {
                    m_Debugger.RunScript(m_DebuggerSettings, use32BitDebugger, scriptFileName, fullDumpFilePath, resultsFileName, overrideSymbolPath, overrideBinaryPath, overrideSourcePath);

                    // Check if the results were generated. If not there must be a command line error so get the output from the
                    // debugger and throw an exception.
                    if (!File.Exists(resultsFileName))
                    {
                        throw new StackHashException("Debugger Error: " + m_Debugger.StandardError, StackHashServiceErrorCode.DebuggerError);
                    }


                    // Load in the results.
                    result = StackHashScriptResult.MergeAnalysisDumpFiles(resultsFileName);

                    // Add a script run note to the error index.
                    StackHashNoteEntry note = new StackHashNoteEntry();

                    // MUST KEEP THIS TEXT THE SAME - because it is used as a search string by the BugTrackerTask.
                    note.Note = String.Format(CultureInfo.CurrentCulture, "Script {0} executed", scriptName);
                    if ((clientData == null) || (clientData.ClientName == null))
                    {
                        note.Source = "Service";
                        note.User   = "******";
                    }
                    else
                    {
                        note.Source = "StackHash Client";
                        note.User   = clientData.ClientName;
                    }

                    note.TimeOfEntry = timeOfRun;
                    int cabNoteId = m_ErrorIndex.AddCabNote(product, file, theEvent, cab, note);

                    // Report the event to bug tracking plug-ins.
                    m_ErrorIndex.AddUpdate(new StackHashBugTrackerUpdate(
                                               StackHashDataChanged.DebugScript, StackHashChangeType.NewEntry, product.Id, file.Id, theEvent.Id, theEvent.EventTypeName, cab.Id, cabNoteId));
                }
                catch (System.Exception ex)
                {
                    // Add a script run note to the error index.
                    StackHashNoteEntry note = new StackHashNoteEntry();
                    note.Note   = String.Format(CultureInfo.CurrentCulture, "Script {0} execution failed: {1}", scriptName, ex.Message);
                    note.Source = "Service";
                    if ((clientData == null) || (clientData.ClientName == null))
                    {
                        note.User = "******";
                    }
                    else
                    {
                        note.User = clientData.ClientName;
                    }
                    note.TimeOfEntry = timeOfRun;
                    m_ErrorIndex.AddCabNote(product, file, theEvent, cab, note);
                    throw;
                }
                finally
                {
                    if (File.Exists(scriptFileName))
                    {
                        File.Delete(scriptFileName);
                    }
                }
            }

            return(result);
        }