Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i have a skill issue #60

Open
BiscuteOwO opened this issue Mar 20, 2024 · 4 comments
Open

i have a skill issue #60

BiscuteOwO opened this issue Mar 20, 2024 · 4 comments

Comments

@BiscuteOwO
Copy link

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

@fadillzzz
Copy link

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.

@BiscuteOwO
Copy link
Author

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

@fadillzzz
Copy link

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
          }
        }

@BiscuteOwO
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants