# linker

Responsible for finding and retrieving lua functions that could be detoured and overwritten.
Its also a powerful library utilizing reflection's interstate capabilities.


# Example

You can call some functions cross-state if you feel the client-side is too unsafe.

-- do note safety of isolate function still applies here
local print = print
local tostring = tostring
local setmetatable = debug.setmetatable
local FindMetaTable = FindMetaTable
local PrintTable = PrintTable

print("menu-state or anystate can now call client-side functions")
linker.isolate(true)

local lp = GLOBAL.LocalPlayer()
print("HP: " .. Entity.Health(lp))
print("Alive: " .. tostring(Player.Alive(lp)))

local pos = Entity.EyePos(lp)
setmetatable(pos, FindMetaTable("Vector"))
print("Position: " .. tostring(pos))

local color = Entity.GetColor(lp)
PrintTable(color)

linker.isolate(false)

# Functions

# linker.meta(library: string, name?: string): function | table

linker.meta(library: string, name?: string): function | table
  • Fetches a metatable class function, like "Player.GetEyeAngles"
  • Not providing a name will return the entire table
local GetEyeAngles = linker.meta("Player", "GetEyeAngles") -- Get's Player's metatable GetEyeAngles
local Entity = linker.meta("Entity") -- Get's Entity.*, basically all functions under Entity
--> ex: Entity.GetClass

# linker.global(library: string, name?: string): function | table

linker.global(library: string, name?: string): function | table
  • Fetches a global class function, like "surface.CreateFont"
  • To fetch raw globals do "GLOBAL", like "GLOBAL.SysTime"
  • Not providing a name will return the entire table
local SysTime = linker.global("GLOBAL", "SysTime") -- Get's SysTime global
local util = linker.global("util") -- Get's util.*, basically all functions under util
--> ex: util.TraceLine

# linker.isolate(state?: boolean): boolean

linker.isolate(state?: boolean): boolean
  • Creates an abolute isolated states, where _G and the ENV will only access linker libraries
  • This is for absolute safety, if any access happens thats not available in linker, it will throw an error for protection reasons
linker.isolate(true)

-- creates detour resistance, these will always be original functions
net.Start("example")
net.SendToServer()

local a = some_random_global_variable -- error, linker does not recognize this global

linker.isolate(false)

local a = some_random_global_variable -- doesn't error as env is restored