Use IntPtr instead of long for pointers
authorAmy Yu <amycmyu@gmail.com>
Fri, 15 Jun 2018 21:17:06 +0000 (14:17 -0700)
committerAmy Yu <amycmyu@gmail.com>
Fri, 15 Jun 2018 21:20:46 +0000 (14:20 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/5a0278defa155de8c0d1f2b6f1d51841006f97cd

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

index a8d4f07..a3739c0 100644 (file)
@@ -20,36 +20,34 @@ namespace R2RDump
         };
 
         [DllImport("coredistools.dll")]
-        [return: MarshalAs(UnmanagedType.I8)]
-        public static extern long InitBufferedDisasm(TargetArch Target);
+        public static extern IntPtr InitBufferedDisasm(TargetArch Target);
 
         [DllImport("coredistools.dll")]
-        public static extern void DumpCodeBlock(long Disasm, ulong Address, IntPtr Bytes, int Size);
+        public static extern void DumpCodeBlock(IntPtr Disasm, ulong Address, IntPtr Bytes, int Size);
 
         [DllImport("coredistools.dll")]
-        [return: MarshalAs(UnmanagedType.I8)]
-        public static extern long GetOutputBuffer();
+        public static extern IntPtr GetOutputBuffer();
 
         [DllImport("coredistools.dll")]
         public static extern void ClearOutputBuffer();
 
         [DllImport("coredistools.dll")]
-        public static extern void FinishDisasm(long Disasm);
+        public static extern void FinishDisasm(IntPtr Disasm);
 
-        public unsafe static string GetCodeBlock(long Disasm, int Address, int Offset, byte[] image, int Size)
+        public unsafe static string GetCodeBlock(IntPtr Disasm, int Address, int Offset, byte[] image, int Size)
         {
             fixed (byte* p = image)
             {
                 IntPtr ptr = (IntPtr)(p + Offset);
                 DumpCodeBlock(Disasm, (ulong)Address, ptr, Size);
             }
-            IntPtr pBuffer = (IntPtr)GetOutputBuffer();
+            IntPtr pBuffer = GetOutputBuffer();
             string buffer = Marshal.PtrToStringAnsi(pBuffer);
             ClearOutputBuffer();
             return buffer;
         }
 
-        public static long GetDisasm(Machine machine)
+        public static IntPtr GetDisasm(Machine machine)
         {
             TargetArch target = TargetArch.Target_Host;
             switch (machine)
index bb457ca..be5c893 100644 (file)
@@ -22,7 +22,7 @@ namespace R2RDump
         private IReadOnlyList<int> _runtimeFunctions = Array.Empty<int>();
         private IReadOnlyList<string> _sections = Array.Empty<string>();
         private bool _diff;
-        private long _disassembler;
+        private IntPtr _disassembler;
         private bool _types;
         private bool _unwind;
         private bool _gc;