Skip to content

Removed unused requires & added a new sanity check!#216

Merged
levno-710 merged 1 commit intoprometheus-lua:masterfrom
SpinnySpiwal:master
Mar 9, 2026
Merged

Removed unused requires & added a new sanity check!#216
levno-710 merged 1 commit intoprometheus-lua:masterfrom
SpinnySpiwal:master

Conversation

@SpinnySpiwal
Copy link
Contributor

@SpinnySpiwal SpinnySpiwal commented Mar 8, 2026

Added a sanity check which works for all Lua versions to prevent someone from using registerArray[1] = true; (this sadly is a real thing, I don't think it can be fixed due to the way the VM is built.)
Why does this benefit the project? It prevents anyone going into any obfuscated file and quite literally beautifying it, looking for the loop, and looking for the first index expression you see, and say the base name was T,
you'd do

while A do
    T[1]=true --> No more AntiTamper?!
end

and if UseDebug is true, all you have to do is run the file and comment out the line of the error call.

@levno-710
Copy link
Member

It could be possible to modify Compiler:allocRegister to not always choose the first free register, but to have a set of the next n free registers and choosing one from them randomly.

Something like this:

local free_regs = {}
local next_free = 1
local free_count = 0

-- ensure at least n free registers exist
local function grow(n)
    while free_count < n do
        free_count = free_count + 1
        free_regs[free_count] = next_free
        next_free = next_free + 1
    end
end

-- allocate a register randomly from the next n free registers
function alloc(n)
    n = n or 8

    grow(n)

    local limit = math.min(n, free_count)
    local idx = math.random(limit)

    local reg = free_regs[idx]

    -- remove chosen register (swap-remove)
    free_regs[idx] = free_regs[free_count]
    free_regs[free_count] = nil
    free_count = free_count - 1

    return reg
end

-- free a register
function free(reg)
    free_count = free_count + 1
    free_regs[free_count] = reg
end

@levno-710 levno-710 merged commit 61f7145 into prometheus-lua:master Mar 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants