delphi - How do I get the number of entries (virtual methods) in the VMT? -


at positive offsets vmt stores pointers user defined virtual methods.
need write code hook vmt. way pointer virtual method in ancestor class.
let's say: tcustomform.showmodal. offset in vmt of tcustomform. offset in hand go tmyform , alter vmt point function need.

i generalize approach , in order know total number of entries vmt holds don't search past end.

how obtain size of (user definable part of) vmt?

digging through rtl source think way count:

function getvmtcount(aclass: tclass): integer; var   p: pointer;   virtualmethodcount: word; begin   p := ppointer(pbyte(aclass) + vmtmethodtable)^;   virtualmethodcount:= pword(p)^;   //size of vmt in bytes   result:= virtualmethodcount * sizeof(pointer) - vmtselfptr;   //number of entries in vmt   result:= result div sizeof(pointer); end; 

feel free correct me if needed.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -