Open BiscuteOwO opened 7 months ago
I think it's because MH_RemoveHook(MH_ALL_HOOKS)
is never called during the shutdown process. So when the second call to bind reaches the following lines, it fails with Status::UnknownError
if (MH_CreateHook(target, _function, _original) != MH_OK || MH_EnableHook(target) != MH_OK) {
return Status::UnknownError;
}
Just a guess, though. Didn't try it myself, but see if you can fix it by adding that MH_RemoveHook(MH_ALL_HOOKS)
call. in the kiero::shutdown
function.
uhh, it still happens sir, and seems it cant get swapchain info on second init, i try to init d3d11 and hook it, when program find out the target is not using d3d11 then hook d3d12, and can not hook present, but the part of hook to get g_pD3D12CommandQueue is fine
I had a similar issue when trying to make a mod menu. What I did was hook a DX12 function to retrieve the command queue, sleep the thread for 2 seconds, then if the command queue was captured successfully, continue using DX12 as normal (hook the present function). Otherwise, unbind and shutdown kiero and reinitialize with D3D11 and then hook the present function. It's a bit of a hackish solution but it works.
bool init() {
if (kiero::init(kiero::RenderType::D3D12) == kiero::Status::Success) {
kiero::bind(54, (void **)&oExecuteCommandLists, hookExecuteCommandLists);
std::this_thread::sleep_for(std::chrono::seconds(2));
if (commandQueue == nullptr) {
kiero::unbind(54);
kiero::shutdown();
return false;
}
kiero::bind(140, (void **)&oPresent, hookPresent);
return true;
}
return false;
}
void initCaller() {
if (init()) {
// we're using DX12
} else {
// reinitialize kiero with DX11 here and hook the present function
}
}
uh i figured it out, the second bind's index(both dx11 dx12) refers to same swapchain address, and this make second hook failed, thank you mate
well its like kiero::init(kiero::RenderType::D3D11); 👇 kiero::bind(8, (void)&oEndScene, hkEndScene); 👇 kiero::shutdown(); 👇 kiero::init(kiero::RenderType::D3D11); 👇 kiero::bind(8, (void)&oEndScene, hkEndScene); the last bind will not work for some reason, and i tried on d3d12, things still happen, what can i do