Use DumpInstruction instead of code block
authorAmy Yu <amycmyu@gmail.com>
Fri, 15 Jun 2018 18:46:49 +0000 (11:46 -0700)
committerAmy Yu <amycmyu@gmail.com>
Sat, 16 Jun 2018 00:14:40 +0000 (17:14 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/1df3d7978e69166fa366c5788d114acf1c743d70

src/coreclr/src/tools/r2rdump/CoreDisTools.cs

index a3739c0..16fef7e 100644 (file)
@@ -26,6 +26,10 @@ namespace R2RDump
         public static extern void DumpCodeBlock(IntPtr Disasm, ulong Address, IntPtr Bytes, int Size);
 
         [DllImport("coredistools.dll")]
+        [return: MarshalAs(UnmanagedType.I4)]
+        public static extern int DumpInstruction(IntPtr Disasm, ulong Address, IntPtr Bytes, int Size);
+
+        [DllImport("coredistools.dll")]
         public static extern IntPtr GetOutputBuffer();
 
         [DllImport("coredistools.dll")]
@@ -36,10 +40,11 @@ namespace R2RDump
 
         public unsafe static string GetCodeBlock(IntPtr Disasm, int Address, int Offset, byte[] image, int Size)
         {
+            int len;
             fixed (byte* p = image)
             {
                 IntPtr ptr = (IntPtr)(p + Offset);
-                DumpCodeBlock(Disasm, (ulong)Address, ptr, Size);
+                len = DumpInstruction(Disasm, (ulong)Address, ptr, Size); //DumpCodeBlock(Disasm, (ulong)Address, ptr, Size);
             }
             IntPtr pBuffer = GetOutputBuffer();
             string buffer = Marshal.PtrToStringAnsi(pBuffer);