Notice: I’m planning on rewriting H3x with new (and better) technology. I realize that I didn’t really ever get this update released and that’s most likely how things will be until I have gotten to the rewrite.
Some general plans for the rewrite:
- Neater code (particularly for those looking to modify my code to better fit their game’s uses)
- Easier alternative to the hooking API
(My current implementation is confusing imo and I have an interesting idea I might play with)
- Custom thread handler/tracker (most likely including some extra thread related tools, notably shutting down scripts)
Here’s some info for those interested in how H3x works currently. There’s also some information on what I’m planning at the very end.
H3x has two main, essential sections:
H3x’s sandbox essentially tries to minimally impact detectability by remaining as close to Roblox’s actual environment as possible. One of the main features of H3x is that it will wrap certain functions into coroutines, which are marked by Roblox as c based functions meaning functions which do not allow c functions will fail (such as coroutine.wrap itself).
There’s a caveat to this trick though. Yielding within a wrapped function will simply permanently yield. This is something I want to address in my rewrite and something I was somewhat unaware of to begin with. Normally c functions can’t yield, and attempting to do so from lua will cause an error (and should in my case). Wrapped functions do not have this behaviour since they are linked with a thread.
I’m pretty proud of the spawning piece of H3x in terms of reliability, speed, and that idea of sticking as close to Roblox lua as possible. This code takes user code, and actually runs it. The method I use to do so is actually pretty simple all things considered. I simply create a “parent” script which will spawn an actual script thread. Getting it to run the code is fairly simple as well. What I do is give the spawner script an event, and a module (for referencing data). The module is required by H3x, necessary data/code is inserted, and the script is ran.
In the rewrite these are the main changes I want to make to these two components of H3x:
- Properly erroring in c functions, as well as documenting that you cannot yield in c functions. Alternatively a better wrapper solution for c functions, which I’ll need to experiment with first.
- The spawner will be faster and more reliable than it was (particularly with certain scripts)
- Custom thread tracing which will have the power to completely, and instantaneously terminate a thread or script, yield/pause its execution externally, and more.
- Smart stack (technically just thread related) tracing and better stack overflow handling (no freezing when there’s a stack overflow, and no recursive threads breaking Roblox’s hang timer)