{
class CoreDisTools
{
+ private const string _dll = "coredistools.dll";
+
public enum TargetArch
{
Target_Host, // Target is the same as host architecture
Target_Arm64
};
- [DllImport("coredistools.dll")]
+ [DllImport(_dll)]
public static extern IntPtr InitBufferedDisasm(TargetArch Target);
- [DllImport("coredistools.dll")]
+ [DllImport(_dll)]
public static extern void DumpCodeBlock(IntPtr Disasm, ulong Address, IntPtr Bytes, int Size);
- [DllImport("coredistools.dll")]
+ [DllImport(_dll)]
[return: MarshalAs(UnmanagedType.I4)]
public static extern int DumpInstruction(IntPtr Disasm, ulong Address, IntPtr Bytes, int Size);
- [DllImport("coredistools.dll")]
+ [DllImport(_dll)]
public static extern IntPtr GetOutputBuffer();
- [DllImport("coredistools.dll")]
+ [DllImport(_dll)]
public static extern void ClearOutputBuffer();
- [DllImport("coredistools.dll")]
+ [DllImport(_dll)]
public static extern void FinishDisasm(IntPtr Disasm);
public unsafe static string GetCodeBlock(IntPtr Disasm, RuntimeFunction rtf, int imageOffset, byte[] image)
public override string ToString()
{
StringBuilder sb = new StringBuilder();
- string tab2 = new string(' ', 8);
- sb.AppendLine($"{tab2}CodeOffset: {CodeOffset}");
- sb.AppendLine($"{tab2}SlotId: {SlotId}");
- sb.AppendLine($"{tab2}IsLive: {IsLive}");
- sb.AppendLine($"{tab2}ChunkId: {ChunkId}");
- sb.Append($"{tab2}--------------------");
+ sb.AppendLine($"\t\tCodeOffset: {CodeOffset}");
+ sb.AppendLine($"\t\tSlotId: {SlotId}");
+ sb.AppendLine($"\t\tIsLive: {IsLive}");
+ sb.AppendLine($"\t\tChunkId: {ChunkId}");
+ sb.Append($"\t\t--------------------");
return sb.ToString();
}
public override string ToString()
{
StringBuilder sb = new StringBuilder();
- string tab = " ";
- sb.AppendLine($"{tab}Version: {Version}");
- sb.AppendLine($"{tab}CodeLength: {CodeLength}");
- sb.AppendLine($"{tab}ReturnKind: {Enum.GetName(typeof(ReturnKinds), ReturnKind)}");
- sb.AppendLine($"{tab}ValidRangeStart: {ValidRangeStart}");
- sb.AppendLine($"{tab}ValidRangeEnd: {ValidRangeEnd}");
+ sb.AppendLine($"\tVersion: {Version}");
+ sb.AppendLine($"\tCodeLength: {CodeLength}");
+ sb.AppendLine($"\tReturnKind: {Enum.GetName(typeof(ReturnKinds), ReturnKind)}");
+ sb.AppendLine($"\tValidRangeStart: {ValidRangeStart}");
+ sb.AppendLine($"\tValidRangeEnd: {ValidRangeEnd}");
if (SecurityObjectStackSlot != -1)
- sb.AppendLine($"{tab}SecurityObjectStackSlot: caller.sp{SecurityObjectStackSlot:+#;-#;+0}");
+ sb.AppendLine($"\tSecurityObjectStackSlot: caller.sp{SecurityObjectStackSlot:+#;-#;+0}");
if (GSCookieStackSlot != -1)
{
- sb.AppendLine($"{tab}GSCookieStackSlot: caller.sp{GSCookieStackSlot:+#;-#;+0}");
+ sb.AppendLine($"\tGSCookieStackSlot: caller.sp{GSCookieStackSlot:+#;-#;+0}");
sb.AppendLine($"GS cookie valid range: [{ValidRangeStart};{ValidRangeEnd})");
}
{
if (_machine == Machine.Amd64)
{
- sb.AppendLine($"{tab}PSPSymStackSlot: initial.sp{PSPSymStackSlot:+#;-#;+0}");
+ sb.AppendLine($"\tPSPSymStackSlot: initial.sp{PSPSymStackSlot:+#;-#;+0}");
}
else
{
- sb.AppendLine($"{tab}PSPSymStackSlot: caller.sp{PSPSymStackSlot:+#;-#;+0}");
+ sb.AppendLine($"\tPSPSymStackSlot: caller.sp{PSPSymStackSlot:+#;-#;+0}");
}
}
if (GenericsInstContextStackSlot != -1)
{
- sb.AppendLine($"{tab}GenericsInstContextStackSlot: caller.sp{GenericsInstContextStackSlot:+#;-#;+0}");
+ sb.AppendLine($"\tGenericsInstContextStackSlot: caller.sp{GenericsInstContextStackSlot:+#;-#;+0}");
}
if (StackBaseRegister != 0xffffffff)
- sb.AppendLine($"{tab}StackBaseRegister: {(Amd64Registers)StackBaseRegister}");
+ sb.AppendLine($"\tStackBaseRegister: {(Amd64Registers)StackBaseRegister}");
if (_machine == Machine.Amd64)
{
- sb.AppendLine($"{tab}Wants Report Only Leaf: {_wantsReportOnlyLeaf}");
+ sb.AppendLine($"\tWants Report Only Leaf: {_wantsReportOnlyLeaf}");
}
else if (_machine == Machine.Arm || _machine == Machine.Arm64)
{
- sb.AppendLine($"{tab}Has Tailcalls: {_wantsReportOnlyLeaf}");
+ sb.AppendLine($"\tHas Tailcalls: {_wantsReportOnlyLeaf}");
}
- sb.AppendLine($"{tab}Size of parameter area: 0x{SizeOfStackOutgoingAndScratchArea:X}");
+ sb.AppendLine($"\tSize of parameter area: 0x{SizeOfStackOutgoingAndScratchArea:X}");
if (SizeOfEditAndContinuePreservedArea != 0xffffffff)
- sb.AppendLine($"{tab}SizeOfEditAndContinuePreservedArea: 0x{SizeOfEditAndContinuePreservedArea:X}");
+ sb.AppendLine($"\tSizeOfEditAndContinuePreservedArea: 0x{SizeOfEditAndContinuePreservedArea:X}");
if (ReversePInvokeFrameStackSlot != -1)
- sb.AppendLine($"{tab}ReversePInvokeFrameStackSlot: {ReversePInvokeFrameStackSlot}");
- sb.AppendLine($"{tab}NumSafePoints: {NumSafePoints}");
- sb.AppendLine($"{tab}NumInterruptibleRanges: {NumInterruptibleRanges}");
- sb.AppendLine($"{tab}SafePointOffsets:");
+ sb.AppendLine($"\tReversePInvokeFrameStackSlot: {ReversePInvokeFrameStackSlot}");
+ sb.AppendLine($"\tNumSafePoints: {NumSafePoints}");
+ sb.AppendLine($"\tNumInterruptibleRanges: {NumInterruptibleRanges}");
+ sb.AppendLine($"\tSafePointOffsets:");
foreach (uint offset in SafePointOffsets)
{
- sb.AppendLine($"{tab}{tab}{offset}");
+ sb.AppendLine($"\t\t{offset}");
}
- sb.AppendLine($"{tab}InterruptibleRanges:");
+ sb.AppendLine($"\tInterruptibleRanges:");
foreach (InterruptibleRange range in InterruptibleRanges)
{
- sb.AppendLine($"{tab}{tab}start:{range.StartOffset}, end:{range.StopOffset}");
+ sb.AppendLine($"\t\tstart:{range.StartOffset}, end:{range.StopOffset}");
}
- sb.AppendLine($"{tab}SlotTable:");
+ sb.AppendLine($"\tSlotTable:");
sb.Append(SlotTable.ToString());
- sb.AppendLine($"{tab}Transitions:");
+ sb.AppendLine($"\tTransitions:");
foreach (GcTransition trans in Transitions.Values)
{
sb.AppendLine(trans.ToString());
}
- sb.AppendLine($"{tab}Size: {Size} bytes");
+ sb.AppendLine($"\tSize: {Size} bytes");
return sb.ToString();
}
public override string ToString()
{
StringBuilder sb = new StringBuilder();
- string tab4 = new string(' ', 16);
- sb.AppendLine($"{tab4}SpOffset: {SpOffset}");
- sb.Append($"{tab4}Base: {Enum.GetName(typeof(GcStackSlotBase), Base)}");
+ sb.AppendLine($"\t\t\t\tSpOffset: {SpOffset}");
+ sb.Append($"\t\t\t\tBase: {Enum.GetName(typeof(GcStackSlotBase), Base)}");
return sb.ToString();
}
public override string ToString()
{
StringBuilder sb = new StringBuilder();
- string tab3 = new string(' ', 12);
if (StackSlot != null)
{
- sb.AppendLine($"{tab3}Stack:");
+ sb.AppendLine($"\t\t\tStack:");
sb.AppendLine(StackSlot.ToString());
}
else
{
- sb.AppendLine($"{tab3}RegisterNumber: {RegisterNumber}");
+ sb.AppendLine($"\t\t\tRegisterNumber: {RegisterNumber}");
}
- sb.AppendLine($"{tab3}Flags: {Flags}");
+ sb.AppendLine($"\t\t\tFlags: {Flags}");
return sb.ToString();
}
public override string ToString()
{
StringBuilder sb = new StringBuilder();
- string tab2 = new string(' ', 8);
- string tab3 = new string(' ', 12);
- sb.AppendLine($"{tab2}NumSlots({NumSlots}) = NumRegisters({NumRegisters}) + NumStackSlots({NumStackSlots}) + NumUntracked({NumUntracked})");
- sb.AppendLine($"{tab2}GcSlots:");
- sb.AppendLine($"{tab3}-------------------------");
+ sb.AppendLine($"\t\tNumSlots({NumSlots}) = NumRegisters({NumRegisters}) + NumStackSlots({NumStackSlots}) + NumUntracked({NumUntracked})");
+ sb.AppendLine($"\t\tGcSlots:");
+ sb.AppendLine($"\t\t\t-------------------------");
foreach (GcSlot slot in GcSlots)
{
sb.Append(slot.ToString());
- sb.AppendLine($"{tab3}-------------------------");
+ sb.AppendLine($"\t\t\t-------------------------");
}
return sb.ToString();
public override string ToString()
{
StringBuilder sb = new StringBuilder();
- string tab2 = new string(' ', 8);
- string tab3 = new string(' ', 12);
-
- sb.AppendLine($"{tab2}{{");
- sb.AppendLine($"{tab3}CodeOffset: {CodeOffset}");
- sb.AppendLine($"{tab3}UnwindOp: {UnwindOp}");
- sb.AppendLine($"{tab3}OpInfo: {OpInfo}");
- sb.AppendLine($"{tab2}}}");
- sb.AppendLine($"{tab2}{{");
- sb.AppendLine($"{tab3}OffsetLow: {OffsetLow}");
- sb.AppendLine($"{tab3}UnwindOp: {UnwindOp}");
- sb.AppendLine($"{tab3}OffsetHigh: {OffsetHigh}");
- sb.AppendLine($"{tab2}}}");
- sb.AppendLine($"{tab2}FrameOffset: {FrameOffset}");
- sb.AppendLine($"{tab2}------------------");
+
+ sb.AppendLine($"\t\t{{");
+ sb.AppendLine($"\t\t\tCodeOffset: {CodeOffset}");
+ sb.AppendLine($"\t\t\tUnwindOp: {UnwindOp}");
+ sb.AppendLine($"\t\t\tOpInfo: {OpInfo}");
+ sb.AppendLine($"\t\t}}");
+ sb.AppendLine($"\t\t{{");
+ sb.AppendLine($"\t\t\tOffsetLow: {OffsetLow}");
+ sb.AppendLine($"\t\t\tUnwindOp: {UnwindOp}");
+ sb.AppendLine($"\t\t\tOffsetHigh: {OffsetHigh}");
+ sb.AppendLine($"\t\t}}");
+ sb.AppendLine($"\t\tFrameOffset: {FrameOffset}");
+ sb.AppendLine($"\t\t------------------");
return sb.ToString();
}
public override string ToString()
{
StringBuilder sb = new StringBuilder();
- string tab = " ";
-
- sb.AppendLine($"{tab}Version: {Version}");
- sb.AppendLine($"{tab}Flags: 0x{Flags:X8}");
- sb.AppendLine($"{tab}SizeOfProlog: {SizeOfProlog}");
- sb.AppendLine($"{tab}CountOfUnwindCodes: {CountOfUnwindCodes}");
- sb.AppendLine($"{tab}FrameRegister: {FrameRegister}");
- sb.AppendLine($"{tab}FrameOffset: {FrameOffset}");
- sb.AppendLine($"{tab}Unwind Codes:");
- sb.AppendLine($"{tab}{tab}------------------");
+
+ sb.AppendLine($"\tVersion: {Version}");
+ sb.AppendLine($"\tFlags: 0x{Flags:X8}");
+ sb.AppendLine($"\tSizeOfProlog: {SizeOfProlog}");
+ sb.AppendLine($"\tCountOfUnwindCodes: {CountOfUnwindCodes}");
+ sb.AppendLine($"\tFrameRegister: {FrameRegister}");
+ sb.AppendLine($"\tFrameOffset: {FrameOffset}");
+ sb.AppendLine($"\tUnwind Codes:");
+ sb.AppendLine($"\t\t------------------");
for (int i = 0; i < CountOfUnwindCodes; i++)
{
sb.Append(UnwindCode[i].ToString());
}
- sb.AppendLine($"{tab}PersonalityRoutineRVA: 0x{PersonalityRoutineRVA:X8}");
- sb.AppendLine($"{tab}Size: {Size} bytes");
+ sb.AppendLine($"\tPersonalityRoutineRVA: 0x{PersonalityRoutineRVA:X8}");
+ sb.AppendLine($"\tSize: {Size} bytes");
return sb.ToString();
}