uasset

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectAssetFiles

func CollectAssetFiles(root, pattern string, recursive bool) ([]string, error)

CollectAssetFiles enumerates files under root matching the provided glob pattern. When recursive is true, subdirectories are traversed. Returned paths are sorted.

func SupportedUE5VersionWindow added in v0.1.8

func SupportedUE5VersionWindow() (min int32, max int32)

SupportedUE5VersionWindow reports the accepted FileVersionUE5 range.

Types

type Asset

type Asset struct {
	Raw     RawAsset
	Summary PackageSummary
	Names   []NameEntry
	Imports []ImportEntry
	Exports []ExportEntry
	// contains filtered or unexported fields
}

Asset is the parsed representation required for read commands.

func ParseBytes

func ParseBytes(data []byte, opts ParseOptions) (*Asset, error)

ParseBytes parses one .uasset from in-memory bytes.

func ParseFile

func ParseFile(path string, opts ParseOptions) (*Asset, error)

ParseFile parses one .uasset file from disk.

func (*Asset) DecodePropertyValue

func (a *Asset) DecodePropertyValue(tag PropertyTag) (any, bool)

DecodePropertyValue decodes one property value for common scalar/reference types. It returns (value, true) when decoded; otherwise (nil, false).

func (*Asset) DecodeSerializedTextFromReader

func (a *Asset) DecodeSerializedTextFromReader(r *ByteReader) (any, bool)

DecodeSerializedTextFromReader decodes one serialized FText payload from the current reader offset. The reader offset advances on success.

func (*Asset) GuessAssetKind

func (a *Asset) GuessAssetKind() string

GuessAssetKind returns a rough kind name derived from import/export class names.

func (*Asset) ParseExportProperties

func (a *Asset) ParseExportProperties(exportIndex int) PropertyListResult

ParseExportProperties parses top-level tagged properties for one export.

func (*Asset) ParseIndex

func (a *Asset) ParseIndex(idx PackageIndex) string

ParseIndex resolves a package index to a human readable target.

func (*Asset) ParseTaggedPropertiesRange

func (a *Asset) ParseTaggedPropertiesRange(startOffset, endOffset int, withClassSerializationControl bool) PropertyListResult

ParseTaggedPropertiesRange parses tagged properties in one byte range.

func (*Asset) ResolveClassName

func (a *Asset) ResolveClassName(exp ExportEntry) string

ResolveClassName returns class object name for one export.

func (*Asset) ResolveExportIndex

func (a *Asset) ResolveExportIndex(index int) (int, error)

ResolveExportIndex converts 1-based export index to zero-based index.

func (*Asset) ResolveImportIndex

func (a *Asset) ResolveImportIndex(index int) (int, error)

ResolveImportIndex converts 1-based import index to zero-based index.

type ByteReader

type ByteReader struct {
	// contains filtered or unexported fields
}

ByteReader is a bounded little-endian binary reader used by parsers and CLI helpers.

func NewByteReader

func NewByteReader(data []byte) *ByteReader

NewByteReader creates a new reader for the given byte slice.

func NewByteReaderWithByteSwapping

func NewByteReaderWithByteSwapping(data []byte, byteSwap bool) *ByteReader

NewByteReaderWithByteSwapping creates a reader with explicit byte-swapping behavior.

func (*ByteReader) EOF

func (r *ByteReader) EOF() bool

func (*ByteReader) IsByteSwapping

func (r *ByteReader) IsByteSwapping() bool

func (*ByteReader) Offset

func (r *ByteReader) Offset() int

func (*ByteReader) ReadBytes

func (r *ByteReader) ReadBytes(n int) ([]byte, error)

func (*ByteReader) ReadEngineVersion

func (r *ByteReader) ReadEngineVersion() (EngineVersion, error)

func (*ByteReader) ReadFString

func (r *ByteReader) ReadFString() (string, error)

func (*ByteReader) ReadGUID

func (r *ByteReader) ReadGUID() (GUID, error)

func (*ByteReader) ReadHash20

func (r *ByteReader) ReadHash20() ([20]byte, error)

func (*ByteReader) ReadInt32

func (r *ByteReader) ReadInt32() (int32, error)

func (*ByteReader) ReadInt64

func (r *ByteReader) ReadInt64() (int64, error)

func (*ByteReader) ReadNameRef

func (r *ByteReader) ReadNameRef(nameCount int) (NameRef, error)

func (*ByteReader) ReadSoftObjectSubPath

func (r *ByteReader) ReadSoftObjectSubPath() (string, error)

ReadSoftObjectSubPath decodes modern FUtf8String sub-path and falls back to legacy FString variants.

func (*ByteReader) ReadUBool

