Advertisement
LocalDuds

Untitled

Jun 1st, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.41 KB | None | 0 0
  1. typedef VOID*(__cdecl* rinsert)(DWORD RLS, int idx);
  2.     rinsert r_l_insert = (rinsert)(unprotect(ASLR(0x800110)));
  3.  
  4.     typedef const char*(__cdecl* getupval)(DWORD RLS, int funcindex, int n);
  5.     getupval r_l_getupvalue = (getupval)(unprotect(ASLR(0x800060)));
  6.  
  7.     typedef const char*(__cdecl* setupval)(DWORD RLS, int funcindex, int n);
  8.     setupval r_l_setupvalue = (setupval)(unprotect(ASLR(0x801D50)));
  9.  
  10.  
  11.     //typedef void*(__cdecl* rgetfenv)(DWORD RLS, int idx);
  12.     //rgetfenv r_l_getfenv = (rgetfenv)(unprotect(ASLR(0x7FFA80)));
  13.  
  14.     int Debug_GetRegistry(lua_State* LS) {
  15.         r_l_pushvalue(RLS, LUA_REGISTRYINDEX);
  16.         return 1;
  17.     }
  18.  
  19.           static int r_l_unpack(lua_State *L) {
  20.  
  21.              int i, e, n;
  22.               luaL_checktype(L, 1, LUA_TTABLE);
  23.               i = luaL_optint(L, 2, 1);
  24.                e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1));
  25.              if (i > e) return 0;  /* empty range */
  26.              n = e - i + 1;  /* number of elements */
  27.                if (n <= 0 || !lua_checkstack(L, n))  /* n <= 0 means arith. overflow */
  28.                   return luaL_error(L, "too many results to unpack");
  29.               r_l_rawgeti(RLS, 1, i);  /* push arg[i] (avoiding overflow problems) */
  30.              while (i++ < e)  /* push arg[i + 1...e] */
  31.                    r_l_rawgeti(RLS, 1, i);
  32.               return n;
  33.        
  34.     }
  35.  
  36.  
  37.     int Debug_GetMetaTable(lua_State* LS) {
  38.         if (lua_gettop(LS) == 0) {
  39.             luaL_error(LS, "'debug.getrawmetatable' needs 1 argument.");
  40.             return 0;
  41.         }
  42.         if (r_l_getmetatable(RLS, -1) == 0) {
  43.             r_l_pushnil(RLS);
  44.             return 0;
  45.         }
  46.         return 1;
  47.     }
  48.  
  49.     int Debug_SetMetaTable(lua_State* LS) {
  50.         if (lua_gettop(LS) == 0) {
  51.             luaL_error(LS, "'debug.setmetatable' needs at least 1 argument.");
  52.             return 0;
  53.         }
  54.         r_l_pushboolean(RLS, r_l_setmetatable(RLS, 1));
  55.         return 1;
  56.     }
  57.  
  58.  
  59.     static int auxupvalue(lua_State *L, int get) {
  60.         const char *name;
  61.         int n = luaL_checkint(L, 2);
  62.         luaL_checktype(L, 1, LUA_TFUNCTION);
  63.         if (lua_iscfunction(L, 1)) return 0;  /* cannot touch C upvalues from Lua */
  64.         name = get ? r_l_getupvalue(RLS, 1, n) : r_l_setupvalue(RLS, 1, n);
  65.         if (name == NULL) return 0;
  66.         r_l_pushstring(RLS, name);
  67.         r_l_insert(RLS, -(get + 1));
  68.         return get + 1;
  69.  
  70.     }
  71.  
  72.     static int db_setupvalue(lua_State *L) {
  73.         luaL_checkany(L, 3);
  74.         return auxupvalue(L, 0);
  75.     }
  76.  
  77.  
  78.     static int db_getupvalue(lua_State *L) {
  79.         return auxupvalue(L, 1);
  80.  
  81.     }
  82.  
  83.     int rgetfenvremake(lua_State* LS) {
  84.         r_l_getfenv(RLS, lua_tonumber(LS, -1));
  85.         return 1;
  86.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement