-
-
Save gavz/29a6efe3c7e4082d3fc579681ed3a190 to your computer and use it in GitHub Desktop.
This file contains hidden or 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