Reputation: 737
Looking through a projects code I found this:
font.Draw(x, y + 15 * 1, fontColor, "agPtr: %p <= %p", *(void**)agLocked.m_ptr, (void**)agLocked.m_ptr);
How is *(void**)agLocked.m_ptr
Different than (void**)agLocked.m_ptr
?
Also this:
unsigned long shift = *(unsigned long*)all.m_ptr;
shift = *(unsigned long*)(shift + 0x30);
shift = *(unsigned long*)(shift + 0x28);
shift = *(unsigned long*)(shift + 0x178);
I have looked at pointer arithmetic and all that and it doesn't make sense to me. Can someone point (heh) me in the right direction? is the first *(void**)
accessing three pointers? why not use (void***)
? While I am comfortable with c++ I would like to better understand the above so that I can contribute to the project.
Upvotes: 1
Views: 82
Reputation: 182761
*(void**)agLocked.m_ptr
This dereferences agLocked.m_ptr
to get a void *
and will probably fault if it's NULL
or contains junk.
(void**)agLocked.m_ptr
This just casts agLocks.m_ptr
to a void **
.
Upvotes: 2