Example #1
0
        public void LoadCurrentTheme()
        {
            StreamReader TextFile = new StreamReader(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\OptionsConfig.txt");
            string       CurrentLine;
            int          IndexOfAnswer;

            while ((CurrentLine = TextFile.ReadLine()) != null)
            {
                IndexOfAnswer  = CurrentLine.LastIndexOf(" ");
                IndexOfAnswer += 1;

                if (CurrentLine.Contains("Opacity: "))
                {
                    string CurrentOpacity = CurrentLine.Substring(IndexOfAnswer);
                    TinyUI_Nud_Opacity.Value = Convert.ToDecimal(CurrentOpacity);
                }

                if (CurrentLine.Contains("AutohookEnabled: "))
                {
                    string Result = CurrentLine.Substring(IndexOfAnswer);
                    if (Result == "Y")
                    {
                        Btn_AutoHook_Click(null, null);
                    }
                }

                if (CurrentLine.Contains("AutohookDelay: "))
                {
                    string Result = CurrentLine.Substring(IndexOfAnswer);
                    TinyUI_Nud_AutoHookInterval.Value = Convert.ToDecimal(Result);
                }
            }

            TextFile.Dispose();
        }
Example #2
0
        /// <summary>
        /// Parse a raw callstack into a pattern
        /// </summary>
        /// <param name="CurrentCrash">The crash with a raw callstack to parse.</param>
        private void ParseCallStack(Crash CurrentCrash)
        {
            // Everything is disabled by default
            bDisplayUnformattedCallStack = false;
            bDisplayModuleNames          = false;
            bDisplayFunctionNames        = false;
            bDisplayFileNames            = false;
            bDisplayFilePathNames        = false;

            bool   bSkipping      = false;
            string LineToSkipUpto = "";

            switch (CurrentCrash.CrashType)
            {
            case 2:
                bSkipping      = true;
                LineToSkipUpto = "FDebug::AssertFailed()";
                break;

            case 3:
                bSkipping      = true;
                LineToSkipUpto = "FDebug::EnsureFailed()";
                break;
            }

            if (string.IsNullOrEmpty(CurrentCrash.RawCallStack))
            {
                return;
            }

            CallStackEntries.Clear();

            // Store off a pre split array of call stack lines
            string[] RawCallStackLines = CurrentCrash.RawCallStack.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);

            // Support older callstacks uploaded before UE4 upgrade
            if (!NewCallstackFormat.Match(RawCallStackLines[0]).Success)
            {
                foreach (string CurrentLine in RawCallStackLines)
                {
                    // Exit if we've hit the max number of lines we want
                    if (CallStackEntries.Count >= MaxLinesToParse)
                    {
                        break;
                    }

                    ParseUE3FormatCallstackLine(CurrentLine);
                }
                return;
            }

            foreach (string CurrentLine in RawCallStackLines)
            {
                // Exit if we've hit the max number of lines we want
                if (CallStackEntries.Count >= MaxLinesToParse)
                {
                    break;
                }

                if (bSkipping)
                {
                    if (CurrentLine.Contains(LineToSkipUpto))
                    {
                        bSkipping = false;
                    }
                }

                if (bSkipping)
                {
                    continue;
                }

                string ModuleName = "<Unknown>";
                string FuncName   = "<Unknown>";
                string FilePath   = "";
                int    LineNumber = 0;

                // Sample line "UE4_Engine!UEngine::Exec() + 21105 bytes [d:\depot\ue4\engine\source\runtime\engine\private\unrealengine.cpp:2777]"

                int PlingOffset        = CurrentLine.IndexOf('!');
                int PlusOffset         = CurrentLine.IndexOf(" + ");
                int BytesOffset        = CurrentLine.IndexOf(" bytes");
                int OpenBracketOffset  = CurrentLine.IndexOf('[');
                int CloseBracketOffset = CurrentLine.LastIndexOf(']');

                // Parse out the juicy info from the line of the callstack
                if (PlingOffset > 0)
                {
                    ModuleName = CurrentLine.Substring(0, PlingOffset).Trim();
                    if (BytesOffset > PlingOffset)
                    {
                        // Grab the function name if it exists
                        FuncName = CurrentLine.Substring(PlingOffset + 1, BytesOffset - PlingOffset + " bytes".Length - 1).Trim();

                        // Grab the source file
                        if (OpenBracketOffset > BytesOffset && CloseBracketOffset > BytesOffset && CloseBracketOffset > OpenBracketOffset)
                        {
                            string FileLinePath = CurrentLine.Substring(OpenBracketOffset + 1, CloseBracketOffset - OpenBracketOffset - 1).Trim();

                            FilePath = FileLinePath.TrimEnd("0123456789:".ToCharArray());
                            int SourceLine = 0;
                            Debug.Assert(FilePath.Length < FileLinePath.Length, "WRONG SIZE");
                            if (int.TryParse(FileLinePath.Substring(FilePath.Length + 1), out SourceLine))
                            {
                                LineNumber = SourceLine;
                            }
                        }
                    }
                }
                else if (BytesOffset > 0)
                {
                    // Grab the module name if there is no function name
                    ModuleName = CurrentLine.Substring(0, PlusOffset).Trim();
                }

                CallStackEntries.Add(new CallStackEntry(CurrentLine, ModuleName, FilePath, FuncName, LineNumber));
            }
        }
