parser

package
v0.0.0-...-5cba970 Latest Latest
Warning

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

Go to latest
Published: May 11, 2025 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	VHDXFileSignature = "vhdxfile"
	HeaderSignature   = "head"
	RegionSignature   = "regi"
	MetadataSignature = "metadata"

	// Represents a GUID of 2DC27766-F623-4200-9D64-115E9BFD4A08
	BAT_GUID = "\x66\x77\xc2\x2d\x23\xf6\x00\x42\x9d\x64\x11\x5e\x9b\xfd\x4a\x08"

	// Represents a GUID of 8B7CA206-4790-4B9A-B8FE-575F050F886E
	Metadata_GUID = "\x06\xa2\x7c\x8b\x90\x47\x9a\x4b\xb8\xfe\x57\x5f\x05\x0f\x88\x6e"

	PAYLOAD_BLOCK_NOT_PRESENT       = 0
	PAYLOAD_BLOCK_UNDEFINED         = 1
	PAYLOAD_BLOCK_ZERO              = 2
	PAYLOAD_BLOCK_UNMAPPED          = 3
	PAYLOAD_BLOCK_FULLY_PRESENT     = 6
	PAYLOAD_BLOCK_PARTIALLY_PRESENT = 7

	// CAA16737-FA36-4D43-B3B6-33F0AA44E76B
	MetadataFileParameters = "\x37\x67\xa1\xca\x36\xfa\x43\x4d\xb3\xb6\x33\xf0\xaa\x44\xe7\x6b"

	// 2FA54224-CD1B-4876-B211-5DBED83BF4B8
	MetadataVirtualDiskSize = "\x24\x42\xa5\x2f\x1b\xcd\x76\x48\xb2\x11\x5d\xbe\xd8\x3b\xf4\xb8"

	// 8141BF1D-A96F-4709-BA47-F233A8FAAB5F
	MetadataLogicalSectorSize = "\x1d\xbf\x41\x81\x6f\xa9\x09\x47\xba\x47\xf2\x33\xa8\xfa\xab\x5f"

	// CDA348C7-445D-4471-9CC9-E9885251C556
	MetadataPhysicalSectorSize = "\xc7\x48\xa3\xcd\x5d\x44\x71\x44\x9c\xc9\xe9\x88\x52\x51\xc5\x56"

	// BECA12AB-B2E6-4523-93EF-C309E000C746
	MetadataVirtualDiskId = "\xab\x12\xca\xbe\xe6\xb2\x23\x45\x93\xef\xc3\x09\xe0\x00\xc7\x46"
)

Variables

This section is empty.

Functions

func ParseArray_byte

func ParseArray_byte(profile *VHDXProfile, reader io.ReaderAt, offset int64, count int) []byte

func ParseString

func ParseString(reader io.ReaderAt, offset int64, length int64) string

func ParseTerminatedString

func ParseTerminatedString(reader io.ReaderAt, offset int64) string

func ParseTerminatedUTF16String

func ParseTerminatedUTF16String(reader io.ReaderAt, offset int64) string

func ParseUTF16String

func ParseUTF16String(reader io.ReaderAt, offset int64, length int64) string

func ParseUint16

func ParseUint16(reader io.ReaderAt, offset int64) uint16

func ParseUint32

func ParseUint32(reader io.ReaderAt, offset int64) uint32

func ParseUint64

func ParseUint64(reader io.ReaderAt, offset int64) uint64

func ParseUint8

func ParseUint8(reader io.ReaderAt, offset int64) byte

func SetDebug

func SetDebug()

func UTF16BytesToUTF8

func UTF16BytesToUTF8(b []byte, o binary.ByteOrder) string

Types

type BATEntry

type BATEntry struct {
	Reader  io.ReaderAt
	Offset  int64
	Profile *VHDXProfile
}

func ParseArray_BATEntry

func ParseArray_BATEntry(profile *VHDXProfile, reader io.ReaderAt, offset int64, count int) []*BATEntry

func (*BATEntry) DebugString

func (self *BATEntry) DebugString() string

func (*BATEntry) FileOffsetMB

func (self *BATEntry) FileOffsetMB() uint64

func (*BATEntry) Size

func (self *BATEntry) Size() int

func (*BATEntry) State

func (self *BATEntry) State() uint64

type Bat

type Bat struct {
	StartOffset, EntrySize uint64
	TotalNumberOfEntries   uint64

	EntriesPerChunk uint64
	// contains filtered or unexported fields
}

func (*Bat) DebugString

func (self *Bat) DebugString() string

