-
1.12 Question on how to find an address given two having already been found
so I have these two addresses
Code:
internal static IntPtr GetCreatureRank = (IntPtr) 0x00605620;
internal static IntPtr GetCreatureType = (IntPtr) 0x00605570;
and I have been trying unsuccessfully to find the CreatureFamily address (to determine what family a player's pet belongs to and yes I know I can do this with Lua)
I am using the 'creature_template' cmangos database structure as reference.
I subtract the Type address from the Rank address and I am left with 0xB0 (176). I figured that there were 12 columns between these so I divided the 0xB0 by 12 and got 0xE (14). I then figured that I just needed multiply this by 13 (because the key that I am trying to get the address to is just 1 column above Type) and I got 0xB6 (182).
this brought me to the conclusion that each key is about 6 bytes and that the address I was looking for was which is totally wrong as you definitely already know.
I tried coming up with different ways to calculate this and even tried just counting the bytes and I keep getting it wrong.
I figured out the itemcachepointer stuff and that was simple because I just had to use offsets but I can't use offsets for this because it does not appear that I am directly accessing a creaturecache (I found a snippet in the dump thread but I kept getting the wrong values with it... maybe I was doing it wrong but it didn't really fit with the delegate scheme anyway)
I'm really trying to just dive right in but I'm probably overlooking something simple and fundamental that I just never acquired knowledge of.
Could someone please explain to me how/why my thinking is wrong and how I should be thinking about this problem so that I can solve it?
thanks in advance
-
Member
it looks like the function is at 6055E0 on 1.12.1 (it is called by the lua function and string is returned from db), you could also access the struct by reading if you got the cache offset, on 3.3.5a i do it like this:
Code:
var creatureCachePtr = MemoryManager.Read<IntPtr>(UnitBaseAddress + 0x964);
var creatureCache = MemoryManager.Read<CreatureCache>(creatureCachePtr);
Logging.Write(creatureCache.Family);
The struct:
Code:
//3.3.5a 12340
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CreatureCache
{
public int Id;
public IntPtr SubNamePtr;
public IntPtr IconNamePtr;
public int TypeFlags;
public int Type;
public int Family;
public int Rank;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2, ArraySubType = UnmanagedType.I4)]
public int[] KillCredit;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4, ArraySubType = UnmanagedType.I4)]
public int[] DisplayId;
public float HpModifier;
public float MpModifier;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4, ArraySubType = UnmanagedType.I1)]
public char[] RacialLeader;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6, ArraySubType = UnmanagedType.I4)]
public int[] QuestItem;
public int MovementId;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4, ArraySubType = UnmanagedType.LPStr)]
public string[] Name;
};
You also need to change the struct for 1.12.1, shouldn't be too hard
Last edited by reapler; 12-06-2018 at 02:50 AM.
-
Post Thanks / Like - 1 Thanks
krycess (1 members gave Thanks to reapler for this useful post)
-
oh my goodness. thank you for your response. I feel like I got spoonfed though. I’m not understanding why I can access the itemcache directly without an objectbase address (why I must use the base address for a unit and not an item) and I am also not understanding why the pointer used by the Lua function is what it is.
why is the family pointer so much closer to rank than type? does this have nothing to do with ‘creature_template’?
-
Member
Originally Posted by
krycess
I’m not understanding why I can access the itemcache directly without an objectbase address (why I must use the base address for a unit and not an item)
The data is actually at the wdb folder, i guess wow just load it and assign the creaturecache pointer to the unit struct, but dunno about items.
Originally Posted by
krycess
why is the family pointer so much closer to rank than type? does this have nothing to do with ‘creature_template’?
Yep, it has nothing to do with creature_template, it is just a database table to hold the templates.