From 671a23e199eeb7dc0ce6ddfab7e830d1c9971514 Mon Sep 17 00:00:00 2001 From: ThirteenAG Date: Tue, 24 Oct 2023 22:42:14 +0800 Subject: [PATCH] additional hooks, appveyor and readme update --- appveyor.yml | 47 ++++++++++++++++++++++++++++------------------ readme.md | 45 +++++++++++++++++++++++++++++++++++++------- release-Win32.bat | 2 +- release-x64.bat | 2 +- release.bat | 12 ++++++------ release.ps1 | 4 ++-- source/dllmain.cpp | 35 ++++++++++++++++++++++++++++++---- 7 files changed, 108 insertions(+), 39 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 64bbeee..c57abef 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,4 @@ -version: 5.{build} -branches: - only: - - master +version: 6.{build} skip_tags: true image: Visual Studio 2022 configuration: Release @@ -22,25 +19,39 @@ artifacts: name: Ultimate-ASI-Loader.zip - path: bin\Ultimate-ASI-Loader_x64.zip name: Ultimate-ASI-Loader_x64.zip -- path: bin\RE7Demo.InfiniteAmmo.zip - name: RE7Demo.InfiniteAmmo.zip -- path: bin\MessageBox_x64.zip - name: MessageBox_x64.zip -- path: bin\OverloadFromFolderDLL_x64.zip - name: OverloadFromFolderDLL_x64.zip -- path: bin\ExeUnprotect.zip - name: ExeUnprotect.zip -- path: bin\MessageBox.zip - name: MessageBox.zip -- path: bin\OverloadFromFolderDLL.zip - name: OverloadFromFolderDLL.zip +- path: bin\RE7Demo.InfiniteAmmo-x64.zip + name: RE7Demo.InfiniteAmmo-x64.zip +- path: bin\MessageBox-x64.zip + name: MessageBox-x64.zip +- path: bin\OverloadFromFolderDLL-x64.zip + name: OverloadFromFolderDLL-x64.zip +- path: bin\ExeUnprotect-Win32.zip + name: ExeUnprotect-Win32.zip +- path: bin\MessageBox-Win32.zip + name: MessageBox-Win32.zip +- path: bin\OverloadFromFolderDLL-Win32.zip + name: OverloadFromFolderDLL-Win32.zip +- path: bin\MonoLoader-Win32.zip + name: MonoLoader-Win32.zip +- path: bin\MonoLoader-x64.zip + name: MonoLoader-x64.zip deploy: - provider: GitHub tag: v$(appveyor_build_version) release: Ultimate ASI Loader v$(appveyor_build_version) - description: DESCRIPTION\n------------------------\nThis is a DLL file which adds ASI plugin loading functionality to any game, which uses any of the following libraries:\n* d3d8.dll\n* d3d9.dll\n* d3d11.dll\n* ddraw.dll\n* dinput.dll\n* dinput8.dll (x86 and x64)\n* dsound.dll (x86 and x64)\n* msacm32.dll\n* msvfw32.dll\n* version.dll (x86 and x64)\n* vorbisFile.dll\n* wininet.dll (x86 and x64)\n* winmm.dll (x86 and x64)\n* xlive.dll\n\n\nINSTALLATION\n------------------------\nIn order to install it, you just need to place DLL into game directory. Usually it works as dinput8.dll, but if it's not, there is a possibility to rename it(see the list of supported names above). + description: DESCRIPTION\n------------------------\nThis is a DLL file which adds ASI plugin loading functionality to any game, which uses any of the following libraries:\n* d3d8.dll\n* d3d9.dll\n* d3d11.dll\n* ddraw.dll\n* dinput.dll\n* dinput8.dll (x86 and x64)\n* dsound.dll (x86 and x64)\n* msacm32.dll\n* msvfw32.dll\n* version.dll (x86 and x64)\n* vorbisFile.dll\n* wininet.dll (x86 and x64)\n* winmm.dll (x86 and x64)\n* winhttp.dll (x86 and x64)\n* xlive.dll\n\n\nINSTALLATION\n------------------------\nIn order to install it, you just need to place DLL into game directory. Usually it works as dinput8.dll, but if it's not, there is a possibility to rename it(see the list of supported names above). auth_token: secure: ugbti+bXX/7zqu39OyiPxgRPd2pQn2FEV/12ABees2fHfpZob0tWXzqD/zSYmibJ artifact: Ultimate-ASI-Loader.zip, Ultimate-ASI-Loader_x64.zip on: - branch: master \ No newline at end of file + branch: master +- provider: GitHub + tag: demo-plugins + release: Ultimate ASI Loader Demo Plugins + description: Demo plugins to test or extend Ultimate ASI Loader's functionality. + auth_token: + secure: ugbti+bXX/7zqu39OyiPxgRPd2pQn2FEV/12ABees2fHfpZob0tWXzqD/zSYmibJ + artifact: RE7Demo.InfiniteAmmo-x64.zip, MessageBox-x64.zip, OverloadFromFolderDLL-x64.zip, ExeUnprotect-Win32.zip, MessageBox-Win32.zip, OverloadFromFolderDLL-Win32.zip, MonoLoader-Win32.zip, MonoLoader-x64.zip + force_update: true + on: + branch: /^(master|monoloader)$/ \ No newline at end of file diff --git a/readme.md b/readme.md index 72c9794..357e4fa 100644 --- a/readme.md +++ b/readme.md @@ -7,24 +7,25 @@ This is a DLL file which adds ASI plugin loading functionality to any game, which uses any of the following libraries: -- [d3d8.dll](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/Win32-latest/d3d8-Win32.zip) +- [d3d8.dll](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/Win32-latest/d3d8-Win32.zip) (x86) - d3d9.dll ([x86](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/Win32-latest/d3d9-Win32.zip) and [x64](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/x64-latest/d3d9-x64.zip)) - d3d10.dll ([x86](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/Win32-latest/d3d10-Win32.zip) and [x64](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/x64-latest/d3d10-x64.zip)) - d3d11.dll ([x86](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/Win32-latest/d3d11-Win32.zip) and [x64](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/x64-latest/d3d11-x64.zip)) - d3d12.dll ([x86](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/Win32-latest/d3d12-Win32.zip) and [x64](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/x64-latest/d3d12-x64.zip)) -- [ddraw.dll](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/Win32-latest/ddraw-Win32.zip) -- [dinput.dll](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/Win32-latest/dinput-Win32.zip) +- [ddraw.dll](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/Win32-latest/ddraw-Win32.zip) (x86) +- [dinput.dll](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/Win32-latest/dinput-Win32.zip) (x86) - dinput8.dll ([x86](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/Win32-latest/dinput8-Win32.zip) and [x64](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/x64-latest/dinput8-x64.zip)) - dsound.dll ([x86](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/Win32-latest/dsound-Win32.zip) and [x64](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/x64-latest/dsound-x64.zip)) -- [msacm32.dll](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/Win32-latest/msacm32-Win32.zip) -- [msvfw32.dll](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/Win32-latest/msvfw32-Win32.zip) +- [msacm32.dll](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/Win32-latest/msacm32-Win32.zip) (x86) +- [msvfw32.dll](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/Win32-latest/msvfw32-Win32.zip) (x86) - version.dll ([x86](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/Win32-latest/version-Win32.zip) and [x64](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/x64-latest/version-x64.zip)) - wininet.dll ([x86](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/Win32-latest/wininet-Win32.zip) and [x64](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/x64-latest/wininet-x64.zip)) - winmm.dll ([x86](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/Win32-latest/winmm-Win32.zip) and [x64](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/x64-latest/winmm-x64.zip)) -- [xlive.dll](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/Win32-latest/xlive-Win32.zip) +- winhttp.dll ([x86](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/Win32-latest/winhttp-Win32.zip) and [x64](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/x64-latest/winhttp-x64.zip)) +- [xlive.dll](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/Win32-latest/xlive-Win32.zip) (x86) +- [binkw32.dll](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/Win32-latest/binkw32-Win32.zip) (rename original to binkw32Hooked.dll, optional) - [bink2w64.dll](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/x64-latest/bink2w64-x64.zip) (rename original to bink2w64Hooked.dll) - [vorbisFile.dll](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/Win32-latest/vorbisFile-Win32.zip) (rename original to vorbisHooked.dll, optional) -- [binkw32.dll](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/Win32-latest/binkw32-Win32.zip) (rename original to binkw32Hooked.dll, optional) With the last two, it is possible to load the original dll by renaming it to 'vorbisHooked.dll' or 'binkw32Hooked.dll'. Usually it is not required and you can simply replace the dll. Always make a backup before replacing any files. @@ -39,6 +40,36 @@ Put ASI files in game root directory, 'scripts' or 'plugins' folder. If configuration is necessary, global.ini file can be placed to 'scripts' or 'plugins' folder. It can be used alongside the chosen dll and if so, it is also possible to use dll name for ini file, e.g. version.dll/version.ini. [See example of global.ini here](https://github.com/ThirteenAG/Ultimate-ASI-Loader/blob/master/data/scripts/global.ini). +## UPDATE FOLDER (Overload From Folder) + +It is possible to install mods that replace files via the `update` folder, allowing you to avoid actual file replacement. + +For example, if a mod replaces the file located at: + +``` +Resident Evil 5\nativePC_MT\Image\Archive\ChapterEnd11.arc +``` + +With Ultimate ASI Loader installed, you can create an `update` folder and place the file at: + +``` +Resident Evil 5\update\nativePC_MT\Image\Archive\ChapterEnd11.arc +``` + +To revert the game to its initial state, simply remove the `update` folder. + +Please note that the `update` folder is relative to the location of the ASI loader, so you need to adjust paths accordingly. For example: + +``` +\Gameface\Content\Movies\1080\GTA_SA_CREDITS_FINAL_1920x1080.mp4 +``` + +Should be adjusted to: + +``` +\Gameface\Binaries\Win64\update\Content\Movies\1080\GTA_SA_CREDITS_FINAL_1920x1080.mp4 +``` + ## ADDITIONAL WINDOWED MODE FEATURE ASI loader have built-in wndmode.dll, which can be loaded, if you create empty wndmode.ini in the folder with asi loader's dll. It will be automatically filled with example configuration at the first run of the game. Settings are not universal and should be changed in every specific case, but usually it works as is. diff --git a/release-Win32.bat b/release-Win32.bat index 73c305b..7fdb81e 100644 --- a/release-Win32.bat +++ b/release-Win32.bat @@ -1,4 +1,4 @@ -set list=d3d8, d3d9, d3d10, d3d11, d3d12, ddraw, dinput, dinput8, dsound, msacm32, msvfw32, version, wininet, winmm, xlive, vorbisFile, binkw32 +set list=d3d8, d3d9, d3d10, d3d11, d3d12, ddraw, dinput, dinput8, dsound, msacm32, msvfw32, version, wininet, winmm, winhttp, xlive, vorbisFile, binkw32 mkdir dist\Win32 cd .\bin\Win32\Release (for %%a in (%list%) do ( diff --git a/release-x64.bat b/release-x64.bat index 57c9b94..d2de13c 100644 --- a/release-x64.bat +++ b/release-x64.bat @@ -1,4 +1,4 @@ -set list=d3d9, d3d10, d3d11, d3d12, dinput8, dsound, version, wininet, winmm, bink2w64 +set list=d3d9, d3d10, d3d11, d3d12, dinput8, dsound, version, wininet, winmm, winhttp, bink2w64 mkdir dist\x64 cd bin\x64\Release\ (for %%a in (%list%) do ( diff --git a/release.bat b/release.bat index de945e0..b1a9968 100644 --- a/release.bat +++ b/release.bat @@ -2,12 +2,12 @@ 7za a -tzip ".\bin\Ultimate-ASI-Loader_x64.zip" ".\bin\x64\Release\dinput8.dll" type nul >"bin\place both files in RESIDENT EVIL 7 biohazard Demo folder" -7za a -tzip ".\bin\RE7Demo.InfiniteAmmo.zip" ".\bin\x64\Release\dinput8.dll" ".\bin\x64\Release\scripts\RE7Demo.InfiniteAmmo.asi" ".\bin\place both files in RESIDENT EVIL 7 biohazard Demo folder" -7za a -tzip ".\bin\MessageBox_x64.zip" ".\bin\x64\Release\scripts\MessageBox_x64.asi" -7za a -tzip ".\bin\OverloadFromFolderDLL_x64.zip" ".\bin\x64\Release\scripts\OverloadFromFolderDLL_x64.asi" -7za a -tzip ".\bin\ExeUnprotect.zip" ".\bin\Win32\Release\scripts\ExeUnprotect.asi" -7za a -tzip ".\bin\MessageBox.zip" ".\bin\Win32\Release\scripts\MessageBox.asi" -7za a -tzip ".\bin\OverloadFromFolderDLL.zip" ".\bin\Win32\Release\scripts\OverloadFromFolderDLL.asi" +7za a -tzip ".\bin\ExeUnprotect-Win32.zip" ".\bin\Win32\Release\scripts\ExeUnprotect.asi" +7za a -tzip ".\bin\RE7Demo.InfiniteAmmo-x64.zip" ".\bin\x64\Release\dinput8.dll" ".\bin\x64\Release\scripts\RE7Demo.InfiniteAmmo.asi" ".\bin\place both files in RESIDENT EVIL 7 biohazard Demo folder" +7za a -tzip ".\bin\MessageBox-Win32.zip" ".\bin\Win32\Release\scripts\MessageBox.asi" +7za a -tzip ".\bin\MessageBox-x64.zip" ".\bin\x64\Release\scripts\MessageBox_x64.asi" +7za a -tzip ".\bin\OverloadFromFolderDLL-x64.zip" ".\bin\x64\Release\scripts\OverloadFromFolderDLL_x64.asi" +7za a -tzip ".\bin\OverloadFromFolderDLL-Win32.zip" ".\bin\Win32\Release\scripts\OverloadFromFolderDLL.asi" EXIT 7-Zip Extra diff --git a/release.ps1 b/release.ps1 index ad5a8fc..9f31086 100644 --- a/release.ps1 +++ b/release.ps1 @@ -1,5 +1,5 @@ -$aliases_array_Win32 = "d3d8", "d3d9", "d3d10", "d3d11", "d3d12", "dinput8", "ddraw", "dinput", "dsound", "msacm32", "msvfw32", "version", "wininet", "winmm", "xlive", "vorbisFile", "binkw32" -$aliases_array_x64 = "d3d9", "d3d10", "d3d11", "d3d12", "dinput8", "dsound", "version", "wininet", "winmm", "bink2w64" +$aliases_array_Win32 = "d3d8", "d3d9", "d3d10", "d3d11", "d3d12", "dinput8", "ddraw", "dinput", "dsound", "msacm32", "msvfw32", "version", "wininet", "winmm", "winhttp", "xlive", "vorbisFile", "binkw32" +$aliases_array_x64 = "d3d9", "d3d10", "d3d11", "d3d12", "dinput8", "dsound", "version", "wininet", "winmm", "winhttp", "bink2w64" $platform_array = "Win32", "x64" $hash_alrg = "SHA512" diff --git a/source/dllmain.cpp b/source/dllmain.cpp index da47d1e..aab2cba 100644 --- a/source/dllmain.cpp +++ b/source/dllmain.cpp @@ -173,6 +173,8 @@ enum Kernel32ExportsNames eSleep, eGetSystemTimeAsFileTime, eGetCurrentProcessId, + eGetCommandLineA, + eGetCommandLineW, eCreateFileA, eCreateFileW, eGetFileAttributesA, @@ -597,9 +599,8 @@ void LoadPluginsAndRestoreIAT(uintptr_t retaddr) for (size_t i = 0; i < Kernel32ExportsNamesCount; i++) { - if (!sFileLoaderPath.empty() && - (i == eCreateFileA || i == eCreateFileW || i == eGetFileAttributesA || - i == eGetFileAttributesW || i == eGetFileAttributesExA || i == eGetFileAttributesExW)) + if (!sFileLoaderPath.empty() && (i == eCreateFileA || i == eCreateFileW + || i == eGetFileAttributesA || i == eGetFileAttributesW || i == eGetFileAttributesExA || i == eGetFileAttributesExW)) continue; if (Kernel32Data[i][IATPtr] && Kernel32Data[i][ProcAddress]) @@ -725,6 +726,18 @@ DWORD WINAPI CustomGetCurrentProcessId() return GetCurrentProcessId(); } +LPSTR WINAPI CustomGetCommandLineA() +{ + LoadPluginsAndRestoreIAT((uintptr_t)_ReturnAddress()); + return GetCommandLineA(); +} + +LPWSTR WINAPI CustomGetCommandLineW() +{ + LoadPluginsAndRestoreIAT((uintptr_t)_ReturnAddress()); + return GetCommandLineW(); +} + std::filesystem::path GetFileName(auto lpFilename) { std::error_code ec; @@ -741,7 +754,7 @@ std::filesystem::path GetFileName(auto lpFilename) auto filePath = std::filesystem::path(lpFilename); auto absolutePath = std::filesystem::absolute(filePath, ec); - auto relativePath = std::filesystem::weakly_canonical(absolutePath, ec).lexically_relative(gamePath); + auto relativePath = std::filesystem::canonical(absolutePath, ec).lexically_relative(gamePath); auto commonPath = gamePath; if (starts_with(relativePath, "..")) @@ -939,6 +952,8 @@ bool HookKernel32IAT(HMODULE mod, bool exe) Kernel32Data[eSleep][ProcAddress] = (size_t)GetProcAddress(GetModuleHandle(TEXT("KERNEL32.DLL")), "Sleep"); Kernel32Data[eGetSystemTimeAsFileTime][ProcAddress] = (size_t)GetProcAddress(GetModuleHandle(TEXT("KERNEL32.DLL")), "GetSystemTimeAsFileTime"); Kernel32Data[eGetCurrentProcessId][ProcAddress] = (size_t)GetProcAddress(GetModuleHandle(TEXT("KERNEL32.DLL")), "GetCurrentProcessId"); + Kernel32Data[eGetCommandLineA][ProcAddress] = (size_t)GetProcAddress(GetModuleHandle(TEXT("KERNEL32.DLL")), "GetCommandLineA"); + Kernel32Data[eGetCommandLineW][ProcAddress] = (size_t)GetProcAddress(GetModuleHandle(TEXT("KERNEL32.DLL")), "GetCommandLineW"); Kernel32Data[eCreateFileA][ProcAddress] = (size_t)GetProcAddress(GetModuleHandle(TEXT("KERNEL32.DLL")), "CreateFileA"); Kernel32Data[eCreateFileW][ProcAddress] = (size_t)GetProcAddress(GetModuleHandle(TEXT("KERNEL32.DLL")), "CreateFileW"); Kernel32Data[eGetFileAttributesA][ProcAddress] = (size_t)GetProcAddress(GetModuleHandle(TEXT("KERNEL32.DLL")), "GetFileAttributesA"); @@ -1081,6 +1096,18 @@ bool HookKernel32IAT(HMODULE mod, bool exe) *(size_t*)i = (size_t)CustomGetCurrentProcessId; matchedImports++; } + else if (ptr == Kernel32Data[eGetCommandLineA][ProcAddress]) + { + if (exe) Kernel32Data[eGetCommandLineA][IATPtr] = i; + *(size_t*)i = (size_t)CustomGetCommandLineA; + matchedImports++; + } + else if (ptr == Kernel32Data[eGetCommandLineW][ProcAddress]) + { + if (exe) Kernel32Data[eGetCommandLineW][IATPtr] = i; + *(size_t*)i = (size_t)CustomGetCommandLineW; + matchedImports++; + } else if (ptr == Kernel32Data[eCreateFileA][ProcAddress]) { if (exe) Kernel32Data[eCreateFileA][IATPtr] = i;