├── .gitignore ├── LICENSE.md ├── README.md ├── UltimateProxyDLL.h ├── UltimateProxyDLL.sln ├── UltimateProxyDLL.vcxproj ├── UltimateProxyDLL.vcxproj.filters ├── dllmain.cpp ├── python_scripts ├── create_export_list.py ├── create_export_ordinals.py └── create_forward_functions.py └── readme_pictures ├── callback_example.png ├── create_export_list.png ├── dllmain_example.png ├── dumpbin.png ├── new_exports.png ├── one_function_call.png ├── proxy_example.png └── usual_proxy_stuff.png /.gitignore: -------------------------------------------------------------------------------- 1 | upd_log.txt 2 | python_scripts/*.txt 3 | 4 | ## Ignore Visual Studio temporary files, build results, and 5 | ## files generated by popular Visual Studio add-ons. 6 | ## 7 | ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore 8 | 9 | # User-specific files 10 | *.rsuser 11 | *.suo 12 | *.user 13 | *.userosscache 14 | *.sln.docstates 15 | 16 | # User-specific files (MonoDevelop/Xamarin Studio) 17 | *.userprefs 18 | 19 | # Mono auto generated files 20 | mono_crash.* 21 | 22 | # Build results 23 | [Dd]ebug/ 24 | [Dd]ebugPublic/ 25 | [Rr]elease/ 26 | [Rr]eleases/ 27 | x64/ 28 | x86/ 29 | [Ww][Ii][Nn]32/ 30 | [Aa][Rr][Mm]/ 31 | [Aa][Rr][Mm]64/ 32 | bld/ 33 | [Bb]in/ 34 | [Oo]bj/ 35 | [Ll]og/ 36 | [Ll]ogs/ 37 | 38 | # Visual Studio 2015/2017 cache/options directory 39 | .vs/ 40 | # Uncomment if you have tasks that create the project's static files in wwwroot 41 | #wwwroot/ 42 | 43 | # Visual Studio 2017 auto generated files 44 | Generated\ Files/ 45 | 46 | # MSTest test Results 47 | [Tt]est[Rr]esult*/ 48 | [Bb]uild[Ll]og.* 49 | 50 | # NUnit 51 | *.VisualState.xml 52 | TestResult.xml 53 | nunit-*.xml 54 | 55 | # Build Results of an ATL Project 56 | [Dd]ebugPS/ 57 | [Rr]eleasePS/ 58 | dlldata.c 59 | 60 | # Benchmark Results 61 | BenchmarkDotNet.Artifacts/ 62 | 63 | # .NET Core 64 | project.lock.json 65 | project.fragment.lock.json 66 | artifacts/ 67 | 68 | # ASP.NET Scaffolding 69 | ScaffoldingReadMe.txt 70 | 71 | # StyleCop 72 | StyleCopReport.xml 73 | 74 | # Files built by Visual Studio 75 | *_i.c 76 | *_p.c 77 | *_h.h 78 | *.ilk 79 | *.meta 80 | *.obj 81 | *.iobj 82 | *.pch 83 | *.pdb 84 | *.ipdb 85 | *.pgc 86 | *.pgd 87 | *.rsp 88 | *.sbr 89 | *.tlb 90 | *.tli 91 | *.tlh 92 | *.tmp 93 | *.tmp_proj 94 | *_wpftmp.csproj 95 | *.log 96 | *.tlog 97 | *.vspscc 98 | *.vssscc 99 | .builds 100 | *.pidb 101 | *.svclog 102 | *.scc 103 | 104 | # Chutzpah Test files 105 | _Chutzpah* 106 | 107 | # Visual C++ cache files 108 | ipch/ 109 | *.aps 110 | *.ncb 111 | *.opendb 112 | *.opensdf 113 | *.sdf 114 | *.cachefile 115 | *.VC.db 116 | *.VC.VC.opendb 117 | 118 | # Visual Studio profiler 119 | *.psess 120 | *.vsp 121 | *.vspx 122 | *.sap 123 | 124 | # Visual Studio Trace Files 125 | *.e2e 126 | 127 | # TFS 2012 Local Workspace 128 | $tf/ 129 | 130 | # Guidance Automation Toolkit 131 | *.gpState 132 | 133 | # ReSharper is a .NET coding add-in 134 | _ReSharper*/ 135 | *.[Rr]e[Ss]harper 136 | *.DotSettings.user 137 | 138 | # TeamCity is a build add-in 139 | _TeamCity* 140 | 141 | # DotCover is a Code Coverage Tool 142 | *.dotCover 143 | 144 | # AxoCover is a Code Coverage Tool 145 | .axoCover/* 146 | !.axoCover/settings.json 147 | 148 | # Coverlet is a free, cross platform Code Coverage Tool 149 | coverage*.json 150 | coverage*.xml 151 | coverage*.info 152 | 153 | # Visual Studio code coverage results 154 | *.coverage 155 | *.coveragexml 156 | 157 | # NCrunch 158 | _NCrunch_* 159 | .*crunch*.local.xml 160 | nCrunchTemp_* 161 | 162 | # MightyMoose 163 | *.mm.* 164 | AutoTest.Net/ 165 | 166 | # Web workbench (sass) 167 | .sass-cache/ 168 | 169 | # Installshield output folder 170 | [Ee]xpress/ 171 | 172 | # DocProject is a documentation generator add-in 173 | DocProject/buildhelp/ 174 | DocProject/Help/*.HxT 175 | DocProject/Help/*.HxC 176 | DocProject/Help/*.hhc 177 | DocProject/Help/*.hhk 178 | DocProject/Help/*.hhp 179 | DocProject/Help/Html2 180 | DocProject/Help/html 181 | 182 | # Click-Once directory 183 | publish/ 184 | 185 | # Publish Web Output 186 | *.[Pp]ublish.xml 187 | *.azurePubxml 188 | # Note: Comment the next line if you want to checkin your web deploy settings, 189 | # but database connection strings (with potential passwords) will be unencrypted 190 | *.pubxml 191 | *.publishproj 192 | 193 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 194 | # checkin your Azure Web App publish settings, but sensitive information contained 195 | # in these scripts will be unencrypted 196 | PublishScripts/ 197 | 198 | # NuGet Packages 199 | *.nupkg 200 | # NuGet Symbol Packages 201 | *.snupkg 202 | # The packages folder can be ignored because of Package Restore 203 | **/[Pp]ackages/* 204 | # except build/, which is used as an MSBuild target. 205 | !**/[Pp]ackages/build/ 206 | # Uncomment if necessary however generally it will be regenerated when needed 207 | #!**/[Pp]ackages/repositories.config 208 | # NuGet v3's project.json files produces more ignorable files 209 | *.nuget.props 210 | *.nuget.targets 211 | 212 | # Microsoft Azure Build Output 213 | csx/ 214 | *.build.csdef 215 | 216 | # Microsoft Azure Emulator 217 | ecf/ 218 | rcf/ 219 | 220 | # Windows Store app package directories and files 221 | AppPackages/ 222 | BundleArtifacts/ 223 | Package.StoreAssociation.xml 224 | _pkginfo.txt 225 | *.appx 226 | *.appxbundle 227 | *.appxupload 228 | 229 | # Visual Studio cache files 230 | # files ending in .cache can be ignored 231 | *.[Cc]ache 232 | # but keep track of directories ending in .cache 233 | !?*.[Cc]ache/ 234 | 235 | # Others 236 | ClientBin/ 237 | ~$* 238 | *~ 239 | *.dbmdl 240 | *.dbproj.schemaview 241 | *.jfm 242 | *.pfx 243 | *.publishsettings 244 | orleans.codegen.cs 245 | 246 | # Including strong name files can present a security risk 247 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 248 | #*.snk 249 | 250 | # Since there are multiple workflows, uncomment next line to ignore bower_components 251 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 252 | #bower_components/ 253 | 254 | # RIA/Silverlight projects 255 | Generated_Code/ 256 | 257 | # Backup & report files from converting an old project file 258 | # to a newer Visual Studio version. Backup files are not needed, 259 | # because we have git ;-) 260 | _UpgradeReport_Files/ 261 | Backup*/ 262 | UpgradeLog*.XML 263 | UpgradeLog*.htm 264 | ServiceFabricBackup/ 265 | *.rptproj.bak 266 | 267 | # SQL Server files 268 | *.mdf 269 | *.ldf 270 | *.ndf 271 | 272 | # Business Intelligence projects 273 | *.rdl.data 274 | *.bim.layout 275 | *.bim_*.settings 276 | *.rptproj.rsuser 277 | *- [Bb]ackup.rdl 278 | *- [Bb]ackup ([0-9]).rdl 279 | *- [Bb]ackup ([0-9][0-9]).rdl 280 | 281 | # Microsoft Fakes 282 | FakesAssemblies/ 283 | 284 | # GhostDoc plugin setting file 285 | *.GhostDoc.xml 286 | 287 | # Node.js Tools for Visual Studio 288 | .ntvs_analysis.dat 289 | node_modules/ 290 | 291 | # Visual Studio 6 build log 292 | *.plg 293 | 294 | # Visual Studio 6 workspace options file 295 | *.opt 296 | 297 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 298 | *.vbw 299 | 300 | # Visual Studio 6 auto-generated project file (contains which files were open etc.) 301 | *.vbp 302 | 303 | # Visual Studio 6 workspace and project file (working project files containing files to include in project) 304 | *.dsw 305 | *.dsp 306 | 307 | # Visual Studio 6 technical files 308 | *.ncb 309 | *.aps 310 | 311 | # Visual Studio LightSwitch build output 312 | **/*.HTMLClient/GeneratedArtifacts 313 | **/*.DesktopClient/GeneratedArtifacts 314 | **/*.DesktopClient/ModelManifest.xml 315 | **/*.Server/GeneratedArtifacts 316 | **/*.Server/ModelManifest.xml 317 | _Pvt_Extensions 318 | 319 | # Paket dependency manager 320 | .paket/paket.exe 321 | paket-files/ 322 | 323 | # FAKE - F# Make 324 | .fake/ 325 | 326 | # CodeRush personal settings 327 | .cr/personal 328 | 329 | # Python Tools for Visual Studio (PTVS) 330 | __pycache__/ 331 | *.pyc 332 | 333 | # Cake - Uncomment if you are using it 334 | # tools/** 335 | # !tools/packages.config 336 | 337 | # Tabs Studio 338 | *.tss 339 | 340 | # Telerik's JustMock configuration file 341 | *.jmconfig 342 | 343 | # BizTalk build output 344 | *.btp.cs 345 | *.btm.cs 346 | *.odx.cs 347 | *.xsd.cs 348 | 349 | # OpenCover UI analysis results 350 | OpenCover/ 351 | 352 | # Azure Stream Analytics local run output 353 | ASALocalRun/ 354 | 355 | # MSBuild Binary and Structured Log 356 | *.binlog 357 | 358 | # NVidia Nsight GPU debugger configuration file 359 | *.nvuser 360 | 361 | # MFractors (Xamarin productivity tool) working folder 362 | .mfractor/ 363 | 364 | # Local History for Visual Studio 365 | .localhistory/ 366 | 367 | # Visual Studio History (VSHistory) files 368 | .vshistory/ 369 | 370 | # BeatPulse healthcheck temp database 371 | healthchecksdb 372 | 373 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 374 | MigrationBackup/ 375 | 376 | # Ionide (cross platform F# VS Code tools) working folder 377 | .ionide/ 378 | 379 | # Fody - auto-generated XML schema 380 | FodyWeavers.xsd 381 | 382 | # VS Code files for those working on multiple tools 383 | .vscode/* 384 | !.vscode/settings.json 385 | !.vscode/tasks.json 386 | !.vscode/launch.json 387 | !.vscode/extensions.json 388 | *.code-workspace 389 | 390 | # Local History for Visual Studio Code 391 | .history/ 392 | 393 | # Windows Installer files from build outputs 394 | *.cab 395 | *.msi 396 | *.msix 397 | *.msm 398 | *.msp 399 | 400 | # JetBrains Rider 401 | *.sln.iml 402 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ultimate Proxy DLL 2 | A header-only library for proxying DLLs with one function call: 3 | 4 | ```cpp 5 | UPD::CreateProxy(dll); 6 | ``` 7 | 8 | ### Features: 9 | * No .masm or other assembly files required 10 | * No module definition files (.def) files required 11 | * No project configuration required 12 | * Built DLL can dynamically proxy any [supported DLL](#supported-dlls) without rebuilding (just rename the DLL) 13 | * Easily create [callbacks](#adding-a-callback) for exported functions 14 | * No race conditions (exported functions will wait for proxy creation) 15 | * No [LoadLibrary calls](https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-best-practices) within DllMain 16 | * Works for 32-bit and 64-bit games (32-bit has limited support!) 17 | 18 | UPD is mainly designed with game modding and the distribution of mods in mind. 19 | 20 | With the limited namespace available for proxy DLLs and thus the possibility of conflicts, letting your users use any DLL name without distributing multiple versions of your mod is a big plus. 21 | 22 | ## Usage 23 | A simple DllMain is all that is needed: 24 | 25 | ```cpp 26 | #include 27 | 28 | #include "UltimateProxyDLL.h" 29 | 30 | BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) 31 | { 32 | if (fdwReason == DLL_PROCESS_ATTACH) 33 | { 34 | UPD::OpenDebugTerminal(); 35 | UPD::CreateProxy(hinstDLL); 36 | } 37 | return TRUE; 38 | } 39 | ``` 40 | 41 | That's it! The DLL will then be proxied properly. 42 | 43 | In the following example, Elden Ring was proxied with a dxgi.dll proxy: 44 | 45 | ![Proxy example pic](https://github.com/techiew/UltimateProxyDLL/blob/master/readme_pictures/proxy_example.png) 46 | 47 | **Note: The debug terminal is optional.** 48 | 49 | From there you can create a new thread and do the usual proxy DLL stuff: 50 | 51 | ```cpp 52 | #include 53 | 54 | #include "UltimateProxyDLL.h" 55 | 56 | DWORD WINAPI NewThread(LPVOID lpParam) 57 | { 58 | printf("Doing some very naughty stuff\n"); 59 | char* p = nullptr; 60 | char c = *p; 61 | return 0; 62 | } 63 | 64 | BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) 65 | { 66 | if (fdwReason == DLL_PROCESS_ATTACH) 67 | { 68 | UPD::OpenDebugTerminal(); 69 | UPD::CreateProxy(hinstDLL); 70 | CreateThread(0, 0, &NewThread, NULL, 0, NULL); 71 | } 72 | return TRUE; 73 | } 74 | ``` 75 | 76 | ## Adding a callback 77 | You may add callbacks back to your own code for when an exported function is called: 78 | 79 | ```cpp 80 | #include 81 | 82 | #include "UltimateProxyDLL.h" 83 | 84 | using FpDirectInput8Create = HRESULT (*)(HINSTANCE, DWORD, REFIID, LPVOID*, LPUNKNOWN); 85 | void* fpDirectInput8Create = nullptr; 86 | 87 | HRESULT CallbackDirectInput8Create(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID* ppvOut, LPUNKNOWN punkOuter) 88 | { 89 | printf("Callback called!\n"); 90 | return (*(FpDirectInput8Create*)fpDirectInput8Create)(hinst, dwVersion, riidltf, ppvOut, punkOuter); 91 | } 92 | 93 | BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) 94 | { 95 | if (fdwReason == DLL_PROCESS_ATTACH) 96 | { 97 | UPD::OpenDebugTerminal(); 98 | fpDirectInput8Create = UPD::RegisterCallback("DirectInput8Create", &CallbackDirectInput8Create); 99 | UPD::CreateProxy(hinstDLL); 100 | } 101 | return TRUE; 102 | } 103 | ``` 104 | 105 | Dinput8.dll was proxied in this example. 106 | 107 | Your callback will be called directly prior to the exported function being executed. 108 | 109 | **Note: It's crucial that the function signature for the callback exactly matches the function signature of the exported function. For instance, the function signature for "DirectInput8Create" used in the example was found [here](https://learn.microsoft.com/en-us/previous-versions/windows/desktop/ee416756(v=vs.85)).** 110 | 111 | **As for the** `return` **with a call to the original exported function - in some cases you might get away with omitting it, but I wouldn't recommend it.** 112 | 113 | ## Supported DLLs 114 | The most common proxy DLLs are supported out of the box: 115 | * dxgi 116 | * d3d10 117 | * d3d11 118 | * d3d12 (callbacks won't work, see [#1](https://github.com/techiew/UltimateProxyDLL/issues/1)) 119 | * dinput8 120 | * XInput1_3 121 | * XInput1_4 122 | * steam_api64 123 | * steam_api 124 | * opengl32 125 | * winhttp 126 | * bink2w64 127 | 128 | See section [Adding support for a DLL](#adding-support-for-a-dll). 129 | 130 | **Note: I do not guarantee that all supported DLLs will work for 32-bit games. Trial and error is required in this case.** 131 | 132 | ## Adding support for a DLL 133 | Adding support for a DLL is simple. In the "python_scripts" folder you will find some Python scripts. 134 | 135 | Use the `create_export_list.py` script by running `python create_export_list.py `. This will create a "<dll>_export_list.txt" file in the script folder: 136 | 137 | ![create_export_list pic](https://github.com/techiew/UltimateProxyDLL/blob/master/readme_pictures/create_export_list.png) 138 | 139 | Copy the contents of the generated file to somewhere at the bottom of "UltimateProxyDLL.h" and build: 140 | 141 | ![New exports pic](https://github.com/techiew/UltimateProxyDLL/blob/master/readme_pictures/new_exports.png) 142 | 143 | The DLL should now be proxied correctly. 144 | 145 | **Note: If your DLL has a higher number of 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 or higher than the number of exports of your DLL.** 146 | 147 | **Also note: Some system DLLs such as user32 may refuse to be proxied!** 148 | 149 | ## Tips and tricks 150 | 151 | ### Checking which DLLs a game loads 152 | 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: 153 | 154 | ![Dumpbin pic](https://github.com/techiew/UltimateProxyDLL/blob/master/readme_pictures/dumpbin.png) 155 | 156 | ### Proxy DLL search order 157 | UPD loads the original to-be-proxied DLL into memory to perform the proxy. 158 | 159 | This search order is followed to find the original DLL: 160 | * Path specified in the call to UPD::CreateProxy (optional) 161 | * The current directory (to do this, add a "_" prefix to the name of the original DLL) 162 | * The system folder 163 | 164 | If the DLL is not found in one location, the next location is attempted. In other words this mimics the Microsoft DLL search order. 165 | 166 | ### Easy way to proxy single DLLs 167 | If you don't care about: 168 | * Function interception/hooking 169 | * Supporting proxying of multiple DLLs at once without rebuilding 170 | * Proxying a DLL that could be in multiple locations (current directory, system folder, ...) 171 | 172 | Then you can simply use this [macro method](https://github.com/mrexodia/perfect-dll-proxy/). 173 | 174 | This method is lightweight, does not require assembly or .def files, and will find the system folder correctly even if someone with a system drive different from yours uses your DLL. 175 | But it can run into issues with ordinals if you want to support dynamic proxying of multiple DLLs at once. 176 | 177 | ### Precompiled DLL for chainloading 178 | I have provided a [precompiled DLL](https://github.com/techiew/UltimateProxyDLL/releases/tag/precompiled-dll) to be used for simple chainloading. 179 | 180 | The precompiled proxy DLL "dxgi.dll" will read the file "upd_chainload.txt" in the working directory and go through the file line by line, calling LoadLibrary on each DLL name it reads. 181 | 182 | As many DLLs as you wish can be entered into the file. Each DLL name must be separated with a newline and end with ".dll". Example entry: ```test.dll```. The precompiled DLL can be renamed to any of the supported DLLs. 183 | 184 | The DLL is built on this commit: [164580d090f7c0625b37fe71d7f52c819df7368a](https://github.com/techiew/UltimateProxyDLL/commit/164580d090f7c0625b37fe71d7f52c819df7368a) 185 | 186 | ### Used in... 187 | Some of my other projects, such as [DirectXHook](https://github.com/techiew/DirectXHook) and [Elden Mod Loader](https://github.com/techiew/EldenRingModLoader). 188 | 189 | ## Contributions 190 | 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. 191 | 192 | ## License 193 | [LICENSE.md](https://github.com/techiew/UltimateProxyDLL/blob/master/LICENSE.md) 194 | -------------------------------------------------------------------------------- /UltimateProxyDLL.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.5.33516.290 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UltimateProxyDLL", "UltimateProxyDLL.vcxproj", "{4BB82839-E406-48B8-9DA5-04EF0183F452}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {4BB82839-E406-48B8-9DA5-04EF0183F452}.Debug|x64.ActiveCfg = Debug|x64 17 | {4BB82839-E406-48B8-9DA5-04EF0183F452}.Debug|x64.Build.0 = Debug|x64 18 | {4BB82839-E406-48B8-9DA5-04EF0183F452}.Debug|x86.ActiveCfg = Debug|Win32 19 | {4BB82839-E406-48B8-9DA5-04EF0183F452}.Debug|x86.Build.0 = Debug|Win32 20 | {4BB82839-E406-48B8-9DA5-04EF0183F452}.Release|x64.ActiveCfg = Release|x64 21 | {4BB82839-E406-48B8-9DA5-04EF0183F452}.Release|x64.Build.0 = Release|x64 22 | {4BB82839-E406-48B8-9DA5-04EF0183F452}.Release|x86.ActiveCfg = Release|Win32 23 | {4BB82839-E406-48B8-9DA5-04EF0183F452}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {681CB4A4-D190-497A-AB55-D19952BDC238} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /UltimateProxyDLL.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {4BB82839-E406-48B8-9DA5-04EF0183F452} 25 | UniversalProxyDLL 26 | 10.0.22000.0 27 | UltimateProxyDLL 28 | 29 | 30 | 31 | DynamicLibrary 32 | true 33 | MultiByte 34 | v143 35 | 36 | 37 | DynamicLibrary 38 | MultiByte 39 | v143 40 | 41 | 42 | DynamicLibrary 43 | true 44 | MultiByte 45 | v143 46 | 47 | 48 | DynamicLibrary 49 | false 50 | MultiByte 51 | v143 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | dxgi 72 | 73 | 74 | dxgi 75 | 76 | 77 | dxgi 78 | 79 | 80 | dxgi 81 | 82 | 83 | 84 | Level3 85 | true 86 | WIN32;_DEBUG;UNIVERSALPROXYDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 87 | true 88 | NotUsing 89 | pch.h 90 | 91 | 92 | Windows 93 | true 94 | 95 | 96 | 97 | 98 | Level3 99 | NotUsing 100 | pch.h 101 | 102 | 103 | Windows 104 | true 105 | 106 | 107 | false 108 | /IGNORE:4202,4104,4197 %(AdditionalOptions) 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | Level3 118 | true 119 | _DEBUG;UNIVERSALPROXYDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 120 | true 121 | NotUsing 122 | pch.h 123 | 124 | 125 | Windows 126 | true 127 | 128 | 129 | 130 | 131 | Level3 132 | NotUsing 133 | pch.h 134 | MultiThreadedDLL 135 | 136 | 137 | Windows 138 | true 139 | 140 | 141 | /IGNORE:4202,4104,4197 %(AdditionalOptions) 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | -------------------------------------------------------------------------------- /UltimateProxyDLL.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | -------------------------------------------------------------------------------- /dllmain.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "UltimateProxyDLL.h" 5 | 6 | BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) 7 | { 8 | if (fdwReason == DLL_PROCESS_ATTACH) 9 | { 10 | try 11 | { 12 | UPD::OpenDebugTerminal(); 13 | UPD::CreateProxy(hinstDLL); 14 | } 15 | catch (std::runtime_error e) 16 | { 17 | std::cout << e.what() << std::endl; 18 | return FALSE; 19 | } 20 | } 21 | return TRUE; 22 | } -------------------------------------------------------------------------------- /python_scripts/create_export_list.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | import subprocess 4 | 5 | try: 6 | import pefile 7 | except ImportError as e: 8 | print("To run this script, please install the 'pefile' package: 'pip install pefile'.") 9 | sys.exit(1) 10 | 11 | if len(sys.argv) != 2: 12 | print("Argument error") 13 | print("Usage: python create_export_list.py ") 14 | sys.exit(1) 15 | 16 | dllpath = sys.argv[1] 17 | if not os.path.exists(dllpath): 18 | print("DLL not found:", dllpath) 19 | sys.exit(1) 20 | 21 | d = [pefile.DIRECTORY_ENTRY["IMAGE_DIRECTORY_ENTRY_EXPORT"]] 22 | pe = pefile.PE(dllpath, fast_load=True) 23 | pe.parse_data_directories(directories=d) 24 | 25 | exports = [[e.ordinal, e.name] for e in pe.DIRECTORY_ENTRY_EXPORT.symbols] 26 | exports.sort(key=lambda e: e[0]) # Sort by ordinal 27 | 28 | export_names = [] 29 | for export in exports: 30 | if export[1] is None: # Ignore exports without names 31 | continue 32 | export_names.append(export[1]) 33 | 34 | num_columns = 50 35 | result_file_name = os.path.basename(dllpath).replace(".dll", "") + "_export_list.txt" 36 | with open(result_file_name, "w") as file: 37 | index = 0 38 | for export_name in export_names: 39 | if type(export_name) is not int: 40 | file.write("Export(" + str(index) + ", " + export_name.decode("utf-8") + ") ") 41 | index += 1 42 | if index % num_columns == 0: 43 | file.write("\n") 44 | 45 | -------------------------------------------------------------------------------- /python_scripts/create_export_ordinals.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | import subprocess 4 | 5 | try: 6 | import pefile 7 | except ImportError as e: 8 | print("To run this script, please install the 'pefile' package: 'pip install pefile'.") 9 | sys.exit(1) 10 | 11 | if len(sys.argv) != 2: 12 | print("Argument error") 13 | print("Usage: python create_export_ordinals.py ") 14 | sys.exit(1) 15 | 16 | num_columns = 50 17 | num_ordinals_to_export = sys.argv[1] 18 | with open("export_ordinals.txt", "w") as file: 19 | for i in range(1, int(num_ordinals_to_export) + 1): 20 | file.write("ExportOrdinal(" + str(i) + ") ") 21 | if i % num_columns == 0: 22 | file.write("\n") 23 | 24 | -------------------------------------------------------------------------------- /python_scripts/create_forward_functions.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | if len(sys.argv) != 4: 4 | print("Argument error") 5 | print("Usage: create_forward_functions.py ") 6 | exit() 7 | 8 | number_of_forwards = int(sys.argv[1]) 9 | number_of_ordinal_forwards = int(sys.argv[2]) 10 | number_of_shared_forwards = int(sys.argv[3]) 11 | macros_num_columns = 50 12 | vector_num_columns = 50 13 | 14 | with open("forward_functions.txt", "w") as file: 15 | # Create normal forward macros 16 | for i in range(0, number_of_forwards): 17 | if i % macros_num_columns == 0 and i != 0: 18 | file.write("\n") 19 | file.write("GenerateForwardFunction(" + str(i) + ") ") 20 | 21 | # Create normal forwards 22 | file.write("\nstd::vector forwardAddresses = {") 23 | for i in range(0, number_of_forwards): 24 | if i % vector_num_columns == 0: 25 | file.write("\n ") 26 | if i == number_of_forwards - 1: 27 | file.write("&Forward" + str(i)) 28 | else: 29 | file.write("&Forward" + str(i) + ", ") 30 | file.write("\n};") 31 | 32 | file.write("\n\n") 33 | 34 | # Create ordinal forward macros 35 | for i in range(1, number_of_ordinal_forwards + 1): 36 | file.write("GenerateForwardOrdinalFunction(" + str(i) + ") ") 37 | if i % macros_num_columns == 0 and i != number_of_ordinal_forwards: 38 | file.write("\n") 39 | 40 | # Create ordinal forwards 41 | file.write("\nstd::vector forwardOrdinalAddresses = {") 42 | file.write("\n ") 43 | for i in range(1, number_of_ordinal_forwards + 1): 44 | if i == number_of_ordinal_forwards: 45 | file.write("&ForwardOrdinal" + str(i)) 46 | else: 47 | file.write("&ForwardOrdinal" + str(i) + ", ") 48 | if i % vector_num_columns == 0 and i != number_of_ordinal_forwards: 49 | file.write("\n ") 50 | file.write("\n};") 51 | 52 | file.write("\n\n") 53 | 54 | # Create shared forward macros 55 | for i in range(0, number_of_shared_forwards): 56 | if i % macros_num_columns == 0 and i != 0: 57 | file.write("\n") 58 | file.write("GenerateForwardSharedFunction(" + str(i) + ") ") 59 | 60 | # Create shared forwards 61 | file.write("\nstd::vector forwardSharedAddresses = {") 62 | for i in range(0, number_of_shared_forwards): 63 | if i % vector_num_columns == 0: 64 | file.write("\n ") 65 | if i == number_of_shared_forwards - 1: 66 | file.write("&ForwardShared" + str(i)) 67 | else: 68 | file.write("&ForwardShared" + str(i) + ", ") 69 | file.write("\n};") -------------------------------------------------------------------------------- /readme_pictures/callback_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techiew/UltimateProxyDLL/c2fb23a5ec07bca5605b657156023e3e758b05af/readme_pictures/callback_example.png -------------------------------------------------------------------------------- /readme_pictures/create_export_list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techiew/UltimateProxyDLL/c2fb23a5ec07bca5605b657156023e3e758b05af/readme_pictures/create_export_list.png -------------------------------------------------------------------------------- /readme_pictures/dllmain_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techiew/UltimateProxyDLL/c2fb23a5ec07bca5605b657156023e3e758b05af/readme_pictures/dllmain_example.png -------------------------------------------------------------------------------- /readme_pictures/dumpbin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techiew/UltimateProxyDLL/c2fb23a5ec07bca5605b657156023e3e758b05af/readme_pictures/dumpbin.png -------------------------------------------------------------------------------- /readme_pictures/new_exports.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techiew/UltimateProxyDLL/c2fb23a5ec07bca5605b657156023e3e758b05af/readme_pictures/new_exports.png -------------------------------------------------------------------------------- /readme_pictures/one_function_call.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techiew/UltimateProxyDLL/c2fb23a5ec07bca5605b657156023e3e758b05af/readme_pictures/one_function_call.png -------------------------------------------------------------------------------- /readme_pictures/proxy_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techiew/UltimateProxyDLL/c2fb23a5ec07bca5605b657156023e3e758b05af/readme_pictures/proxy_example.png -------------------------------------------------------------------------------- /readme_pictures/usual_proxy_stuff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techiew/UltimateProxyDLL/c2fb23a5ec07bca5605b657156023e3e758b05af/readme_pictures/usual_proxy_stuff.png --------------------------------------------------------------------------------