public RenderHooks(float aspectRatioLimit, IReloadedHooks hooks) { _memory = Memory.CurrentProcess; _aspectConverter = new AspectConverter(aspectRatioLimit); _draw2PViewPortHook = hooks.CreateHook <sub_422AF0>(Draw2PViewportHook, 0x422AF0).Activate(); _drawSpecialStageGaugeHook = hooks.CreateHook <sub_5263C0>(DrawSpecialStageGaugeImpl, 0x5263C0).Activate(); _drawSpecialStageBarHook = hooks.CreateHook <sub_526280>(DrawSpecialStageBarImpl, 0x526280, 0xD).Activate(); _draw2PStatusHook = hooks.CreateHook <sub_422A70>(Draw2pStatusImpl, 0x422A70).Activate(); _renderPrimitiveHook = hooks.CreateHook <_rwD3D8Im2DRenderPrimitive>(RenderPrimitiveImpl, 0x00662B00).Activate(); _renderVideoHook = hooks.CreateHook <sub_644450>(RenderVideoHookImpl, 0x644450).Activate(); _drawFullVideoFrameHook = hooks.CreateHook <DrawFullVideoFrame>(DrawFullVideoFrameHookImpl, 0x0042A100).Activate(); _drawSmallVideoFrameHook = hooks.CreateHook <DrawSmallFrame>(DrawSmallFrameImpl, 0x00429F80).Activate(); _drawTitlecardElementsHook = hooks.CreateHook <sub_442850>(DrawTitlecardElementsImpl, 0x442850).Activate(); _drawSpecialStageLinkHook = hooks.CreateHook <sub_526F60>(DrawSpecialStageLinkImpl, 0x526F60).Activate(); _getVertexBufferSubmission = hooks.CreateWrapper <sub_651E20>(0x651E20, out _); _drawNowLoadingHook = hooks.CreateHook <sub_44EAC0>(DrawNowLoadingImpl, 0x44EAC0).Activate(); _executeCreditsHook = hooks.CreateHook <sub_4545F0>(ExecuteCredits, 0x4545F0).Activate(); _drawResultScreenDotsHook = hooks.CreateHook <sub_438A90>(DrawResultScreenDotsImpl, 0x438A90).Activate(); _drawPowerupBoxHook = hooks.CreateHook <DrawPowerupBox>(DrawPowerupBoxImpl, 0x479AB0).Activate(); _drawEmeraldHookReverseWrap = hooks.CreateReverseWrapper <DrawEmeraldHook>(DrawSpecialStageEmeraldImpl); _addressOfHook = new Pinnable <IntPtr>(_drawEmeraldHookReverseWrap.WrapperPointer); _drawSpecialStageEmeraldIndicatorHook = hooks.CreateAsmHook(new[] { "use32", // Offset to first param (after execution of code) "push eax", // + 8 "push esi", // + 12 "push ecx", // + 16 "push edx", // + 20 /* Push address of stack parameters up stack. */ "lea edx, [esp + 32]", "lea ecx, [esp + 28]", "lea ebx, [esp + 24]", "lea eax, [esp + 20]", "push edx", "push ecx", "push ebx", "push eax", $"call dword [0x{(long)_addressOfHook.Pointer:X}]", "add esp, 16", "pop edx", "pop ecx", "pop esi", "pop eax" }, 0x458920).Activate(); _memory.ChangePermission((IntPtr)_descriptionX, sizeof(void *), Kernel32.MEM_PROTECTION.PAGE_EXECUTE_READWRITE); _memory.ChangePermission((IntPtr)_descriptionY, sizeof(void *), Kernel32.MEM_PROTECTION.PAGE_EXECUTE_READWRITE); _memory.ChangePermission((IntPtr)_descriptionWidth, sizeof(void *), Kernel32.MEM_PROTECTION.PAGE_EXECUTE_READWRITE); _memory.ChangePermission((IntPtr)_descriptionHeight, sizeof(void *), Kernel32.MEM_PROTECTION.PAGE_EXECUTE_READWRITE); _memory.ChangePermission((IntPtr)_pickupBoxSeparation, sizeof(void *), Kernel32.MEM_PROTECTION.PAGE_EXECUTE_READWRITE); _memory.ChangePermission((IntPtr)_dotsVertSeparation, sizeof(void *), Kernel32.MEM_PROTECTION.PAGE_EXECUTE_READWRITE); _memory.ChangePermission((IntPtr)_dotsHorzSeparation, sizeof(void *), Kernel32.MEM_PROTECTION.PAGE_EXECUTE_READWRITE); _memory.ChangePermission((IntPtr)_dotsHeight, sizeof(void *), Kernel32.MEM_PROTECTION.PAGE_EXECUTE_READWRITE); _memory.ChangePermission((IntPtr)_dotsWidth, sizeof(void *), Kernel32.MEM_PROTECTION.PAGE_EXECUTE_READWRITE); }
public DebugBoot(string modDirectory, IReloadedHooks hooks) { // Setup Config _configurator = new Configurator(modDirectory); _config = _configurator.GetConfiguration <Config.Config>(0); _config.ConfigurationUpdated += configurable => { _config = (Config.Config)configurable; ConfigToPinnable(_config); Console.WriteLine($"Debug Boot Configuration Updated. Set new main menu mode."); }; ConfigToPinnable(_config); // Apply Boot Time Constants *_stageId = _config.BootOptions.Stage; *_teamOne = _config.BootOptions.TeamP1; *_teamTwo = _config.BootOptions.TeamP2; *_teamThree = _config.BootOptions.TeamP3; *_teamFour = _config.BootOptions.TeamP4; // Setup mid function hooks. // Disasm name: Main::Loop string[] asmHookSetMainMenu = { $"use32", $"mov ecx, dword [{(IntPtr)_mainMenuSystemMode.Pointer}]", // New line, sacrificing ECX. $"mov [eax + 0x38], ecx", $"mov ecx, [esi]", $"mov [esi + 4], edi", }; string[] asmHookStartGame = { $"use32", $"mov [{(IntPtr)_ediBackup.Pointer}], edi", // Backup EDI $"mov edi, dword [{(IntPtr)_bootSystemMode.Pointer}]", // Replace EDI $"mov [0xA82034], ebp", $"mov [eax + 0x38], edi", // Set SystemMode $"mov edi, dword [{(IntPtr)_ediBackup.Pointer}]", // Restore EDI }; _loadMainMenuHook = hooks.CreateAsmHook(asmHookSetMainMenu, 0x427342, AsmHookBehaviour.DoNotExecuteOriginal).Activate(); _bootHook = hooks.CreateAsmHook(asmHookStartGame, 0x00427138, AsmHookBehaviour.DoNotExecuteOriginal).Activate(); }
public DefaultSettingsHook(DefaultSettings defaultSettings, IReloadedHooks hooks) { DefaultSettings = defaultSettings; ReadConfigFromIniHook = hooks.CreateHook <ReadConfigfromINI>(ReadConfigFromIni, 0x00629CE0).Activate(); }
public AspectRatioHook(float aspectRatioLimit, IReloadedHooks hooks) { AspectRatioLimit = aspectRatioLimit; SetViewWindowHook = hooks.CreateHook <RwCameraSetViewWindow>(SetViewWindowImpl, 0x0064AC80).Activate(); }
public ClippingPlanesHook(float aspectLimit, IReloadedHooks hooks) { AspectRatioLimit = aspectLimit; BuildClipPlanesHook = hooks.CreateHook <CameraBuildPerspClipPlanes>(BuildClipPlanesImpl, 0x0064AF80).Activate(); }
public StageLoadCrashFixHook(IReloadedHooks hooks) { _cameraInitHook = hooks.CreateHook <TObjCamera_Init>(TObjCameraInit, 0x0061D3B0).Activate(); }