Example #3
0
        //.*?\(.*?\).*?\[.*?\]

        /// <summary>
        /// Parse a raw callstack into a pattern
        /// </summary>
        /// <param name="CurrentCrash">The crash with a raw callstack to parse.</param>
        private void ParseCallStack(Crash CurrentCrash)
        {
            // Everything is disabled by default
            bDisplayUnformattedCallStack = false;
            bDisplayModuleNames          = false;
            bDisplayFunctionNames        = false;
            bDisplayFileNames            = false;
            bDisplayFilePathNames        = false;

            bool   bSkipping      = false;
            string LineToSkipUpto = "";

            switch (CurrentCrash.CrashType)
            {
            case 2:
                bSkipping      = true;
                LineToSkipUpto = "FDebug::AssertFailed";
                break;

            case 3:
                bSkipping      = true;
                LineToSkipUpto = "FDebug::";
                break;
            }

            if (string.IsNullOrEmpty(CurrentCrash.RawCallStack))
            {
                return;
            }

            CallStackEntries.Clear();

            // Store off a pre split array of call stack lines
            string[] RawCallStackLines = CurrentCrash.RawCallStack.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);

            int Middle = RawCallStackLines.Length / 2;

            // Support older callstacks uploaded before UE4 upgrade
            if (!NewCallstackFormat.Match(RawCallStackLines[Middle]).Success)
            {
                foreach (string CurrentLine in RawCallStackLines)
                {
                    // Exit if we've hit the max number of lines we want
                    if (CallStackEntries.Count >= MaxLinesToParse)
                    {
                        break;
                    }

                    ParseUE3FormatCallstackLine(CurrentLine);
                }
                return;
            }

            foreach (string CurrentLine in RawCallStackLines)
            {
                // Exit if we've hit the max number of lines we want
                if (CallStackEntries.Count >= MaxLinesToParse)
                {
                    break;
                }

                if (bSkipping)
                {
                    if (CurrentLine.Contains(LineToSkipUpto))
                    {
                        bSkipping = false;
                    }
                }

                if (bSkipping)
                {
                    continue;
                }

                string ModuleName = "<Unknown>";
                string FuncName   = "<Unknown>";
                string FilePath   = "";
                int    LineNumber = 0;

                //
                // Generic sample line "UE4_Engine!UEngine::Exec() {+ 21105 bytes} [d:\depot\ue4\engine\source\runtime\engine\private\unrealengine.cpp:2777]"
                //
                // Mac
                // thread_start()  Address = 0x7fff87ae141d (filename not found) [in libsystem_pthread.dylib]
                //
                // Linux
                // Unknown!AFortPlayerController::execServerSaveLoadoutData(FFrame&, void*) + some bytes

                int ModuleSeparator    = CurrentLine.IndexOf('!');
                int PlusOffset         = CurrentLine.IndexOf(" + ");
                int OpenFuncSymbol     = CurrentLine.IndexOf('(');
                int CloseFuncSymbol    = CurrentLine.IndexOf(')');
                int OpenBracketOffset  = CurrentLine.IndexOf('[');
                int CloseBracketOffset = CurrentLine.LastIndexOf(']');

                int MacModuleStart = CurrentLine.IndexOf("[in ");
                int MacModuleEnd   = MacModuleStart > 0 ? CurrentLine.IndexOf("]", MacModuleStart) : 0;

                bool bLinux   = CurrentCrash.PlatformName.Contains("Linux");
                bool bMac     = CurrentCrash.PlatformName.Contains("Mac");
                bool bWindows = CurrentCrash.PlatformName.Contains("Windows");


                // Parse out the juicy info from the line of the callstack
                if (ModuleSeparator > 0)
                {
                    ModuleName = CurrentLine.Substring(0, ModuleSeparator).Trim();
                    if (OpenFuncSymbol > ModuleSeparator && CloseFuncSymbol > OpenFuncSymbol)
                    {
                        // Grab the function name if it exists
                        FuncName  = CurrentLine.Substring(ModuleSeparator + 1, OpenFuncSymbol - ModuleSeparator - 1).Trim();
                        FuncName += "()";

                        // Grab the source file
                        if (OpenBracketOffset > CloseFuncSymbol && CloseBracketOffset > OpenBracketOffset && (bWindows || bLinux))
                        {
                            string FileLinePath = CurrentLine.Substring(OpenBracketOffset + 1, CloseBracketOffset - OpenBracketOffset - 1).Trim();

                            FilePath = FileLinePath.TrimEnd("0123456789:".ToCharArray());

                            if (FileLinePath.Length > FilePath.Length + 1)
                            {
                                int SourceLine = 0;
                                if (int.TryParse(FileLinePath.Substring(FilePath.Length + 1), out SourceLine))
                                {
                                    LineNumber = SourceLine;
                                }
                            }
                        }
                    }
                }
                else if (bWindows)
                {
                    // Grab the module name if there is no function name
                    int WhiteSpacePos = CurrentLine.IndexOf(' ');
                    ModuleName = WhiteSpacePos > 0 ? CurrentLine.Substring(0, WhiteSpacePos) : CurrentLine;
                }

                if (bMac && MacModuleStart > 0 && MacModuleEnd > 0)
                {
                    int AddressOffset     = CurrentLine.IndexOf("Address =");
                    int OpenFuncSymbolMac = AddressOffset > 0 ? CurrentLine.Substring(0, AddressOffset).LastIndexOf('(') : 0;
                    if (OpenFuncSymbolMac > 0)
                    {
                        FuncName  = CurrentLine.Substring(0, OpenFuncSymbolMac).Trim();
                        FuncName += "()";
                    }

                    ModuleName = CurrentLine.Substring(MacModuleStart + 3, MacModuleEnd - MacModuleStart - 3).Trim();
                }

                // Remove callstack entries that match any of these functions.
                var FuncsToRemove = new HashSet <string>(new string[]
                {
                    "RaiseException",
                    "FDebug::",
                    "Error::Serialize",
                    "FOutputDevice::Logf",
                    "FMsg::Logf",
                    "ReportCrash",
                    "NewReportEnsure",
                    "EngineCrashHandler",
                    "FLinuxPlatformStackWalk::CaptureStackBackTrac",
                    "FGenericPlatformStackWalk::StackWalkAndDump",
                    "FLinuxCrashContext::CaptureStackTrace",
                    "CommonLinuxCrashHandler",
                    // Generic crash handler for all platforms
                });

                bool Contains = FuncsToRemove.Contains(FuncName, new CustomFuncComparer());
                if (!Contains)
                {
                    CallStackEntries.Add(new CallStackEntry(CurrentLine, ModuleName, FilePath, FuncName, LineNumber));
                }
            }
        }
