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 ResolutionVariablePatcher(Config.Config config) { _config = new Config.Config(); OnLocationChangeEventHandler = OnLocationChange; User32.SetWinEventHook(EventObjectLocationchange, EventObjectLocationchange, HINSTANCE.NULL, OnLocationChangeEventHandler, (uint)Process.GetCurrentProcess().Id, 0, User32.WINEVENT.WINEVENT_OUTOFCONTEXT); _draw2PViewPortHook = new Hook <sub_422AF0>(Draw2PViewportHook, 0x422AF0).Activate(); _drawSpecialStageGaugeHook = new Hook <sub_5263C0>(DrawSpecialStageGaugeImpl, 0x5263C0).Activate(); _drawSpecialStageBarHook = new Hook <sub_526280>(DrawSpecialStageBarImpl, 0x526280, 0xD).Activate(); _drawSpecialStageEmeraldIndicatorHook = new Hook <sub_458920>(DrawSpecialStageEmeraldImpl, 0x458920).Activate(); _draw2PStatusHook = new Hook <sub_422A70>(Draw2pStatusImpl, 0x422A70).Activate(); _renderPrimitiveHook = new Hook <_rwD3D8Im2DRenderPrimitive>(RenderPrimitiveImpl, 0x00662B00).Activate(); _renderVideoHook = new Hook <sub_644450>(RenderVideoHookImpl, 0x644450).Activate(); _drawFullVideoFrameHook = new Hook <DrawFullVideoFrame>(DrawFullVideoFrameHookImpl, 0x0042A100).Activate(); _drawSmallVideoFrameHook = new Hook <DrawSmallFrame>(DrawSmallFrameImpl, 0x00429F80).Activate(); _drawTitlecardElementsHook = new Hook <sub_442850>(DrawTitlecardElementsImpl, 0x442850).Activate(); _drawSpecialStageLinkHook = new Hook <sub_526F60>(DrawSpecialStageLinkImpl, 0x526F60).Activate(); _getVertexBufferSubmission = Wrapper.Create <sub_651E20>(0x651E20); _drawNowLoadingHook = new Hook <sub_44EAC0>(DrawNowLoadingImpl, 0x44EAC0).Activate(); _executeCreditsHook = new Hook <sub_4545F0>(ExecuteCredits, 0x4545F0).Activate(); }