func (r *ByteReader) ReadUBool() (bool, error)

func (*ByteReader) ReadUTF8String

func (r *ByteReader) ReadUTF8String() (string, error)

ReadUTF8String decodes UE UTF-8 string serialization used by FUtf8String.

func (*ByteReader) ReadUint8

func (r *ByteReader) ReadUint8() (uint8, error)

func (*ByteReader) ReadUint16

func (r *ByteReader) ReadUint16() (uint16, error)

func (*ByteReader) ReadUint32

func (r *ByteReader) ReadUint32() (uint32, error)

func (*ByteReader) Remaining

func (r *ByteReader) Remaining() int

func (*ByteReader) Seek

func (r *ByteReader) Seek(offset int) error

func (*ByteReader) SetByteSwapping

func (r *ByteReader) SetByteSwapping(enabled bool)

func (*ByteReader) Skip

func (r *ByteReader) Skip(n int) error

type CompressedChunk

type CompressedChunk struct {
	UncompressedOffset int32 `json:"uncompressedOffset"`
	UncompressedSize   int32 `json:"uncompressedSize"`
	CompressedOffset   int32 `json:"compressedOffset"`
	CompressedSize     int32 `json:"compressedSize"`
}

CompressedChunk mirrors FCompressedChunk.

type CustomVersion

type CustomVersion struct {
	Key     GUID  `json:"key"`
	Version int32 `json:"version"`
}

CustomVersion is one entry in FCustomVersionContainer.

type EngineVersion

type EngineVersion struct {
	Major      uint16 `json:"major"`
	Minor      uint16 `json:"minor"`
	Patch      uint16 `json:"patch"`
	Changelist uint32 `json:"changelist"`
	Branch     string `json:"branch"`
}

EngineVersion mirrors FEngineVersion fields used in package summary.

func (EngineVersion) Version

func (v EngineVersion) Version() string

Version returns Major.Minor string.

type ExportEntry

type ExportEntry struct {
	ClassIndex    PackageIndex `json:"classIndex"`
	SuperIndex    PackageIndex `json:"superIndex"`
	TemplateIndex PackageIndex `json:"templateIndex"`
	OuterIndex    PackageIndex `json:"outerIndex"`
	ObjectName    NameRef      `json:"objectName"`
	ObjectFlags   uint32       `json:"objectFlags"`
	SerialSize    int64        `json:"serialSize"`
	SerialOffset  int64        `json:"serialOffset"`

	// Relative offsets within the export serialized payload (not file absolute offsets).
	// UE source reference: SavePackage2.cpp adjusts by SerialOffset before saving export map.
	ScriptSerializationStartOffset int64 `json:"scriptSerializationStartOffset"`
	ScriptSerializationEndOffset   int64 `json:"scriptSerializationEndOffset"`

	ForcedExport             bool   `json:"forcedExport"`
	NotForClient             bool   `json:"notForClient"`
	NotForServer             bool   `json:"notForServer"`
	NotAlwaysLoadedForEditor bool   `json:"notAlwaysLoadedForEditor"`
	IsAsset                  bool   `json:"isAsset"`
	IsInheritedInstance      bool   `json:"isInheritedInstance"`
	GeneratePublicHash       bool   `json:"generatePublicHash"`
	PackageFlags             uint32 `json:"packageFlags"`

	FirstExportDependency                 int32 `json:"firstExportDependency"`
	SerializationBeforeSerializationDeps  int32 `json:"serializationBeforeSerializationDependencies"`
	CreateBeforeSerializationDeps         int32 `json:"createBeforeSerializationDependencies"`
	SerializationBeforeCreateDependencies int32 `json:"serializationBeforeCreateDependencies"`
	CreateBeforeCreateDependencies        int32 `json:"createBeforeCreateDependencies"`
}

ExportEntry mirrors one serialized FObjectExport entry used by read commands.

type GUID

type GUID [16]byte

GUID is a simple 128-bit identifier from UE serialization.

func (GUID) String

func (g GUID) String() string

type GenerationInfo

type GenerationInfo struct {
	ExportCount int32 `json:"exportCount"`
	NameCount   int32 `json:"nameCount"`
}

GenerationInfo is one FGenerationInfo entry.

type ImportEntry

type ImportEntry struct {
	ClassPackage   NameRef      `json:"classPackage"`
	ClassName      NameRef      `json:"className"`
	OuterIndex     PackageIndex `json:"outerIndex"`
	ObjectName     NameRef      `json:"objectName"`
	PackageName    NameRef      `json:"packageName"`
	ImportOptional bool         `json:"importOptional"`
}

ImportEntry mirrors one serialized FObjectImport entry used by read commands.