Example #4
0
        /// <summary>
        /// Loads the Sonic Heroes Configuration File, returns under the custom struct defined in the same file.
        /// </summary>
        public static Sonic_Heroes_Configuration_File Load_Configuration_File()
        {
            Sonic_Heroes_Configuration_File ConfigFile = new Sonic_Heroes_Configuration_File();
            string ConfigFilePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\SEGA\SONICHEROES\sonic_h.ini";

            try
            {
                string CurrentLine;
                System.IO.StreamReader INIConfigFile = new System.IO.StreamReader(ConfigFilePath);

                // Initialize size of struct arrays;
                ConfigFile.ControllerOne = new byte[8];
                ConfigFile.ControllerTwo = new byte[8];
                ConfigFile.MouseControls = new byte[8];

                while ((CurrentLine = INIConfigFile.ReadLine()) != null)
                {
                    if (CurrentLine.StartsWith("Frame_Rate"))
                    {
                        ConfigFile.FrameRate = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                    }
                    else if (CurrentLine.StartsWith("Free_Camera"))
                    {
                        ConfigFile.FreeCamera = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                    }
                    else if (CurrentLine.StartsWith("Fog"))
                    {
                        ConfigFile.FogEmulation = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                    }
                    else if (CurrentLine.StartsWith("Clip_Range"))
                    {
                        ConfigFile.ClipRange = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                    }
                    else if (CurrentLine.StartsWith("Anisotoropic"))
                    {
                        ConfigFile.AnisotropicFiltering = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                    }
                    else if (CurrentLine.StartsWith("Pad_Assign1"))
                    {
                        ReadStringByteArray(CurrentLine.Substring(CurrentLine.IndexOf(" ") + 1), ConfigFile.ControllerOne);
                    }
                    else if (CurrentLine.StartsWith("Pad_Assign2"))
                    {
                        ReadStringByteArray(CurrentLine.Substring(CurrentLine.IndexOf(" ") + 1), ConfigFile.ControllerTwo);
                    }
                    else if (CurrentLine.StartsWith("Mouse_Assign"))
                    {
                        ReadStringByteArray(CurrentLine.Substring(CurrentLine.IndexOf(" ") + 1), ConfigFile.MouseControls);
                    }
                    else if (CurrentLine.StartsWith("Screen_Size_Selection"))
                    {
                        ConfigFile.Screensize = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                    }
                    else if (CurrentLine.StartsWith("Screen_Full"))
                    {
                        ConfigFile.FullScreen = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                    }
                    else if (CurrentLine.StartsWith("Language"))
                    {
                        ConfigFile.Language = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                    }
                    else if (CurrentLine.StartsWith("3D_Sound"))
                    {
                        ConfigFile.SurroundSound = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                    }
                    else if (CurrentLine.StartsWith("SE_Volume"))
                    {
                        ConfigFile.SFXVolume = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                    }
                    else if (CurrentLine.StartsWith("SE_On"))
                    {
                        ConfigFile.SFXToggle = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                    }
                    else if (CurrentLine.StartsWith("BGM_Volume"))
                    {
                        ConfigFile.BGMVolume = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                    }
                    else if (CurrentLine.StartsWith("BGM_On"))
                    {
                        ConfigFile.BGMToggle = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                    }
                    else if (CurrentLine.StartsWith("Cheap_Shadow"))
                    {
                        ConfigFile.SoftShadows = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                    }
                    else if (CurrentLine.StartsWith("Mouse_Control_Type"))
                    {
                        ConfigFile.MouseControlType = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                    }
                }

                INIConfigFile.Dispose();
                return(ConfigFile);
            }
            catch (Exception)
            {
                // If the game is not Sonic Heroes or a config file is missing, set a default file into memory undefined defaults.
                MessageBox.Show("Could not find the Sonic Heroes configuration ini. The settings in the mod loader have been replaced with the defaults.");
                return(ConfigFile);
            }
        }
        private void LoadHeroesConfig()
        {
            string ConfigFilePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\SEGA\SONICHEROES\sonic_h.ini";
            string CurrentLine;

            System.IO.StreamReader INIConfigFile = new System.IO.StreamReader(ConfigFilePath);

            // Initialize size of struct arrays;
            ConfigFile.ControllerOne = new byte[8];
            ConfigFile.ControllerTwo = new byte[8];
            ConfigFile.MouseControls = new byte[8];

            while ((CurrentLine = INIConfigFile.ReadLine()) != null)
            {
                if (CurrentLine.StartsWith("Frame_Rate"))
                {
                    ConfigFile.FrameRate = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                }
                else if (CurrentLine.StartsWith("Free_Camera"))
                {
                    ConfigFile.FreeCamera = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                }
                else if (CurrentLine.StartsWith("Fog"))
                {
                    ConfigFile.FogEmulation = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                }
                else if (CurrentLine.StartsWith("Clip_Range"))
                {
                    ConfigFile.ClipRange = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                }
                else if (CurrentLine.StartsWith("Anisotoropic"))
                {
                    ConfigFile.AnisotropicFiltering = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                }
                else if (CurrentLine.StartsWith("Pad_Assign1"))
                {
                    ReadStringByteArray(CurrentLine.Substring(CurrentLine.IndexOf(" ") + 1), ConfigFile.ControllerOne);
                }
                else if (CurrentLine.StartsWith("Pad_Assign2"))
                {
                    ReadStringByteArray(CurrentLine.Substring(CurrentLine.IndexOf(" ") + 1), ConfigFile.ControllerTwo);
                }
                else if (CurrentLine.StartsWith("Mouse_Assign"))
                {
                    ReadStringByteArray(CurrentLine.Substring(CurrentLine.IndexOf(" ") + 1), ConfigFile.MouseControls);
                }
                else if (CurrentLine.StartsWith("Screen_Size_Selection"))
                {
                    ConfigFile.Screensize = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                }
                else if (CurrentLine.StartsWith("Screen_Full"))
                {
                    ConfigFile.FullScreen = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                }
                else if (CurrentLine.StartsWith("Language"))
                {
                    ConfigFile.Language = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                }
                else if (CurrentLine.StartsWith("3D_Sound"))
                {
                    ConfigFile.SurroundSound = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                }
                else if (CurrentLine.StartsWith("SE_Volume"))
                {
                    ConfigFile.SFXVolume = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                }
                else if (CurrentLine.StartsWith("SE_On"))
                {
                    ConfigFile.SFXToggle = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                }
                else if (CurrentLine.StartsWith("BGM_Volume"))
                {
                    ConfigFile.BGMVolume = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                }
                else if (CurrentLine.StartsWith("BGM_On"))
                {
                    ConfigFile.BGMToggle = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                }
                else if (CurrentLine.StartsWith("Cheap_Shadow"))
                {
                    ConfigFile.SoftShadows = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                }
                else if (CurrentLine.StartsWith("Mouse_Control_Type"))
                {
                    ConfigFile.MouseControlType = byte.Parse(CurrentLine.Substring(CurrentLine.LastIndexOf(" ") + 1));
                }
            }

            INIConfigFile.Dispose();
        }