edit

package
v0.2.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendExportDependencies added in v0.2.0

func AppendExportDependencies(asset *uasset.Asset, exportIndex int, deps []uasset.PackageIndex) ([]byte, error)

AppendExportDependencies appends one or more package indices to one export's DependsMap entry, preserving existing order and skipping duplicates.

func AppendImportEntries added in v0.2.0

func AppendImportEntries(asset *uasset.Asset, entries []uasset.ImportEntry) ([]byte, error)

AppendImportEntries appends serialized ImportMap entries without rewriting existing import indices. This is only safe for append-only scenarios where new references point at the newly appended imports.

func BuildNameIndexRemap added in v0.1.8

func BuildNameIndexRemap(oldNames, newNames []uasset.NameEntry) (map[int32]int32, error)

BuildNameIndexRemap matches old NameMap indices to the corresponding indices in a rewritten NameMap. Exact entry matches are paired first; remaining unmatched entries are paired in order, which covers one-entry rename/reorder flows such as Blueprint variable rename.

func BuildNameIndexRemapAllowInsertedNewEntries added in v0.2.0

func BuildNameIndexRemapAllowInsertedNewEntries(oldNames, newNames []uasset.NameEntry) (map[int32]int32, error)

BuildNameIndexRemapAllowInsertedNewEntries matches each old NameMap entry to an exact entry in newNames while permitting additional unmatched entries in newNames. This is suitable for flows that insert new names without deleting or renaming existing ones.

func ComputeNameEntryHashesUE56

func ComputeNameEntryHashesUE56(value string) (nonCaseHash uint16, casePreservingHash uint16)

ComputeNameEntryHashesUE56 computes FNameEntrySerialized hash fields following UE's FCrc::StrCrc32 / FCrc::Strihash_DEPRECATED behavior.

func ExpandNamesReferencedFromExportDataCount added in v0.2.0

func ExpandNamesReferencedFromExportDataCount(asset *uasset.Asset, targetCount int32) ([]byte, error)

ExpandNamesReferencedFromExportDataCount raises NamesReferencedFromExportDataCount to at least targetCount. This is useful for write flows that append NameMap entries and immediately reference them from export data.

func ExportPropertyBounds added in v0.2.0

func ExportPropertyBounds(asset *uasset.Asset, exp uasset.ExportEntry) (start int, end int, withClassControl bool)

ExportPropertyBounds returns the byte range of the tagged property region within an export's serial data.

func FinalizePackageBytes added in v0.1.8

func FinalizePackageBytes(data []byte, unversionedFileUE5 int32) error

FinalizePackageBytes updates the UE5 saved hash field when the package format includes it. The hash is computed over the header+exports bytes with the saved-hash field zeroed, matching UE SavePackage behavior.

func InsertExportEntries added in v0.2.0

func InsertExportEntries(asset *uasset.Asset, insertAt int, entries []ExportInsertEntry) ([]byte, error)

InsertExportEntries inserts export-map entries at zero-based position, expands DependsMap with empty entries, remaps existing positive export references in headers and tagged properties, and rebuilds the export-serial region in final export order.

func InsertImportEntries added in v0.2.0

func InsertImportEntries(asset *uasset.Asset, insertAt int, entries []uasset.ImportEntry) ([]byte, error)

InsertImportEntries inserts ImportMap entries at zero-based position and remaps ImportMap / ExportMap package indices that point to shifted imports.

func PatchInstancedTailNameRefs added in v0.2.0

func PatchInstancedTailNameRefs(oldAsset, asset *uasset.Asset, indexRemap map[int32]int32, opts uasset.ParseOptions) ([]byte, *uasset.Asset, error)

PatchInstancedTailNameRefs scans export tails for instanced NameRef pairs (Name index + Number where Number > 0, e.g. "Image_22" stored as {nameIndex("Image"), 23}) and rewrites them using the ORIGINAL payload bytes as the source of truth. This avoids cascading remaps when a rewritten NameRef index is itself also a valid old NameMap index.

func RemapOpaqueExportNameRefs added in v0.2.0

func RemapOpaqueExportNameRefs(payload []byte, indexRemap map[int32]int32) ([]byte, bool)

RemapOpaqueExportNameRefs performs an opaque scan of an export payload, remapping all NameRef-like int32 pairs according to the index remap.

func RemoveExportEntries added in v0.2.0

func RemoveExportEntries(asset *uasset.Asset, removeIndices []int) ([]byte, error)

RemoveExportEntries removes the selected zero-based ExportMap entries, remaps remaining positive export references, rewrites DependsMap, and rebuilds the export serial region in final kept-export order.

func RemoveImportEntries added in v0.2.0

func RemoveImportEntries(asset *uasset.Asset, removeIndices []int) ([]byte, error)

RemoveImportEntries removes the selected zero-based ImportMap entries and remaps remaining negative import references in import/export headers, DependsMap, export payloads, preload dependencies, and the asset registry imported-classes trailer.

func ReorderExports added in v0.2.0

func ReorderExports(asset *uasset.Asset, newOrder []int) ([]byte, error)

ReorderExports rewrites the export map and serial region to the provided zero-based export order, remapping positive export references in headers, tagged properties, DependsMap, and known opaque export tails.

func ReplaceExportDependencies added in v0.2.0

func ReplaceExportDependencies(asset *uasset.Asset, exportIndex int, deps []uasset.PackageIndex) ([]byte, error)

ReplaceExportDependencies rewrites one export's DependsMap entry while preserving all other export dependency lists.

func RewriteAsset

func RewriteAsset(asset *uasset.Asset, mutations []ExportMutation) ([]byte, error)

RewriteAsset rewrites the .uasset bytes with optional export payload mutations. It recalculates export serial offsets/sizes and applies summary offset translation.

