Пример #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); }
        }
Пример #2
0
        public Feature_Force_Load_Level()
        {
            // Retrieves all of the available possible levels that could be loaded, as well as their individual Stage IDs.
            Get_All_Levels();

            /// <summary>
            /// x86 Mnemonics which dynamically load the appropriate blending address based on the currently controlling character.
            /// </summary>
            string[] Menu_Enter_Hook_ASM_Mnemonics = new string[]
            {
                "use32",
                "mov eax,[edi+0x58]",
                "push dword 0x40578D",
                "ret"
            };

            // Get Assembly Code for the Mnemonics
            byte[] Menu_Enter_Hook_ASM_Bytes = Program.Sonic_Heroes_Networking_Client.SendData_Alternate(Message_Type.Client_Call_Assemble_x86_Mnemonics, Serialize_x86_ASM_Mnemonics(Menu_Enter_Hook_ASM_Mnemonics), true);

            // Set Hook - Hooked at random address triggered post loading of main menu.
            Menu_Enter_Hook_ASM = new SonicHeroes.Hooking.ASM_Hook((IntPtr)0x405785, Menu_Enter_Hook_ASM_Bytes, 8, Program.Sonic_Heroes_Networking_Client, true);

            // Activate Hook Such that Menu_Enter_Hook Picks up the New Bytes.
            Menu_Enter_Hook_ASM.Activate();

            // Set Hook - Hooked at random address triggered post loading of main menu.
            Menu_Enter_Hook = new SonicHeroes.Hooking.Injection((IntPtr)0x405785, (Force_Level_Load_Hook)Force_Load_Level_Method, 8, Program.Sonic_Heroes_Networking_Client, false);

            // Deactivate Hook.
            Menu_Enter_Hook_ASM.Deactivate();

            // At startup set initial teams to be Team Sonic for P1 and disable others
            Program.Sonic_Heroes_Process.WriteMemory((IntPtr)0x8D6920, new byte[] { 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF });
        }
        // 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();
        }