chill1Penguin / l64decode

A Python script to decode Farming Simulator 2019 .l64 files to LuaJIT bytecode files.
MIT License
13 stars 7 forks source link

Unable to decode FS25 files #11

Open TAEMBO opened 2 weeks ago

TAEMBO commented 2 weeks ago

This script works fine to decode Farming Simulator 22 files, however Farming Simulator 25 seems to be using a different format - an error 'File "{filePath}" contains an invalid .l64 header.' is returned for any and all l64 files retrieved from FS25.

Here's a download link to one of the .l64 files in question: https://cdn.taembo.net/main.l64

4c65736975 commented 1 day ago

@Bizyak13 This script removes the first byte from .l64 files decompiled by L64Decoder, allowing decompilers like Unluau to recognize the bytecode version. It works for me, and using this method, I was able to successfully decompile 1,228 files out of 1,703 to plain Lua.

What version of Unluau are you using? I'm only getting 873 successfully converted files. any idea to why the other ones are failing?

@Mmtrx

v1.0.9alpha

monsieurbab commented 9 hours ago

Hello,

Has anyone really managed to decompile the files into LUA readable like it was on FS22?

I tried to follow the steps suggested in this issue but I can't get any usable LUA code.

And I get code like @Bizyak13:

; unluau disassembler version 2.0.0.0, elapsed: 0.03115s
FenceSegment.lua: Luau bytecode executable, version 3, hash: 0x39729da457cdcccec5afdbe3f81ca24b

function <FenceSegment.lua:28> (75 instructions, 384 bytes)
2 params, 8 slots, 0 upvalues, 22 constants
function registerXMLPaths(v1, v2) -- line 28 through 40
   1    LOADK               4 0
   ...
   96   RETURN              0 1

   constants (22)
      index  type     value
      0      string   "Fence"
      1      string   "setXMLSpecializationType"
      2      string   "XMLValueType"
      3      string   "ANGLE"
      4      import   ["XMLValueType","ANGLE"]
      5      string   "#maxVerticalAngle"
      6      string   ""
      7      string   "register"
      8      string   "FLOAT"
      9      import   ["XMLValueType","FLOAT"]
      10     string   "#price"
      11     string   "price per segment"
      12     string   "NODE_INDEX"
      13     import   ["XMLValueType","NODE_INDEX"]
      14     string   ".poles.pole(?)#node"
      15     string   ".poles.pole(?)#radius"
      16     string   ".poles.pole(?)#height"
      17     string   ".panels#maxScale"
      18     string   ".panels.panel(?)#node"
      19     string   ".panels.panel(?)#length"
      20     string   ".panels.panel(?)#width"
      21     string   ".panels.panel(?)#height"

   locals (2)
      index  name     startpc  endpc    type
      0      schema   0        96       
      1      basePath 0        96       
end
...

This is the only method that does not give errors. I tried also unluau 1.0.9alpha with l64Decoder v1.0.0.1 or l64Decoder v1.0.0.0 lua files. Also tried python script of @4c65736975 to remove first byte then unluau 1.0.9alpha or unluau 2.0.0beta but there's always errors at the luau decompiler step.

Is anyone have idea how to reconstruct the luau decompiler output? Thanks.

Bizyak13 commented 9 hours ago

@monsieurbab it is only partly possible as far as I know, since only the unluau-1.0.9alpha works, but has issues. Some OpCodes are not properly handled and there are some NREs. I'm trying to figure this out on my own but the progress is slow, since no one else is sharing their fixes, and I am not so familiar with C# and decompiling.