Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get every virtual function index just as the compiler does?

Is there some plugin or tool which can read a .h file (or simply modify Intellisense itself) and spit out every function and it's virtual function table index? There's a pattern which I have yet to figure out having to do with polymorphism, and it gets 5x harder when you start to have 5 classes or more deriving from each other. No matter what, though, the MSVC++ compiler always spits out the correct virtual function table index when it compiles the virtual function call from C++ to Assembly. There has to be a better way to get that index without loading, break-pointing, reading the offset, and rewriting the code, right?

Thanks!

like image 392
Gbps Avatar asked Feb 27 '23 20:02

Gbps


1 Answers

Use the hidden Microsoft C/C++ compiler option "/d1 reportAllClassLayout". This will print out the memory layout and vtables of all your classes.

like image 67
Patrick Avatar answered Mar 22 '23 23:03

Patrick