尝试执行绕道附加,但无法将我的lua函数的数据类型转换为LPVOID
Trying to do DetourAttach but cannot convert my lua function's datatype to LPVOID
所以这就是我的函数实际上看起来像
DetourAttach(&(LPVOID&)lua_tolstring, (PBYTE)tostring);
lua_tolstring
是const 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);
相关文章:
- 使用 LuaBridge 或 Lua 将对象传递给 Lua 函数C++
- 将 Lua 函数块转换为 C 字符串
- 调用 lua 函数的地址为 C/C++?
- 如何使用重新定义的打印函数打印Lua表?
- 如何在C++中获取lua函数作为参数,然后调用它
- C++-在没有自定义.lib文件的情况下从Lua C模块调用Lua函数
- 将带有字段的表作为参数从C++传递给 Lua 函数?
- Lua 中看起来像表的函数是什么?
- 如何在C++中从Lua函数获取返回表?
- 从Qt/C++-App并行运行两个Lua函数
- Lua C API 自定义打印函数,在字符串中传递空格时不调用
- C++ 和 Lua 函数之间的交互与 3D 矢量参数
- 如何获取从C++发送到Lua函数的表的更新值?
- 包装C++函数以使用 SWIG 获取 Lua 字符串表
- 如何在 lua cpp 模块中调用托管 c++ dll 函数
- 在C 函数中打印一个来自LUA的静态变量
- 从 LUA 脚本调用类函数C++
- 如何在LUA C API中分配全局LUA函数变量
- 如何安全地从 Lua 调用C++函数
- 尝试执行绕道附加,但无法将我的lua函数的数据类型转换为LPVOID