aboutsummaryrefslogtreecommitdiff
path: root/loadlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-01-13 14:30:27 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-01-13 14:30:27 -0200
commitb678f246a48933723271c4d304eec759a2691e47 (patch)
treef8853d7922c472598a21ba689a8bbf8dd121ffb8 /loadlib.c
parentf270e7f044037c5a648be90b6c452b820b275bbe (diff)
downloadlua-b678f246a48933723271c4d304eec759a2691e47.tar.gz
lua-b678f246a48933723271c4d304eec759a2691e47.tar.bz2
lua-b678f246a48933723271c4d304eec759a2691e47.zip
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 (limited to 'loadlib.c')
-rw-r--r--loadlib.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/loadlib.c b/loadlib.c
index d6b52a6c..eba25e30 100644
--- a/loadlib.c
+++ b/loadlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: loadlib.c,v 1.78 2010/01/11 17:55:25 roberto Exp roberto $ 2** $Id: loadlib.c,v 1.79 2010/01/13 16:09:05 roberto Exp roberto $
3** Dynamic library loader for Lua 3** Dynamic library loader for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5** 5**
@@ -133,6 +133,14 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
133 133
134#undef setprogdir 134#undef setprogdir
135 135
136/*
137** optional flags for LoadLibraryEx
138*/
139#if !defined(LUA_LLE_FLAGS)
140#define LUA_LLE_FLAGS 0
141#endif
142
143
136static void setprogdir (lua_State *L) { 144static void setprogdir (lua_State *L) {
137 char buff[MAX_PATH + 1]; 145 char buff[MAX_PATH + 1];
138 char *lb; 146 char *lb;
@@ -159,12 +167,12 @@ static void pusherror (lua_State *L) {
159} 167}
160 168
161static void ll_unloadlib (void *lib) { 169static void ll_unloadlib (void *lib) {
162 FreeLibrary((HINSTANCE)lib); 170 FreeLibrary((HMODULE)lib);
163} 171}
164 172
165 173
166static void *ll_load (lua_State *L, const char *path, int seeglb) { 174static void *ll_load (lua_State *L, const char *path, int seeglb) {
167 HINSTANCE lib = LoadLibrary(path); 175 HMODULE lib = LoadLibraryEx(path, NULL, LUA_LLE_FLAGS);
168 (void)(seeglb); /* symbols are 'global' by default? */ 176 (void)(seeglb); /* symbols are 'global' by default? */
169 if (lib == NULL) pusherror(L); 177 if (lib == NULL) pusherror(L);
170 return lib; 178 return lib;
@@ -172,7 +180,7 @@ static void *ll_load (lua_State *L, const char *path, int seeglb) {
172 180
173 181
174static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { 182static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
175 lua_CFunction f = (lua_CFunction)GetProcAddress((HINSTANCE)lib, sym); 183 lua_CFunction f = (lua_CFunction)GetProcAddress((HMODULE)lib, sym);
176 if (f == NULL) pusherror(L); 184 if (f == NULL) pusherror(L);
177 return f; 185 return f;
178} 186}