Skip to content

Commit

Permalink
fix: support for latest patch
Browse files Browse the repository at this point in the history
feat: upwards teleport
  • Loading branch information
ATX authored and ATX committed Sep 22, 2021
1 parent 38a2faa commit 4a8cf47
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 15 deletions.
11 changes: 6 additions & 5 deletions MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
<Label x:Name="positionLabel" Content="Position" HorizontalAlignment="Left" Height="35" Margin="10,3,0,0" VerticalAlignment="Top" Width="196" FontSize="20" Foreground="White" FontWeight="Bold"/>
<TextBlock x:Name="positionLabelBlock" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="17,41,0,0" Height="85" Width="61" FontSize="20" Foreground="White" TextAlignment="Left"><Run Text="x"/><LineBreak/><Run Text="y"/><LineBreak/><Run Text="z"/></TextBlock>
<TextBlock x:Name="positionBlock" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="78,41,0,0" Height="85" Width="116" FontSize="20" Foreground="White" TextAlignment="Right"/>
<Button x:Name="godModeBtn" Content="[F2] God Mode" HorizontalAlignment="Left" Height="28" Margin="218,47,0,0" VerticalAlignment="Top" Width="200" FontSize="16" Background="#FF666666" Foreground="White" BorderBrush="#FF040404" Click="godModeBtn_Click" />
<Label x:Name="godModeLabel" Content="OFF" HorizontalAlignment="Left" Height="35" Margin="423,46,0,0" VerticalAlignment="Top" Width="46" FontSize="16" FontWeight="Bold" Foreground="Red" RenderTransformOrigin="0.571,-1.489" />
<Button x:Name="ammoBtn" Content="[F3] Unlimited Ammo" HorizontalAlignment="Left" Height="28" Margin="218,82,0,0" VerticalAlignment="Top" Width="200" FontSize="16" Background="#FF666666" Foreground="White" BorderBrush="#FF040404" Click="ammoBtn_Click" />
<Label x:Name="ammoLabel" Content="OFF" HorizontalAlignment="Left" Height="35" Margin="423,81,0,0" VerticalAlignment="Top" Width="46" FontSize="16" FontWeight="Bold" Foreground="Red" RenderTransformOrigin="0.571,-1.489" />
<Button x:Name="godModeBtn" Content="[F3] God Mode" HorizontalAlignment="Left" Height="28" Margin="218,78,0,0" VerticalAlignment="Top" Width="200" FontSize="16" Background="#FF666666" Foreground="White" BorderBrush="#FF040404" Click="godModeBtn_Click" />
<Label x:Name="godModeLabel" Content="OFF" HorizontalAlignment="Left" Height="35" Margin="423,77,0,0" VerticalAlignment="Top" Width="46" FontSize="16" FontWeight="Bold" Foreground="Red" RenderTransformOrigin="0.571,-1.489" />
<Button x:Name="ammoBtn" Content="[F4] Infinite Ammo" HorizontalAlignment="Left" Height="28" Margin="218,111,0,0" VerticalAlignment="Top" Width="200" FontSize="16" Background="#FF666666" Foreground="White" BorderBrush="#FF040404" Click="ammoBtn_Click" />
<Label x:Name="ammoLabel" Content="OFF" HorizontalAlignment="Left" Height="35" Margin="423,110,0,0" VerticalAlignment="Top" Width="46" FontSize="16" FontWeight="Bold" Foreground="Red" RenderTransformOrigin="0.571,-1.489" />
<Button x:Name="teleUpBtn" Content="[F2] Teleport Up" HorizontalAlignment="Left" Height="28" Margin="218,45,0,0" VerticalAlignment="Top" Width="200" FontSize="16" Background="#FF666666" Foreground="White" BorderBrush="#FF040404" Click="teleUpBtn_Click" />

</Grid>

</Window>
</Window>
86 changes: 76 additions & 10 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ public partial class MainWindow : Window
public bool hooked = false;

DeepPointer characterDP = new DeepPointer(0x02D5F688, 0x8, 0x8, 0x98, 0xA0, 0x1F0, 0x0);
DeepPointer rotationDP = new DeepPointer(0x810, 0x0);
DeepPointer statusDP = new DeepPointer(0x900);

IntPtr xVelPtr, yVelPtr, zVelPtr, xPosPtr, yPosPtr, zPosPtr, godPtr, ammoPtr;
IntPtr xVelPtr, yVelPtr, zVelPtr, xPosPtr, yPosPtr, zPosPtr, godPtr, ammoPtr, rotAPtr, rotBPtr;

bool god, ammo, teleFw = false;
bool god, ammo, teleFw, teleUp = false;
float[] storedPos = new float[5] { 0f, 0f, 0f, 0f, 0f };


float xVel, yVel, zVel, xPos, yPos, zPos;
float xVel, yVel, zVel, xPos, yPos, zPos, rotA, rotB;

private void teleportFwBtn_Click(object sender, RoutedEventArgs e)
{
Expand All @@ -45,6 +46,17 @@ private void ammoBtn_Click(object sender, RoutedEventArgs e)
ToggleAmmo();
}

private void Button_Click(object sender, RoutedEventArgs e)
{
TestFunction();
}

private void teleUpBtn_Click(object sender, RoutedEventArgs e)
{
e.Handled = true;
TeleportUpward();
}

private void saveBtn_Click(object sender, RoutedEventArgs e)
{
e.Handled = true;
Expand Down Expand Up @@ -96,7 +108,6 @@ private void Update(object sender, EventArgs e)
return;
}

Debug.WriteLine(game.Modules.Count);

