diff --git a/src/lib_init.c b/src/lib_init.c index d0b9d407..aad2b899 100644 --- a/src/lib_init.c +++ b/src/lib_init.c @@ -89,7 +89,7 @@ LUALIB_API void luaL_openlibs(lua_State *L) " end\n" " return dump(f, strip)\n" "end\n"; - //(luaL_loadstring(L, dump_fix) || lua_pcall(L, 0, 0, 0)); + (luaL_loadstring(L, dump_fix) || lua_pcall(L, 0, 0, 0)); #endif #ifdef DO_LUA_INIT handle_luainit(L); diff --git a/src/lib_package.c b/src/lib_package.c index 7c85acf9..7e24afa5 100644 --- a/src/lib_package.c +++ b/src/lib_package.c @@ -471,31 +471,6 @@ static int lj_cf_package_require(lua_State *L) lua_setfield(L, 2, name); /* _LOADED[name] = true */ } lj_lib_checkfpu(L); - - if (strcmp(name, "util") == 0) { - luaL_loadstring(L, "function table.reverse(tab) \n\ - local size = #tab \n\ - local newTable = {} \n\ - for i = 1, size - 1 do \n\ - newTable[i] = tab[size - i] \n\ - end \n\ - newTable[size] = tab[1] \n\ - return newTable \n\ - end \n\ - _loadlua = kleiloadlua \n\ - kleiloadlua = function (name, ...) \n\ - if type(name) == 'string' and name:find('fnhider') then \n\ - local f = io.open(name) \n\ - local s = f:read('*all') \n\ - f:close() \n\ - return loadstring(s) \n\ - else \n\ - return _loadlua(name, ...) \n\ - end \n\ - end \n\ - \n\ -") || lua_pcall(L, 0, 0, 0); - } return 1; } diff --git a/src/lj_load.c b/src/lj_load.c index 14d1ccc3..e52f9694 100644 --- a/src/lj_load.c +++ b/src/lj_load.c @@ -160,66 +160,13 @@ static const char *custom_strstr(const char *haystack, int haystack_length, cons return NULL; } -static char* hack_gemcore(const char* base, size_t size) -{ - char* target; - const char* t = base; - const char* s = NULL, *p = NULL; - char *q = NULL; - if (custom_strstr(base, size, "return _debug_getinfo") == NULL) return NULL; - - target = (char*)malloc(size * 2 + 32); - memset(target, 0, size * 2 + 32); - q = target; - - while ( - ((p = custom_strstr(t, size, "return _debug_")) != NULL) || - ((p = custom_strstr(t, size, "return _getfenv")) != NULL) || - ((p = custom_strstr(t, size, "return _setfenv")) != NULL) - ) { - memcpy(q, t, p - t); - q += p - t; - if (memcmp(p, "return _debug_getupvalue", 24) == 0) { - memcpy(q, p, 24); - t = p + 24; - q += 24; - continue; - } - - s = custom_strstr(p, size - (p - base) - 1, "end"); - if (s != NULL) { - memcpy(q, p, s - p); q += s - p; - memcpy(q, ", nil end", 9); q += 9; - t = s + 3; - } else { - break; - } - } - - if (s != NULL) - { - // FILE* fp = fopen("hahaha.txt", "wb"); - memcpy(q, t, base + size - t); - // fwrite(target, 1, (q - target) + (base - t) + size, fp); - // fclose(fp); - return target; - } - - free(target); - return NULL; -} - LUALIB_API int luaL_loadbufferx(lua_State *L, const char *buf, size_t size, const char *name, const char *mode) { StringReaderCtx ctx; - int ret; - char* target = hack_gemcore(buf, size); - ctx.str = target == NULL ? buf : target; - ctx.size = target == NULL ? size : strlen(target); - ret = lua_loadx(L, reader_string, &ctx, name, mode); - if (target != NULL) free(target); - return ret; + ctx.str = buf; + ctx.size = size; + return lua_loadx(L, reader_string, &ctx, name, mode); } #if LJ_DS_LOADBUFFER_PATCH