Skip to content

single file header only library for getting virtual function offset from PMF

Notifications You must be signed in to change notification settings

ManulMap/vm_offset

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vm offset

Convenient way to get virtual method offset from virtual table using a pointer to member function(pmf)

This lib uses very tricky compiler implementation dependent methods to get the offset

example

struct A {
    virtual void f0() {}
    virtual void f1() {}
    virtual void f2() {}
};

const auto f2_offset = vm_offs::get_vm_index(&A::f2);

Tested on msvc, clang for windows(clang, clang-cl), and godbolt(itanium abi clang and gcc).

If it doesn't work correctly for you, consider using these methods directly.

const auto f2_index_itanium = vm_offs::get_vm_offset_itanium(&A::f2);
const auto f2_index_msvc = vm_offs::get_vm_offset_itanium(&A::f2);
const auto f2_index_clang = vm_offs::get_vm_offset_win_clang(&A::f2);

About

single file header only library for getting virtual function offset from PMF

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published