pcc

package module
v0.0.0-...-b4bb484 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 7 Imported by: 0

README

me2pcc

Go library for reading Mass Effect 2 OT PCC (package) files.

Part of the pcc-toolkit project.

Installation

go get github.com/commander-spaceman/me2pcc

Usage

import pcc "github.com/commander-spaceman/me2pcc"

// Read a PCC file fully
summary, err := pcc.ReadFile("BioD_CitHub.pcc")

// Read with raw decompressed bytes
rawData, summary, err := pcc.ReadFileRaw("BioD_CitHub.pcc")

// Parse properties from an export
props, _ := pcc.ParsePropertyCollection(rawData, summary.Names, export.SerialOffset, export.SerialSize)

API

File reading
Function Description
ReadFile(path) Read and parse a PCC file
ReadFileHeaderOnly(path) Parse only the header and game profile
ReadFileRaw(path) Read, decompress, parse, return raw bytes
ReadFileExports(path, predicate) Read and filter exports by predicate
ReadFileFromBytes(data, path) Parse from in-memory bytes
ReadFileFromBytesAndExports(data, path, predicate) Parse and filter exports from bytes
Property parsing
Function Description
ParsePropertyTags(data, names, offset, size, strict) Parse property name/type/size tags
ParsePropertyCollection(data, names, offset, size) Parse property values into a map
ParseStructArrayItemsAsPropertyCollections(...) Parse array of structs into property collections
ComputeExportProperties(rawData, summary, tags, semantic) Compute properties for all exports
ExtractBioConversationKeyProperties(...) Extract BioConversation key array properties
Utility
Function Description
ReadRawI32(data, offset) Read a little-endian int32
ResolveName(data, offset, names) Resolve a name table index
MapOffsetsToContainers(exports, offsets, dataLen) Map byte offsets to containing exports
InferGameProfile(uv, lv) Infer game profile from version numbers

Types

Type Description
FileSummary Parsed PCC file with header, names, imports, exports
Header PCC header fields
Export Export table entry
Import Import table entry
PropertyTag Parsed property tag (name, type, size, offset)
ParsedProperty Decoded property value
ContainerHit Byte offset mapped to owning export
GameProfile Game profile enum (me2_ot, le2, me3_ot, le3)

License

MIT

Documentation

Index

Constants

View Source
const ChunkBlockHeaderSize = 8
View Source
const ChunkHeaderMagic = 0x9E2A83C1
View Source
const ChunkHeaderSize = 16
View Source
const CompressedFlag = 0x02000000
View Source
const CompressionLZO = 0x2
View Source
const MaxBlockSizeOT = 0x20000
View Source
const PackageMagic = 0x9E2A83C1

Variables

View Source
var PropertyTypeNames = map[string]bool{
	"ArrayProperty":     true,
	"BoolProperty":      true,
	"ByteProperty":      true,
	"ClassProperty":     true,
	"ComponentProperty": true,
	"DelegateProperty":  true,
	"FloatProperty":     true,
	"InterfaceProperty": true,
	"IntProperty":       true,
	"MapProperty":       true,
	"NameProperty":      true,
	"ObjectProperty":    true,
	"StrProperty":       true,
	"StringRefProperty": true,
	"StructProperty":    true,
}

Functions

func ComputeExportProperties

func ComputeExportProperties(rawData []byte, summary *FileSummary, includeTags, includeSemantic bool) map[int]ExportProperties

func FindExtraPropertyTags

func FindExtraPropertyTags(data []byte, names []string, serialOffset, serialSize int, wantedNames []string) map[string]PropertyTag

func FindInt32ArrayByName

func FindInt32ArrayByName(data []byte, names []string, start, end int, propName string) []int

FindInt32ArrayByName scans raw bytes in range [start, end) for an ArrayProperty<IntProperty> with the given property name. Returns the int32 element values.

func FindIntPropertyByName

func FindIntPropertyByName(data []byte, names []string, start, end int, propName string) (int, bool)

FindIntPropertyByName scans raw bytes in range [start, end) for a scalar int-like property with the given name and returns its value.

func FindStructArrayItemStarts

func FindStructArrayItemStarts(data []byte, names []string, start, end int, propName string) (int, int, int)

FindStructArrayItemStarts scans raw bytes for an ArrayProperty<StructProperty> and returns the absolute payload start, item count, and stride hint. Returns (-1, 0, 0) if not found.

func HasStructSignature

func HasStructSignature(data []byte, names []string, payloadOffset, payloadSize int) bool

func ParsePropertyCollection

func ParsePropertyCollection(data []byte, names []string, startOffset, maxSize int) (map[string]ParsedProperty, int)

func ParsePropertyHeader

func ParsePropertyHeader(data []byte, names []string, cursor, end int) (string, string, int, int, int, int)

func ParseStructArrayItemsAsPropertyCollections

func ParseStructArrayItemsAsPropertyCollections(
	data []byte, names []string, payloadOffset, payloadSize, count int,
) []map[string]ParsedProperty

func ReadArrayPropertyCount

func ReadArrayPropertyCount(data []byte, tag PropertyTag) int

func ReadArrayPropertyI32Rows

func ReadArrayPropertyI32Rows(data []byte, tag PropertyTag, itemWidth int) [][]int

func ReadArrayPropertyI32Values

func ReadArrayPropertyI32Values(data []byte, tag PropertyTag) []int

func ReadArrayPropertyObjectValues

func ReadArrayPropertyObjectValues(data []byte, tag PropertyTag) []int

func ReadArrayPropertyPayloadInfo

func ReadArrayPropertyPayloadInfo(data []byte, tag PropertyTag) (int, int, int)

func ReadArrayPropertyPayloadInfoWithStructMeta

func ReadArrayPropertyPayloadInfoWithStructMeta(data []byte, names []string, tag PropertyTag) (int, int, int)

func ReadArrayPropertyStructHeadI32

func ReadArrayPropertyStructHeadI32(data []byte, tag PropertyTag, headI32 int) [][]int

func ReadArrayPropertyStructI32Matrix

func ReadArrayPropertyStructI32Matrix(data []byte, tag PropertyTag) [][]int

func ReadObjectPropertyValue

func ReadObjectPropertyValue(data []byte, tag PropertyTag) int

func ReadRawI32

func ReadRawI32(data []byte, offset int) int

func ResolveName

func ResolveName(data []byte, offset int, names []string) string

Types

type ArrayLayoutInfo

type ArrayLayoutInfo struct {
	Count        int  `json:"count"`
	PayloadSize  int  `json:"payload_size"`
	BytesPerItem *int `json:"bytes_per_item,omitempty"`
	Remainder    int  `json:"remainder"`
	IsTightI32   bool `json:"is_tight_i32"`
}

func AnalyzeArrayPropertyLayout

func AnalyzeArrayPropertyLayout(data []byte, tag PropertyTag) ArrayLayoutInfo

type ContainerHit

type ContainerHit struct {
	StrRef         int    `json:"strref"`
	AbsoluteOffset int    `json:"absolute_offset"`
	LocalOffset    int    `json:"local_offset"`
	ExportIndex    int    `json:"export_index"`
	ExportName     string `json:"export_name,omitempty"`
	ClassName      string `json:"class_name,omitempty"`
	SerialOffset   int    `json:"serial_offset"`
	SerialSize     int    `json:"serial_size"`
}

func MapOffsetsToContainers

func MapOffsetsToContainers(exports []Export, offsets map[int][]int, dataLen int) []ContainerHit

type Export

type Export struct {
	Index           int    `json:"index"`
	ClassIndex      int    `json:"class_index"`
	ObjectNameIndex int    `json:"object_name_index"`
	SerialSize      int    `json:"serial_size"`
	SerialOffset    int    `json:"serial_offset"`
	ObjectName      string `json:"object_name,omitempty"`
	ClassName       string `json:"class_name,omitempty"`
}

type ExportDetail

type ExportDetail struct {
	Export     Export `json:"export"`
	SerialData string `json:"serial_data,omitempty"`
}

type ExportProperties

type ExportProperties struct {
	Tags          []PropertyTag             `json:"property_tags,omitempty"`
	SemanticProps map[string]ParsedProperty `json:"semantic_props,omitempty"`
}

type FileSummary

type FileSummary struct {
	Path        string      `json:"file"`
	GameProfile GameProfile `json:"game_profile"`
	Compressed  bool        `json:"compressed"`
	Header      Header      `json:"header"`
	Names       []string    `json:"names,omitempty"`
	Imports     []Import    `json:"imports,omitempty"`
	Exports     []Export    `json:"exports"`
}

func ReadFile

func ReadFile(path string) (*FileSummary, error)

func ReadFileExports

func ReadFileExports(path string, predicate func(Export) bool) (*FileSummary, map[int][]byte, error)

func ReadFileFromBytes

func ReadFileFromBytes(data []byte, path string) (*FileSummary, error)

func ReadFileFromBytesAndExports

func ReadFileFromBytesAndExports(data []byte, path string, predicate func(Export) bool) (*FileSummary, map[int][]byte, error)

func ReadFileHeaderOnly

func ReadFileHeaderOnly(path string) (*FileSummary, error)

func ReadFileRaw

func ReadFileRaw(path string) ([]byte, *FileSummary, error)

func ReadFileRawFromBytes

func ReadFileRawFromBytes(data []byte, path string) ([]byte, *FileSummary, error)

func (*FileSummary) RequireME2

func (fs *FileSummary) RequireME2() error

type GameProfile

type GameProfile string
const (
	ProfileME2OT   GameProfile = "me2_ot"
	ProfileLE2     GameProfile = "le2"
	ProfileME3OT   GameProfile = "me3_ot"
	ProfileLE3     GameProfile = "le3"
	ProfileUnknown GameProfile = "unknown"
)

func InferGameProfile

func InferGameProfile(uv, lv int) GameProfile

func (GameProfile) String

func (p GameProfile) String() string
type Header struct {
	UnrealVersion   int    `json:"unreal_version"`
	LicenseeVersion int    `json:"licensee_version"`
	Flags           uint32 `json:"flags"`
	NameCount       int    `json:"name_count"`
	NameOffset      int    `json:"name_offset"`
	ExportCount     int    `json:"export_count"`
	ExportOffset    int    `json:"export_offset"`
	ImportCount     int    `json:"import_count"`
	ImportOffset    int    `json:"import_offset"`
}

func (Header) String

func (h Header) String() string

type Import

type Import struct {
	ClassNameIndex  int `json:"class_name_index"`
	ObjectNameIndex int `json:"object_name_index"`
}

type ParsedProperty

type ParsedProperty struct {
	Name     string      `json:"name"`
	PropType string      `json:"prop_type"`
	Value    interface{} `json:"value"`
}

type PropertyTag

type PropertyTag struct {
	Name        string `json:"name"`
	PropType    string `json:"prop_type"`
	Size        int    `json:"size"`
	ArrayIndex  int    `json:"array_index"`
	ValueOffset int    `json:"value_offset"`
}

func ExtractBioConversationKeyProperties

func ExtractBioConversationKeyProperties(data []byte, names []string, serialOffset, serialSize int) []PropertyTag

func ParsePropertyTags

func ParsePropertyTags(data []byte, names []string, startOffset, size int, strict bool) ([]PropertyTag, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL