Skip to content

Instantly share code, notes, and snippets.

@aixxe
Created February 7, 2017 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aixxe/68afce6655ff5acb524eb7963f093d07 to your computer and use it in GitHub Desktop.
Save aixxe/68afce6655ff5acb524eb7963f093d07 to your computer and use it in GitHub Desktop.
Various virtual method table helper functions.
inline void**& GetVirtualTable(void* baseclass) {
return *reinterpret_cast<void***>(baseclass);
}
inline void* GetVirtualFunction(void* vftable, size_t index) {
return reinterpret_cast<void*>(GetVirtualTable(vftable)[index]);
}
template <typename Fn> inline Fn GetVirtualFunction(void* vftable, size_t index) {
return reinterpret_cast<Fn>(GetVirtualTable(vftable)[index]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment