Rebzzel / kiero

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

[D3D9] Full screen hook not working #10

Closed xHeisa closed 4 years ago

xHeisa commented 4 years ago

Hello. I am hooking Reset and Present like this but it does not seem to work when the game is in full screen.

#define KIERO_USE_MINHOOK    1
    if (kiero::init(kiero::RenderType::D3D9) == kiero::Status::Success)
    {
        kiero::bind(16, (void**)&context::reset_original, context::reset_hook);

        kiero::bind(17, (void**)&context::present_original, context::present_hook);
    }

Present never gets called, but it works fine in borderless / windowed mode. The game's name is Rocket League. Thanks in advance.

Rebzzel commented 4 years ago

Hello, @xHeisa!

How do you check that Present is not called? Using the debugger, console print or calls draw functions?

If you using console print you should keep in mind that the function will only be called when the game window is expanded. If debugger or drawing function, then you might want to try playing with this parameter.

I don't have this game so I can't check it out. But in the games I tested, everything worked fine.

Have a nice day!

xHeisa commented 4 years ago

Hello, @xHeisa!

Hello, @Rebzzel , thank you for taking the time to reply on the issue I'm having.

How do you check that Present is not called? Using the debugger, console print or calls draw functions?

I am printing with console prints.

I have added some message boxes in the source code to see where it is failing, it seems to be entering here:

https://github.com/Rebzzel/kiero/blob/master/kiero.cpp#L129

devenv_2020-03-21_22-30-09

The message box shows this line.

If debugger or drawing function, then you might want to try playing with this parameter.

I have tried to change that parameter, but to no avail.

Rebzzel commented 4 years ago

Hmm, it looks weird.

Try to see what CreateDevice returns. It must be something from here.

Have a nice day!

Rebzzel commented 4 years ago

Veeeeeeery weird, because everything works fine for me. proof

xHeisa commented 4 years ago

Thank you for confirming that my doubts about this hook were wrong, it turns out it might actually be from the renderer I am using.

I seem to be getting a black screen when minimizing / going to full screen

https://github.com/yazzn/renderer_d3d9

Rebzzel commented 4 years ago

Yes, I encountered the same problem when testing the imgui example. Here is my solve. Try to see probably it will give you an idea.

Good luck, @xHeisa!

xHeisa commented 4 years ago

@Rebzzel again, thank you. Would it be possible for you to also try that d3d9 renderer ? I am not sure what needs to be "reset" from that renderer.

I think that's causing the black screen. And maybe you can add it as an example renderer, because it's really fast at drawing and almost no FPS drops.

Rebzzel commented 4 years ago

Hmm. I think the solution to the problem for this render is quite simple.

Since the author didn't bother to write the reset function, you will have to do it yourself. This will be easy enough to do.

See how this is done in imgui: https://github.com/ocornut/imgui/blob/master/examples/imgui_impl_dx9.cpp#L275 https://github.com/ocornut/imgui/blob/master/examples/imgui_impl_dx9.cpp#L247

You will need to do the same with these parameters: https://github.com/yazzn/renderer_d3d9/blob/master/renderer/renderer.hpp#L102 https://github.com/yazzn/renderer_d3d9/blob/master/renderer/renderer.hpp#L103 https://github.com/yazzn/renderer_d3d9/blob/master/font/font.hpp#L49

And call your received result as here.

xHeisa commented 4 years ago

@Rebzzel The author of the renderer seems to have wrote those functions: https://github.com/yazzn/renderer_d3d9/blob/master/renderer/renderer.cpp#L18 https://github.com/yazzn/renderer_d3d9/blob/master/renderer/renderer.cpp#L77

Now I'm calling those functions in Reset, and everything seems working good, except resolution changes, that renderer does not seem to account for that, causing drawings to be miss-positioned if you change the resolution.

Thank you for your help and your example implementations, fixed a few bugs too!