type NameEntry

type NameEntry struct {
	Value              string `json:"value"`
	NonCaseHash        uint16 `json:"nonCaseHash"`
	CasePreservingHash uint16 `json:"casePreservingHash"`
}

NameEntry mirrors one serialized FNameEntrySerialized entry from NameMap.

type NameRef

type NameRef struct {
	Index  int32 `json:"index"`
	Number int32 `json:"number"`
}

NameRef is one serialized FName (index + number).

func (NameRef) Display

func (n NameRef) Display(names []NameEntry) string

Display resolves name text (best effort) and appends suffix if numbered.

func (NameRef) IsNone

func (n NameRef) IsNone(names []NameEntry) bool

IsNone reports whether this is NAME_None with no number.

type PackageIndex

type PackageIndex int32

PackageIndex is UE's FPackageIndex representation.

func (PackageIndex) IsNull

func (p PackageIndex) IsNull() bool

IsNull reports whether the index is null.

func (PackageIndex) Kind

func (p PackageIndex) Kind() string

Kind returns the index class: export/import/null.

func (PackageIndex) ResolveIndex

func (p PackageIndex) ResolveIndex() int

ResolveIndex returns the zero-based index for import/export or -1 for null.

func (PackageIndex) String

func (p PackageIndex) String() string

type PackageSummary

type PackageSummary struct {
	Tag                    int32 `json:"tag"`
	ByteSwapped            bool  `json:"byteSwapped,omitempty"`
	LegacyFileVersion      int32 `json:"legacyFileVersion"`
	LegacyUE3Version       int32 `json:"legacyUE3Version"`
	FileVersionUE4         int32 `json:"fileVersionUE4"`
	FileVersionUE5         int32 `json:"fileVersionUE5"`
	FileVersionLicenseeUE4 int32 `json:"fileVersionLicenseeUE4"`
	SavedHash              [20]byte
	TotalHeaderSize        int32           `json:"totalHeaderSize"`
	CustomVersions         []CustomVersion `json:"customVersions"`

	PackageName  string `json:"packageName"`
	PackageFlags uint32 `json:"packageFlags"`

	NameCount  int32 `json:"nameCount"`
	NameOffset int32 `json:"nameOffset"`

	SoftObjectPathsCount  int32 `json:"softObjectPathsCount"`
	SoftObjectPathsOffset int32 `json:"softObjectPathsOffset"`

	LocalizationID string `json:"localizationId"`

	GatherableTextDataCount  int32 `json:"gatherableTextDataCount"`
	GatherableTextDataOffset int32 `json:"gatherableTextDataOffset"`

	MetaDataOffset int32 `json:"metaDataOffset"`

	ExportCount  int32 `json:"exportCount"`
	ExportOffset int32 `json:"exportOffset"`

	ImportCount  int32 `json:"importCount"`
	ImportOffset int32 `json:"importOffset"`

	CellExportCount  int32 `json:"cellExportCount"`
	CellExportOffset int32 `json:"cellExportOffset"`
	CellImportCount  int32 `json:"cellImportCount"`
	CellImportOffset int32 `json:"cellImportOffset"`

	DependsOffset int32 `json:"dependsOffset"`

	SoftPackageReferencesCount  int32 `json:"softPackageReferencesCount"`
	SoftPackageReferencesOffset int32 `json:"softPackageReferencesOffset"`

	SearchableNamesOffset       int32 `json:"searchableNamesOffset"`
	ThumbnailTableOffset        int32 `json:"thumbnailTableOffset"`
	ImportTypeHierarchiesCount  int32 `json:"importTypeHierarchiesCount,omitempty"`
	ImportTypeHierarchiesOffset int32 `json:"importTypeHierarchiesOffset,omitempty"`
	PersistentGUID              GUID  `json:"persistentGuid"`

	Generations []GenerationInfo `json:"generations"`

	SavedByEngineVersion               EngineVersion `json:"savedByEngineVersion"`
	CompatibleEngineVersion            EngineVersion `json:"compatibleEngineVersion"`
	CompressionFlags                   uint32        `json:"compressionFlags"`
	CompressedChunks                   []CompressedChunk
	PackageSource                      uint32   `json:"packageSource"`
	AdditionalPackagesToCook           []string `json:"additionalPackagesToCook"`
	AssetRegistryDataOffset            int32    `json:"assetRegistryDataOffset"`
	BulkDataStartOffset                int64    `json:"bulkDataStartOffset"`
	WorldTileInfoDataOffset            int32    `json:"worldTileInfoDataOffset"`
	ChunkIDs                           []int32  `json:"chunkIds"`
	PreloadDependencyCount             int32    `json:"preloadDependencyCount"`
	PreloadDependencyOffset            int32    `json:"preloadDependencyOffset"`
	NamesReferencedFromExportDataCount int32    `json:"namesReferencedFromExportDataCount"`
	PayloadTOCOffset                   int64    `json:"payloadTocOffset"`
	DataResourceOffset                 int32    `json:"dataResourceOffset"`

	SummarySize int  `json:"summarySize"`
	Unversioned bool `json:"unversioned"`
}

