1. using System;
  2. using System.Collections.Generic;
  3. namespace WowMoPObjMgrTest
  4. {
  5. class ObjectManager : IEnumerable<WowObject>
  6. {
  7. private IntPtr BaseAddress;
  8. private const int s_curMgr = 0x00BE1D2C;
  9. private const int FirstObjectOfs = 0xC;
  10. private const int NextObjectOfs = 0x4;
  11. //const int FirstObjectOfs = 0xCC;
  12. //const int NextObjectOfs = 0xC4;
  13. private const int LocalGuidOfs = 0xD0;
  14. public ObjectManager()
  15. {
  16. IntPtr objMgrPtr = Memory.BaseAddress + s_curMgr;
  17. BaseAddress = Memory.Read<IntPtr>(objMgrPtr);
  18. }
  19. public ulong LocalGuid
  20. {
  21. get { return Memory.Read<ulong>(BaseAddress + LocalGuidOfs); }
  22. }
  23. public IntPtr FirstObject()
  24. {
  25. return Memory.Read<IntPtr>(BaseAddress + FirstObjectOfs);
  26. }
  27. public IntPtr NextObject(IntPtr current)
  28. {
  29. return Memory.Read<IntPtr>(current + Memory.Read<int>(BaseAddress + NextObjectOfs) + 4);
  30. }
  31. System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
  32. {
  33. return GetEnumerator();
  34. }
  35. public IEnumerator<WowObject> GetEnumerator()
  36. {
  37. IntPtr first = FirstObject();
  38. while (((first.ToInt64() & 1) == 0) && first != IntPtr.Zero)
  39. {
  40. yield return new WowObject(first);
  41. first = NextObject(first);
  42. }
  43. }
  44. }
  45. }