Rebzzel / kiero

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

Add support for hooking multiple rendering types #40

Closed Symbai closed 3 years ago

Symbai commented 3 years ago

For an universal graphic hooking library it would be nice if we can hook multiple instead of just one rendering type. Kiero checks for libraries and address already. We could get rid of specifying the rendering type, just check for all loaded libraries and addresses. And let us hook them if we want to.

Example:

int success = kiero::init();
if (kiero::isInitialized(kiero::RenderType::D3D9))
{
    kiero::bind(kiero::RenderType::D3D9, 16, (void**)&oReset, hkReset);
}

if (kiero::isInitialized(kiero::RenderType::D3D10))
{
    kiero::bind(kiero::RenderType::D3D10, 8, (void**)&oPresent, hkPresent);
}

Reason is that several games have loaded multiple rendering libraries even if they currently don't use them. For example RDR2 has loaded Vulcan and DX12. With the example above we can write one library that works no matter which rendering engine the user is currently using. While right now, we have to build one dx12 library and one vulcan library.

Rebzzel commented 3 years ago

I have already commented it #27 here.

Symbai commented 3 years ago

Using RenderType::Auto doesn't work on these targets. Because using Auto it will use the first RenderType it finds. If game has DX12 and Vulcan library loaded but game uses Vulcan, using RenderingType::Auto sets hook to DX12 instead of Vulcan. Because DX12 comes in your loop first. It simply quits as soon as it has found a known module.

My idea is to hook all loaded rendering types. But for this people need to change minhook as it doesn't allow hooking a function twice (which will happen on hooking DX11 and DX12 present function as its identical).

Rebzzel commented 3 years ago

You should reread the topic again.