Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:AngelScript bytecode

From ReverseEngineering.wiki
Format
Magic none
Endianness byte-oriented variable-length integers
On this wiki Facts · Code · Notes · Topics

Module stream written by asIScriptModule::SaveByteCode: no magic and no version number, a variable-length integer stream starting with the strip-debug-info flag, then enums, class types, funcdefs, typedefs, globals, functions and used-entity tables.

Overview

SaveByteCode(asIBinaryStream*, stripDebugInfo) calls asCWriter::Write (source/as_restore.cpp). The stream has no signature or version field, so it is recognized only by context (a game calling LoadByteCode) and by readable strings.

Encoding

WriteEncodedInt64: one byte for values below 64 (bit 7 is the sign); otherwise the first byte's high bits give the length (01xxxxxx 2 bytes, 011xxxxx 3 bytes, 0111xxxx 4 bytes, 01111xxx 5 bytes, longer forms with more leading ones), the remaining bytes big-endian.

Strings: an encoded integer, then the bytes. Even value len*2 = new string of len bytes follows; odd value index*2+1 = reference to an earlier saved string.

Order of content

Parsed sequentially, no offset table:

  1. Encoded flag: 1 if debug info was stripped, else 0.
  2. Enum types, class and interface types (names), funcdefs.
  3. Interface methods, class methods and behaviours, class properties.
  4. Typedefs.
  5. Global properties (scriptGlobals), script functions, global functions.
  6. Bind (imported function) information with the module name to import from.
  7. Used types, used type ids, used functions, used global properties, used string constants, used object properties.

Function bytecode is a sequence of 32-bit words; opcodes are asBC_* (asBC_PopPtr = 0 up to asBC_MAXBYTECODE = 201 in 2.38, table in include/angelscript.h). Opcode numbers change between releases, so match the game's AngelScript version first.

Notes

Source read at the pinned commit, not tested on a real saved module.

Code & repositories

  • https://github.com/codecat/angelscript-mirror @ c81df254037524b18cd41a57805cfec76acd05bf · license: Zlib (declared by the contributor; GitHub's detector did not recognize a license file)
    Mirror of the AngelScript SDK (zlib). Useful without running: sdk/angelscript/source/as_restore.cpp (bytecode writer/reader), include/angelscript.h (API, asBC_ opcode table), as_scriptengine.cpp (version/options strings).
    Tested on: source read, not run: source read, not run · checked 2026-10-18; archived; last activity 2025-08-14

See also

Library:AngelScript.