game.ReadValue<float>(xPosPtr, out xPos);
game.ReadValue<float>(yPosPtr, out yPos);
Expand All @@ -107,6 +118,9 @@ private void Update(object sender, EventArgs e)
game.ReadValue<float>(zVelPtr, out zVel);
double hVel = (Math.Sqrt(xVel * xVel + yVel * yVel));

game.ReadValue<float>(rotAPtr, out rotA);
game.ReadValue<float>(rotBPtr, out rotB);

game.ReadValue<bool>(godPtr, out god);
game.ReadValue<bool>(ammoPtr, out ammo);

Expand All @@ -121,6 +135,10 @@ private void Update(object sender, EventArgs e)
{
TeleportForward();
}
if (teleUp)
{
TeleportUpward();
}
}

private bool Hook()
Expand Down Expand Up @@ -179,6 +197,10 @@ private void DerefPointers()
godPtr = statusBasePtr + 0x10;
ammoPtr = statusBasePtr + 0x20;

rotationDP.DerefOffsets(game, out basePtr);
rotAPtr = basePtr + 0x1B4;
rotBPtr = basePtr + 0x1B8;

}

private void InputKeyDown(object sender, KeyEventArgs e)
Expand All @@ -189,9 +211,12 @@ private void InputKeyDown(object sender, KeyEventArgs e)
teleFw = true;
break;
case Keys.F2:
ToggleGod();
teleUp = true;
break;
case Keys.F3:
ToggleGod();
break;
case Keys.F4:
ToggleAmmo();
break;
case Keys.F5:
Expand Down Expand Up @@ -227,9 +252,7 @@ private void TeleportForward()
if (!hooked)
return;

float a = new DeepPointer(0x3283134).Deref<float>(game);
float b = new DeepPointer(0x3283138).Deref<float>(game);
System.Windows.Media.Media3D.Quaternion q = new System.Windows.Media.Media3D.Quaternion(0, b, 0, a);
System.Windows.Media.Media3D.Quaternion q = new System.Windows.Media.Media3D.Quaternion(0, rotB, 0, rotA);
float angle = ((float)((q.Angle / 2) * -q.Axis.Y));
angle = (float)(angle / 180 * Math.PI);

Expand All @@ -243,6 +266,22 @@ private void TeleportForward()
game.WriteBytes(yPosPtr, BitConverter.GetBytes((float)(yPos + (float)(y * scale * 1))));
}

private void TeleportUpward()
{
if (!hooked)
return;


float scale = 1f;
if(zVel < 0.0f)
{
scale = Math.Abs(zVel) / 10;
}

game.WriteBytes(zPosPtr, BitConverter.GetBytes((float)(zPos + (float)(scale * 1))));

}

private void Teleport()
{
if (!hooked)
Expand Down Expand Up @@ -285,6 +324,9 @@ private void InputKeyUp(object sender, KeyEventArgs e)
case Keys.F1:
teleFw = false;
break;
case Keys.F2:
teleUp = false;
break;
}
e.Handled = true;
}
Expand Down Expand Up @@ -399,6 +441,12 @@ private bool WriteFunctionHooks()
jumpCode = StringToByteArray("E9 " + IntPtrToASMString(new IntPtr((uint)jumpOffset), 4) + " 90");
game.WriteBytes(consumeAmmoPtr, jumpCode);

SigScanTarget rotationTarget = new SigScanTarget("48 89 5D 28 48 8B D3 48 8D 0D ?? ?? ?? ??");
IntPtr ptr = scanner.Scan(rotationTarget) + 0xA;
ptr += game.ReadValue<int>(ptr) + 0x4;
_ = new DeepPointer(0x810).DerefOffsets(game, out IntPtr newRotPtr);
game.WriteBytes(newRotPtr, BitConverter.GetBytes(ptr.ToInt64()));

game.WriteValue<byte>(statusPtr, 0x1);
return true;
}
Expand All @@ -410,7 +458,7 @@ byte[] StringToByteArray(string input)
byte[] output = new byte[byteStringArray.Length];
for (int i = 0; i < byteStringArray.Length; i++)
{
output[i] = Byte.Parse(byteStringArray[i], System.Globalization.NumberStyles.HexNumber);
output[i] = byte.Parse(byteStringArray[i], System.Globalization.NumberStyles.HexNumber);
}
return output;
}
Expand All @@ -429,5 +477,23 @@ string IntPtrToASMString(IntPtr input, int length = 8)
return output;
}


void TestFunction()
{
SignatureScanner scanner = new SignatureScanner(game, game.MainModule.BaseAddress, game.MainModule.ModuleMemorySize);
/*
Deathloop.exe+C0CDF5 - 42 89 04 37 - mov [rdi+r14],eax
Deathloop.exe+C0CDF9 - 48 83 C3 20 - add rbx,20
Deathloop.exe+C0CDFD - 48 89 5D 28 - mov [rbp+28],rbx
Deathloop.exe+C0CE01 - 48 8B D3 - mov rdx,rbx
Deathloop.exe+C0CE04 - 48 8D 0D A5616702 - lea rcx,[Deathloop.exe+3282FB0] <---
*/
SigScanTarget rotationTarget = new SigScanTarget("48 89 5D 28 48 8B D3 48 8D 0D ?? ?? ?? ??");
IntPtr ptr = scanner.Scan(rotationTarget) + 0xA;
ptr += game.ReadValue<int>(ptr) + 0x4;
_ = new DeepPointer(0x810).DerefOffsets(game, out IntPtr newRotPtr);
game.WriteBytes(newRotPtr, BitConverter.GetBytes(ptr.ToInt64()));
}

}
}
}

0 comments on commit 4a8cf47

Please sign in to comment.