| View previous topic :: View next topic |
| Author |
Message |
exohaxor Expert Cheater
Reputation: 1
Joined: 02 Sep 2018 Posts: 101
|
Posted: Fri Aug 23, 2019 5:39 am Post subject: string.dump |
|
|
why string dump gets all code
| Code: |
function test()
print("hi")
end
r = string.dump(test)
print(string.len(r)) |
i just add some comments to outside of test function but somehow lenght of dumped code increases
how to fix
edit: i also tested on repl it and normal lua it works fine but in CE it gets whole code
_________________
hi |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Fri Aug 23, 2019 4:25 pm Post subject: |
|
|
string.dump does not only dump the single function like it implies. It's basically a snapshot of the Lua state at that time to ensure the function will work again when re-executed as a normal function. So everything in the current context of the state will be recorded to some degree (the func, upvals, params, etc.).
To give you an idea of what it does behind the scenes:
string.dump calls lua_dump.
lua_dump calls luaU_dump:
https://github.com/cheat-engine/cheat-engine/blob/master/Cheat%20Engine/lua53/lua53/src/ldump.c#L201
luaU_dump calls the functions above it to rebuild the byte code which includes a header of data containing information about the chunk.
The main thing here would be DumpFunction which handles dumping all of the needed information and extra data that may be required for things to work properly. There isn't anything "wrong" or to fix. This is just how Lua works.
Keep in mind as well, Lua in CE is 5.3 so data stored is going to be larger with the different structures of the newer version of Lua. If you are testing on something else (like you said repl) it may be a different/older version of Lua.
As an example, the same code you pasted is different in size between 5.1 and 5.3:
5.1: 115 bytes
5.3: 204 bytes
You'd have to manually edit Lua's dump functions if you want it to strip out other data (such as comments) if you absolutely need that option.
_________________
- Retired. |
|
| Back to top |
|
 |
exohaxor Expert Cheater
Reputation: 1
Joined: 02 Sep 2018 Posts: 101
|
Posted: Sat Aug 24, 2019 1:25 pm Post subject: |
|
|
so can i dump single function? is there a way?
_________________
hi |
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 472
Joined: 09 May 2003 Posts: 25875 Location: The netherlands
|
Posted: Sat Aug 24, 2019 2:45 pm Post subject: |
|
|
encodeFunction strips comments so you can use that
| Code: |
function test()
print("hi") --fjkldsffsdfdsfsddsfsdfsdfsdfsdfsdfsdfrfdsf
end
r = string.dump(decodeFunction(encodeFunction(test)))
print(string.len(r))
|
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
exohaxor Expert Cheater
Reputation: 1
Joined: 02 Sep 2018 Posts: 101
|
Posted: Sun Aug 25, 2019 4:42 am Post subject: |
|
|
k thanks exactly what i wanted
_________________
hi |
|
| Back to top |
|
 |
|