func (*Bat) GetFileOffset

func (self *Bat) GetFileOffset(block int) uint64

type BatRange

type BatRange struct {
	FileOffset uint64
}

type BatReader

type BatReader struct {
	BlockSize       uint64
	EntriesPerChunk uint64
	Size            uint64
	Reader          io.ReaderAt
	// contains filtered or unexported fields
}

func (*BatReader) ReadAt

func (self *BatReader) ReadAt(buff []byte, off int64) (int, error)

type FileParameters

type FileParameters struct {
	Reader  io.ReaderAt
	Offset  int64
	Profile *VHDXProfile
}

func (*FileParameters) BlockSize

func (self *FileParameters) BlockSize() uint32

func (*FileParameters) DebugString

func (self *FileParameters) DebugString() string

func (*FileParameters) HasParent

func (self *FileParameters) HasParent() uint64

func (*FileParameters) Size

func (self *FileParameters) Size() int

type FileType

type FileType struct {
	Reader  io.ReaderAt
	Offset  int64
	Profile *VHDXProfile
}

func (*FileType) Creator

func (self *FileType) Creator() string

func (*FileType) DebugString

func (self *FileType) DebugString() string

func (*FileType) Header1

func (self *FileType) Header1() *Header

func (*FileType) Header2

func (self *FileType) Header2() *Header

func (*FileType) Region1

func (self *FileType) Region1() *Region

func (*FileType) Region2

func (self *FileType) Region2() *Region

func (*FileType) Signature

func (self *FileType) Signature() string

func (*FileType) Size

func (self *FileType) Size() int

type GUID

type GUID struct {
	Reader  io.ReaderAt
	Offset  int64
	Profile *VHDXProfile
}

func (GUID) AsString

func (self GUID) AsString() string

func (*GUID) Data1

func (self *GUID) Data1() uint32

func (*GUID) Data2

func (self *GUID) Data2() uint16

func (*GUID) Data3

func (self *GUID) Data3() uint16

func (*GUID) Data4

func (self *GUID) Data4() []byte

func (*GUID) DebugString

func (self *GUID) DebugString() string

func (*GUID) Size

func (self *GUID) Size() int
type Header struct {
	Reader  io.ReaderAt
	Offset  int64
	Profile *VHDXProfile
}

func (*Header) DebugString

func (self *Header) DebugString() string

func (*Header) SequenceNumber

func (self *Header) SequenceNumber() uint64

func (*Header) Signature

func (self *Header) Signature() string

func (*Header) Size

func (self *Header) Size() int

type Metadata

type Metadata struct {
	Reader  io.ReaderAt
	Offset  int64
	Profile *VHDXProfile
}

func (*Metadata) DebugString

func (self *Metadata) DebugString() string

func (*Metadata) Entries

func (self *Metadata) Entries() []*MetadataEntry

func (*Metadata) EntryCount

func (self *Metadata) EntryCount() uint16

func (*Metadata) ParseMetadata

func (self *Metadata) ParseMetadata() *VHDXMetadata

func (*Metadata) Signature

func (self *Metadata) Signature() string

func (*Metadata) Size

func (self *Metadata) Size() int

type MetadataEntry

type MetadataEntry struct {
	Reader  io.ReaderAt
	Offset  int64
	Profile *VHDXProfile
}

func ParseArray_MetadataEntry

func ParseArray_MetadataEntry(profile *VHDXProfile, reader io.ReaderAt, offset int64, count int) []*MetadataEntry

func (*MetadataEntry) DebugString

func (self *MetadataEntry) DebugString() string

func (*MetadataEntry) GUID

func (self *MetadataEntry) GUID() string

func (*MetadataEntry) Length

func (self *MetadataEntry) Length() uint32

func (*MetadataEntry) MetadataOffset

func (self *MetadataEntry) MetadataOffset() uint32

func (*MetadataEntry) Size

func (self *MetadataEntry) Size() int

type Misc

type Misc struct {
	Reader  io.ReaderAt
	Offset  int64
	Profile *VHDXProfile
}

func (*Misc) Bats

func (self *Misc) Bats() []*BATEntry

func (*Misc) DebugString

func (self *Misc) DebugString() string

func (*Misc) Regions

func (self *Misc) Regions() []*RegionEntry

func (*Misc) Size

func (self *Misc) Size() int

type Region

type Region struct {
	Reader  io.ReaderAt
	Offset  int64
	Profile *VHDXProfile
}

func (*Region) DebugString

func (self *Region) DebugString() string

func (*Region) EntryCount

func (self *Region) EntryCount() uint32

func (*Region) Signature

func (self *Region) Signature() string

func (*Region) Size

func (self *Region) Size() int

type RegionEntry

type RegionEntry struct {
	Reader  io.ReaderAt
	Offset  int64
	Profile *VHDXProfile
}

func ParseArray_RegionEntry

func ParseArray_RegionEntry(profile *VHDXProfile, reader io.ReaderAt, offset int64, count int) []*RegionEntry

func (*RegionEntry) DebugString

func (self *RegionEntry) DebugString() string

func (*RegionEntry) FileOffset

func (self *RegionEntry) FileOffset() uint64

func (*RegionEntry) GUID

func (self *RegionEntry) GUID() string

func (*RegionEntry) IsRequired

func (self *RegionEntry) IsRequired() uint32

func (*RegionEntry) Length

func (self *RegionEntry) Length() uint32

func (*RegionEntry) Size

func (self *RegionEntry) Size() int

type VHDXFile

type VHDXFile struct {
	Metadata *VHDXMetadata
	// contains filtered or unexported fields
}

func NewVHDXFile

func NewVHDXFile(reader io.ReaderAt) (*VHDXFile, error)

func (*VHDXFile) DebugString

func (self *VHDXFile) DebugString() string

func (*VHDXFile) ReadAt

func (self *VHDXFile) ReadAt(buff []byte, off int64) (int, error)

func (*VHDXFile) Validate

func (self *VHDXFile) Validate() error

type VHDXMetadata

type VHDXMetadata struct {
	BlockSize          uint64
	HasParent          bool
	VirtualDiskSize    uint64
	LogicalSectorSize  uint64
	PhysicalSectorSize uint32
	VirtualDiskId      string
}

type VHDXProfile

type VHDXProfile struct {
	Off_BATEntry_State               int64
	Off_BATEntry_FileOffsetMB        int64
	Off_FileParameters_BlockSize     int64
	Off_FileParameters_HasParent     int64
	Off_FileType_Signature           int64
	Off_FileType_Creator             int64
	Off_FileType_Header1             int64
	Off_FileType_Header2             int64
	Off_FileType_Region1             int64
	Off_FileType_Region2             int64
	Off_GUID_Data1                   int64
	Off_GUID_Data2                   int64
	Off_GUID_Data3                   int64
	Off_GUID_Data4                   int64
	Off_Header_Signature             int64
	Off_Header_SequenceNumber        int64
	Off_Metadata_Signature           int64
	Off_Metadata_EntryCount          int64
	Off_Metadata_Entries             int64
	Off_MetadataEntry_GUID           int64
	Off_MetadataEntry_MetadataOffset int64
	Off_MetadataEntry_Length         int64
	Off_Misc_Regions                 int64
	Off_Misc_Bats                    int64
	Off_Region_Signature             int64
	Off_Region_EntryCount            int64
	Off_RegionEntry_GUID             int64
	Off_RegionEntry_FileOffset       int64
	Off_RegionEntry_Length           int64
	Off_RegionEntry_IsRequired       int64
}

func NewVHDXProfile

func NewVHDXProfile() *VHDXProfile

func (*VHDXProfile) BATEntry

func (self *VHDXProfile) BATEntry(reader io.ReaderAt, offset int64) *BATEntry

func (*VHDXProfile) FileParameters

func (self *VHDXProfile) FileParameters(reader io.ReaderAt, offset int64) *FileParameters

func (*VHDXProfile) FileType

func (self *VHDXProfile) FileType(reader io.ReaderAt, offset int64) *FileType

func (*VHDXProfile) GUID

func (self *VHDXProfile) GUID(reader io.ReaderAt, offset int64) *GUID

func (*VHDXProfile) Header

func (self *VHDXProfile) Header(reader io.ReaderAt, offset int64) *Header

func (*VHDXProfile) Metadata

func (self *VHDXProfile) Metadata(reader io.ReaderAt, offset int64) *Metadata

func (*VHDXProfile) MetadataEntry

func (self *VHDXProfile) MetadataEntry(reader io.ReaderAt, offset int64) *MetadataEntry

func (*VHDXProfile) Misc

func (self *VHDXProfile) Misc(reader io.ReaderAt, offset int64) *Misc

func (*VHDXProfile) Region

func (self *VHDXProfile) Region(reader io.ReaderAt, offset int64) *Region

func (*VHDXProfile) RegionEntry

func (self *VHDXProfile) RegionEntry(reader io.ReaderAt, offset int64) *RegionEntry

Jump to

Keyboard shortcuts

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