From 82d303160722e39ee7d2663bb5b39bee206f98d1 Mon Sep 17 00:00:00 2001 From: Seemann Date: Thu, 12 Jun 2025 18:40:26 -0400 Subject: [PATCH 1/2] Add files via upload --- vorbisFile.cpp | 73 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 53 insertions(+), 20 deletions(-) diff --git a/vorbisFile.cpp b/vorbisFile.cpp index 1e06e94..2b3862d 100644 --- a/vorbisFile.cpp +++ b/vorbisFile.cpp @@ -2,10 +2,15 @@ // Written by Silent // Based on ASI Loader by Stanislav "listener" Golovin // Initialization part made by NTAuthority +// Modified by fastman92 to add sorting of ASI files by their name #include #include +#include +#include +#include + BYTE originalCode[5]; BYTE* originalEP = 0; HINSTANCE hExecutableInstance; @@ -126,9 +131,18 @@ void ExcludedEntriesListFree(ExcludedEntriesList* list) } } -void FindFiles(WIN32_FIND_DATA* fd, ExcludedEntriesList* list) +struct tPluginToBeLoaded +{ + std::string dirPath; + std::string pluginFilename; +}; + +void FindFiles(std::deque& pluginPaths, WIN32_FIND_DATAA* fd, ExcludedEntriesList* list) { - HANDLE asiFile = FindFirstFile ("*.asi", fd); + char curDir[MAX_PATH]; + GetCurrentDirectoryA(_countof(curDir), curDir); + + HANDLE asiFile = FindFirstFileA ("*.asi", fd); if (asiFile != INVALID_HANDLE_VALUE) { @@ -143,19 +157,25 @@ void FindFiles(WIN32_FIND_DATA* fd, ExcludedEntriesList* list) (fd->cFileName[pos-2] == 's' || fd->cFileName[pos-2] == 'S') && (fd->cFileName[pos-1] == 'i' || fd->cFileName[pos-1] == 'I')) { - if ( !list || !ExcludedEntriesListHasEntry(list, fd->cFileName) ) - LoadLibrary (fd->cFileName); + if (!list || !ExcludedEntriesListHasEntry(list, fd->cFileName)) + { + tPluginToBeLoaded plugin; + plugin.dirPath = curDir; + plugin.pluginFilename = fd->cFileName; + + pluginPaths.push_back(plugin); + } } } - } while (FindNextFile (asiFile, fd)); + } while (FindNextFileA (asiFile, fd)); FindClose (asiFile); } } void LoadPlugins() { - HMODULE vorbisHooked = LoadLibrary ("vorbishooked"); + HMODULE vorbisHooked = LoadLibraryA ("vorbishooked"); if ( vorbisHooked ) { __ov_open_callbacks = GetProcAddress (vorbisHooked, "ov_open_callbacks"); @@ -168,14 +188,16 @@ void LoadPlugins() __ov_time_seek_page = GetProcAddress (vorbisHooked, "ov_time_seek_page"); // Regular ASI Loader - WIN32_FIND_DATA fd; + WIN32_FIND_DATAA fd; + std::deque pluginsToBeLoaded; + char moduleName[MAX_PATH]; char preparedPath[128]; // stores scripts\*exename*\settings.ini char* tempPointer; int nWantsToLoadPlugins; int nThatExeWantsPlugins; - GetModuleFileName(NULL, moduleName, MAX_PATH); + GetModuleFileNameA(NULL, moduleName, MAX_PATH); tempPointer = strrchr(moduleName, '.'); *tempPointer = '\0'; @@ -185,9 +207,9 @@ void LoadPlugins() strcat(preparedPath, "\\settings.ini"); // Before we load any ASI files, let's see if user wants to do it at all - nWantsToLoadPlugins = GetPrivateProfileInt("globalsets", "loadplugins", TRUE, "scripts\\global.ini"); + nWantsToLoadPlugins = GetPrivateProfileIntA("globalsets", "loadplugins", TRUE, "scripts\\global.ini"); // Or perhaps this EXE wants to override global settings? - nThatExeWantsPlugins = GetPrivateProfileInt("exclusivesets", "loadplugins", -1, preparedPath); + nThatExeWantsPlugins = GetPrivateProfileIntA("exclusivesets", "loadplugins", -1, preparedPath); if ( nThatExeWantsPlugins ) // Will not process only if this EXE wishes not to load anything but its exclusive plugins { @@ -223,17 +245,17 @@ void LoadPlugins() fclose(iniFile); } - FindFiles(&fd, &excludes); - if ( SetCurrentDirectory("scripts\\") ) + FindFiles(pluginsToBeLoaded, &fd, &excludes); + if ( SetCurrentDirectoryA("scripts\\") ) { - FindFiles(&fd, &excludes); - if ( SetCurrentDirectory(tempPointer + 1) ) + FindFiles(pluginsToBeLoaded, &fd, &excludes); + if ( SetCurrentDirectoryA(tempPointer + 1) ) { - FindFiles(&fd, NULL); // Exclusive plugins are not being excluded - SetCurrentDirectory("..\\..\\"); + FindFiles(pluginsToBeLoaded, &fd, NULL); // Exclusive plugins are not being excluded + SetCurrentDirectoryA("..\\..\\"); } else - SetCurrentDirectory("..\\"); + SetCurrentDirectoryA("..\\"); } // Free the remaining excludes @@ -246,12 +268,23 @@ void LoadPlugins() // We need to cut settings.ini from the path again tempPointer = strrchr(preparedPath, '\\'); tempPointer[1] = '\0'; - if ( SetCurrentDirectory(preparedPath) ) + if ( SetCurrentDirectoryA(preparedPath) ) { - FindFiles(&fd, NULL); - SetCurrentDirectory("..\\..\\"); + FindFiles(pluginsToBeLoaded, &fd, NULL); + SetCurrentDirectoryA("..\\..\\"); } } + + // Load ASI plugins + std::sort(pluginsToBeLoaded.begin(), pluginsToBeLoaded.end(), [](tPluginToBeLoaded& a, tPluginToBeLoaded& b) { return a.pluginFilename < b.pluginFilename; }); + + for (auto& plugin : pluginsToBeLoaded) + { + char pluginPath[MAX_PATH]; + sprintf(pluginPath, "%s\\%s", plugin.dirPath.c_str(), plugin.pluginFilename.c_str()); + // MessageBoxA(NULL, pluginPath, "Test", MB_OK); + LoadLibraryA(pluginPath); + } } // Unprotect the module NOW (CLEO 4.1.1.30f crash fix) From 6eb0aad3a9ff353f9ec26f5a915be80b23c572de Mon Sep 17 00:00:00 2001 From: Seemann Date: Sat, 10 Jan 2026 11:38:11 -0500 Subject: [PATCH 2/2] update build script --- .github/workflows/build.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 793d16c..60317fe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars32.bat" cl -c /GS- /GF /O2 vorbisFile.cpp - link /dll /nodefaultlib /entry:_DllMainCRTStartup@12 vorbisFile.obj Kernel32.lib LIBCMT.LIB libvcruntime.lib libucrt.lib + link /dll /nodefaultlib /entry:_DllMainCRTStartup@12 vorbisFile.obj Kernel32.lib LIBCMT.LIB libvcruntime.lib libucrt.lib libcpmt.lib - name: Upload artifact uses: actions/upload-artifact@v6 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 96dbb5b..e030573 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,7 +18,7 @@ jobs: run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars32.bat" cl -c /GS- /GF /O2 vorbisFile.cpp - link /dll /nodefaultlib /entry:_DllMainCRTStartup@12 vorbisFile.obj Kernel32.lib LIBCMT.LIB libvcruntime.lib libucrt.lib + link /dll /nodefaultlib /entry:_DllMainCRTStartup@12 vorbisFile.obj Kernel32.lib LIBCMT.LIB libvcruntime.lib libucrt.lib libcpmt.lib - name: Create Release uses: ncipollo/release-action@main