Need help decompiling .beam file

To get the source I created a base mix project:

mix new myproject

In mix.exs deps() function I added this dependency:

{:decompilerl, github: "niahoo/decompilerl"}

Then I renamed your beam file to holiday_role_data.beam (removed the “4”) because the module inside is holiday_role_data and must match the file name.

The beam file is in the root of the project directory.

Then I created a tt.exs file with this content:

Code.append_path(File.cwd!())
Decompilerl.decompile(:holiday_role_data)
System.halt()

And then run this file with mix run tt.exs > holiday_role_data.erl

Note that you must then edit the file to remove the text “Retrieving code for holiday_role_data”.

It may be possible to have better results with GitHub - michalmuskala/decompile because it can generate elixir source instead of erlang. But I don’t know it as much as decompilerl.

1 Like