aussiemon / ljd Goto Github PK
View Code? Open in Web Editor NEWThis project forked from iroot/ljd
LuaJIT Raw-Bytecode Decompiler (LJD)
License: GNU General Public License v3.0
This project forked from iroot/ljd
LuaJIT Raw-Bytecode Decompiler (LJD)
License: GNU General Public License v3.0
Problematic place in the code:
Line 252 in 1c4e1a2
Test code:
_remove_invalid_references()
if (len(info.references) != 2):
for ref in info.references:
print("ID:", ref.identifier.id)
assert len(info.references) == 2
Output:
ID: 861
ID: 861
ID: 883
ID: 883
File "\ljd\ast\slotworks.py", line 252, in _fill_massive_refs
assert len(info.references) == 2
AssertionError
Solution: in array info.references
all duplicates should be removed.
The devel branch of znix's fork contains important fixes, you should probably merge it too.
(https://gitlab.com/znixian/luajit-decompiler/-/tree/devel)
luac64 File operation with this suffix failed
Unknown prototype flags: 11100000
Failed to read prototype
I upload the file here
app_ui_bag_BagLayer.zip
Lua tables can have an empty trailing comma. Consider "without" vs "with" trailing comma:
mytable = {
1,
2
}
mytable = {
1,
2,
}
Now if the next version added the element "3" and you compared the diff, then the "without" version will have 2 changed lines (remove & add) whereas the "with" version will only have one line diff (add three).
Even in my own code I usually add the trailing comma to not forget it later on when extending a table. Since the decompiler output is used mostly in a read-only fashion, I suggest it to be added at all times.
Following code fails for some files (state.debuginfo.addr_to_line_map
is empty, so index our of bounds exception is thrown):
Line 1265 in 2ed0381
My workaround was
line_mapping = -1
if preceding_index >= 0 and preceding_index < len(state.debuginfo.addr_to_line_map):
line_mapping = state.debuginfo.addr_to_line_map[preceding_index]
Not sure if it's a good or bad fix, but it does work.
Original Lua string constants may contain "unusual" characters, and when such a string is encountered, ljd stops writing more Lua. I am not very familiar with the differences between string encodings, so I can't be more specific about what characters cause this. This is what I did to work around the issue:
I changed value
to value.encode('ascii', 'replace').decode()
in the following two lines:
https://github.com/Aussiemon/ljd/blob/2ed0381b2e563531b0fe8de0a574cea8e6a04478/ljd/ast/builder.py#LL928C27-L928C27
https://github.com/Aussiemon/ljd/blob/2ed0381b2e563531b0fe8de0a574cea8e6a04478/ljd/ast/builder.py#LL1030C12-L1030C12
This replaces any problematic characters with ?
so information is lost. I am not sure what the real fix would look like that does not lose this information.
To put it simply, is there a way to replace an AST node by an unrelated one (possibly constructed on the fly during traversal)? For example, flattening loadstring("...")("...")
https://github.com/Aussiemon/ljd/blame/2ed0381b2e563531b0fe8de0a574cea8e6a04478/ljd/ast/helpers.py#L92
why the check for function depth and up value needed?
local T = {
a = 1,
}
T.self_val = T
would be squashed to
local T = {
a = 1,
self_val = T
}
in function depth 0 (main file execution)
Traceback (most recent call last):
File "main.py", line 476, in <module>
retval = main_obj.main()
File "main.py", line 301, in main
ast = self.decompile(self.options.file_name)
File "main.py", line 411, in decompile
ljd.ast.unwarper.unwarp(ast, False)
File "/tools/ljd/ljd/ast/unwarper.py", line 94, in unwarp
_run_step(_unwarp_ifs, node)
File "/tools/ljd/ljd/ast/unwarper.py", line 137, in _run_step
statements.contents = step(statements.contents, **kargs)
File "/tools/ljd/ljd/ast/unwarper.py", line 392, in _unwarp_ifs
_unwarp_if_statement(start, body, end, end)
File "/tools/ljd/ljd/ast/unwarper.py", line 1704, in _unwarp_if_statement
else_blocks = _unwarp_ifs(else_body, else_body[-1], topmost_end)
File "/tools/ljd/ljd/ast/unwarper.py", line 392, in _unwarp_ifs
_unwarp_if_statement(start, body, end, end)
File "/tools/ljd/ljd/ast/unwarper.py", line 1704, in _unwarp_if_statement
else_blocks = _unwarp_ifs(else_body, else_body[-1], topmost_end)
File "/tools/ljd/ljd/ast/unwarper.py", line 392, in _unwarp_ifs
_unwarp_if_statement(start, body, end, end)
File "/tools/ljd/ljd/ast/unwarper.py", line 1704, in _unwarp_if_statement
else_blocks = _unwarp_ifs(else_body, else_body[-1], topmost_end)
File "/tools/ljd/ljd/ast/unwarper.py", line 392, in _unwarp_ifs
_unwarp_if_statement(start, body, end, end)
File "/tools/ljd/ljd/ast/unwarper.py", line 1700, in _unwarp_if_statement
then_blocks = _unwarp_ifs(then_body, then_body[-1], topmost_end)
File "/tools/ljd/ljd/ast/unwarper.py", line 392, in _unwarp_ifs
_unwarp_if_statement(start, body, end, end)
File "/tools/ljd/ljd/ast/unwarper.py", line 1728, in _unwarp_if_statement
then_blocks = _unwarp_ifs(body, body[-1], topmost_end)
File "/tools/ljd/ljd/ast/unwarper.py", line 392, in _unwarp_ifs
_unwarp_if_statement(start, body, end, end)
File "/tools/ljd/ljd/ast/unwarper.py", line 1669, in _unwarp_if_statement
topmost_end)
File "/tools/ljd/ljd/ast/unwarper.py", line 1766, in _extract_if_expression
assert false is not None
AssertionError
this is file zip
1 (2).zip
issuse2
There is one more question. It's during decompilation. There will be many uv0 that cannot obtain its actual function
hello i tried to convert luajt languages to lua but show this error in cmd with administator mode why?
python "C:\luajit\main.py" "C:\luajit\AISowingCultivatorFix.lua" "C:\luajit\lua\AISowingCultivatorFix.lua"
Usage: main.py [options]
main.py: error: Too many arguments.
Hello,I tried to decompile luajit, but the following error occurred:
Traceback (most recent call last):
File "main.py", line 468, in
retval = main_obj.main()
File "main.py", line 299, in main
ast = self.decompile(self.options.file_name)
File "main.py", line 403, in decompile
ljd.ast.unwarper.unwarp(ast, False)
File "C:\Users\xxx\Desktop\ljd-2021_revision\ljd\ast\unwarper.py", line 51, in unwarp
_run_step(_fix_loops, node, repeat_until=False)
File "C:\Users\xxx\Desktop\ljd-2021_revision\ljd\ast\unwarper.py", line 137, in _run_step
statements.contents = step(statements.contents, **kargs)
File "C:\Users\xxx\Desktop\ljd-2021_revision\ljd\ast\unwarper.py", line 1794, in _fix_loops
blocks = _handle_single_loop(start, end, blocks, repeat_until)
File "C:\Users\xxx\Desktop\ljd-2021_revision\ljd\ast\unwarper.py", line 1870, in _handle_single_loop
loop = _unwarp_loop(start, end, body)
File "C:\Users\xxx\Desktop\ljd-2021_revision\ljd\ast\unwarper.py", line 2070, in _unwarp_loop
expression = expr_body + body[:i]
TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.