Skip to content

Instantly share code, notes, and snippets.

@AinTunez
Created June 25, 2018 18:47
Show Gist options
  • Select an option

  • Save AinTunez/7313045da65af90edd324738d40daa22 to your computer and use it in GitHub Desktop.

Select an option

Save AinTunez/7313045da65af90edd324738d40daa22 to your computer and use it in GitHub Desktop.
public class MemoryEditor {
Process p = null;
public MemoryEditor(string s) {
p = Process.GetProcessesByName(s).FirstOrDefault();
}
public IntPtr[] search (byte[] pattern [, IntPtr startIndex, IntPtr endIndex]) {
// search for occurences of a byte pattern and return an array containg the addresses
// null is for wildcard matches
// example byte pattern [0x4B,0x12,null,null,0x90]
}
public void getAddressValue (IntPtr address, IntPtr offset, int valueLength) {
// get the value at address + offset
}
public void setAddressValue (IntPtr address, IntPtr offset, byte[] values) {
// set the value at address + offset to values
}
public void setAddressChangeListener(IntPtr address, IntPtr offset, int valueLength, method p) {
// when the value at address is changed, perform method p before continuing
}
public void myAddressChanged (EventArgs e) {
byte[] oldValue = e.oldValue;
byte[] newValue = e.newValue;
setAddressValue(myAddress, oldValue); // prevent the change
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment