Documentation
¶
Index ¶
- Constants
- Variables
- func PackDirectory(dirPath string)
- type ArrayProperty
- type BaseProperty
- type BoolProperty
- type ByteProperty
- type CasToc
- type DepLinks
- type Dependencies
- type DepsHeader
- type Directory
- type EIoContainerFlags
- type EOType
- type EnumProperty
- type ExportObject
- type FGuid
- type FIoChunkHash
- type FIoChunkID
- type FIoContainerID
- type FIoDirectoryIndexEntry
- type FIoDirectoryIndexResource
- type FIoFileIndexEntry
- type FIoOffsetAndLength
- type FIoStoreTocCompressedBlockEntry
- func (f *FIoStoreTocCompressedBlockEntry) GetCompressedSize() uint32
- func (f *FIoStoreTocCompressedBlockEntry) GetOffset() uint64
- func (f *FIoStoreTocCompressedBlockEntry) GetUncompressedSize() uint32
- func (f *FIoStoreTocCompressedBlockEntry) SetCompressedSize(size uint32)
- func (f *FIoStoreTocCompressedBlockEntry) SetOffset(offset uint64)
- func (f *FIoStoreTocCompressedBlockEntry) SetUncompressedSize(size uint32)
- type FIoStoreTocEntryMeta
- type FIoStoreTocEntryMetaFlags
- type FIoStoreTocResourceInfo
- type FName
- type FSHAHash
- type FString
- type FileDependency
- type FileInfo
- type FloatProperty
- type Int64Property
- type IntProperty
- type NameInterface
- type NameProperty
- type ObjectProperty
- type Property
- type SoftObjectProperty
- type StructProperty
- type UAssetHeader
- type UAssetResource
- type UTocData
- type UTocHeader
- type UexpDataTable
- type UexpStructure
Constants ¶
const ( EIoChunkTypeBulkData = 2 EIoChunkTypeOptionalBulkData = 3 )
const ( // these are the types of Export Objects, with special thanks to Helios EOTypeFunction EOType = 1 EOTypeEnum = 3 EOTypeGeneratedClass = 9 EOTypeTable = 11 EOTypeMeshComponent = 41 EOTypeObject = 49 )
const ( MagicUtoc string = "-==--==--==--==-" VersionUtoc uint32 = 3 LegacyUtoc uint32 = 2 UnrealSignature string = "\xC1\x83\x2A\x9E" MountPoint string = "../../../" NoneEntry uint32 = 0xffffffff PackFileName string = "Packed_P" )
const ( NoneContainerFlag EIoContainerFlags = iota CompressedContainerFlag = iota EncryptedContainerFlag = (1 << iota) SignedContainerFlag = (1 << iota) IndexedContainerFlag = (1 << iota) )
const (
CompSize = 0x10000
)
Variables ¶
var ( ErrWrongMagic = errors.New("error: magic number was not found") ErrUnknownUtocVersion = errors.New("error: utoc version is unknown") ErrContainerFlag = errors.New("WARNING: the container flags were not 0 nor the indexed flag, so it could be a special case") ErrExpectedBytesRead = errors.New("expected to have read all bytes") ErrTocEntryBounds = errors.New("TocEntry out of container bounds") )
var ParsedDataPath string = "./Runtime/"
Functions ¶
func PackDirectory ¶
func PackDirectory(dirPath string)
PackDirectory builds the directory structure recursively of the entire directory Then, it packs the retrieved structure into a UCAS/UTOC file combination.
Types ¶
type ArrayProperty ¶
type ArrayProperty struct {
ArrayType string `json:"arraytype"`
ArrayStructType string `json:"arraystructtype,omitempty"` // only if ArrayType == "StructProperty"
Size int `json:"arraysize"`
Children []any
}
func (ArrayProperty) GetName ¶
func (x ArrayProperty) GetName() string
type BaseProperty ¶
type BaseProperty struct {
Value string `json:"baseproperty"`
Secondary int32 `json:"secondary,omitempty"`
Children []Property `json:"properties"`
}
BaseProperty is the same as the regular Property except, its children are Properties
type BoolProperty ¶
type BoolProperty struct {
Value bool `json:"bool"`
}
func (BoolProperty) GetName ¶
func (x BoolProperty) GetName() string
type ByteProperty ¶
type ByteProperty struct {
Value byte `json:"byte"`
}
type CasToc ¶
func ParseUTocFile ¶
type DepLinks ¶
type DepLinks struct {
FileSize uint64 // uncompressed file size
ExportObjects uint32 // number of Export Objects
MostlyOne uint32 // this is either 1, 2 or 3, but most often 1.
// All entries have a unique value for this field, starting at 0
// It does skip some numbers, so I'm not sure what this means.
// Looks like some kind of index though
SomeIndex uint64
DependencyPackages uint32 // number of dependency packages that this connection has
Offset uint32 // an offset to point to the dependency packages
}
type Dependencies ¶
type Dependencies struct {
ThisPackageID uint64 `json:"packageID"`
ChunkIDToDependencies map[uint64]FileDependency
}
Dependencies contains data extracted from the dependencies section in the .ucas file. An instance of this will be used to convert back to this section.
func ParseDependencies ¶
func ParseDependencies(b []byte) *Dependencies
func (*Dependencies) Deparse ¶
func (d *Dependencies) Deparse() *[]byte
Deparses the Dependencies struct exactly as how it was parsed This was checked using a simple diff tool.
type DepsHeader ¶
type EIoContainerFlags ¶
type EIoContainerFlags uint8
type EnumProperty ¶
the rest are "terminal" structures
func (EnumProperty) GetName ¶
func (x EnumProperty) GetName() string
type ExportObject ¶
type ExportObject struct {
SerialOffset uint64
SerialSize uint64
ObjectNameOffset uint32 // index in the Names Directory list; name of this "file"
SomeNumber uint32
ClassNameOffset uint64
FileHashes [4]uint64
Type uint16
OtherValues [3]uint16
}
total bytes: 72
type FGuid ¶
type FGuid struct {
A, B, C, D uint32
}
four components that make up a unique identifier. Seems a bit overkill, but: https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Source/Runtime/Core/Public/Misc/Guid.h
type FIoChunkHash ¶
type FIoContainerID ¶
type FIoContainerID uint64
type FIoDirectoryIndexEntry ¶
type FIoDirectoryIndexResource ¶
type FIoDirectoryIndexResource struct {
MountPoint FString
DirectoryEntries []FIoDirectoryIndexEntry
FileEntries []FIoFileIndexEntry
StringTable []FString
}
type FIoFileIndexEntry ¶
type FIoOffsetAndLength ¶
func (*FIoOffsetAndLength) GetLength ¶
func (f *FIoOffsetAndLength) GetLength() uint64
func (*FIoOffsetAndLength) GetOffset ¶
func (f *FIoOffsetAndLength) GetOffset() uint64
func (*FIoOffsetAndLength) SetLength ¶
func (f *FIoOffsetAndLength) SetLength(length uint64)
func (*FIoOffsetAndLength) SetOffset ¶
func (f *FIoOffsetAndLength) SetOffset(offset uint64)
type FIoStoreTocCompressedBlockEntry ¶
type FIoStoreTocCompressedBlockEntry struct {
Offset [5]uint8
CompressedSize [3]uint8
UncompressedSize [3]uint8
CompressionMethod uint8
}
func (*FIoStoreTocCompressedBlockEntry) GetCompressedSize ¶
func (f *FIoStoreTocCompressedBlockEntry) GetCompressedSize() uint32
func (*FIoStoreTocCompressedBlockEntry) GetOffset ¶
func (f *FIoStoreTocCompressedBlockEntry) GetOffset() uint64
func (*FIoStoreTocCompressedBlockEntry) GetUncompressedSize ¶
func (f *FIoStoreTocCompressedBlockEntry) GetUncompressedSize() uint32
func (*FIoStoreTocCompressedBlockEntry) SetCompressedSize ¶
func (f *FIoStoreTocCompressedBlockEntry) SetCompressedSize(size uint32)
func (*FIoStoreTocCompressedBlockEntry) SetOffset ¶
func (f *FIoStoreTocCompressedBlockEntry) SetOffset(offset uint64)
func (*FIoStoreTocCompressedBlockEntry) SetUncompressedSize ¶
func (f *FIoStoreTocCompressedBlockEntry) SetUncompressedSize(size uint32)
type FIoStoreTocEntryMeta ¶
type FIoStoreTocEntryMeta struct {
ChunkHash FIoChunkHash
Flags FIoStoreTocEntryMetaFlags
}
type FIoStoreTocEntryMetaFlags ¶
type FIoStoreTocEntryMetaFlags uint8
const ( NoneMetaFlag FIoStoreTocEntryMetaFlags = iota CompressedMetaFlag MemoryMappedMetaFlag )
type FIoStoreTocResourceInfo ¶
type FIoStoreTocResourceInfo struct {
Header UTocHeader
TocFileSize uint64
ChunkIDs []FIoChunkID
IDToChunk map[uint64]FIoChunkID
ChunkIDToIndex map[FIoChunkID]uint32
ChunkIDToOfflengths map[FIoChunkID]FIoOffsetAndLength
CompressionBlocks []FIoStoreTocCompressedBlockEntry
ChunkMetas []FIoStoreTocEntryMeta
ChunkBlockSignatures []FSHAHash
CompressionMethods []FName
DirectoryResource FIoDirectoryIndexResource
// DirectoryIndexBuffer []byte
Offlengths []FIoOffsetAndLength
}
type FileDependency ¶
type FloatProperty ¶
type FloatProperty struct {
Value float32 `json:"float"`
}
func (FloatProperty) GetName ¶
func (x FloatProperty) GetName() string
type Int64Property ¶
type Int64Property struct {
Value int64 `json:"int64"`
}
func (Int64Property) GetName ¶
func (x Int64Property) GetName() string
type IntProperty ¶
type IntProperty struct {
Value int32 `json:"int"`
}
func (IntProperty) GetName ¶
func (x IntProperty) GetName() string
type NameInterface ¶
type NameInterface interface{ GetName() string }
These interfaces are for finding the "None" value while parsing
type NameProperty ¶
type NameProperty struct {
Value string `json:"name"`
SecondaryValue int32 `json:"secondary,omitempty"`
}
func (NameProperty) GetName ¶
func (x NameProperty) GetName() string
type ObjectProperty ¶
type ObjectProperty struct {
Value int32 `json:"object"`
}
func (ObjectProperty) GetName ¶
func (x ObjectProperty) GetName() string
type Property ¶
type Property struct {
Value string `json:"property"`
Secondary int32 `json:"secondary,omitempty"`
Child any `json:"child,omitempty"`
}
each regular property has a child that is another structure property or a "terminal"
type SoftObjectProperty ¶
type StructProperty ¶
type StructProperty struct {
StructType string `json:"structtype"`
Children []any `json:"children"`
}
keep parsing until "None" all properties that come in between are children of this Property
func (StructProperty) GetName ¶
func (x StructProperty) GetName() string
type UAssetHeader ¶
type UAssetHeader struct {
RepeatNumber [2]uint64 // same number repeated twice
PackageFlags uint32 // value will be 0x80000000
TotalHeaderSize uint32 // of the original file header size; but that included the dependencies...
NamesDirectoryOffset uint32 // points to nullbyte, so do +1
NamesDirectoryLength uint32 // length is in bytes
NamesHashesOffset uint32 // first entry is always the algorithm ID
NamesHashesLength uint32 // length is in bytes
ImportObjectsOffset uint32
ExportObjectsOffset uint32 // offset to some extra header information
ExportMetaOffset uint32 // points to some memory, just store the either 24 or 32 bytes.
DependencyPackagesOffset uint32 // first value is a uint32, number of dependency packages.
DependencyPackagesSize uint64
}
static header with the first 64 bytes of the .uasset file
type UAssetResource ¶
type UAssetResource struct {
Header UAssetHeader
NamesDir []string
ExportObjects []ExportObject
// the rest of the file probably won't change in mods
ImportObjects []byte
ExportMeta []byte
DependencyPackages []byte
ParsedJSON *[]byte
}
func ParseUAssetFile ¶
func ParseUAssetFile(path string) (uasset UAssetResource, err error)
ParseUAssetFile takes a string and it expects the full .uasset file, including .uexp If the .uexp isn't there, there might be problems. Not all data must be parsed; only the parts that may be changed due to modding. That's what I'm doing here.
func (*UAssetResource) DeparseUAssetFile ¶
func (uasset *UAssetResource) DeparseUAssetFile(json *[]byte) *[]byte
func (*UAssetResource) PrintNamesDirectory ¶
func (u *UAssetResource) PrintNamesDirectory()
type UTocData ¶
type UTocData struct {
IDs []FIoChunkID
Offlengths []FIoOffsetAndLength
CBlocks []FIoStoreTocCompressedBlockEntry
Metas []FIoStoreTocEntryMeta
BlockSize uint32
Deps *Dependencies
FNameToID map[string]uint64
}
type UTocHeader ¶
type UTocHeader struct {
Magic [16]byte
Version uint32 // they state it's uint8, but I doubt it
HeaderSize uint32
EntryCount uint32
CompressedBlockEntryCount uint32
CompressedBlockEntrySize uint32 // they say "For sanity checking"
CompressionMethodNameCount uint32
CompressionMethodNameLength uint32
CompressionBlockSize uint32
DirectoryIndexSize uint32
PartitionCount uint32 // should be 0
ContainerID FIoContainerID
EncryptionKeyGuid FGuid
ContainerFlags EIoContainerFlags
Padding [63]byte
}
useful: https://github.com/jashking/UnrealPakViewer/blob/master/PakAnalyzer/Private/IoStoreDefines.h Unreal Docs: https://github.com/EpicGames/UnrealEngine/blob/99b6e203a15d04fc7bbbf554c421a985c1ccb8f1/Engine/Source/Runtime/Core/Private/IO/IoStore.h
type UexpDataTable ¶
type UexpDataTable struct {
Name string `json:"name"`
Header []Property `json:"datatableheader"`
BaseProperties []BaseProperty `json:"datatable"`
}
implements UexpStructure
func (UexpDataTable) GetType ¶
func (u UexpDataTable) GetType() EOType
type UexpStructure ¶
type UexpStructure interface {
GetType() EOType
}