Skip to content

ActualMasterOogway/Iridium

Repository files navigation

Iridium - Luau Bytecode Deserializer

Iridium is a Luau bytecode deserializer and disassembler written in Luau. It takes compiled bytecode and gives you back the protos, instructions, constants, and type info as plain Luau values you can read directly.

Description

Iridium parses Luau bytecode versions 3 through 9, including Roblox-flavoured blobs with their MAC-envelope trailer. You get structured access to the proto tree, constant pools, the instruction stream (operands and AUX words included), and the type-info section. Use it for reverse engineering, compiler work, or any tool that needs to read bytecode below the source level.

Features

  • Bytecode Parsing

    • Support for Luau bytecode versions 3-9
    • Typed bytecode support (typesversion 1-3)
    • Encoding-key recovery for opcode-shuffled bytecode
    • Roblox bytecode envelope detection (v0 and v1 trailer formats)
  • Function Analysis

    • Function prototype extraction
    • Stack size information
    • Parameter count detection
    • Upvalue tracking
    • Vararg function detection
    • Native-compilation flag inspection
  • Instruction Decoding

    • Complete instruction set support
    • Opcode identification
    • Operand extraction (A/B/C/D/E, signed where appropriate)
    • AUX-word handling and instruction flow analysis
    • Lazy decoding via a packed Instructions container
  • Constant Pool Management

    • Nil constants
    • Boolean constants
    • Number constants
    • String constants
    • Import constants
    • Table constants
    • Closure constants
    • Vector constants
    • TableWithConstants constants
    • Integer constants
  • Type System

    • Type version detection
    • Userdata type mapping
    • Type flags parsing
    • Type data parsing
      • Version 1
      • Version 2
      • Version 3
  • Debug Info

    • Line information
    • Local-variable scopes
    • Debug names
  • Utility Functions

    • String reference resolution
    • Type mapping utilities
    • Hexadecimal conversion

Usage

local Iridium, Types = require("Iridium"), require("Iridium/Types")

-- Deserialize bytecode from a string, buffer, or BufferReader
local deserialized = Iridium:Deserialize(bytecodeData)

-- Access function information
local mainFunction = deserialized.Protos[deserialized.ProtoEntryPoint]

-- Inspect instructions (Instructions implements __iter / __index / __len,
-- so iteration and indexing work like a 1-indexed array)
for pc, instruction in mainFunction.Instructions do
    print(pc, instruction.OpCodeInfo.Name, instruction.A, instruction.B, instruction.C)
end

-- Access constants
for i, constant in mainFunction.Constants do
    print(constant.__type, constant)
end

-- Roblox bytecode envelope (when present)
if deserialized.HasRobloxEnvelope then
    print("Roblox trailer v" .. deserialized.RobloxTrailerVersion)
end

For advanced usage I'd suggest checking this example out

Building from Source

Click here.

Contributing

Contributions are welcome! Feel free to submit issues or pull requests to help improve Iridium.

Authors

  • ActualMasterOogway - Creator and main developer

Acknowledgements

  • atrexus - Unluau was a really helpful resource
  • lovre - Platinum helped me find where I was underreading/overreading
  • GRH - Helped me reading line information correctly ❤