Groups > Microsoft > WinDbg > Using IDebugSymbols3::GetFieldOffset() with multiply-derived class




Using IDebugSymbols3::GetFieldOffset() with multiply-derived
class

Using IDebugSymbols3::GetFieldOffset() with multiply-derived class
Wed, 9 Apr 2008 10:44:00 -0700
Assuming a class structure similar to the following:

class CMyClass : CBaseClass, COtherBase
{
   int myfield;
}

I want to be able to get the value of myfield, given a COtherBase pointer. 
Offsetting the address by GetFieldOffset doesn't work because the COtherBase 
pointer is starting from the wrong point in memory.

For example, ((COtherBase *) p) == 0x7115740 but ((CMyClass *) p) == 
0x7115730. Therefore, I need to subtract 0x10 from my address before using 
the value from GetFieldOffset, so that I'll land at the correct location. 
That means that I need to figure out the 'this' pointer adjustment used in 
the dynamic cast.

Unfortunately, I haven't had any luck finding a function (or series of 
funcitons) that will allow me to examine the class hierarchy at this level. 
I'm sure there has to be a way, I just haven't been able to determine it.

Does anyone know how to do it?

Thanks,

Dan

PS

Figuring it out by comparing the offset of a field in COtherBase with the 
same offset in CMyClass won't work for me; because, in my case, COtherBase 
does not contain any fields.
Post Reply
about | contact