Skip to content

Instantly share code, notes, and snippets.

@kevingosse

kevingosse/Timers.cs

Last active Mar 1, 2017
Embed
What would you like to do?
var dataTarget = DataTarget.LoadCrashDump(path);
var runtime = dataTarget.ClrVersions[0].CreateRuntime(Path.Combine(folder, "mscordacwks.dll"));
var heap = runtime.GetHeap();
ClrInstanceField field = null;
var targets = new List<string>();
foreach (var address in heap.EnumerateObjectAddresses())
{
var type = heap.GetObjectType(address);
if (type.Name == "System.Threading.TimerCallback")
{
if (field == null)
{
field = type.Fields.First(f => f.Name == "_target");
}
var targetAddress = (ulong)field.GetValue(address);
var target = heap.GetObjectType(targetAddress);
targets.Add(target.Name);
}
}
foreach (var group in targets.GroupBy(t => t).OrderByDescending(g => g.Count()))
{
Console.WriteLine("{0}\t{1}", group.Key, group.Count());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment