The BEAM includes tooling to do part of this, :beam_disasm
.
{:ok, {{_, 200, _}, headers, body_charlist}} = :httpc.request('https://github.com/granados12/decompile/blob/main/holiday_role_data4.beam?raw=true')
body = :binary.list_to_bin(body_charlist)
:beam_disasm.file(body)
This produces output like (you’ll want to make sure to use IO.inspect(limit: :infinity)
to prevent cutting off terms):
{:beam_file, :holiday_role_data,
[
{:all_son, 0, 12},
{:all_son2, 0, 14},
{:bid_son, 1, 21},
{:get, 1, 853},
{:get_const, 1, 1259},
{:get_open, 1, 59},
{:list_open_son, 1, 4},
{:list_open_total, 0, 2},
{:list_son, 1, 16},
{:list_total, 0, 10},
{:main_ico, 1, 1257},
{:module_info, 0, 1265},
{:module_info, 1, 1267},
{:open_ico, 1, 1255}
],
[
lager_records: [
condition: [:label, :op, :val, :msg],
holiday: [:camp_id, :total_id, :bid, :tbid, :cli_type, :cli_type_name, :start_time, :end_time,
:condition, :type, :title, :title2, :main_ico, :ico, :type_ico, :top_banner, :rule_str,
:time_str, :bottom_alert, :sort_val, :reward_title, :aim_title, :reward, :item_effect,
:mail_subject, :mail_content, :cli_reward, :panel_type, :open_day, :open_day_min,
:open_day_max, :merge_day, :process_show_reward, :platform_id, :platform_exclude_id,
:hide_srv_ids, :channel_ban],
holiday_total: [:id, :name, :icon_id, :start_time, :end_time, :status, :open_day, :merge_day,
:is_show, :type]
],
vsn: [320956466309601905319104183717896391347]
],
[
options: [
:error_summary,
{:hipe, [:o3]},
:debug_info,
{:i, 'inc'},
{:outdir, 'ebin'},
{:parse_transform, :lager_transform},
{:d, :disable_auth},
{:d, :enable_gm_cmd},
{:d, :debug},
{:d, :data_debug}
],
version: '7.0.4',
source: '/elora/server/src/data/holiday_role_data.erl'
],
[
{:function, :list_open_total, 0, 2,
[
{:label, 1},
{:line, 1},
{:func_info, {:atom, :holiday_role_data}, {:atom, :list_open_total}, 0},
{:label, 2},
{:allocate_zero, 1, 0},
{:move, {:literal, "HĐ Gộp SV"}, {:x, 0}},
{:line, 2},
{:call_ext, 1, {:extfunc, :lang, :get, 1}},
{:move, {:x, 0}, {:y, 0}},
{:move, {:literal, "HĐ Mở SV"}, {:x, 0}},
{:line, 3},
{:call_ext, 1, {:extfunc, :lang, :get, 1}},
{:test_heap, 28, 1},
{:put_tuple, 11, {:x, 1}},
{:put, {:atom, :holiday_total}},
{:put, {:integer, 103}},
{:put, {:x, 0}},
{:put, {:integer, 0}},
{:put, {:literal, {:open_day, 1}}},
{:put, {:literal, {:open_day, 56, 86399}}},
{:put, {:integer, 1}},
{:put, {:integer, 0}},
{:put, {:integer, 0}},
{:put, {:integer, 1}},
{:put, {:integer, 1}},
{:put_list, {:x, 1}, nil, {:x, 1}},
{:put_tuple, 11, {:x, 2}},
{:put, {:atom, :holiday_total}},
{:put, {:integer, 104}},
{:put, {:y, 0}},
{:put, {:integer, 0}},
{:put, {:literal, {:merge_day, 1}}},
As for editing this BEAM file, that’s not something that’s normally done - BEAM files are written by the compiler so if you want to change them you change the Erlang etc code and recompile. According to the metadata in that file, that’s in src/data/holiday_role_data.erl
.