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:NRBF (.NET BinaryFormatter stream)

From ReverseEngineering.wiki
Format
Vendor Microsoft
Magic 00 (record type 0, SerializedStreamHeader)
Extensions .sav, .dat, .bin (game specific)
Endianness little-endian
On this wiki Facts · Code · Notes · Topics

The MS-NRBF Remoting Binary Format written by .NET's BinaryFormatter, still used by many Unity and other .NET games for save files: a stream of records, each starting with a one-byte record type, the first being the SerializationHeaderRecord (type 0) and the last MessageEnd (type 11).

Overview

Specified in [MS-NRBF] (Microsoft Open Specifications). A BinaryFormatter file has no text magic: it starts with record type byte 00 (SerializedStreamHeader), then RootId i32, HeaderId i32, MajorVersion i32 (must be 1) and MinorVersion i32 (must be 0). The header is 17 bytes. Checked (dotnet/runtime System.Formats.Nrbf at 66368e9db028, SerializedStreamHeaderRecord.cs and NrbfDecoder.cs): RootId is any non-zero value, HeaderId is ignored by the reader, MajorVersion must be 1 and MinorVersion 0, so bytes 9-16 are always 01 00 00 00 00 00 00 00; that is what the decoder's StartsWithPayloadHeader tests. Typical BinaryFormatter files have RootId 1 and HeaderId -1: 00 01 00 00 00 FF FF FF FF 01 00 00 00 00 00 00 00. The stream ends with 0B (MessageEnd). Unity games commonly produced such files with BinaryFormatter and a [Serializable] save class; class and assembly names are stored in the clear.

Record types

RecordTypeEnumeration (one byte): 0 SerializedStreamHeader, 1 ClassWithId, 2 SystemClassWithMembers, 3 ClassWithMembers, 4 SystemClassWithMembersAndTypes, 5 ClassWithMembersAndTypes, 6 BinaryObjectString, 7 BinaryArray, 8 MemberPrimitiveTyped, 9 MemberReference, 10 ObjectNull, 11 MessageEnd, 12 BinaryLibrary, 13 ObjectNullMultiple256, 14 ObjectNullMultiple, 15 ArraySinglePrimitive, 16 ArraySingleObject, 17 ArraySingleString, 21 MethodCall, 22 MethodReturn.

PrimitiveTypeEnumeration: 1 Boolean, 2 Byte, 3 Char, 5 Decimal, 6 Double, 7 Int16, 8 Int32, 9 Int64, 10 SByte, 11 Single, 12 TimeSpan, 13 DateTime, 14 UInt16, 15 UInt32, 16 UInt64, 17 Null, 18 String (4 is unused).

Reading

Checked (System.Formats.Nrbf BinaryReaderExtensions.cs): strings are LengthPrefixedString, read with .NET BinaryReader.ReadString (a 7-bit encoded length, then UTF-8 bytes); the decoder does not enforce the shortest length encoding, and a Decimal is stored as such a string, parsed with the invariant culture. Unverified: the layout of the class records, from general knowledge of the spec: a class record gives an object id, the class name, the member count and member names; the "AndTypes" variants then list a BinaryType per member and additional info, and a BinaryLibrary record (12) names the assembly. Member values follow in declaration order; repeated objects are MemberReference records pointing to an object id.

For reversers

  • Strings such as Version=1.0.0.0, Culture=neutral, PublicKeyToken=null and the game's assembly name near the start identify the stream and the save class; decompile that class (Format:.NET metadata (ECMA-335)) to understand the members.
  • Unverified: .NET deprecates BinaryFormatter because deserializing untrusted data is unsafe; do not feed untrusted saves to a game's loader outside a sandbox.
  • NRBF has no overall length or checksum field, so editing a value in place only needs string length prefixes to stay consistent.

See also Technique:Reverse engineering game save files, Library:Unity/PlayerPrefs.

Code & repositories

  • https://github.com/dotnet/runtime @ 66368e9db028ee74da106612a72534c2d58e3a6f · license: MIT (declared by the contributor for the files used; GitHub reports MIT (read from LICENSE.TXT; GitHub's API was busy) for the repository)
    src/libraries/System.Formats.Nrbf is a managed reader of NRBF payloads (record types, primitive types, header check).
    Tested on: source read, not run · checked 2026-10-19