1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Using RTSSHooks.dll in my C++ Program

Discussion in 'Rivatuner Statistics Server (RTSS) Forum' started by Gilad, May 11, 2019.

  1. Gilad

    Gilad New Member

    Messages:
    3
    Likes Received:
    0
    GPU:
    GTX
    Hey everyone,

    This is my first post here, so my apologies if I post in the wrong section.
    First of all, I would like to thank the owner of RTSS for this awesome tool that from all the tools I found out there, does the best job.
    Now to the topic:
    I'm hooking a really old game client that uses DirectX-8 that has some issues with frame rate fluctuation due to not having frame rate limitation which causes shuttering that affects the game play. If I use RTSS to cap the frame rate, everything works well in the game and no undefined behavior.
    So my approach was, to create my own DLL called i.e; FPSLimit.dll and then patching the entry point of the old game client to LoadLibrary on my custom dll, so when my dll gets loaded, I spawn a new thread to cap the frame rate automatically of the caller module, without having to manually inject the dll using external program or anything like that.
    Now I tried different approaches to cap the frame rate which kind of failed for me and then I did some more re-search on RTSS and how does the SDK works, so I can maybe use my DLL to use RTSS functionality which will help me do what I want, without having to re-invent the wheels.
    I found 2 samples under the installation folder; `Pipe` and `SharedMemory`, which the code there wasn't very clear to get to my approach and interact with the RTSS SDK. I then realized, that the `RTSS.exe` uses `RTUI.dll` for the GUI functionality using the MFC framework and all the actual behavior happens in the `RTSSHooks.dll`, which loads a profile and by using the profile, it knows what process to hook.

    So my questions are:
    * How would I actually use `RTSSHooks.dll` to simply hook a specified process just so I can cap the frame rate?
    * How does RTSS actually cap the frame rate? is it using the actual graphic card driver? Or does it find the pointer to the direct3d device and hook all the calls to present so it will actually be responsible on presenting the frame when the time is right to present depending on the Limit value?

    I got kind of lost in that which is why I opened an account in this forum so I can find some direction of better approaches for what I want to achieve and I would kindly appreciate any help and hints!
    Thank you very much for reading!

    Regards,
    Gilad
     
    Last edited: May 11, 2019
  2. Unwinder

    Unwinder Moderator Staff Member

    Messages:
    14,209
    Likes Received:
    1,269
    > * How would I actually use `RTSSHooks.dll` to simply hook a specified process just so I can cap the frame rate?

    You cannot make it hook just specified process and just to cap framerate. Only global hook can be installed, with all functionality (OSD and so on) enabled and it will be injected in all running processes. Just like RTSS were running without GUI.

    > Or does it find the pointer to the direct3d device and hook all the calls to present so it will actually be responsible on presenting the frame when the time is right to present depending on the Limit value?


    This
     
  3. Gilad

    Gilad New Member

    Messages:
    3
    Likes Received:
    0
    GPU:
    GTX
    Thanks for the reply Unwinder!
    Hmm...I wonder how it's not possible if the GUI application uses RTSSHooks.dll while having the ability specifying a specific profile(process) to hook? I'm asking because, how come the RTSS GUI can do that and I can't? while the core functionality exists in the RTSSHooks.dll. Sounds like a design fault if that's the case. :/
    There is no good example of using the actual DLL functionality? I'm confused because I saw you provided an actual SDK for the application with 2 samples, so I guess your intention was to make it possible for other fellow developers to use it's core functionality(probably misunderstanding on my side).

    My apologies if I sounded a little harsh, but as a developer(I guess most of us), I don't want to waste my time and re-invent the wheels having to create my own hook.
     
  4. Unwinder

    Unwinder Moderator Staff Member

    Messages:
    14,209
    Likes Received:
    1,269
    That's not a design fault and honestly what you say is just impolite if not insulting, sorry. I don't believe that a developer can misunderstand the meaning of "global hook" term. RTSS is NOT intended to be injected just in one desired process. It is global hook intended to be injected in everything with a possibility of blacklisting some processes via application profiles.


    RTSSHooks DLL is NOT intended to be used without RTSS. Quite opposite, license agreement is prohibiting to redistribute core RTSS components independently.
    And I'm afraid that I stop replying at this point, sorry.

     

  5. Gilad

    Gilad New Member

    Messages:
    3
    Likes Received:
    0
    GPU:
    GTX
    I'm sorry you had to take it in a personal way and attack back.

    Did not have any plans to redistribute it, just for a personal use.

    Well, thanks for your time anyway, I guess I have another little project added to my todo list and open-source it.
     
  6. Unwinder

    Unwinder Moderator Staff Member

    Messages:
    14,209
    Likes Received:
    1,269
    No problem. DX hooking is an interesting and challenging task so doing it yourself will give you nice experience.
     

Share This Page