Exemple #1
0
 public Data(Buffer2D <Vector4> buffer)
 {
     this.pointer  = (Vector4 *)buffer.Pin();
     this.pinnable = Unsafe.As <Pinnable <Vector4> >(buffer.Array);
     this.array    = buffer.Array;
     this.width    = buffer.Width;
 }
 public PinnedStageConfig(StageConfig config)
 {
     StartPositions = new Pinnable <PositionStart>(config.StartPositions);
     EndPositions   = new Pinnable <PositionEnd>(config.EndPositions);
     BragPositions  = new Pinnable <PositionEnd>(config.BragPositions);
     StageId        = config.StageId;
 }
Exemple #3
0
        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);
        }
Exemple #4
0
        public void Setup()
        {
            this.width    = 2048;
            this.buffer   = new Buffer2D <Vector4>(2048, 2048);
            this.pointer  = (Vector4 *)this.buffer.Pin();
            this.array    = this.buffer.Array;
            this.pinnable = Unsafe.As <Pinnable <Vector4> >(this.array);

            this.startIndex = 2048 / 2 - (this.Count / 2);
            this.endIndex   = 2048 / 2 + (this.Count / 2);
        }
Exemple #5
0
        public DefaultStage(Stage stageId)
        {
            StageId = stageId;
            var stageInfo = StageInfo.FromStageId(stageId);

            if (stageInfo.MultiplayerStartPositions != null)
            {
                // For Rose and Chaotix copy 1P and 2P spawns in multiplayer.
                _startPositionsSingleInMultiplayer = new Pinnable <PositionStart>(new[]
                {
                    stageInfo.MultiplayerStartPositions->Player1Start,
                    stageInfo.MultiplayerStartPositions->Player2Start,
                    stageInfo.MultiplayerStartPositions->Player1Start,
                    stageInfo.MultiplayerStartPositions->Player2Start
                });

                StartPositions = _startPositionsSingleInMultiplayer.Pointer;
            }
            else
            {
                if (stageInfo.StartPositions != null)
                {
                    StartPositions = &stageInfo.StartPositions->SonicStart;
                }
            }

            if (stageInfo.MultiplayerBragPositions != null)
            {
                BragPositions = &stageInfo.EndPositions->SonicEnd;
            }

            if (stageInfo.EndPositions != null)
            {
                EndPositions = &stageInfo.EndPositions->SonicEnd;
            }

            /* Replace any nulls with defaults. */
            if (StartPositions == null)
            {
                StartPositions = _defaultStartPositions.Pointer;
            }

            if (EndPositions == null)
            {
                EndPositions = _defaultEndPositions.Pointer;
            }

            if (BragPositions == null)
            {
                BragPositions = _defaultEndPositions.Pointer;
            }
        }