Skip to content

Commit

Permalink
Merge pull request #68 from luvit/dll_load_failure_handler
Browse files Browse the repository at this point in the history
DLL Load Failure Handling
  • Loading branch information
rjemanuele committed Mar 19, 2015
2 parents dda7682 + aa50ae1 commit e9fafd9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ add_definitions( -DLUVI_VERSION="${LUVI_VERSION}" )
if(MSVC)
set(winsvc src/winsvc.h src/winsvcaux.h src/winsvc.c src/winsvcaux.c)
add_definitions( -DWITH_WINSVC -DLUA_BUILD_AS_DLL -DLUA_LIB -DBUILDING_UV_SHARED )

add_library (luvi_renamed src/luvi_renamed.c)
endif()

if(UNIX)
Expand Down
2 changes: 2 additions & 0 deletions make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ CALL make.bat tiny
CALL make.bat test
github-release upload --user luvit --repo luvi --tag %LUVI_TAG% --file luvi.exe --name luvi-tiny-Windows-amd64.exe
github-release upload --user luvit --repo luvi --tag %LUVI_TAG% --file build\Release\luvi.lib --name luvi-tiny-Windows-amd64.lib
github-release upload --user luvit --repo luvi --tag %LUVI_TAG% --file build\Release\luvi_renamed.lib --name luvi_renamed-tiny-Windows-amd64.lib
GOTO :end

:publish-static
Expand All @@ -79,6 +80,7 @@ CALL make.bat static
CALL make.bat test
github-release upload --user luvit --repo luvi --tag %LUVI_TAG% --file luvi.exe --name luvi-static-Windows-amd64.exe
github-release upload --user luvit --repo luvi --tag %LUVI_TAG% --file build\Release\luvi.lib --name luvi-static-Windows-amd64.lib
github-release upload --user luvit --repo luvi --tag %LUVI_TAG% --file build\Release\luvi_renamed.lib --name luvi_renamed-static-Windows-amd64.lib
GOTO :end

:end
23 changes: 23 additions & 0 deletions src/luvi_renamed.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "windows.h"
#include "delayimp.h"
FARPROC WINAPI LoadFailureHook(unsigned dliNotify, PDelayLoadInfo pdli);
extern PfnDliHook __pfnDliFailureHook2 = LoadFailureHook;


FARPROC WINAPI LoadFailureHook(unsigned dliNotify, PDelayLoadInfo pdli)
{
if (dliNotify == dliFailLoadLib) {
if (_stricmp("luvi.exe", pdli->szDll) == 0) {
TCHAR name[MAX_PATH + 1];
DWORD ret = GetModuleFileName(NULL, name, MAX_PATH + 1);
if (ret > 0) {
HMODULE module = LoadLibrary(name);
if (module) {
return (FARPROC)module;
}
}
}
}
return 0;
}

0 comments on commit e9fafd9

Please sign in to comment.