func RewriteImportExportNameRefs added in v0.1.8

func RewriteImportExportNameRefs(asset *uasset.Asset, indexRemap map[int32]int32) ([]byte, error)

RewriteImportExportNameRefs patches ImportMap / ExportMap NameRef indices after the NameMap ordering changes.

func RewriteNameMap

func RewriteNameMap(asset *uasset.Asset, names []uasset.NameEntry) ([]byte, error)

RewriteNameMap replaces the serialized NameMap with the provided entries and updates dependent offsets/count fields.

func RewriteRawRange

func RewriteRawRange(asset *uasset.Asset, start, end int64, replacement []byte) ([]byte, error)

RewriteRawRange replaces one non-export byte range and updates summary/export offsets. The range must not overlap export serial payloads.

func RewriteSoftObjectPathEntries added in v0.2.0

func RewriteSoftObjectPathEntries(asset *uasset.Asset, entries []SoftObjectPathEntry) ([]byte, error)

RewriteSoftObjectPathEntries replaces the package soft object path list with the provided entries. The entry count must stay unchanged so the summary count remains valid.

Types

type ExportInsertEntry added in v0.2.0

type ExportInsertEntry struct {
	Header  uasset.ExportEntry
	Payload []byte
}

ExportInsertEntry is one inserted export header plus its serialized payload.

type ExportMutation

type ExportMutation struct {
	ExportIndex    int
	Payload        []byte
	UpdateScript   bool
	ScriptStartRel int64
	ScriptEndRel   int64
}

ExportMutation describes one replacement for an export payload.

func BuildExportNameRemapMutations added in v0.1.8

func BuildExportNameRemapMutations(oldAsset, newAsset *uasset.Asset, indexRemap map[int32]int32, fromDisplay, toDisplay string) ([]ExportMutation, error)

func BuildExportNameRemapMutationsPropertyOnly added in v0.2.0

func BuildExportNameRemapMutationsPropertyOnly(oldAsset, newAsset *uasset.Asset, indexRemap map[int32]int32) ([]ExportMutation, error)

BuildExportNameRemapMutations reserializes tagged-property exports against the rewritten NameMap and updates Blueprint-facing display strings that UE renames alongside variable declarations. BuildExportNameRemapMutationsPropertyOnly remaps NameRef indices only within the tagged-property region of each export. Bytecode, script headers, and other opaque areas are left untouched. This avoids false-positive remapping of int32 values that coincidentally match old name indices.

func BuildExportPackageIndexDeleteMutations added in v0.2.0

func BuildExportPackageIndexDeleteMutations(oldAsset, newAsset *uasset.Asset, importRemap map[int]int, removeSet map[int]bool) ([]ExportMutation, error)

BuildExportPackageIndexDeleteMutations reserializes tagged-property exports after ImportMap deletion shifts or removes import package indices referenced from export payloads.

func BuildExportPackageIndexRemapMutations added in v0.2.0

func BuildExportPackageIndexRemapMutations(oldAsset, newAsset *uasset.Asset, importRemap map[int]int) ([]ExportMutation, error)

BuildExportPackageIndexRemapMutations reserializes tagged-property exports after ImportMap insertion shifts import package indices referenced from export payloads.

type PropertyAddResult

type PropertyAddResult struct {
	Mutation     ExportMutation
	ExportIndex  int
	PropertyName string
	PropertyType string
	ArrayIndex   int32
	NewValue     any
	NewSize      int32
	ByteDelta    int
}

PropertyAddResult is the computed mutation for one prop add operation.

func BuildPropertyAddMutation

func BuildPropertyAddMutation(asset *uasset.Asset, exportIndex int, specJSON string) (*PropertyAddResult, error)

BuildPropertyAddMutation builds one export mutation for `bpx prop add`.

func BuildPropertyAddMutationBefore added in v0.2.0

func BuildPropertyAddMutationBefore(asset *uasset.Asset, exportIndex int, specJSON string, beforeProperty string) (*PropertyAddResult, error)

BuildPropertyAddMutationBefore builds one export mutation for `bpx prop add` and inserts the new top-level property immediately before another top-level property when it exists on the target export.

type PropertyRemoveResult

type PropertyRemoveResult struct {
	Mutation     ExportMutation
	ExportIndex  int
	PropertyName string
	ArrayIndex   int32
	OldValue     any
	OldSize      int32
	ByteDelta    int
}

PropertyRemoveResult is the computed mutation for one prop remove operation.

func BuildPropertyRemoveMutation

func BuildPropertyRemoveMutation(asset *uasset.Asset, exportIndex int, path string) (*PropertyRemoveResult, error)

BuildPropertyRemoveMutation builds one export mutation for `bpx prop remove`.

type PropertySetResult

type PropertySetResult struct {
	Mutation     ExportMutation
	ExportIndex  int
	PropertyName string
	Path         string
	OldValue     any
	NewValue     any
	OldSize      int32
	NewSize      int32
	ByteDelta    int
}

PropertySetResult is the computed mutation for one prop set operation.

func BuildPropertySetMutation

func BuildPropertySetMutation(asset *uasset.Asset, exportIndex int, path string, valueJSON string) (*PropertySetResult, error)

BuildPropertySetMutation builds one export mutation for `bpx prop set`.

type SoftObjectPathEntry added in v0.2.0

type SoftObjectPathEntry struct {
	PackageName uasset.NameRef
	AssetName   uasset.NameRef
	SubPath     string
}

SoftObjectPathEntry is one decoded soft object path list entry.

func ReadSoftObjectPathEntries added in v0.2.0

func ReadSoftObjectPathEntries(asset *uasset.Asset) ([]SoftObjectPathEntry, error)

ReadSoftObjectPathEntries decodes the package soft object path list.

Jump to

Keyboard shortcuts

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