Skip to content

Commit

Permalink
Add GetVTableIndex method
Browse files Browse the repository at this point in the history
  • Loading branch information
qubka committed Dec 23, 2024
1 parent 8fcff2d commit e820d73
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
17 changes: 17 additions & 0 deletions polyhook.pplugin.in
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,23 @@
"description": "Address of original function"
}
},
{
"name": "GetVTableIndex",
"group": "Lookup",
"description": "Attempts to find virtual table index of virtual function",
"funcName": "GetVTableIndex",
"paramTypes": [
{
"type": "ptr64",
"name": "pFunc",
"description": "Function address"
}
],
"retType": {
"type": "int32",
"description": "Virtual table index"
}
},
{
"name": "UnhookAll",
"group": "Core",
Expand Down
12 changes: 9 additions & 3 deletions src/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ void PolyHookPlugin::OnPluginStart() {
}

void PolyHookPlugin::OnPluginEnd() {
unhookAll();
}

Callback* PolyHookPlugin::hookDetour(void* pFunc, DataType returnType, std::span<const DataType> arguments) {
Expand Down Expand Up @@ -348,17 +349,17 @@ int PolyHookPlugin::getVTableIndex(void* pFunc) const {

extern "C"
PLUGIN_API Callback* HookDetour(void* pFunc, DataType returnType, const plg::vector<DataType>& arguments) {
return g_polyHookPlugin.hookDetour(pFunc, returnType, std::span(arguments.data(), arguments.size()));
return g_polyHookPlugin.hookDetour(pFunc, returnType, arguments.const_span());
}

extern "C"
PLUGIN_API Callback* HookVirtual(void* pClass, int index, DataType returnType, const plg::vector<DataType>& arguments) {
return g_polyHookPlugin.hookVirtual(pClass, index, returnType, std::span(arguments.data(), arguments.size()));
return g_polyHookPlugin.hookVirtual(pClass, index, returnType, arguments.const_span());
}

extern "C"
PLUGIN_API Callback* HookVirtualByFunc(void* pClass, void* pFunc, DataType returnType, const plg::vector<DataType>& arguments) {
return g_polyHookPlugin.hookVirtual(pClass, pFunc, returnType, std::span(arguments.data(), arguments.size()));
return g_polyHookPlugin.hookVirtual(pClass, pFunc, returnType, arguments.const_span());
}

extern "C"
Expand Down Expand Up @@ -396,6 +397,11 @@ PLUGIN_API void* FindOriginalAddr(void* pClass, void* pAddr) {
return g_polyHookPlugin.findOriginalAddr(pClass, pAddr);
}

extern "C"
PLUGIN_API int GetVTableIndex(void* pFunc) {
return g_polyHookPlugin.getVTableIndex(pFunc);
}

extern "C"
PLUGIN_API void UnhookAll() {
return g_polyHookPlugin.unhookAll();
Expand Down
1 change: 1 addition & 0 deletions sym/exported_symbols.lds
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ FindDetour
FindVirtual
FindVirtualByFunc
FindOriginalAddr
GetVTableIndex
UnhookAll
UnhookAllVirtual
AddCallback
Expand Down
1 change: 1 addition & 0 deletions sym/version_script.lds
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
FindVirtual;
FindVirtualByFunc;
FindOriginalAddr;
GetVTableIndex;
UnhookAll;
UnhookAllVirtual;
AddCallback;
Expand Down

0 comments on commit e820d73

Please sign in to comment.