commit b678f246a48933723271c4d304eec759a2691e47
parent f270e7f044037c5a648be90b6c452b820b275bbe
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Wed, 13 Jan 2010 14:30:03 -0200
HINSTANCE -> HMODULE (they are the same thing, but the MS documentation
uses the latter) + LoadLibrary -> LoadLibraryEx with optional arguments,
to allow the option LOAD_WITH_ALTERED_SEARCH_PATH
Diffstat:
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/loadlib.c b/loadlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: loadlib.c,v 1.78 2010/01/11 17:55:25 roberto Exp roberto $
+** $Id: loadlib.c,v 1.79 2010/01/13 16:09:05 roberto Exp roberto $
** Dynamic library loader for Lua
** See Copyright Notice in lua.h
**
@@ -133,6 +133,14 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
#undef setprogdir
+/*
+** optional flags for LoadLibraryEx
+*/
+#if !defined(LUA_LLE_FLAGS)
+#define LUA_LLE_FLAGS 0
+#endif
+
+
static void setprogdir (lua_State *L) {
char buff[MAX_PATH + 1];
char *lb;
@@ -159,12 +167,12 @@ static void pusherror (lua_State *L) {
}
static void ll_unloadlib (void *lib) {
- FreeLibrary((HINSTANCE)lib);
+ FreeLibrary((HMODULE)lib);
}
static void *ll_load (lua_State *L, const char *path, int seeglb) {
- HINSTANCE lib = LoadLibrary(path);
+ HMODULE lib = LoadLibraryEx(path, NULL, LUA_LLE_FLAGS);
(void)(seeglb); /* symbols are 'global' by default? */
if (lib == NULL) pusherror(L);
return lib;
@@ -172,7 +180,7 @@ static void *ll_load (lua_State *L, const char *path, int seeglb) {
static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
- lua_CFunction f = (lua_CFunction)GetProcAddress((HINSTANCE)lib, sym);
+ lua_CFunction f = (lua_CFunction)GetProcAddress((HMODULE)lib, sym);
if (f == NULL) pusherror(L);
return f;
}