I was reading this article (which is about how to allocate class object in the stack segment) and came across to this snippet. If I understand correctly he wants to get the address of our PocoClass
with the header (with lock object and type information).
TypedReference typedReference = __makeref(heapPoco);
int* poco1Address = (int*)(*(int*)(*(int*)(&typedReference)) - 4);
Question
If we know that a class has 2 other "objects/information" before actual data, then why are we subtracting 4
(he's in 32bit mode in his example) from our address, shouldn't it be 2 * 4
, because we have a pointer that points to "type object" and before that we have the "lock object".