Skip to content

Commit

Permalink
Changed: Revert to Reloaded.Memory 5.0.X
Browse files Browse the repository at this point in the history
  • Loading branch information
Sewer56 committed May 7, 2024
1 parent 89d9a5e commit 95d5d98
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PackageReference Include="MessagePack" Version="2.3.85" />
<PackageReference Include="MessagePackAnalyzer" Version="2.3.85" />
<PackageReference Include="Ninject" Version="3.3.4" />
<PackageReference Include="Reloaded.Memory" Version="8.0.1" />
<PackageReference Include="Reloaded.Memory" Version="5.1.0" />
<PackageReference Include="Reloaded.WPF.Animations" Version="1.2.3" />
<PackageReference Include="StructLinq" Version="0.27.1" />
<PackageReference Include="ToString.Fody" Version="1.11.0" />
Expand Down
4 changes: 2 additions & 2 deletions Riders.Tweakbox/Components/Debug/DolphinDumperWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ private unsafe void ImportGears()
return;

var memory = new ExternalMemory(process);
var pointer = new FixedArrayPtr<ExtremeGear>((nuint)dolphinAddress, Player.OriginalNumberOfGears, true, memory);
var pointer = new FixedArrayPtr<ExtremeGear>((ulong)dolphinAddress, Player.OriginalNumberOfGears, true, memory);
var nativeGearPtr = (ExtremeGear*)Player.Gears.Pointer;

for (var x = 0; x < pointer.Count; x++)
{
// Copy gear data.
var copiedGearPtr = pointer.GetPointerToElement(x);
memory.ReadRaw((nuint)copiedGearPtr, out byte[] copiedGearBytes, pointer.ElementSize);
memory.ReadRaw((IntPtr)copiedGearPtr, out byte[] copiedGearBytes, pointer.ElementSize);

// Swap endian of known data.
Reflection.SwapStructEndianness(typeof(ExtremeGear), copiedGearBytes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ private void PatchMaxGearId(int maxId)

private void SetupNewPointers<T>(string pointerName, ref T[] output, ref RefFixedArrayPtr<T> apiEndpoint, int[] sourceAddresses) where T : unmanaged
{
var fixedArrayPtr = new FixedArrayPtr<T>((nuint)apiEndpoint.Pointer, apiEndpoint.Count);
var fixedArrayPtr = new FixedArrayPtr<T>((ulong)apiEndpoint.Pointer, apiEndpoint.Count);
SetupNewPointers(pointerName, ref output, ref fixedArrayPtr, sourceAddresses);
apiEndpoint = new RefFixedArrayPtr<T>((nuint)fixedArrayPtr.Pointer, fixedArrayPtr.Count);
apiEndpoint = new RefFixedArrayPtr<T>((ulong)fixedArrayPtr.Pointer, fixedArrayPtr.Count);
}

private void SetupNewPointers<T>(string pointerName, ref T[] output, ref FixedArrayPtr<T> apiEndpoint, int[] sourceAddresses) where T : unmanaged
Expand All @@ -148,15 +148,15 @@ private void SetupNewPointers<T>(string pointerName, ref T[] output, ref FixedAr
fixed (T* ptr = output)
{
// Fix pointer in library.
apiEndpoint = new FixedArrayPtr<T>((nuint)ptr, MaxGearCount);
apiEndpoint = new FixedArrayPtr<T>((ulong)ptr, MaxGearCount);

// Patch all pointers in game code.
var originalAddress = (byte*)originalData.Pointer;
var newAddress = (byte*)ptr;

foreach (var codePointer in sourceAddresses)
{
Memory.Instance.SafeRead((nuint)codePointer, out int address);
Memory.Instance.SafeRead((IntPtr)codePointer, out int address);
var offset = (byte*)(address) - originalAddress;
var target = newAddress + offset;
Memory.Instance.SafeWrite((IntPtr)codePointer, (int)target);
Expand Down
2 changes: 1 addition & 1 deletion Riders.Tweakbox/Controllers/MissingModelController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public MissingModelController(IReloadedHooks hooks)
_loadPlayerModelMenuHook = hooks.CreateAsmHook(menuHookAsm, 0x00460C26, AsmHookBehaviour.ExecuteFirst).Activate();

// Compare Super Sonic Gear Model instead of Gear Id
Memory.Instance.WriteRaw(0x460BCB, new byte[] { 0x83, 0xFB, 0x12, 0x90, 0x90, 0x90, 0x90 }); // cmp ebx, 0x12
Memory.Instance.WriteRaw((IntPtr)0x460BCB, new byte[] { 0x83, 0xFB, 0x12, 0x90, 0x90, 0x90, 0x90 }); // cmp ebx, 0x12

string[] changeCharacterToSuperAsm = new[]
{
Expand Down
4 changes: 2 additions & 2 deletions Riders.Tweakbox/Controllers/StartupRestrictionKill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ public class StartupRestrictionKill : IController
public StartupRestrictionKill()
{
// Ignore launcher check result.
Memory.CurrentProcess.SafeWriteRaw(0x005118CF, _jmpSkipLauncher);
Memory.CurrentProcess.SafeWriteRaw((IntPtr)0x005118CF, _jmpSkipLauncher);

// Ignore only one instance check result.
Memory.CurrentProcess.SafeWriteRaw(0x0051190F, _jmpSkipOneInstance);
Memory.CurrentProcess.SafeWriteRaw((IntPtr)0x0051190F, _jmpSkipOneInstance);
}
}
}
2 changes: 1 addition & 1 deletion Riders.Tweakbox/Misc/Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public Patch(IntPtr address, byte[] bytes, bool changePermission = false)
/// </summary>
public unsafe Patch ChangePermission()
{
Memory.CurrentProcess.ChangePermission((nuint)_address, _bytes.Length, Kernel32.MEM_PROTECTION.PAGE_EXECUTE_READWRITE);
Memory.CurrentProcess.ChangePermission(_address, _bytes.Length, Kernel32.MEM_PROTECTION.PAGE_EXECUTE_READWRITE);
return this;
}

Expand Down
2 changes: 1 addition & 1 deletion Riders.Tweakbox/Riders.Tweakbox.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
<PackageReference Include="Ninject" Version="3.3.4" />
<PackageReference Include="Reloaded.Imgui.Hook" Version="3.0.0" />
<PackageReference Include="Reloaded.Imgui.Hook.Direct3D9" Version="1.0.2" />
<PackageReference Include="Reloaded.Memory" Version="8.0.1" />
<PackageReference Include="Reloaded.Memory" Version="5.1.0" />
<PackageReference Include="Reloaded.Mod.Interfaces" Version="2.1.0" />
<PackageReference Include="Reloaded.SharedLib.Hooks" Version="1.9.0" />
<PackageReference Include="Reloaded.WPF.Animations" Version="1.2.3" />
Expand Down

0 comments on commit 95d5d98

Please sign in to comment.