Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_ENV may not be the first upval #47

Open
viruscamp opened this issue Oct 7, 2016 · 1 comment
Open

_ENV may not be the first upval #47

viruscamp opened this issue Oct 7, 2016 · 1 comment

Comments

@viruscamp
Copy link
Owner

viruscamp commented Oct 7, 2016

_ENV may not be the first upval in 5.2 and 5.3 , pay attention to it when processing stripped code

local a
local function c()
    a=a+1
    return math.abs(a)
end

upval list from chunkspy

                         * upvalue names:
00E2  02000000           size_upvalue_names (2)
                         upvalue [0]: a
00E6  02000000           string size (2)
00EA  6100               "a\0"
                         upvalue [1]: _ENV
00EC  05000000           string size (5)
00F0  5F454E5600         "_ENV\0"

decompiled:

local a = nil
local c = function()
  -- function num : 0_0 , upvalues : a, _ENV
  a = a + 1
  return (math.abs)(a)
end
@viruscamp viruscamp changed the title _ENV is not the first upval _ENV may not be the first upval Oct 7, 2016
@viruscamp
Copy link
Owner Author

So , if I got a stripped function chunk , I cannot determine whether _ENV is used or which upval is _ENV .

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

No branches or pull requests

1 participant