runtime
Contains functions that modify the Lua(u) Virtual Machine runtime.
Functions
disablenative
runtime.
disablenative
(
fn:
(
T...
)
→
U...
--
The function to disable native code execution for.
) →
(
)
Disables the execution of native generated code for the provided function.
Hooking functions
You may need to call this function in the future before hooking functions!
Example
-- This signals the compiler to enable native code generation on the protos the main proto contains!
-- This means herein if the LVM supports native code, it will be enabled for the functions the code has (and if the compiler believes it to be 'benefitial'!)
--!native
local function a()
local function b()
print("hi b")
print(runtime.isnativecode(a)) -- true
print(runtime.isnativecode(b)) -- true
runtime.disablenative(debug.info(1, "f")) -- entry point is now bytecode, should be able to be restored without limitations.
runtime.disablenative(debug.info(2, "f")) -- entry point is now bytecode, should be able to be restored without limitations.
print(runtime.isnativecode(a)) -- false
print(runtime.isnativecode(b)) -- false
end
print("hi a")
b()
end
-- Uncomment if you remove --!native
-- runtime.enablenative(a)
a()
Implementation
Depending on your implementation, you may be unable to remove native code from a function that is on the callstack currently. Investigate into the CodeGen implementation to learn how to do things properly.
Errors
Type | Description |
---|---|
VM is not supported | The VM does not support native code. |
enablenative
runtime.
enablenative
(
fn:
(
T...
)
→
U...
--
The function to enable native code execution for.
) →
(
)
Enables the execution of native generated code, if the Lua(u) VM is prepared for it.
Errors
Type | Description |
---|---|
VM is not supported | The VM does not support native code. |
isnativecode
runtime.
isnativecode
(
fn:
(
T...
)
→
U...
--
The function to check.
) →
boolean
--
Whether the function is implemented in native code or running with a native code implementation.
Checks if the current function is implemented in the form of native code (implemented in C or runs with generated native code).
can_vm_run_native_code
runtime.
can_vm_run_native_code
(
) →
boolean
--
Whether the VM can run native code.
Checks if the current Lua(u) VM can run native code.
getstringatom
runtime.
getstringatom
(
str:
string
--
The string to get the atom of.
) →
number
--
The atom of str, as a signed 16 bit integer (short/I16/std::int16_t).
Obtains the 'atom' of the given string str
.
getstringhash
runtime.
getstringhash
(
str:
string
--
The string to get the hash of.
) →
number
--
The hash of str, as an unsigned integer.
Obtains the hash of the given string str
that was assigned to it by Lua(u).
enablepointerencoding
runtime.
enablepointerencoding
(
) →
(
)
Enables pointer encoding for the Lua(u) VM.
Implementation
This function should be implemented as a way to restore the pointer encryption key to the original value, using the key that RBX::ScriptContext contains. While any value is acceptable, it is recommended to use the value from RBX::ScriptContext in order to avoid issues.
disablepointerencoding
runtime.
disablepointerencoding
(
) →
(
)
Disables pointer encoding for the Lua(u) VM.
Executor Development
This can help locate objects in memory to find out about their true structure in memory.
getrawaddress
runtime.
getrawaddress
(
obj:
any
--
The object to retrieve the address of.
) →
string
--
The raw address.
Gets the raw address of the provided value using topointer
.
isinstance
runtime.
isinstance
(
obj:
userdata
--
The object to check.
) →
boolean
--
Whether the object is a userdata
of type Instance
.
Returns whether the given object is a userdata of type Instance.
Implementation
This function should NEVER be implemented as a __type check. You must figure out a way to do it yourself.
getuserdatatag
runtime.
getuserdatatag
(
obj:
userdata
--
The object which inherits from userdata.
) →
number
--
The userdata tag of the object.
Returns the userdata tag for the provided object.
setluaufflag
runtime.
setluaufflag
(
flagName:
string
,
--
The name of the flag to set.
flagValue:
boolean
--
The value to set the flag to.
) →
(
)
Sets a fast flag in the Lua(u) VM for specific behaviour.
Implementation
This functions should affect the Roblox VM as well if you are using a RVM/CLVM execution method.
disableerrorlogging
runtime.
disableerrorlogging
(
) →
(
)
Disables the error logging Roblox does on the VM. This is NOT the same as disabling error logging in the VM itself, it simply disables the ScriptContext.Error
signal.
Implementation
This function can be implemented using hooksignal
or getconnections
, but it must continue to work even if new connections are added to the event.
enableerrorlogging
runtime.
enableerrorlogging
(
) →
(
)
Enables the error logging Roblox does on the VM. This is NOT the same as disabling error logging in the VM itself, it simply enables the ScriptContext.Error
signal again after being disabled.
getrbxbuildhash
Optionalruntime.
getrbxbuildhash
(
) →
string
--
The ROBLOX build hash.
Returns the Version hash of the current, running ROBLOX version. The version hash is the hash that follows the 'version' string in version-...
.
gethwid
runtime.
gethwid
(
) →
string
--
The hash of your tool's calculated HWID, as a hex string.
Returns the HWID for the running computer.
HWID Hashing
After performing your own tool's HWID calculations, you are expected to provide a hex-formatted hash that cannot be reconstructed back to the original HWID.
checkcaller
runtime.
checkcaller
(
) →
boolean
--
Whether the current thread was created by the executor.
Returns whether the current thread was created by the executor.
getnamecallmethod
runtime.
getnamecallmethod
(
) →
string?
--
The namecall method, if nil, there is no namecall set.
Returns the current namecall method.
setnamecallmethod
runtime.
setnamecallmethod
(
newNamecall:
string
--
The namecall method to set.
) →
string?
--
The namecall method, if nil, there is no namecall set.
Sets the current namecall method.
Errors
Type | Description |
---|---|
no namecall currently | There is no namecall currently occurring. |
getthreadidentity
runtime.
getthreadidentity
(
th:
thread?
--
The thread to get the identity of (if nil, defaults to current thread)
) →
number
--
The thread identity of the current thread (or given thread)
Gets the current thread identity and capabilities.
setthreadidentity
runtime.
setthreadidentity
(
threadIdentity:
number
--
The thread identity to set. Must be between 0 and 8
) →
(
)
Sets the current thread identity and capabilities.
setfpscap
runtime.
setfpscap
(
fps:
number?
--
The maximum amount of frames per second (fps). If no value is provided, it automatically defaults to 1000.
) →
(
)
Sets the maximum amount of frames per second (fps) to run the game engine can run at.
Implementation
This function should set the FPS to 1000 if the valueo of fps
is 0.
Errors
Type | Description |
---|---|
invalid fps value | The fps value is invalid, i.e., it is less than 0 |
getfpscap
runtime.
getfpscap
(
) →
number
--
The current target FPS of the game engine.
Sets the maximum amount of frames per second (fps) to run the game engine can run at.
rubisload
Optionalruntime.
rubisload
(
) →
(
(
(
)
→
(
)
)
|
nil
)
,
string?
--
The closure that was loaded, if successful, or nil if it failed with a second string return.
Loads a scrap from the Rubis API.
TIP
This is simply loadstring
, but specific towards the Rubis API.
getbytecode
Optionalruntime.
getbytecode
(
luauCode:
string
--
The Luau code to get the bytecode of.
) →
string
--
The bytecode of the given Luau code.
Returns the bytecode of the given Luau code.
decompile
Optionalruntime.
decompile
(
) →
string
--
The decompiled Luau bytecode.
Decompiles the given Luau bytecode or script.
disassemble
Optionalruntime.
disassemble
(
) →
string
--
The disassembled Luau bytecode.
Disassembles the given Luau bytecode or script.
setcalltrace
Optionalruntime.
setcalltrace
(
isEnabled:
boolean
--
Whether to enable call tracing.
) →
boolean
Allows you to trace execution calls to diagnose a crash.