// Thanks to Lee Culver and Jeff Cyr // for the code: // https://github.com/Microsoft/clrmd/issues/35 public static ClrMethod GetDelegateMethod(ulong methodPtr, ClrDump clrDump) { ulong magicPtr = methodPtr + 5; ulong magicValue1 = clrDump.ReadHeapPointer(magicPtr + 1); ulong magicValue2 = clrDump.ReadHeapPointer(magicPtr + 2); ulong mysticPtr = magicPtr + 8 * (magicValue2 & 0xFF) + 3; ulong mysticOffset = 8 * (magicValue1 & 0xFF); ulong mysticValue = clrDump.ReadRuntimePointer(mysticPtr); ulong methodDescriptorPtr = mysticValue + mysticOffset; return(clrDump.GetMethodByHandle(methodDescriptorPtr)); }
// Thanks to Lee Culver and Jeff Cyr // for the code: // https://github.com/Microsoft/clrmd/issues/35 public static ClrMethod GetDelegateMethod(ulong methodPtr, ClrDump clrDump) { ulong magicPtr = methodPtr + 5; ulong magicValue1 = clrDump.ReadHeapPointer(magicPtr + 1); ulong magicValue2 = clrDump.ReadHeapPointer(magicPtr + 2); ulong mysticPtr = magicPtr + 8 * (magicValue2 & 0xFF) + 3; ulong mysticOffset = 8 * (magicValue1 & 0xFF); ulong mysticValue = clrDump.ReadRuntimePointer(mysticPtr); ulong methodDescriptorPtr = mysticValue + mysticOffset; ClrMethod method = clrDump.GetMethodByHandle(methodDescriptorPtr); return method; }