Created
May 3, 2021 23:08
-
-
Save xpn/1ebb297ff364d28df048db4db4236258 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Reflection; | |
using System.Runtime.InteropServices; | |
namespace NautilusProject | |
{ | |
public class ReadGadget | |
{ | |
public static IntPtr ReadMemory(IntPtr addr) | |
{ | |
var stubHelper = typeof(System.String).Assembly.GetType("System.StubHelpers.StubHelpers"); | |
var GetNDirectTarget = stubHelper.GetMethod("GetNDirectTarget", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); | |
// Spray away | |
IntPtr unmanagedPtr = Marshal.AllocHGlobal(200); | |
for (int i = 0; i < 200; i += IntPtr.Size) | |
{ | |
Marshal.Copy(new[] { addr }, 0, unmanagedPtr + i, 1); | |
} | |
return (IntPtr)GetNDirectTarget.Invoke(null, new object[] { unmanagedPtr }); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment