Skip to content

Commit

Permalink
updated to include wireframe toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
Daylonz committed Feb 9, 2021
1 parent 315743a commit 2595e87
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 18 deletions.
42 changes: 35 additions & 7 deletions MCCBounceEnable/src/UIForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 65 additions & 11 deletions MCCBounceEnable/src/UIForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ public partial class UIForm : Form

private static readonly int VK_MENU = 0x12; //Alt key.
private static readonly int VK_O = 0x4F; //O key.
private static readonly int VK_W = 0x57; //W key.
private DateTime lastHotkeyPress = DateTime.Now;

Controller controller = null;

public readonly IMemoryPattern test = new DwordPattern("48 8B 05 ?? ?? ?? ?? F3 0F 10 40 04 C3 CC CC CC 48 8B 05");
private IntPtr lastAddr = IntPtr.Zero;
public readonly IMemoryPattern tickRatePattern = new DwordPattern("48 8B 05 ?? ?? ?? ?? F3 0F 10 40 04 C3 CC CC CC 48 8B 05");
public readonly IMemoryPattern wireFramePattern = new DwordPattern("BB 02 00 00 00 0F B6");

private IntPtr lastTRAddr = IntPtr.Zero;
private IntPtr lastWFAddr = IntPtr.Zero;

byte[] value30 = { 0x1E, 0x00, 0x89, 0x88, 0x08, 0x3D };
byte[] value60 = { 0x3C, 0x00, 0x89, 0x88, 0x88, 0x3C };
Expand Down Expand Up @@ -70,13 +74,13 @@ public void setTickrate(int desired)
var process = getProcess();
process.Memory = new ExternalProcessMemory(process.Handle);
byte[] addressValue;
if (lastAddr != IntPtr.Zero)
if (lastTRAddr != IntPtr.Zero)
{
addressValue = process.Memory.Read(lastAddr, 6);
addressValue = process.Memory.Read(lastTRAddr, 6);
if (!addressValue.SequenceEqual(value30) && !addressValue.SequenceEqual(value60))
{
PatternScanner scanner = new PatternScanner(process["halo2.dll"]);
PatternScanResult result = scanner.Find(test);
PatternScanResult result = scanner.Find(tickRatePattern);
if (!result.Found)
{
MessageBox.Show("Could not find tick rate in memory. Make sure you're in a game!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Expand All @@ -86,13 +90,13 @@ public void setTickrate(int desired)
IntPtr addressLocation = (result.ReadAddress + 7 + BitConverter.ToInt32(offset, 0));
addressValue = process.Memory.Read(addressLocation, 8);
IntPtr tickAddress = new IntPtr(BitConverter.ToInt64(addressValue, 0) + 2);
lastAddr = tickAddress;
lastTRAddr = tickAddress;
}
}
else
{
PatternScanner scanner = new PatternScanner(process["halo2.dll"]);
PatternScanResult result = scanner.Find(test);
PatternScanResult result = scanner.Find(tickRatePattern);
if (!result.Found)
{
MessageBox.Show("Could not find tick rate in memory. Make sure you're in a game!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Expand All @@ -102,26 +106,63 @@ public void setTickrate(int desired)
IntPtr addressLocation = (result.ReadAddress + 7 + BitConverter.ToInt32(offset, 0));
addressValue = process.Memory.Read(addressLocation, 8);
IntPtr tickAddress = new IntPtr(BitConverter.ToInt64(addressValue, 0) + 2);
lastAddr = tickAddress;
lastTRAddr = tickAddress;
}

if (desired == 30)
{
process.Memory.Write(lastAddr, value30);
process.Memory.Write(lastTRAddr, value30);
}

if (desired == 60)
{
process.Memory.Write(lastAddr, value60);
process.Memory.Write(lastTRAddr, value60);
}
}
catch (Win32Exception e)
{
lastAddr = IntPtr.Zero;
lastTRAddr = IntPtr.Zero;
setTickrate(desired);
}
}

public void toggleWireFrame(bool activate)
{
try
{
var process = getProcess();
process.Memory = new ExternalProcessMemory(process.Handle);
byte[] addressValue;
if (lastWFAddr == IntPtr.Zero)
{
PatternScanner scanner = new PatternScanner(process["halo2.dll"]);
PatternScanResult result = scanner.Find(wireFramePattern);
if (!result.Found)
{
MessageBox.Show("Could not find wire frame in memory. Make sure you're in a game!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
byte[] offset = process.Memory.Read(result.ReadAddress + 8, 4);
IntPtr addressLocation = (result.ReadAddress + 12 + BitConverter.ToInt32(offset, 0));
lastWFAddr = addressLocation;
}

if (activate)
{
process.Memory.Write(lastWFAddr, 1);
}
else
{
process.Memory.Write(lastWFAddr, 0);
}
}
catch (Win32Exception e)
{
lastWFAddr = IntPtr.Zero;
toggleWireFrame(activate);
}
}

public static bool IsAdministrator()
{
return (new WindowsPrincipal(WindowsIdentity.GetCurrent()))
Expand Down Expand Up @@ -153,9 +194,11 @@ private void timer1_Tick(object sender, EventArgs e)
{
short keyState1 = GetAsyncKeyState(VK_MENU);
short keyState2 = GetAsyncKeyState(VK_O);
short keyState3 = GetAsyncKeyState(VK_W);

bool altIsPressed = ((keyState1 >> 15) & 0x0001) == 0x0001;
bool oIsPressed = ((keyState2 >> 15) & 0x0001) == 0x0001;
bool wIsPressed = ((keyState3 >> 15) & 0x0001) == 0x0001;

if (controller == null)
{
Expand All @@ -182,6 +225,17 @@ private void timer1_Tick(object sender, EventArgs e)
lastHotkeyPress = DateTime.Now;
}
}

if (altIsPressed && wIsPressed)
{
if (DateTime.Now.Subtract(lastHotkeyPress).TotalSeconds > 1)
{
toggleWireFrame(!checkBox2.Checked);
checkBox2.Checked = !checkBox2.Checked;
SystemSounds.Asterisk.Play();
lastHotkeyPress = DateTime.Now;
}
}
}
catch (SharpDX.SharpDXException)
{
Expand Down

0 comments on commit 2595e87

Please sign in to comment.