尝试执行绕道附加,但无法将我的lua函数的数据类型转换为LPVOID

Trying to do DetourAttach but cannot convert my lua function's datatype to LPVOID

本文关键字:函数 lua 我的 数据 LPVOID 类型转换 执行      更新时间:2023-10-16

所以这就是我的函数实际上看起来像

DetourAttach(&(LPVOID&)lua_tolstring, (PBYTE)tostring);

lua_tolstringconst char*LPVOID给了我这个错误。

typedef void* LPVOID
invalid type conversion

我该如何完成此工作?

您没有适合Detourattach的正确语义。第一个参数是指针对函数的指针,应将其初始化为挂钩的原始函数。第二个参数是包含钩函数的指针到功能。

请参阅此博客以获取示例。

因此,您不能仅通过该功能。您必须初始化一个变量,例如:

// Declaration of LUA API function in header
const char*lua_tostring (lua_State *L, int index);
// Your hook function must have this signature to match
const char*my_tostring (lua_State *L, int index);
// Your variable
const char* (*Real_lua_tostring)(lua_State *L, int index) = lua_tostring;
// Make the call
DetourAttach(&(LPVOID&)Real_lua_tolstring, (PVOID)my_tostring);