gmcl_debug
big words from someone who the only thing he has under his belt is being a known paster
- - - Updated - - -
good job trying to sound smart, ~ExPorTeDfUnCtIoNs~ "uNdEfInED bEhAvIoR"
come back when you learn how to code, and i'm not talking about your version of coding by spewing new stl additions into ur code unnecessarily to show how M0D3RN you are
- - - Updated - - -
good job trying to sound smart, ~ExPorTeDfUnCtIoNs~ "uNdEfInED bEhAvIoR"
come back when you learn how to code, and i'm not talking about your version of coding by spewing new stl additions into ur code unnecessarily to show how M0D3RN you are
"Known paster" Please, show me where some of my projects are paste. That's just a useless insult that proves nothing about a person. And oh god, apparently using the language as the creators fucking designed it is apparently the wrong way to do it. C style casts cannot prove that the type was converted safely or even correctly, because it is only checked on RUN-TIME. The new casting system was introduced to be able to prove that you casted from one data type to another safely and correctly at COMPILE-TIME. You're ego is so massive it's not even funny. And are you kidding me, I'm explaining exactly what it does and you turn it into me sounding smart. Look at the fucking code, dipshit.
https://anteru.net/blog/2007/12/18/200/
Code:
#include "Windows.h"
typedef int(*lua_CFunction)(void* L);
typedef struct luaL_Reg {
const char *name;
lua_CFunction func;
} luaL_Reg;
struct lua_Debug {
int event;
const char *name; /* (n) */
const char *namewhat; /* (n) 'global', 'local', 'field', 'method' */
const char *what; /* (S) 'Lua', 'C', 'main', 'tail' */
const char *source; /* (S) */
int currentline; /* (l) */
int linedefined; /* (S) */
int lastlinedefined; /* (S) */
unsigned char nups; /* (u) number of upvalues */
unsigned char nparams;/* (u) number of parameters */
char isvararg; /* (u) */
char istailcall; /* (t) */
char short_src[60]; /* (S) */
/* private part */
struct CallInfo *i_ci; /* active function */
};
HMODULE lua_shared;
void(*luaL_checkany)(void*, int);
int(*luaL_checkint)(void*, int);
void(*luaL_checktype)(void*, int, int);
void(*luaL_register)(void*, const char*, const luaL_Reg*);
int(*luaL_argerror)(void*, int, const char*);
int(*luaL_error)(void*, const char*, ...);
int(*lua_iscfunction)(void*, int);
const char*(*lua_getupvalue)(void*, int, int);
const char*(*lua_setupvalue)(void*, int, int);
void(*lua_pushstring)(void*, const char*);
void(*lua_insert)(void*, int);
void(*lua_getfield)(void*, int, const char*);
void(*lua_pushvalue)(void*, int);
int(*lua_getinfo)(void*, const char*, lua_Debug*);
void*(*lua_upvalueid)(void*, int, int);
void(*lua_pushlightuserdata)(void*, void*);
void(*lua_upvaluejoin)(void*, int, int, int, int);
int(*lua_type)(void*, int);
void*(*lua_tothread)(void*, int);
int(*lua_getstack)(void*, int, lua_Debug*);
void(*lua_settop)(void*, int);
int(*lua_checkstack)(void*, int);
void(*lua_xmove)(void*, void*, int);
const char*(*lua_setlocal)(void*, const lua_Debug*, int);
#define luaL_argcheck(L, cond,numarg,extramsg) \
((void)((cond) || luaL_argerror(L, (numarg), (extramsg))))
int remade_lua_setupvalue(void* L)
{
luaL_checkany(L, 3);
const char* name;
int n = luaL_checkint(L, 2);
luaL_checktype(L, 1, 6);
if (lua_iscfunction(L, 1)) return 0; /* cannot touch C upvalues from Lua */
name = lua_setupvalue(L, 1, n);
if (name == nullptr) return 0;
lua_pushstring(L, name);
lua_insert(L, -1);
return 1;
}
int check_upvalue(void* L, int argf, int argnup)
{
lua_Debug ar;
int nup = luaL_checkint(L, argnup);
luaL_checktype(L, argf, 6);
lua_pushvalue(L, argf);
lua_getinfo(L, ">u", &ar);
luaL_argcheck(L, 1 <= nup && nup <= ar.nups, argnup, "invalid upvalue index");
return nup;
}
int remade_lua_upvalueid(void* L)
{
int n = check_upvalue(L, 1, 2);
lua_pushlightuserdata(L, lua_upvalueid(L, 1, n));
return 1;
}
int remade_lua_upvaluejoin(void* L)
{
int n1 = check_upvalue(L, 1, 2);
int n2 = check_upvalue(L, 3, 4);
luaL_argcheck(L, !lua_iscfunction(L, 1), 1, "Lua function expected");
luaL_argcheck(L, !lua_iscfunction(L, 3), 3, "Lua function detected");
lua_upvaluejoin(L, 1, n1, 3, n2);
return 0;
}
void* getthread(void* L, int* arg)
{
if (lua_type(L, 1) == 8)
{
*arg = 1;
return lua_tothread(L, 1);
}
*arg = 0;
return L;
}
void checkstack(void* L, void* L1, int n)
{
if (L != L1 && !lua_checkstack(L1, n))
luaL_error(L, "stack overflow");
}
int remade_lua_setlocal(void* L)
{
int arg;
void* L1 = getthread(L, &arg);
lua_Debug ar;
if (!lua_getstack(L1, luaL_checkint(L, arg + 1), &ar))
return luaL_argerror(L, arg + 1, "level out of range");
luaL_checkany(L, arg + 3);
lua_settop(L, arg + 3);
checkstack(L, L1, 1);
lua_xmove(L, L1, 1);
lua_pushstring(L, lua_setlocal(L1, &ar, luaL_checkint(L, arg + 2)));
return 1;
}
static const luaL_Reg dblib[] =
{
{"setlocal", remade_lua_setlocal},
{"setupvalue", remade_lua_setupvalue},
{"upvalueid", remade_lua_upvalueid},
{"upvaluejoin", remade_lua_upvaluejoin},
{NULL, NULL}
};
extern "C" __declspec(dllexport) int gmod13_open(void* s)
{
lua_shared = GetModuleHandleA("lua_shared.dll");
luaL_checkany = reinterpret_cast<void(*)(void*, int)>(GetProcAddress(lua_shared, "luaL_checkany"));
luaL_checkint = reinterpret_cast<int(*)(void*, int)>(GetProcAddress(lua_shared, "luaL_checkinteger"));
luaL_checktype = reinterpret_cast<void(*)(void*, int, int)>(GetProcAddress(lua_shared, "luaL_checktype"));
luaL_register = reinterpret_cast<void(*)(void*, const char*, const luaL_Reg*)>(GetProcAddress(lua_shared, "luaL_register"));
luaL_argerror = reinterpret_cast<int(*)(void*, int, const char*)>(GetProcAddress(lua_shared, "luaL_argerror"));
luaL_error = reinterpret_cast<int(*)(void*, const char*, ...)>(GetProcAddress(lua_shared, "luaL_error"));
lua_iscfunction = reinterpret_cast<int(*)(void*, int)>(GetProcAddress(lua_shared, "lua_iscfunction"));
lua_getupvalue = reinterpret_cast<const char*(*)(void*, int, int)>(GetProcAddress(lua_shared, "lua_getupvalue"));
lua_setupvalue = reinterpret_cast<const char*(*)(void*, int, int)>(GetProcAddress(lua_shared, "lua_setupvalue"));
lua_pushstring = reinterpret_cast<void(*)(void*, const char*)>(GetProcAddress(lua_shared, "lua_pushstring"));
lua_insert = reinterpret_cast<void(*)(void*, int)>(GetProcAddress(lua_shared, "lua_insert"));
lua_getfield = reinterpret_cast<void(*)(void*, int, const char*)>(GetProcAddress(lua_shared, "lua_getfield"));
lua_pushvalue = reinterpret_cast<void(*)(void*, int)>(GetProcAddress(lua_shared, "lua_pushvalue"));
lua_getinfo = reinterpret_cast<int(*)(void*, const char*, lua_Debug*)>(GetProcAddress(lua_shared, "lua_getinfo"));
lua_upvalueid = reinterpret_cast<void*(*)(void*, int, int)>(GetProcAddress(lua_shared, "lua_upvalueid"));
lua_pushlightuserdata = reinterpret_cast<void(*)(void*, void*)>(GetProcAddress(lua_shared, "lua_pushlightuserdata"));
lua_upvaluejoin = reinterpret_cast<void(*)(void*, int, int, int, int)>(GetProcAddress(lua_shared, "lua_upvaluejoin"));
lua_type = reinterpret_cast<int(*)(void*, int)>(GetProcAddress(lua_shared, "lua_type"));
lua_tothread = reinterpret_cast<void*(*)(void*, int)>(GetProcAddress(lua_shared, "lua_tothread"));
lua_getstack = reinterpret_cast<int(*)(void*, int, lua_Debug*)>(GetProcAddress(lua_shared, "lua_getstack"));
lua_settop = reinterpret_cast<void(*)(void*, int)>(GetProcAddress(lua_shared, "lua_settop"));
lua_checkstack = reinterpret_cast<int(*)(void*, int)>(GetProcAddress(lua_shared, "lua_checkstack"));
lua_xmove = reinterpret_cast<void(*)(void*, void*, int)>(GetProcAddress(lua_shared, "lua_xmove"));
lua_setlocal = reinterpret_cast<const char*(*)(void*, const lua_Debug*, int)>(GetProcAddress(lua_shared, "lua_setlocal"));
luaL_register(s, "debug", dblib);
return 0;
}
extern "C" __declspec(dllexport) int gmod13_close(void* s)
{
return 0;
}
keep your nerd rage down retard
haha gmod devs were too lazy to fix the exploit so they just removed the functions fucking homos
"the functions aren't long so they must be easy to fix!"
debug.setupvalue is only 2 lines long. Feel free to fix it.
debug.setupvalue is only 2 lines long. Feel free to fix it.
Then fix ipairs?
it can be fixed by changing it back to the regular lua one
problem is it pushes the upvalue
Code:
static int ipairsaux(lua_State*L){
int i=luaL_checkint(L,2);
luaL_checktype(L,1,5);
i++;
lua_pushinteger(L,i);
lua_rawgeti(L,1,i);
return(lua_isnil(L,-1))?0:2;
}
static int luaB_ipairs(lua_State*L){
luaL_checktype(L,1,5);
lua_pushvalue(L,lua_upvalueindex(1));
lua_pushvalue(L,1);
lua_pushinteger(L,0);
return 3;
}
I have the biggest brain here, bow down to me.
There's still a fork on github, and I may have done a function style cast on one of my template functions. Sometimes you need to be able to cast from pointers as well as standard data types in one function. Overloading that function with a static_cast as well as a reinterpret_cast wouldn't work as the compiler would have no idea which one you want to use.