PackageSummary is the parsed FPackageFileSummary (subset required by read commands + validation).

func (PackageSummary) IsEditorOnlyFiltered

func (s PackageSummary) IsEditorOnlyFiltered() bool

IsEditorOnlyFiltered reports whether PKG_FilterEditorOnly is set.

func (PackageSummary) IsUE56

func (s PackageSummary) IsUE56() bool

IsUE56 reports whether summary looks like UE 5.6 package metadata.

func (PackageSummary) SavedHashHex

func (s PackageSummary) SavedHashHex() string

SavedHashHex returns the package saved hash in lowercase hex.

func (PackageSummary) SupportsPropertyTagCompleteTypeName

func (s PackageSummary) SupportsPropertyTagCompleteTypeName() bool

SupportsPropertyTagCompleteTypeName reports whether FPropertyTag uses complete type-name format.

func (PackageSummary) SupportsScriptSerializationOffsets

func (s PackageSummary) SupportsScriptSerializationOffsets() bool

SupportsScriptSerializationOffsets reports whether export map includes script offset fields.

func (PackageSummary) SupportsSoftObjectPathListInSummary

func (s PackageSummary) SupportsSoftObjectPathListInSummary() bool

SupportsSoftObjectPathListInSummary reports whether package summary carries SoftObjectPathsCount/Offset.

func (PackageSummary) SupportsTopLevelAssetPathSoftObjectPath

func (s PackageSummary) SupportsTopLevelAssetPathSoftObjectPath() bool

SupportsTopLevelAssetPathSoftObjectPath reports whether FSoftObjectPath uses TopLevelAssetPath + SubPath.

func (PackageSummary) UsesByteSwappedSerialization

func (s PackageSummary) UsesByteSwappedSerialization() bool

UsesByteSwappedSerialization reports whether package numeric fields should be byte-swapped.

func (PackageSummary) UsesUnversionedPropertySerialization

func (s PackageSummary) UsesUnversionedPropertySerialization() bool

UsesUnversionedPropertySerialization reports whether export map omits script offsets.

type ParseOptions

type ParseOptions struct {
	KeepUnknown bool
}

ParseOptions controls parser behavior.

func DefaultParseOptions

func DefaultParseOptions() ParseOptions

DefaultParseOptions returns CLI defaults.

type PropertyListResult

type PropertyListResult struct {
	Properties []PropertyTag `json:"properties"`
	Warnings   []string      `json:"warnings"`
	EndOffset  int           `json:"endOffset"`
}

PropertyListResult wraps parsed properties and parse warnings.

type PropertyTag

type PropertyTag struct {
	Name                         NameRef            `json:"name"`
	TypeNodes                    []PropertyTypeNode `json:"typeNodes"`
	Size                         int32              `json:"size"`
	Flags                        uint8              `json:"flags"`
	ArrayIndex                   int32              `json:"arrayIndex"`
	StructGUID                   *GUID              `json:"structGuid,omitempty"`
	PropertyGUID                 *GUID              `json:"propertyGuid,omitempty"`
	PropertyExtensions           uint8              `json:"propertyExtensions,omitempty"`
	OverridableOperation         uint8              `json:"overridableOperation,omitempty"`
	ExperimentalOverridableLogic bool               `json:"experimentalOverridableLogic,omitempty"`
	Offset                       int                `json:"offset"`
	ValueOffset                  int                `json:"valueOffset"`
}

PropertyTag represents one top-level property tag in tagged property serialization.

func (PropertyTag) TypeString

func (p PropertyTag) TypeString(names []NameEntry) string

TypeString renders the nested type name in a stable textual format.

type PropertyTypeNode

type PropertyTypeNode struct {
	Name       NameRef `json:"name"`
	InnerCount int32   `json:"innerCount"`
}

PropertyTypeNode is one node in UE::FPropertyTypeName serialized stream.

type RawAsset

type RawAsset struct {
	Bytes []byte
}

RawAsset keeps the original asset bytes so a no-op write is byte identical.

func (RawAsset) SerializeUnmodified

func (r RawAsset) SerializeUnmodified() []byte

SerializeUnmodified returns a copy of the original bytes.

Jump to

Keyboard shortcuts

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