mirror of https://github.com/rusefi/lua.git
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
This commit is contained in:
parent
f270e7f044
commit
b678f246a4
16
loadlib.c
16
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
|
** Dynamic library loader for Lua
|
||||||
** See Copyright Notice in lua.h
|
** 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
|
#undef setprogdir
|
||||||
|
|
||||||
|
/*
|
||||||
|
** optional flags for LoadLibraryEx
|
||||||
|
*/
|
||||||
|
#if !defined(LUA_LLE_FLAGS)
|
||||||
|
#define LUA_LLE_FLAGS 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static void setprogdir (lua_State *L) {
|
static void setprogdir (lua_State *L) {
|
||||||
char buff[MAX_PATH + 1];
|
char buff[MAX_PATH + 1];
|
||||||
char *lb;
|
char *lb;
|
||||||
|
@ -159,12 +167,12 @@ static void pusherror (lua_State *L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ll_unloadlib (void *lib) {
|
static void ll_unloadlib (void *lib) {
|
||||||
FreeLibrary((HINSTANCE)lib);
|
FreeLibrary((HMODULE)lib);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void *ll_load (lua_State *L, const char *path, int seeglb) {
|
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? */
|
(void)(seeglb); /* symbols are 'global' by default? */
|
||||||
if (lib == NULL) pusherror(L);
|
if (lib == NULL) pusherror(L);
|
||||||
return lib;
|
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) {
|
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);
|
if (f == NULL) pusherror(L);
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue