From f841376e58081eab15601f3b5ba273185fbd0770 Mon Sep 17 00:00:00 2001 From: zeromus Date: Tue, 26 Oct 2010 20:48:24 +0000 Subject: [PATCH] delay load lua51.dll --- desmume/src/windows/DeSmuME_2005.vcproj | 6 ++++++ desmume/src/windows/DeSmuME_2008.vcproj | 9 ++++++--- desmume/src/windows/DeSmuME_2010.vcxproj | 12 ++++++------ desmume/src/windows/luaconsole.cpp | 5 +++-- desmume/src/windows/main.cpp | 12 ++++++++++++ desmume/src/windows/main.h | 1 + 6 files changed, 34 insertions(+), 11 deletions(-) diff --git a/desmume/src/windows/DeSmuME_2005.vcproj b/desmume/src/windows/DeSmuME_2005.vcproj index 11243e1ae..84a06f2a6 100644 --- a/desmume/src/windows/DeSmuME_2005.vcproj +++ b/desmume/src/windows/DeSmuME_2005.vcproj @@ -85,6 +85,7 @@ OutputFile="$(OutDir)\$(ProjectName)_debug.exe" AdditionalLibraryDirectories=".\zlib123;agg;.libs" IgnoreDefaultLibraryNames="LIBCPMT" + DelayLoadDLLs="lua51.dll" GenerateDebugInformation="true" GenerateMapFile="true" OptimizeReferences="2" @@ -177,6 +178,7 @@ AdditionalDependencies="directx-x64-ddraw-dinput8-dsound-dxerr8-dxguid.lib lua51.lib glib-vc8-x64.lib 7z-vc8-x64.lib zlib-vc8-x64.lib agg-2.5-x64.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib" OutputFile="$(OutDir)\$(ProjectName)_x64_debug.exe" AdditionalLibraryDirectories=".\zlib123;agg;.libs" + DelayLoadDLLs="lua51.dll" GenerateDebugInformation="true" GenerateMapFile="true" OptimizeReferences="2" @@ -275,6 +277,7 @@ AdditionalDependencies="directx-win32-ddraw-dinput8-dsound-dxerr8-dxguid.lib libelf_libdwarf-vc8-Win32.lib lua51.lib glib-vc8-Win32.lib 7z-vc8-Win32.lib zlib-vc8-Win32.lib agg-2.5.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib Rpcrt4.lib" OutputFile="$(OutDir)\$(ProjectName)_release.exe" AdditionalLibraryDirectories=".\zlib123;agg;.libs" + DelayLoadDLLs="lua51.dll" GenerateDebugInformation="true" GenerateMapFile="true" EnableCOMDATFolding="0" @@ -373,6 +376,7 @@ AdditionalDependencies="directx-x64-ddraw-dinput8-dsound-dxerr8-dxguid.lib lua51.lib glib-vc8-x64.lib 7z-vc8-x64.lib zlib-vc8-x64.lib agg-2.5-x64.lib lua-5.1.4-x64.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib" OutputFile="$(OutDir)\$(ProjectName)_x64_release.exe" AdditionalLibraryDirectories=".\zlib123;agg;.libs" + DelayLoadDLLs="lua51.dll" GenerateDebugInformation="true" GenerateMapFile="true" EnableCOMDATFolding="0" @@ -473,6 +477,7 @@ AdditionalDependencies="directx-win32-ddraw-dinput8-dsound-dxerr8-dxguid.lib libelf_libdwarf-vc8-Win32.lib lua51.lib glib-vc8-Win32.lib 7z-vc8-Win32.lib zlib-vc8-Win32.lib agg-2.5.lib vfw32.lib winmm.lib comctl32.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib Rpcrt4.lib" OutputFile="$(OutDir)\$(ProjectName)_releaseFastBuild.exe" AdditionalLibraryDirectories=".\zlib123;agg;.libs" + DelayLoadDLLs="lua51.dll" GenerateDebugInformation="true" GenerateMapFile="true" OptimizeReferences="2" @@ -574,6 +579,7 @@ AdditionalDependencies="directx-x64-ddraw-dinput8-dsound-dxerr8-dxguid.lib lua51.lib glib-vc8-x64.lib 7z-vc8-x64.lib zlib-vc8-x64.lib agg-2.5-x64.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib" OutputFile="$(OutDir)\$(ProjectName)_x64_releaseFastBuild.exe" AdditionalLibraryDirectories=".\zlib123;agg;.libs" + DelayLoadDLLs="lua51.dll" GenerateDebugInformation="true" GenerateMapFile="true" OptimizeReferences="2" diff --git a/desmume/src/windows/DeSmuME_2008.vcproj b/desmume/src/windows/DeSmuME_2008.vcproj index 4b4ed0c0a..c3ae0e6ab 100644 --- a/desmume/src/windows/DeSmuME_2008.vcproj +++ b/desmume/src/windows/DeSmuME_2008.vcproj @@ -81,7 +81,7 @@ AdditionalDependencies="directx-win32-ddraw-dinput8-dsound-dxerr8-dxguid.lib libelf_libdwarf-vc8-Win32.lib lua51.lib glib-vc8-Win32.lib 7z-vc8-Win32.lib zlib-vc8-Win32.lib agg-2.5.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib comctl32.lib" OutputFile="$(OutDir)\$(ProjectName)_debug.exe" AdditionalLibraryDirectories=".\zlib123;agg;.libs" - DelayLoadDLLs="" + DelayLoadDLLs="lua51.dll" GenerateDebugInformation="true" GenerateMapFile="true" RandomizedBaseAddress="1" @@ -170,6 +170,7 @@ AdditionalDependencies="directx-x64-ddraw-dinput8-dsound-dxerr8-dxguid.lib libelf_libdwarf-vc8-x64.lib lua51.lib glib-vc8-x64.lib 7z-vc8-x64.lib zlib-vc8-x64.lib agg-2.5-x64.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib" OutputFile="$(OutDir)\$(ProjectName)_x64_debug.exe" AdditionalLibraryDirectories=".\zlib123;agg;.libs" + DelayLoadDLLs="lua51.dll" GenerateDebugInformation="true" GenerateMapFile="true" RandomizedBaseAddress="1" @@ -263,7 +264,7 @@ AdditionalDependencies="directx-win32-ddraw-dinput8-dsound-dxerr8-dxguid.lib libelf_libdwarf-vc8-Win32.lib lua51.lib glib-vc8-Win32.lib 7z-vc8-Win32.lib zlib-vc8-Win32.lib agg-2.5.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib comctl32.lib" OutputFile="$(OutDir)\$(ProjectName)_release.exe" AdditionalLibraryDirectories=".\zlib123;agg;.libs" - DelayLoadDLLs="" + DelayLoadDLLs="lua51.dll" GenerateDebugInformation="true" OptimizeReferences="2" RandomizedBaseAddress="1" @@ -357,6 +358,7 @@ AdditionalDependencies="directx-x64-ddraw-dinput8-dsound-dxerr8-dxguid.lib libelf_libdwarf-vc8-x64.lib lua51.lib glib-vc8-x64.lib 7z-vc8-x64.lib zlib-vc8-x64.lib agg-2.5-x64.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib" OutputFile="$(OutDir)\$(ProjectName)_x64_release.exe" AdditionalLibraryDirectories=".\zlib123;agg;.libs" + DelayLoadDLLs="lua51.dll" GenerateDebugInformation="true" OptimizeReferences="2" RandomizedBaseAddress="1" @@ -450,7 +452,7 @@ AdditionalDependencies="directx-win32-ddraw-dinput8-dsound-dxerr8-dxguid.lib libelf_libdwarf-vc8-Win32.lib lua51.lib glib-vc8-Win32.lib 7z-vc8-Win32.lib zlib-vc8-Win32.lib agg-2.5.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib comctl32.lib" OutputFile="$(OutDir)\$(ProjectName)_dev+.exe" AdditionalLibraryDirectories=".\zlib123;agg;.libs" - DelayLoadDLLs="" + DelayLoadDLLs="lua51.dll" GenerateDebugInformation="true" OptimizeReferences="2" LinkTimeCodeGeneration="0" @@ -545,6 +547,7 @@ AdditionalDependencies="directx-x64-ddraw-dinput8-dsound-dxerr8-dxguid.lib libelf_libdwarf-vc8-x64.lib lua51.lib glib-vc8-x64.lib 7z-vc8-x64.lib zlib-vc8-x64.lib agg-2.5-x64.lib vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib shlwapi.lib" OutputFile="$(OutDir)\$(ProjectName)_x64_dev+.exe" AdditionalLibraryDirectories=".\zlib123;agg;.libs" + DelayLoadDLLs="lua51.dll" GenerateDebugInformation="true" OptimizeReferences="2" LinkTimeCodeGeneration="0" diff --git a/desmume/src/windows/DeSmuME_2010.vcxproj b/desmume/src/windows/DeSmuME_2010.vcxproj index 50ae7c967..76e546036 100644 --- a/desmume/src/windows/DeSmuME_2010.vcxproj +++ b/desmume/src/windows/DeSmuME_2010.vcxproj @@ -184,7 +184,7 @@ directx-win32-ddraw-dinput8-dsound-dxerr8-dxguid.lib;lua51.lib;glib-vc8-Win32.lib;7z-vc8-Win32.lib;zlib-vc8-Win32.lib;agg-2.5.lib;vfw32.lib;winmm.lib;opengl32.lib;glu32.lib;ws2_32.lib;user32.lib;gdi32.lib;shell32.lib;comdlg32.lib;shlwapi.lib;comctl32.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName)_debug.exe .\zlib123;agg;.libs;%(AdditionalLibraryDirectories) - %(DelayLoadDLLs) + lua51.dll true true false @@ -229,7 +229,7 @@ directx-win32-ddraw-dinput8-dsound-dxerr8-dxguid.lib;lua51.lib;glib-vc8-Win32.lib;7z-vc8-Win32.lib;zlib-vc8-Win32.lib;agg-2.5.lib;vfw32.lib;winmm.lib;opengl32.lib;glu32.lib;ws2_32.lib;user32.lib;gdi32.lib;shell32.lib;comdlg32.lib;shlwapi.lib;comctl32.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName)_release.exe .\zlib123;agg;.libs;%(AdditionalLibraryDirectories) - %(DelayLoadDLLs) + lua51.dll true true false @@ -274,7 +274,7 @@ directx-win32-ddraw-dinput8-dsound-dxerr8-dxguid.lib;lua51.lib;glib-vc8-Win32.lib;7z-vc8-Win32.lib;zlib-vc8-Win32.lib;agg-2.5.lib;vfw32.lib;winmm.lib;opengl32.lib;glu32.lib;ws2_32.lib;user32.lib;gdi32.lib;shell32.lib;comdlg32.lib;shlwapi.lib;comctl32.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName)_dev+.exe .\zlib123;agg;.libs;%(AdditionalLibraryDirectories) - %(DelayLoadDLLs) + lua51.dll true true @@ -318,7 +318,7 @@ directx-x64-ddraw-dinput8-dsound-dxerr8-dxguid.lib;lua51.lib;glib-vc8-x64.lib;7z-vc8-x64.lib;zlib-vc8-x64.lib;agg-2.5-x64.lib;vfw32.lib;winmm.lib;opengl32.lib;glu32.lib;ws2_32.lib;user32.lib;gdi32.lib;shell32.lib;comdlg32.lib;shlwapi.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName)_x64_debug.exe .\zlib123;agg;.libs;%(AdditionalLibraryDirectories) - wpcap.dll;%(DelayLoadDLLs) + wpcap.dll;lua51.dll true true false @@ -363,7 +363,7 @@ directx-x64-ddraw-dinput8-dsound-dxerr8-dxguid.lib;lua51.lib;glib-vc8-x64.lib;7z-vc8-x64.lib;zlib-vc8-x64.lib;agg-2.5-x64.lib;vfw32.lib;winmm.lib;opengl32.lib;glu32.lib;ws2_32.lib;user32.lib;gdi32.lib;shell32.lib;comdlg32.lib;shlwapi.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName)_x64_release.exe .\zlib123;agg;.libs;%(AdditionalLibraryDirectories) - wpcap.dll;%(DelayLoadDLLs) + lua51.dll true true false @@ -409,7 +409,7 @@ directx-x64-ddraw-dinput8-dsound-dxerr8-dxguid.lib;lua51.lib;glib-vc8-x64.lib;7z-vc8-x64.lib;zlib-vc8-x64.lib;agg-2.5-x64.lib;vfw32.lib;winmm.lib;opengl32.lib;glu32.lib;ws2_32.lib;user32.lib;gdi32.lib;shell32.lib;comdlg32.lib;shlwapi.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName)_x64_dev+.exe .\zlib123;agg;.libs;%(AdditionalLibraryDirectories) - wpcap.dll;%(DelayLoadDLLs) + wpcap.dll;lua51.dll true true diff --git a/desmume/src/windows/luaconsole.cpp b/desmume/src/windows/luaconsole.cpp index bc1e0be06..3c8f71e10 100644 --- a/desmume/src/windows/luaconsole.cpp +++ b/desmume/src/windows/luaconsole.cpp @@ -631,13 +631,14 @@ LRESULT CALLBACK LuaScriptProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara char LogicalName[1024], PhysicalName[1024]; bool exists = ObtainFile(Str_Tmp, LogicalName, PhysicalName, "luarun", s_nonLuaExtensions, sizeof(s_nonLuaExtensions)/sizeof(*s_nonLuaExtensions)); Update_Recent_Script(LogicalName, info.subservient); - RunLuaScriptFile((int)hDlg, PhysicalName); + if(DemandLua()) + RunLuaScriptFile((int)hDlg, PhysicalName); } break; case IDC_BUTTON_LUASTOP: { PrintToWindowConsole((int)hDlg, "user clicked stop button\r\n"); SetActiveWindow(MainWindow->getHWnd()); - StopLuaScript((int)hDlg); + if(DemandLua()) StopLuaScript((int)hDlg); } break; case IDC_NOTIFY_SUBSERVIENT: { diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index b82233c53..ea649ae20 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -2128,6 +2128,18 @@ void joinThread_gdb( void *thread_handle) { } +bool DemandLua() +{ + HMODULE mod = LoadLibrary("lua51.dll"); + if(!mod) + { + MessageBox(NULL, "lua51.dll was not found. Please get it into your PATH or in the same directory as desmume.exe", "DeSmuME", MB_OK | MB_ICONERROR); + return false; + } + FreeLibrary(mod); + return true; +} + int MenuInit() { diff --git a/desmume/src/windows/main.h b/desmume/src/windows/main.h index 2a89f14a7..4ee257b5f 100644 --- a/desmume/src/windows/main.h +++ b/desmume/src/windows/main.h @@ -22,6 +22,7 @@ void AviEnd(); void WavRecordTo(int wavmode); void WavEnd(); void UpdateToolWindows(); +bool DemandLua(); extern bool frameCounterDisplay; extern bool FpsDisplay;