2017-03-05 54 views

回答

0

您對DetourAttach沒有正確的語義。第一個參數是一個指向函數的指針,它應該被初始化爲被掛鉤的原始函數。第二個參數是一個包含你的鉤子函數的指針函數。

查看This blog的例子。

所以你不能只是傳遞函數。您必須初始化變量,例如:

// 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); 
相關問題