0

I am trying to convert a script to binary representation using string.dump, but I saw that the luaj 3.0.1 representation is different from lua 5.2, has some way of changing this, or turns the luaj 3.0.1 representation into lua 5.2 ?

Code

Globals _G = JsePlatform.standardGlobals();
LuaValue Function = _G.load("return string.dump(function() return 'Test' end),true);");
String Return = Function.call().toString();

Output in Hex

1B 4C 75 61 52 0 0 4 4 4 8 0 19 93 D A 1A A 0 0 0 1 0 0 0 1 0 0 2 0 0 0 3 0 0 0 1 1 0 0 1F 0 80 0 1F 0 0 0 1 4 0 0 0 5 54 65 73 74 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Egor Skriptunoff
  • 23,359
  • 2
  • 34
  • 64
Idle
  • 1
  • 1
  • Please upload binary representation generated by luaj – Egor Skriptunoff Oct 17 '19 at 09:10
  • Done, i upload. – Idle Oct 17 '19 at 09:29
  • 1
    This is a correct Lua 5.2 bytecode for 32-bit big-endian CPU. You can use [this tool](https://lua-bytecode.github.io/) to convert a Lua bytecode to another platform (select `L4808` for converting to x64). – Egor Skriptunoff Oct 17 '19 at 11:37
  • How i select L4808 Sorry, i'm is new in luaj – Idle Oct 17 '19 at 15:54
  • `bytecode_x64 = require"lua-bytecode"(string.dump(your_function), "L4808")`, the module is [here](https://github.com/lua-bytecode/lua-bytecode.github.io/blob/master/lua-bytecode.lua) – Egor Skriptunoff Oct 17 '19 at 16:08
  • Man, I'm sorry, I saw it here and the problem is saving, for some reason when I write a file in java it is nullifying the null bytes, I'm sorry for bothering you so much – Idle Oct 18 '19 at 00:50
  • The problem "How Java could save a binary file containing zero bytes" deserves separate SO question. It is not luaj-specific. – Egor Skriptunoff Oct 18 '19 at 02:57

0 Answers0