从 string.dump 返回值中删除源块

发布于 2024-11-29 17:43:23 字数 446 浏览 0 评论 0原文

我正在尝试制作一个闭源lua文件,为此,我冒着没有人会花很长时间转换(是否是某种形式的程序集)任何 string.dump 的风险返回。

但是, string.dump 还返回了一块字符串,其中包含其转储的代码的完整源代码。无论我做什么,我似乎都无法制作一个自动源代码删除器来从返回的字符串中删除源代码-它似乎没有按原样传递,我不知道它是否会删除我的缩进、新行、空格,或者在某些条件下删除一些内容或什么。

所以基本上;说我有

local a = string.dump(function() print("Hello world") end)

一个类似的东西:

LuaQ(源)(我想保留的东西让它工作)

但是我想删除源块,但是即使我传递相同的内容,string.find也不会找到它源码进去找。

如果我有任何不清楚的地方,请说。

I'm trying to make a closed-source lua file, and to do so, I'm taking the risk that noone in their right mind is going to take a long time converting (Is it some form of assembly) whatever string.dump returns.

However, string.dump also has a chunk of the string returned with the full source of the code dumped by it. No matter what I do, I can't seem to make an automatic source-code deleter that deletes the source from the returned string- It doesn't seem to be passed as-is, I don't know whether it removes my indenting, new lines, spaces, or it removes some under certain conditions or what.

So basically; say I had

local a = string.dump(function() print("Hello world") end)

a would be something like:

LuaQ (source) (the stuff I want to keep that makes it work I guess)

But I want to remove the source chunk, but string.find won't locate it even when I pass identical source in to find.

If I was unclear anywhere, please say.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

最终幸福 2024-12-06 17:43:23

看一下LuaC的源码。我相信您看到的只是调试信息,LuaC 可以选择从生成的字节码中删除调试信息。您可能会看一下它是如何做到这一点的。

也就是说,字符串文字在程序的字节码中始终可见,因为 Lua 将它们作为纯文本存储在字节码中。

Take a look at the source of LuaC. I believe what you are seeing are just debugging informations, and LuaC has the option to strip debugging info out of a generated bytecode. You might take a look at how it does that.

That said, the string literals will always be visible in the bytecode of your program since Lua stores them as plain text in the bytecode.

何时共饮酒 2024-12-06 17:43:23

a=string.dump(function() print("Hello world") end) 之后,a 确实包含功能。它确实包含函数中的字符串。尽管。但是,您可能正在使用 loadstring 并且默认情况下会添加完整的字符串作为块的名称。尝试使用 loadstring(source,"=") 代替。

After a=string.dump(function() print("Hello world") end), a does not contain the source code for the function. It does contain the string in the function. though. However, you're probably using loadstring and the by default does add the complete strings as the name of the chunk. Try loadstring(source,"=") instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文