Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. using System;
  2. using Microsoft.Diagnostics.Runtime;
  3.  
  4. namespace ConsoleApplication1
  5. {
  6. class Program
  7. {
  8.  
  9. static void Main(string[] args)
  10. {
  11. DataTarget dt=DataTarget.AttachToProcess(17680,5000,AttachFlag.Passive);
  12.  
  13. using (dt)
  14. {
  15. ClrInfo runtimeInfo = dt.ClrVersions[0];
  16. ClrRuntime runtime = runtimeInfo.CreateRuntime();
  17.  
  18. ClrType type;
  19.  
  20. foreach (ulong obj in runtime.Heap.EnumerateObjectAddresses())
  21. {
  22. type = runtime.Heap.GetObjectType(obj);
  23.  
  24. if (type == null) continue;
  25.  
  26. if (type.Name == "System.Windows.Forms.Form" ||
  27. (type.BaseType != null && type.BaseType.Name == "System.Windows.Forms.Form"))
  28. {
  29. Console.WriteLine("Address 0x{0:X}: {1}", obj, type.Name);
  30. ClrInstanceField f = type.GetFieldByName("Foo");
  31. object val = f.GetValue(obj);
  32. if (val != null) Console.WriteLine(val.ToString());
  33. }
  34. }
  35. }
  36.  
  37. Console.ReadKey();
  38. }
  39.  
  40. }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement