Skip to content

Header-only library allowing setup of dynamic DLL proxying in one line.

License

Notifications You must be signed in to change notification settings

techiew/UniversalProxyDLL

Repository files navigation

Universal Proxy DLL

A header-only library for proxying DLLs with one function call:

One function call pic

Features:

  • No .masm or .def files required
  • No project configuration required
  • Built DLL can dynamically proxy any supported DLL without rebuilding (just rename the DLL)
  • Set callbacks for exported functions
  • No race conditions (exported functions will wait for proxy creation)
  • No LoadLibrary calls within DllMain
  • Works for 32-bit and 64-bit games (32-bit has limited support!)

Example

A simple DLL with a DllMain looking like this:

DllMain example pic

Is all that is needed, the DLL is then proxied properly (dxgi.dll was proxied in this example):

Proxy example pic

Note: The debug terminal is optional.

You can then create a new thread and do the usual proxy DLL stuff:

Usual proxy stuff pic

Callback example

You may add callbacks to exported functions (dinput8.dll was used in this example):

Callback example pic

Your callback will be called when the exported function is called (directly prior to it).

Note: You'll have to specify the correct function signature in the same manner as shown in the example. For instance, the function signature for "DirectInput8Create" used in the example was found here.

Supported DLLs

Yes, technically this is not universal, only on paper. See section "Adding support for a DLL".

The most common proxy DLLs are supported out of the box:

  • dxgi
  • d3d10
  • d3d11
  • d3d12 (see issue #1)
  • dinput8
  • XInput1_3
  • XInput1_4
  • steam_api64
  • steam_api
  • opengl32
  • winhttp
  • bink2w64

Note: I do not guarantee that all supported DLLs will work for 32-bit games. Trial and error is required in this case.

Adding support for a DLL

Adding support for a DLL is simple. In the "scripts" folder you will find some Python scripts.

Use the "create_export_list.py" script by running python create_export_list.py <path_to_dll>. This will create a "<dll>_export_list.txt" file in the script folder:

create_export_list pic

Copy the contents of the generated file to somewhere at the bottom of "UniversalProxyDLL.h" and build:

New exports pic

The DLL should now be proxied correctly.

However if your DLL has more exports than the current amount of Forward and ForwardOrdinal functions, you must also use the scripts "create_export_ordinals.py" and "create_forward_functions.py" to generate an amount of functions equal to the number of exports of your DLL.

Note: some system DLLs such as user32 may refuse to be proxied!

Checking which DLLs a game loads

To check which DLLs you can use to create proxies for specific games, you may for example use the "dumpbin" tool provided with Visual Studio:

Dumpbin pic

Used in...

Some of my other projects, such as DirectXHook and Elden Mod Loader.

Contributions

If you find that a DLL is not supported and you've added the exports yourself, I'd appreciate if you'd create a PR so the exports can be made available to others. Thank you.

License

LICENSE.md

About

Header-only library allowing setup of dynamic DLL proxying in one line.

Resources

License

Stars

Watchers

Forks

Packages

No packages published