Skip to content

Commit

Permalink
Fix Xbox One port.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Pall committed Jun 16, 2015
1 parent fe56522 commit 28d8728
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/lib_package.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static void pusherror(lua_State *L)
wchar_t wbuffer[128];
char buffer[128*2];
if (FormatMessageW(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
NULL, error, 0, buffer, sizeof(wbuffer)/sizeof(wchar_t), NULL) &&
NULL, error, 0, wbuffer, sizeof(wbuffer)/sizeof(wchar_t), NULL) &&
WideCharToMultiByte(CP_ACP, 0, wbuffer, 128, buffer, 128*2, NULL, NULL))
#else
char buffer[128];
Expand All @@ -119,7 +119,7 @@ static void ll_unloadlib(void *lib)

static void *ll_load(lua_State *L, const char *path, int gl)
{
HINSTANCE lib = LoadLibraryA(path);
HINSTANCE lib = LoadLibraryExA(path, NULL, 0);
if (lib == NULL) pusherror(L);
UNUSED(gl);
return lib;
Expand Down
1 change: 0 additions & 1 deletion src/lj_arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@
#define LJ_TARGET_XBOXONE 1
#define LJ_TARGET_CONSOLE 1
#define LJ_TARGET_GC64 1
#define LoadLibraryA(name) LoadLibraryExA((name), NULL, 0)
#endif

#define LJ_NUMMODE_SINGLE 0 /* Single-number mode only. */
Expand Down
10 changes: 5 additions & 5 deletions src/lj_clib.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ LJ_NORET LJ_NOINLINE static void clib_error(lua_State *L, const char *fmt,
wchar_t wbuf[128];
char buf[128*2];
if (!FormatMessageW(FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_SYSTEM,
NULL, err, 0, buf, sizeof(wbuf)/sizeof(wchar_t), NULL) ||
NULL, err, 0, wbuf, sizeof(wbuf)/sizeof(wchar_t), NULL) ||
!WideCharToMultiByte(CP_ACP, 0, wbuf, 128, buf, 128*2, NULL, NULL))
#else
char buf[128];
Expand Down Expand Up @@ -208,7 +208,7 @@ static const char *clib_extname(lua_State *L, const char *name)
static void *clib_loadlib(lua_State *L, const char *name, int global)
{
DWORD oldwerr = GetLastError();
void *h = (void *)LoadLibraryA(clib_extname(L, name));
void *h = (void *)LoadLibraryExA(clib_extname(L, name), NULL, 0);
if (!h) clib_error(L, "cannot load module " LUA_QS ": %s", name);
SetLastError(oldwerr);
UNUSED(global);
Expand Down Expand Up @@ -249,9 +249,9 @@ static void *clib_getsym(CLibrary *cl, const char *name)
GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS|GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
(const char *)&_fmode, &h);
break;
case CLIB_HANDLE_KERNEL32: h = LoadLibraryA("kernel32.dll"); break;
case CLIB_HANDLE_USER32: h = LoadLibraryA("user32.dll"); break;
case CLIB_HANDLE_GDI32: h = LoadLibraryA("gdi32.dll"); break;
case CLIB_HANDLE_KERNEL32: h = LoadLibraryExA("kernel32.dll", NULL, 0); break;
case CLIB_HANDLE_USER32: h = LoadLibraryExA("user32.dll", NULL, 0); break;
case CLIB_HANDLE_GDI32: h = LoadLibraryExA("gdi32.dll", NULL, 0); break;
}
if (!h) continue;
clib_def_handle[i] = (void *)h;
Expand Down
2 changes: 1 addition & 1 deletion src/lj_profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ static void profile_timer_start(ProfileState *ps)
{
#if LJ_TARGET_WINDOWS
if (!ps->wmm) { /* Load WinMM library on-demand. */
ps->wmm = LoadLibraryA("winmm.dll");
ps->wmm = LoadLibraryExA("winmm.dll", NULL, 0);
if (ps->wmm) {
ps->wmm_tbp = (WMM_TPFUNC)GetProcAddress(ps->wmm, "timeBeginPeriod");
ps->wmm_tep = (WMM_TPFUNC)GetProcAddress(ps->wmm, "timeEndPeriod");
Expand Down

0 comments on commit 28d8728

Please sign in to comment.