Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using Microsoft.Diagnostics.Runtime;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- DataTarget dt=DataTarget.AttachToProcess(17680,5000,AttachFlag.Passive);
- using (dt)
- {
- ClrInfo runtimeInfo = dt.ClrVersions[0];
- ClrRuntime runtime = runtimeInfo.CreateRuntime();
- ClrType type;
- foreach (ulong obj in runtime.Heap.EnumerateObjectAddresses())
- {
- type = runtime.Heap.GetObjectType(obj);
- if (type == null) continue;
- if (type.Name == "System.Windows.Forms.Form" ||
- (type.BaseType != null && type.BaseType.Name == "System.Windows.Forms.Form"))
- {
- Console.WriteLine("Address 0x{0:X}: {1}", obj, type.Name);
- ClrInstanceField f = type.GetFieldByName("Foo");
- object val = f.GetValue(obj);
- if (val != null) Console.WriteLine(val.ToString());
- }
- }
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement