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

Encountered an issue while using the Example Dx11 Hook with Dx11Game Rune Factory 5 #130

Closed
vsylva opened this issue Aug 27, 2023 · 15 comments · Fixed by #158
Closed

Encountered an issue while using the Example Dx11 Hook with Dx11Game Rune Factory 5 #130

vsylva opened this issue Aug 27, 2023 · 15 comments · Fixed by #158
Labels
bug Something isn't working dx11
Milestone

Comments

@vsylva
Copy link
Contributor

vsylva commented Aug 27, 2023

GIF 2023-8-27 23-19-53

hudhook rev 3b86352

The game is unable to respond to the mouse and keyboard inputs properly.

No ERROR is displayed on the console.

After pressing a key, the game responds multiple times to the pressed key after a few seconds. Mouse clicks require multiple attempts, and the response is delayed by a few seconds.

From the example dx11_hook

use hudhook::hooks::dx11::ImguiDx11Hooks;
use hudhook::hooks::ImguiRenderLoop;

use tracing::metadata::LevelFilter;
struct Dx11HookExample;

impl Dx11HookExample {
    fn new() -> Self {
        println!("Initializing");
        hudhook::alloc_console().expect("AllocConsole");
        hudhook::enable_console_colors();

        tracing_subscriber::fmt()
            .with_max_level(LevelFilter::ERROR)
            .with_thread_ids(true)
            .with_file(true)
            .with_line_number(true)
            .with_thread_names(true)
            .init();

        Dx11HookExample
    }
}

impl ImguiRenderLoop for Dx11HookExample {
    fn render(&mut self, _ui: &mut imgui::Ui) {
        // ui.window("Hello world").size([300.0, 110.0], Condition::FirstUseEver).build(|| {
        //     ui.text("Hello world!");
        //     ui.text("こんにちは世界!");
        //     ui.text("This...is...imgui-rs!");
        //     ui.separator();
        //     let mouse_pos = ui.io().mouse_pos;
        //     ui.text(format!("Mouse Position: ({:.1},{:.1})", mouse_pos[0], mouse_pos[1]));
        // });
    }
}

hudhook::hudhook!(Dx11HookExample::new().into_hook::<ImguiDx11Hooks>());
@vsylva
Copy link
Contributor Author

vsylva commented Aug 27, 2023

I have tried multiple methods, but still unable to resolve the issue🤷
I performed hooking using C++ and rendered an ImGui demo window, and did not encounter the aforementioned issues.

@veeenu
Copy link
Owner

veeenu commented Aug 27, 2023

It looks like mouse inputs are being translated incorrectly somewhere.

The most likely culprit should be the new raw input system or possibly something to do with client rects.

This new input system is rather recent and I've only personally tested it against the ds3 and er practice tools (and the integration test cases).

Could you try with a much earlier version of hudhook (this commit is the last one without the input system) and report whether it still fails or it behaves correctly?

(P.S. thank you for reporting this, I was about to release 0.5 but I want this to be fixed before that happens.)

@veeenu veeenu added the bug Something isn't working label Aug 27, 2023
@veeenu veeenu added this to the 0.5.0 milestone Aug 27, 2023
@vsylva
Copy link
Contributor Author

vsylva commented Aug 27, 2023

It looks like mouse inputs are being translated incorrectly somewhere.

The most likely culprit should be the new raw input system or possibly something to do with client rects.

This new input system is rather recent and I've only personally tested it against the ds3 and er practice tools (and the integration test cases).

Could you try with a much earlier version of hudhook (this commit is the last one without the input system) and report whether it still fails or it behaves correctly?

(P.S. thank you for reporting this, I was about to release 0.5 but I want this to be fixed before that happens.)

I conducted new tests using ver 0.4, and the issues still persist.
In two other games, Sekiro and Raft, ver 0.4 and 0.5 can successfully hook

@veeenu
Copy link
Owner

veeenu commented Aug 27, 2023

Could you try running ReShade against the game, and check whether you get similar behavior? If everything works ok with it, this is probably not dependent on the input processing but on something else. If ReShade has similar problems, I'm not sure how to proceed.

@vsylva
Copy link
Contributor Author

vsylva commented Aug 27, 2023

Could you try running ReShade against the game, and check whether you get similar behavior? If everything works ok with it, this is probably not dependent on the input processing but on something else. If ReShade has similar problems, I'm not sure how to proceed.

ReShade 5.9.2 successfully hooked, and MSI Afterburner was also successfully hooked.

@vsylva
Copy link
Contributor Author

vsylva commented Aug 28, 2023

A new issue has emerged where injection into the DX11 game 'Richman 10' results in this situation. This problem does not occur when using a test DLL written in C++.

hudhook

2
1

cpp

cpp

@veeenu
Copy link
Owner

veeenu commented Aug 28, 2023

Which hooking engine does the C++ version use? I think we could compare DX11 hook implementations and see what we got wrong.

P.S. these "insufficient display size" errors are common when the game window is minimized. Otherwise it means the game has more than one hwnd and we got the wrong one somehow.

@vsylva
Copy link
Contributor Author

vsylva commented Aug 28, 2023

Which hooking engine does the C++ version use? I think we could compare DX11 hook implementations and see what we got wrong.

P.S. these "insufficient display size" errors are common when the game window is minimized. Otherwise it means the game has more than one hwnd and we got the wrong one somehow.

This one /~https://github.com/vSylva/d3d_hook_with_imgui

@veeenu
Copy link
Owner

veeenu commented Aug 28, 2023

I see you are using imgui's own dx11 renderer which may have deviated from my implementation over time. Your C++ resize hook impl is also much simpler in flow than mine, so that could also be a possible culprit.

I'm honestly not sure what could trigger this. I have briefly looked into it but it's probably going to take me quite a bit of time to find all the similarities/differences. I very much want to see this solved though as I want to target as wide a coverage as possible.

@vsylva
Copy link
Contributor Author

vsylva commented Aug 28, 2023

I see you are using imgui's own dx11 renderer which may have deviated from my implementation over time. Your C++ resize hook impl is also much simpler in flow than mine, so that could also be a possible culprit.

I'm honestly not sure what could trigger this. I have briefly looked into it but it's probably going to take me quite a bit of time to find all the similarities/differences. I very much want to see this solved though as I want to target as wide a coverage as possible.

Haha, i prefer hudhook over cpp, this problem is really giving a headache

@veeenu veeenu modified the milestones: 0.5.0, 0.6.0 Sep 28, 2023
@veeenu veeenu added the dx11 label Oct 31, 2023
@veeenu veeenu mentioned this issue Feb 24, 2024
4 tasks
@vsylva
Copy link
Contributor Author

vsylva commented Feb 28, 2024

/~https://github.com/veeenu/hudhook/blob/heck-compositors-altogether/examples/demo_hook_dx11.rs

(DX11) Rune Factory 5 seems to work well, no keyboard key issues have appeared

RF5_TEST.mp4

(DX11) richman10

After the game starts, a progress bar for loading resources will appear

image

Injecting demo_hook_dx11.dll at this time will cause the game window to turn black

image

At the same time, an error occurs

image

After the game finishes loading resources, the ImGui demo will be displayed correctly

image

@veeenu
Copy link
Owner

veeenu commented Feb 28, 2024

Glad to see at least the input errors and the weird artifacts are gone. I think the blackout issue could stem from the fact that currently we're not backing up the renderer state and so it gets completely overridden.

For some reason my state backup code is consistently crashing so I commented that out until I figure out why.

As an aside, I want to build more complex test harnesses (a rotating cube would be enough) in order to have a "closer to real life" testbed.

@veeenu
Copy link
Owner

veeenu commented Feb 29, 2024

@vsylva I have added state backup back to Dx11. It should not crash now. Could you please give richman10 another spin?

@vsylva
Copy link
Contributor Author

vsylva commented Feb 29, 2024

@vsylva I have added state backup back to Dx11. It should not crash now. Could you please give richman10 another spin?

Thank you
A new issue has arisen: injection causes a crash

image

@vsylva
Copy link
Contributor Author

vsylva commented Feb 29, 2024

78c8d21

It appears to be working well

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dx11
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants