Bundle 2/Need for Speed Most Wanted

From Burnout Wiki

Need for Speed Most Wanted uses version 5 of the Bundle format, adding support for streams and updating certain fields and enumerations.

Memory types

Separate data chunks are used to define what memory type resources are loaded into. These chunks are platform specific (see EMemoryType). Keep these in mind when viewing the structures.

Structures

CgsResource::BundleV2

Offset Length Type Name Description Comments
0x0 0x4 char[4] macMagicNumber Bundle magic bnd2
0x4 0x2 uint16_t muVersion Bundle version 5
0x6 0x2 uint16_t muPlatform Platform the bundle is built for See Platform
0x8 0x4 uint32_t muDebugDataOffset Bundle debug data offset ResourceStringTable XML
0xC 0x4 uint32_t muResourceEntriesCount Number of resources in the bundle
0x10 0x4 uint32_t muResourceEntriesOffset Resource entries offset
0x14 0x10 uint32_t[4] mauResourceDataOffset Per-memory type resource data offsets
0x24 0x4 uint32_t muFlags Bundle flags See eBundleFlags
0x28 0x8 ID mDefaultResourceId Default resource to access
0x30 0x4 int32_t miDefaultResourceStreamIndex Stream index of the default resource
0x34 0x3C char[4][15] macStreamName Names of the streams contained in the bundle

CgsResource::BundleV2::ResourceEntry

Entries are sorted sequentially by, from highest to lowest level:

  1. Stream offset
  2. Index from ID (if Game Changer)
  3. Resource type from ID (if Game Changer)
  4. ID type
  5. Resource ID (lower 32 bits)
Offset Length Type Name Description Comments
0x0 0x8 ID mResourceId Resource ID
0x8 0x10 uint32_t[4] mauUncompressedSizeAndAlignment Per-memory type resource sizes Has high nibble for alignment; changes between platforms
1 << [nibble] equals the memory alignment value
0x18 0x10 uint32_t[4] mauSizeAndAlignmentOnDisk Per-memory type compressed resource sizes
0x28 0x10 uint32_t[4] mauDiskOffset Per-memory type resource offsets Relative to the start of the respective memory type's data offset
0x38 0x4 uint32_t muImportOffset Imports offset
0x3C 0x4 uint32_t muResourceTypeId Resource type See resource types
0x40 0x2 uint16_t muImportCount Number of imports
0x42 0x1 uint8_t muFlags Resource flags Unused?
0x43 0x1 uint8_t muStreamOffset Stream index Per-bundle. Refer to macStreamName
0x44 0x4 Padding

CgsResource::BundleV2::ImportEntry

Import entries are appended to the resource data.

Offset Length Type Name Description Comments
0x0 0x8 ID mResourceId Imported resource ID
0x8 0x4 uint32_t muImportTypeAndOffset Offset of the pointer to be set at runtime See import type
0xC 0x4 Padding

CgsResource::ID

Offset Length Type Name Description Comments
0x0 0x8 CHash mHash Resource ID ID type stored in highest 8 bits, ID in lowest 32 bits. See ID type

Game Changer ID

This is a specific type of ID which is not an explicitly defined structure, but stores extra information in the high bits of the ID.

Offset Length Type Name Description Comments
0x0 0x1 EIdType ID type See ID type
0x1 0x1 uint8_t Index
0x2 0x2 uint16_t Resource type ID See resource types
Does not always match the entry's muResourceTypeId field
0x4 0x4 uint32_t Resource ID/Game changer ID ID tracked by the game database. See UniqueId

Typedefs

CgsResource::ID::CHash

Name Type Length Comments
CHash uint64_t 0x8

Enumerations

Platform

Name Value Comments
KU_BUNDLE_PLATFORM_PC 1 PC
KU_BUNDLE_PLATFORM_PS3 2 PlayStation 3
KU_BUNDLE_PLATFORM_X360 3 Xbox 360
? 4 PlayStation Vita
? 5 Wii U

CgsResource::BundleV2::eBundleFlags

Name Value Comments
E_FLAGS_DEFAULT 0x0
E_FLAGS_ZLIB_COMPRESSION 0x1 Resources are compressed using zlib
E_FLAGS_CONTAINS_DEBUG_DATA 0x2 Resource string table XML data is present
E_FLAGS_NON_ASYNCH_FIXUP_REQUIRED 0x4
E_FLAGS_MULTISTREAM_BUNDLE 0x8 More than one stream is used
E_FLAGS_DELTA_BUNDLE 0x10 Contains additions to a base bundle
E_FLAGS_CONTAINS_DEFAULT_RESOURCE 0x20 A default resource ID is specified in mDefaultResourceId

CgsResource::BundleV2::eImportType

Name Value Comments
E_IMPORT_TYPE_POINTER 0
E_IMPORT_TYPE_RESOURCE_HANDLE 1

CgsResource::ID::EIdType

Name Value Comments
E_ID_TYPE_NORMAL 0x0 Lowercase resource name CRC32 hash
E_ID_TYPE_GAMECHANGER 0x1 See Game Changer ID
E_ID_TYPE_RESOURCE_LIST 0x80
E_ID_TYPE_DELTA_BUNDLE 0xC0 Additions to a base resource

EMemoryType

PlayStation 3, PlayStation Vita

Name Value Comments
E_MEMTYPE_MAIN 0
E_MEMTYPE_GRAPHICS_SYSTEM 1
E_MEMTYPE_GRAPHICS_LOCAL 2
E_MEMTYPE_DISPOSABLE 3
E_MEMTYPE_NUMTYPES 4

Xbox 360

Name Value Comments
E_MEMTYPE_MAIN 0
E_MEMTYPE_PHYSICAL? 1 PHYSICAL
E_MEMTYPE_DISPOSABLE 2
? 3 DUMMY
E_MEMTYPE_NUMTYPES 4

PC

Name Value Comments
E_MEMTYPE_MAIN 0
E_MEMTYPE_DISPOSABLE 1
? 2 DUMMY
? 3 DUMMY
E_MEMTYPE_NUMTYPES 4

Wii U

Name Value Comments
E_MEMTYPE_MAIN 0
? 1 MEM1
? 2 GRAPHICS_MEM2
E_MEMTYPE_DISPOSABLE 3
E_MEMTYPE_NUMTYPES 4