Exemplo n.º 1
0
        static void Main()
        {
            try
            {
                ////////////// MOD LOADER DLL SKELETON CODE ///////////////////////////////////////////////////////////////////////////////////////////////////
                AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(SonicHeroes.Misc.SonicHeroes_Miscallenous.CurrentDomain_SetAssemblyResolve);
                Sonic_Heroes_Networking_Client.SetupClient(IPAddress.Loopback);                                                                                                            /// Set up networking with the Sonic Heroes Mod Loader.
                Sonic_Heroes_Networking_Client_II.SetupClient(IPAddress.Loopback);                                                                                                         /// Set up networking with the Sonic Heroes Mod Loader.
                byte[] Response = Sonic_Heroes_Networking_Client.SendData_Alternate(Message_Type.Client_Call_Send_Message, Encoding.ASCII.GetBytes(Mod_Name + " | Loading... OK!"), true); /// Say to the Mod Loader that we have loaded so the end user can know.
                Sonic_Heroes_Process = Process.GetCurrentProcess();                                                                                                                        /// We will use this for reading and writing memory.
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                // Load the Controller Deadzone Config
                Controller_Deadzones = new Controller_Config_Deadzones();
                Load_Controller_Deadzone_Configuration();

                // Define the controller manager.
                SonicHeroes_Joystick_Manager = new SonicHeroes.Controller.DirectInput_Joystick_Manager();


                // Declare new hook.
                Heroes_Controller_Function_Hook = new SonicHeroes.Hooking.Injection
                                                  (
                    (IntPtr)0x445B3A,     // Immediately after the controls are acquired by the game.
                    (Heroes_Controller_Function_Delegate)Heroes_Controller_Function_Override,
                    6
                                                  );

                // Activate our hook!
                Heroes_Controller_Function_Hook.Activate();
            }
            catch (Exception Ex) { Sonic_Heroes_Networking_Client.SendData_Alternate(Message_Type.Client_Call_Send_Message, Encoding.ASCII.GetBytes(Mod_Name + " Failed To Load: " + Ex.Message), false); }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Attempts to forcefully load a level into the current game.
        /// </summary>
        public void Force_Load_Level()
        {
            // Write requested stage to memory.
            Program.Sonic_Heroes_Process.WriteMemory((IntPtr)SonicHeroesVariables.Stage_CurrentStage.PlayerStageIDToLoad, BitConverter.GetBytes(Stage_Entry_List[Stage_Enum_Index].Stage_ID));
            Program.Sonic_Heroes_Process.WriteMemory((IntPtr)SonicHeroesVariables.Stage_CurrentStage.PlayerStageChoiceMainMenu, BitConverter.GetBytes(Stage_Entry_List[Stage_Enum_Index].Stage_ID));

            // Check if in level.
            byte In_Level = Program.Sonic_Heroes_Process.ReadMemory <byte>((IntPtr)SonicHeroes.Variables.SonicHeroesVariables.Game_CurrentState.CurrentlyInLevel, 1);

            if (In_Level == 1)
            {
                // Secretly put us back in the main menu if we are in a stage.
                Invoke_External_Class.Exit_Stage_X();
                Menu_Enter_Hook_ASM.Activate();
                Menu_Enter_Hook.Activate();
            }
            else
            {
                Force_Load_Level_Method();
            }
        }
        // Initializes the FOV/Aspect Ratio Fix
        public void Initialize_FOV_Aspect_Ratio_Fix()
        {
            // Read Stock FoV
            Get_Stock_Field_Of_View(); // Calculate Stock Aspect Ratio

            // Add to the delegate in the transparent overlay Window to act on changes based on Window Size and Location.
            Heroes_Window_Move_Hook_Delegate_Graphics_Menu = new WinEventDelegate(WinEventProc);

            // Set Delegate
            SetWinEventHook(WINAPI_Components.EVENT_OBJECT_LOCATIONCHANGE, WINAPI_Components.EVENT_OBJECT_LOCATIONCHANGE, IntPtr.Zero, Heroes_Window_Move_Hook_Delegate_Graphics_Menu, 0, 0, WINAPI_Components.WINEVENT_OUTOFCONTEXT);

            // Allocate Memory to Store HUD Centering Value
            Menu_Center_Value_Address             = Program.Sonic_Heroes_Process.AllocateMemory(sizeof(float));
            Menu_Vertical_Center_Value_Address    = Program.Sonic_Heroes_Process.AllocateMemory(sizeof(float));
            FOV_ASM_Menu_Horizontal_Value_Address = Program.Sonic_Heroes_Process.AllocateMemory(sizeof(float));
            FOV_ASM_Menu_Vertical_Value_Address   = Program.Sonic_Heroes_Process.AllocateMemory(sizeof(float));

            // Write Default Values
            Program.Sonic_Heroes_Process.WriteMemory(Menu_Center_Value_Address, BitConverter.GetBytes(1.00F));          // Make sure to not offset menus, this value will be auto set when entering a stage.
            Program.Sonic_Heroes_Process.WriteMemory(Menu_Vertical_Center_Value_Address, BitConverter.GetBytes(1.00F)); // Make sure to not offset menus, this value will be auto set when entering a stage.
            Program.Sonic_Heroes_Process.WriteMemory(FOV_ASM_Menu_Horizontal_Value_Address, BitConverter.GetBytes(Menu_Horizonal_Field_Of_View_Scale));
            Program.Sonic_Heroes_Process.WriteMemory(FOV_ASM_Menu_Vertical_Value_Address, BitConverter.GetBytes(Menu_Vertical_Field_Of_View_Scale));

            // Backup the original instructions.
            ASM_HUD_FOV_Horizontal_Instruction_Original  = Program.Sonic_Heroes_Process.ReadMemory((IntPtr)UNKNOWN_HORIZONTAL_POSITION_ASM_INSTRUCTION, 6); // Not in Variables because real purpose is unknown. Shifts UI.
            ASM_HUD_FOV_Vertical_Instruction_Original    = Program.Sonic_Heroes_Process.ReadMemory((IntPtr)UNKNOWN_VERTICAL_POSITION_ASM_INSTRUCTION, 5);   // Not in Variables because real purpose is unknown. Shifts UI.
            ASM_Menu_FOV_Instruction_Horizontal_Original = Program.Sonic_Heroes_Process.ReadMemory((IntPtr)HORIZONTAL_FOV_ASM_INSTRUCTION, 6);              // Original Instruction.
            ASM_Menu_FOV_Instruction_Vertical_Original   = Program.Sonic_Heroes_Process.ReadMemory((IntPtr)VERTICAL_FOV_ASM_INSTRUCTION, 6);                // Original Instruction.
            Victory_Screen_FOV_X_Instruction_Original    = Program.Sonic_Heroes_Process.ReadMemory((IntPtr)VICTORY_SCREEN_X_ASPECTRATIO_INSTRUCTION, 6);    // Original Instruction.
            Victory_Screen_FOV_Y_Instruction_Original    = Program.Sonic_Heroes_Process.ReadMemory((IntPtr)VICTORY_SCREEN_Y_ASPECTRATIO_INSTRUCTION, 6);    // Original Instruction.

            // Write the new instructions.
            ASM_HUD_FOV_Horizontal_Instruction_Override.AddRange(new byte[] { 0x8B, 0x15 });                             // mov edx
            ASM_HUD_FOV_Horizontal_Instruction_Override.AddRange(BitConverter.GetBytes((int)Menu_Center_Value_Address)); // Address for mov edx.

            // Write the new instructions.
            ASM_HUD_FOV_Vertical_Instruction_Override.AddRange(new byte[] { 0xA1 });                                                                                                                // mov eax
            ASM_HUD_FOV_Vertical_Instruction_Override.AddRange(BitConverter.GetBytes((int)Menu_Vertical_Center_Value_Address));                                                                     // Address for mov eax.

            ASM_Menu_FOV_Instruction_Horizontal_Override.AddRange(new byte[] { 0xD9, 0x05 });                                                                                                       // fld
            ASM_Menu_FOV_Instruction_Horizontal_Override.AddRange(BitConverter.GetBytes((int)FOV_ASM_Menu_Horizontal_Value_Address));                                                               // Address for fld.

            ASM_Menu_FOV_Instruction_Vertical_Override.AddRange(new byte[] { 0xD9, 0x05 });                                                                                                         // fld
            ASM_Menu_FOV_Instruction_Vertical_Override.AddRange(BitConverter.GetBytes((int)FOV_ASM_Menu_Vertical_Value_Address));                                                                   // Address for fld.

            Victory_Screen_FOV_X_Instruction_Override.AddRange(new byte[] { 0xD8, 0x0D });                                                                                                          // FMUL
            Victory_Screen_FOV_Y_Instruction_Override.AddRange(new byte[] { 0xD8, 0x0D });                                                                                                          // FMUL
            Victory_Screen_FOV_X_Instruction_Override.AddRange(BitConverter.GetBytes((int)SonicHeroes.Variables.SonicHeroesVariables.Game_Field_Of_View_and_Aspect_Ratio.Horizontal_Aspect_Ratio)); // Point address to X FOV
            Victory_Screen_FOV_Y_Instruction_Override.AddRange(BitConverter.GetBytes((int)SonicHeroes.Variables.SonicHeroesVariables.Game_Field_Of_View_and_Aspect_Ratio.Vertical_Aspect_Ratio));   // Point address to Y FOV

            // Enable Menu FOV Fix on Game Launch
            Set_Menu_Scale();

            // Set Hooks
            Menu_Enter_Hook    = new SonicHeroes.Hooking.Injection((IntPtr)0x6B842C, (Enable_Menu_FOV)Enable_Menu_Scaling, 6, Program.Sonic_Heroes_Networking_Client, false);
            Menu_Exit_Hook     = new SonicHeroes.Hooking.Injection((IntPtr)0x6B84FC, (Enable_Menu_FOV)Disable_Menu_Scaling, 8, Program.Sonic_Heroes_Networking_Client, false);
            Results_Enter_Hook = new SonicHeroes.Hooking.Injection((IntPtr)0x6CECB0, (Set_Results_Menu_Location_Live)Set_Results_Menu_Location, 6, Program.Sonic_Heroes_Networking_Client, false);
            Menu_Enter_Hook.Activate();
            Menu_Exit_Hook.Activate();
            //Results_Enter_Hook.Activate();
        }