| | WoW Memory Editing WoW Memory Editing for learning purposes only.
This section is more advanced than others on MMOwned Read the section specific rules, infractions will be given out if u break them!That is including the expectations! - If you don't meet them then don't post |  | 
07-22-2009
| | Sergeant | | | Join Date: Jul 2009
Posts: 38
Reputation: 9 Level up: 49%, 206 Points needed | | | | [C#, Idea] Direct access to object manager So I was thinking.. why make local copy of all objects in object manager each x seconds when we can directly interate through them? Yes, saving local copy every x seconds and then work with it is probably in most cases faster, but I dont really need to loop through whole array that often so it makes big difference. Code: public class BaseObjectCollection : IEnumerable<BaseObject> {
internal BaseObjectCollection( uint firstNodeAddress ) {
this.firstNodeAddress = firstNodeAddress;
}
private uint firstNodeAddress;
public BaseObject FindByGuid( ulong guid ) {
foreach ( BaseObject obj in this )
if ( obj.Guid == guid )
return obj;
return null;
}
#region IEnumerable
public IEnumerator<BaseObject> GetEnumerator() {
return new BaseObjectCollectionEnumerator( firstNodeAddress );
}
IEnumerator IEnumerable.GetEnumerator() {
return new BaseObjectCollectionEnumerator( firstNodeAddress );
}
#endregion
}
public class BaseObjectCollectionEnumerator : MemoryManager, IEnumerator<BaseObject> {
private const uint nextNodeOffset = 0x3c;
private const uint guidOffset = 0x30;
private const uint typeOffset = 0x14;
internal BaseObjectCollectionEnumerator( uint firstNodeAddress ) {
this.firstNodeAddress = firstNodeAddress;
}
private uint firstNodeAddress;
private uint lastNodeAddress;
private BaseObject current;
#region IEnumerator
public void Reset() {
current = null;
lastNodeAddress = firstNodeAddress;
}
public bool MoveNext() {
uint pCurrent;
if ( current == null )
pCurrent = firstNodeAddress;
else
pCurrent = reader.ReadUInt( ( IntPtr )( lastNodeAddress + nextNodeOffset ) );
if ( pCurrent == 0 || pCurrent % 2 != 0 )
return false;
lastNodeAddress = pCurrent;
ulong guid = reader.ReadULong( ( IntPtr )( pCurrent + guidOffset ) );
BaseObjectType type = ( BaseObjectType )reader.ReadUInt( ( IntPtr )( pCurrent + typeOffset ) );
switch ( type ) {
case BaseObjectType.Container:
current = new BaseObject( pCurrent );
break;
case BaseObjectType.Corpse:
current = new BaseObject( pCurrent );
break;
case BaseObjectType.DynamicObject:
current = new BaseObject( pCurrent );
break;
case BaseObjectType.GameObject:
current = new BaseObject( pCurrent );
break;
case BaseObjectType.Item:
current = new BaseObject( pCurrent );
break;
case BaseObjectType.Player:
current = new Player( pCurrent );
break;
case BaseObjectType.Unit:
current = new Unit( pCurrent );
break;
default:
throw new Exception( "Unknown object type " + type );
}
return true;
}
public BaseObject Current {
get { return current; }
}
object IEnumerator.Current {
get { return current; }
}
#endregion
#region IDisposable
public void Dispose() {
current = null;
}
#endregion
}
public enum BaseObjectType {
Item = 1,
Container = 2,
Unit = 3,
Player = 4,
GameObject = 5,
DynamicObject = 6,
Corpse = 7
}
My projects is just at begining, so I have only defined BaseObject, Unit and Player, but I think everyone who reads this section can write those objects on its own. Also class MemoryManager is just little helper that allows me to read with "reader.xxx" instead of "WowClient.Reader.xxx" cuz I dont want to make reader static nor keep reference in every class.
Is there something that I forgot, that makes this way of accessing objects bad? | Donate to remove ads, get your "DONATOR title, and get access to the MMOwned community's elite Shoutbawx. 
07-22-2009
|  | Contributor | | | Join Date: Sep 2006
Posts: 318
Reputation: 126 Level up: 19%, 571 Points needed |     | | | So, for the technically challenged, what would that mean for others? What could we do with this that we couldn't do already? >_> | 
07-22-2009
| | Contributor | | | Join Date: Sep 2006 Location: Jaedenar O.o
Posts: 567
Reputation: 162 Level up: 58%, 336 Points needed |     | | | Why would you do this?
Doesn't it complicate stuff alot?
Storing the objects in a dictionary or list is still direct access, all you do is find all the base addresses for the objects, and store those.
In all your properties you then just implement the memory reading using that base object that you already stored.
That means you will only read the memory when it's necessary, and the initial loop of getting the baseaddresses is really fast (my tests said 1 ms).
__________________ http://www.main-dev.com/
I was here. ~Dragon[Sky] I was here too. ~Kuiren | 
07-22-2009
| | Corporal | | | Join Date: Jan 2009
Posts: 33
Reputation: 10 Level up: 87%, 52 Points needed | | | | I dont understand, looks to me that you do exactly what you trying to avoid, youre creating your baseobject for every object in the manager you are iterating over.
Dont worry (too much) bout performance when creating copies of the objects in the manager. They arent that many, you dont need to do it too often, and youre not on a c64 counting rasterinterrupt sweeps and timing them with NOPs anymore... When you start having hundreds of thousands of objects then you can start worrying and start using object caches. | 
07-22-2009
| | Sergeant | | | Join Date: Jul 2009
Posts: 38
Reputation: 9 Level up: 49%, 206 Points needed | | | Yes thats direct access for objects (that i'm using too), but not the actual list. With this method I should have almost* always the actual array.
The BaseObject is just wrapper like you said Code: public class BaseObject : MemoryManager {
internal BaseObject( uint address ) {
this.address = address;
}
private uint address;
internal uint Address {
get { return address; }
}
public Serial Guid {
get { return new Serial( reader.ReadULong( ( IntPtr )( address + 0x30 ) ) ); }
}
internal uint Fields {
get { return reader.ReadUInt( ( IntPtr )( address + 0x8 ) ); }
}
public BaseObjectType Type {
get { return ( BaseObjectType )reader.ReadUInt( ( IntPtr )( address + 0x14 ) ); }
}
}
* I'm not sure how exactly wowclient handles object lists, if nodes after object removal got somehow erased or something - that would break this a little bit cuz I would loose reference to next node. | 
07-22-2009
|  | Site Donator | | | Join Date: Apr 2008
Posts: 305
Reputation: 62 Level up: 31%, 484 Points needed |   | | | You're early optimizing.
__________________ Don't believe everything you think. | 
07-23-2009
|  | Master Sergeant | | | Join Date: Jul 2009
Posts: 84
Reputation: 19 Level up: 79%, 85 Points needed |   | | Does anyone happen to know offsets from ObjectManager (i hope i find it correctly  ) to LocalGUID, FirstObject and NextObject?
Have to say i've searched for it. And found 0xC0, 0xAC and 0x30. Are they right?
And offsets to objects's XYZ. I've found 0x7D0 0x7D4 0x7D8 but it seems to be 0x7D4 0x7D8 0x7DC as i look it in wow process. | 
07-23-2009
|  | MaiN's Biatch Legendary User | | | Join Date: Mar 2007 Location: VirtualAllocEx
Posts: 1,115
Nominated 26 Times in 3 Posts  TOTM/W Award(s): 1 Reputation: 727 Points: 36,171, Level: 28 | Level up: 95%, 129 Points needed |     | | | They are correct | 
07-23-2009
|  | Master Sergeant | | | Join Date: Jul 2009
Posts: 84
Reputation: 19 Level up: 79%, 85 Points needed |   | | Ok. it's nice to hear that. I'm not surprised.
But i wonder why i've got GUIDs with 0 0 0 coords. Like this Quote:
GUID: 4780000100DFDA92 Location: 0.000000 0.000000 0.000000
GUID: 4780000100DFDAC9 Location: 0.000000 0.000000 0.000000
GUID: 4780000102057C57 Location: 0.000000 0.000000 0.000000
GUID: 4780000102058C5A Location: 0.000000 0.000000 0.000000
GUID: 4780000102154AA2 Location: 0.000000 0.000000 0.000000
GUID: 07800000018B69B3 Location: 10438.055664 782.408997 1322.679932
GUID: 4780000102B98A79 Location: 0.000000 0.000000 0.000000
GUID: F110003040000059 Location: 0.000000 0.000000 0.000000
GUID: F11000303F0003B6 Location: 0.000000 0.000000 0.000000
GUID: F13000081D001722 Location: 10389.803711 763.477112 1319.954102
GUID: F130002F80000678 Location: 10394.998047 743.602966 1319.880127
GUID: F11000806F0000B2 Location: 0.000000 0.000000 0.000000
GUID: F11000080D0000B3 Location: 0.000000 0.000000 0.000000
GUID: F1300021870012D9 Location: 10407.167969 713.794189 1321.617065
GUID: F130000E0500067D Location: 10436.689453 794.837341 1322.701904
| Or maybe they are some kind of abstract objects (i'm not a wow player so i don't know if something like this exists) or maybe it's because of wrong ObjectManager manager pointer? | 
07-23-2009
|  | Knight | | | Join Date: Apr 2009
Posts: 219
Reputation: 11 Level up: 10%, 454 Points needed |   | | | Guess the coords of your items. | 
07-23-2009
|  | Site Donator | | | Join Date: Jul 2009
Posts: 105
Reputation: 10 Level up: 1%, 497 Points needed | | | | Even if abstrac object exists, there are coordinates (no?), I think it's because of wrong ObjectManager manager pointer too. | 
07-23-2009
|  | Master Sergeant | | | Join Date: Jul 2009
Posts: 84
Reputation: 19 Level up: 79%, 85 Points needed |   | | | I've sold almost all i had, but the number of "zero coords" GUID didn't become less. (And imho it's reasonable that items have the same coords, that you have).
I'm using 0x2C as offset from ThreadBase to TLS, and 0x10 as offset from TLS to ObjectManager. Maybe they are wrong? | 
07-23-2009
|  | MaiN's Biatch Legendary User | | | Join Date: Mar 2007 Location: VirtualAllocEx
Posts: 1,115
Nominated 26 Times in 3 Posts  TOTM/W Award(s): 1 Reputation: 727 Points: 36,171, Level: 28 | Level up: 95%, 129 Points needed |     | | | Dont use that old method | 
07-23-2009
|  | MMOwned WebDev Legendary User | | | Join Date: Jan 2008
Posts: 1,909
Nominated 5 Times in 1 Post Reputation: 1029 Points: 22,671, Level: 21 | Level up: 17%, 1,329 Points needed |     | | | Stop using s_curMgr and all that crap. Learn how to use EnumVisibleObjects. It's far faster than the crap you guys are doing. (And more controlled)
Certain objects won't have locations; as they're unnecessary. (See; items) |  |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | All times are GMT -4. The time now is 10:59 AM. |