From 344f87049693224887c4d311159d2983c1fbbb1f Mon Sep 17 00:00:00 2001 From: ThirteenAG Date: Wed, 25 Oct 2023 00:58:42 +0800 Subject: [PATCH] additional hooks, appveyor and readme update --- appveyor.yml | 2 +- readme.md | 29 +++++++++++++++++++++++++++++ source/dllmain.cpp | 34 +++++++++++++++++++++++++++++++--- 3 files changed, 61 insertions(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 64bbeee..d86b59f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -38,7 +38,7 @@ 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 diff --git a/readme.md b/readme.md index eab07b6..357e4fa 100644 --- a/readme.md +++ b/readme.md @@ -40,6 +40,35 @@ 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 diff --git a/source/dllmain.cpp b/source/dllmain.cpp index da47d1e..06ef2a7 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,9 @@ 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)) + // GetFileAttributes functions are not kept because of degraded loading times in some games + // Plugins can still use them via exports + if (!sFileLoaderPath.empty() && (i == eCreateFileA || i == eCreateFileW)) continue; if (Kernel32Data[i][IATPtr] && Kernel32Data[i][ProcAddress]) @@ -725,6 +727,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; @@ -939,6 +953,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 +1097,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;