Rebzzel / kiero

Universal graphical hook for a D3D9-D3D12, OpenGL and Vulkan based games.
MIT License
1.01k stars 217 forks source link

problem about kiero::bind #2

Closed WallBreaker2 closed 5 years ago

WallBreaker2 commented 5 years ago

the kiero::bind(..) function is defined as follow: void kiero::bind(uint16_t _index, void _original, void _function) { // TODO: Need own detour function

ifdef KIERO_USE_MINHOOK

if (g_renderType > 0)
{
    MH_CreateHook((void*)g_methodsTable[_index], _function, &_original);
    MH_EnableHook((void*)g_methodsTable[_index]);
}

endif

} but it just change the Formal parameters instead of actual parameters. so the call like kiero::bind(42, oEndScene, hkEndScene) do not work and can casue process crash. I change it as follow: //void kiero::bind(uint16_t _index, void _original, void _function) void kiero::bind(uint16_t _index, void* _original, void _function) { // TODO: Need own detour function

ifdef KIERO_USE_MINHOOK

if (g_renderType > 0)
{
    //MH_CreateHook((void*)g_methodsTable[_index], _function, &_original);
    MH_CreateHook((void*)g_methodsTable[_index], _function, _original);
    MH_EnableHook((void*)g_methodsTable[_index]);

}

endif

} and the call kiero::bind(42, (void**)&g_oEndScene, hkEndScene) works well.

Rebzzel commented 5 years ago

Probably, it happened because i wrote this code at night. Thanks you for reporting. Will be fixed on a next commit.