Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › MultiPlayer Game Hacks & Cheats › Steam Games Hacks & Cheats › Garry's Mod Hacks & Cheats › Garry's Mod Coding & Resources › Help with getting Client lua state when hooking from Menu State

QuestionHelp with getting Client lua state when hooking from Menu State

Posts 1–4 of 4 · Page 1 of 1
TH
TheAJSlammer
Help with getting Client lua state when hooking from Menu State
What's up, guys. I'm having trouble getting Client Lua state when using a module from menu state. I am already hooking from CreateLuaInterfaceFn but I'm having trouble getting it all working. Any hooks you guys can recommend or headers I might be missing/not thinking about?
For reference, I'm trying to call lua hooks between menu and client for a bot I'm building. Due to the bot running in client and the management/'backend' running in menu I'd like to notify menu on completed tasks etc.

The codebase is from the loonix branch of 'gm_roc' (credits to LennyPenny and meepen) because it seemed the closest to my use case. So I hope that helps if you wanted to see the headers and structs I'm using

I've been a software engineer for a number of years but I've never really gone near C++ before. So sorry if any of this cringes you out. Simple modules seemed fluid but going into hooking and process level stuff, I'm lost. Appreciate any help!

Code:
using namespace GarrysMod;

Lua::Shared* luaShared;

VTable *luashared_vt;
VTable *client_vt;

Lua::Interface *cState;
Lua::ILuaBase *MENU;

int CallOnClient(lua_State *state)
{
	if (!cState)
		LUA->ThrowError("Not in game");
	
	//Lua::ILuaBase *CLIENT = cState->state->luabase;

	//CLIENT->PushSpecial(Lua::SPECIAL_GLOB);
	//CLIENT->GetField(-1, "hook");
	//CLIENT->GetField(-1, "Call");
	//CLIENT->PushString(LUA->GetString(1));
	//CLIENT->PushNil();
	//CLIENT->PushString(LUA->GetString(2));
	//CLIENT->Call(3, 1);
	//CLIENT->Pop(2);

	return 0;
}

int CallOnMenu(lua_State *state)
{
	const char *name = LUA->GetString(1);
	const char *data = LUA->GetString(2);
	if (!cState)
		LUA->ThrowError("Not in game");
	//MENU->PushSpecial(Lua::SPECIAL_GLOB);
	//MENU->GetField(-1, "hook");
	//MENU->GetField(-1, "Call");
	//MENU->PushString(name, strlen(name));
	//MENU->PushNil();
	//MENU->PushString(data, strlen(data));
	//MENU->Call(3, 1);
	//MENU->Pop(2);
	return 0;
}


typedef Lua::Interface *(__thiscall *hCreateLuaInterfaceFn)(Lua::Shared*, unsigned char, bool);
void *__hook hCreateLuaInterface(Lua::Shared *ths, HOOK_EDX(void *) uchar state, bool renew)
{
	Lua::Interface* hState = hCreateLuaInterfaceFn(luashared_vt->getold(Lua::Shared::CREATELUAINTERFACE))(ths, state, renew);

	if (state != Lua::Interface::CLIENT)
		return hState;

	cState = hState;

	//Push CallOnMenu to Client state

	client_vt = new VTable(cState);

	return cState;
}

typedef void *(__thiscall *hCloseLuaInterfaceFn)(Lua::Shared *, Lua::Interface *);
void *__hook hCloseLuaInterface(Lua::Shared *ths, HOOK_EDX(void *) Lua::Interface *iface)
{
	if (iface == cState)
		cState = NULL;

	return hCloseLuaInterfaceFn(luashared_vt->getold(Lua::Shared::CLOSELUAINTERFACE))(ths, iface);
}

GMOD_MODULE_OPEN()
{
	MENU = LUA;
	luaShared = GetInterface<Lua::Shared*>("lua_shared", "LUASHARED003");

	LUA->PushSpecial(Lua::SPECIAL_GLOB);
		LUA->PushString("CallOnClient");
		LUA->PushCFunction(CallOnClient);
		LUA->SetTable(-3);
	LUA->Pop();

	luashared_vt = new VTable(luaShared);
	luashared_vt->hook(Lua::Shared::CREATELUAINTERFACE, (void *)&hCreateLuaInterface);
	luashared_vt->hook(Lua::Shared::CLOSELUAINTERFACE, (void *)&hCloseLuaInterface);

	return 0;
}

GMOD_MODULE_CLOSE()
{
	return 0;
}
#1 · edited 6y ago · 6y ago
TH
TheAJSlammer
I've decided to just make 2 modules, one for menu and one for client. Getting the Client interface and pushing to it too early causes crashes, so it's easier just to load in a seperate module.

May be closed now.
#2 · 6y ago
SU
suchisgood
This is null causing you to crash!

luaShared = GetInterface<Lua::Shared*>("lua_shared", "LUASHARED003");
#3 · 6y ago
HI
Himself1
in your create interface hook, the unsigned char is the interface type
it's called for menu, server, and client; but since you're already in menu, you'll only be seeing server and client
#4 · 6y ago
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Similar Threads

  • I want help with getting improved fullscreen and stuff for my fabiano client.By nytemart in Realm of the Mad God Private Servers Help
    4Last post 9y ago
  • pls help!! i get client mfc error when using hacks on cfph!By luluhircerk in CrossFire PH Help
    9Last post 14y ago
  • Help with Obsidian Client errorBy CaladusX in Minecraft Help
    5Last post 12y ago
  • Need help with getting past SSO errorBy sweepy15 in Vindictus Help
    6Last post 14y ago
  • Need help with multi clientBy anhhao2185 in Vindictus Help
    13Last post 15y ago

Tags for this Thread

None