core

package
v0.0.0-...-eb4ac69 Latest Latest
Warning

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

Go to latest
Published: May 3, 2018 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abort

func Abort(err error)

func AddErrorInfo

func AddErrorInfo(err error, format string, args ...interface{}) error

func CheckedMain

func CheckedMain(main_task_func Handler)

func ClearBuffer

func ClearBuffer(b []byte)

func Concat

func Concat(s1 []int64, s2 []int) []int64

func DecodeInt

func DecodeInt(b []byte) int64

func DecodeString

func DecodeString(b []byte, sz int) string

func DeferedCall

func DeferedCall(defered_func Handler)

func DiscardPanic

func DiscardPanic()

func EnsureWrapped

func EnsureWrapped(err error) error

func FillBuffer

func FillBuffer(b []byte, v byte)

func FprintBytes

func FprintBytes(w io.Writer, b []byte)

func FprintStruct

func FprintStruct(w io.Writer, value interface{})

func GetDirectory

func GetDirectory() (string, error)

func GetPartition

func GetPartition() string

func GetSource

func GetSource(err error) error

func IsEof

func IsEof(err error) bool

func IsWrapped

func IsWrapped(err error) bool

func NewFileId

func NewFileId() string

func OnError

func OnError(h func(error))

func OpenFile

func OpenFile(path string, mode OpenMode) (*os.File, error)

func PrintBoot

func PrintBoot(disk_name string)

func PrintBytes

func PrintBytes(b []byte)

func PrintError

func PrintError(err error)

func PrintStruct

func PrintStruct(value interface{})

func Read

func Read(buffer []byte, data interface{}) error

func ReadRecord

func ReadRecord(decoder IDecoder) (data.IDataRecord, error)

func Recover

func Recover(h func(error))

func StringSize

func StringSize(s string) int

func StructSize

func StructSize(value interface{}) int

func ToBool

func ToBool(v string) (bool, error)

func ToInt

func ToInt(v string) (int64, error)

func WinDiskPath

func WinDiskPath(letter rune) string

func WrapError

func WrapError(err error) error

func Write

func Write(writer io.Writer, data interface{}) error

func WriteRecord

func WriteRecord(encoder IEncoder, record data.IDataRecord) error

Types

type Args

type Args map[string]string

func GetArgs

func GetArgs() Args

func (Args) Bool

func (self Args) Bool(key string) bool

func (Args) BoolDef

func (self Args) BoolDef(key string, default_value bool) bool

func (Args) BoolExt

func (self Args) BoolExt(key string) (bool, bool)

func (Args) BoolFull

func (self Args) BoolFull(key string) (bool, bool, error)

func (Args) Idx

func (self Args) Idx(key string) int64

func (Args) IdxDef

func (self Args) IdxDef(key string, default_value int64) int64

func (Args) IdxExt

func (self Args) IdxExt(key string) (int64, bool)

func (Args) IdxFull

func (self Args) IdxFull(key string) (int64, bool, error)

func (Args) Int

func (self Args) Int(key string) int64

func (Args) IntDef

func (self Args) IntDef(key string, default_value int64) int64

func (Args) IntExt

func (self Args) IntExt(key string) (int64, bool)

func (Args) IntFull

func (self Args) IntFull(key string) (int64, bool, error)

type AttrFlag

type AttrFlag uint16
const (
	AFLAG_NONE AttrFlag = iota
	AFLAG_COMPRESSED
)

type AttributeDefinition

type AttributeDefinition struct {
	AttributeName   [64]Char
	AttributeNumber uint32
	Unknown         [2]uint32
	Flags           uint32
	MinimumSize     uint64
	MaximumSize     uint64
}

type AttributeDesc

type AttributeDesc struct {
	Record  *FileRecord
	Header  *AttributeHeader
	Index   int
	Name    string
	Desc    interface{}
	RunList RunList
}

func (*AttributeDesc) GetRunList

func (self *AttributeDesc) GetRunList() RunList

func (*AttributeDesc) GetSize

func (self *AttributeDesc) GetSize() uint64

func (*AttributeDesc) GetValue

func (self *AttributeDesc) GetValue(io *DiskIO) (*AttributeValue, error)

func (*AttributeDesc) NonResidentDesc

func (self *AttributeDesc) NonResidentDesc() *NonResidentAttribute

func (*AttributeDesc) ResidentDesc

func (self *AttributeDesc) ResidentDesc() *ResidentAttribute

type AttributeHeader

type AttributeHeader struct {
	AttributeType   AttributeType
	Length          uint32
	NonResident     Boolean
	NameLength      uint8
	NameOffset      uint16
	Flags           AttrFlag
	AttributeNumber uint16
}

type AttributeListAttribute

type AttributeListAttribute struct {
	AttributeType       AttributeType
	Length              uint16
	NameLength          uint8
	NameOffset          uint8
	LowVcn              ClusterNumber
	FileReferenceNumber uint64
	AttributeNumber     uint16
	AlignmentOrReserved [3]uint16
}

type AttributeType

type AttributeType uint32
const (
	ATTR_NONE                  AttributeType = 0x00000000
	ATTR_STANDARD_INFORMATION  AttributeType = 0x00000010
	ATTR_ATTRIBUTE_LIST        AttributeType = 0x00000020
	ATTR_FILE_NAME             AttributeType = 0x00000030
	ATTR_OBJECT_ID             AttributeType = 0x00000040
	ATTR_SECURITY_DESCRIPTOR   AttributeType = 0x00000050
	ATTR_VOLUME_NAME           AttributeType = 0x00000060
	ATTR_VOLUME_INFORMATION    AttributeType = 0x00000070
	ATTR_DATA                  AttributeType = 0x00000080
	ATTR_INDEX_ROOT            AttributeType = 0x00000090
	ATTR_INDEX_ALLOCATION      AttributeType = 0x000000A0
	ATTR_BITMAP                AttributeType = 0x000000B0
	ATTR_REPARSE_POINT         AttributeType = 0x000000C0
	ATTR_EA_INFORMATION        AttributeType = 0x000000D0
	ATTR_EA                    AttributeType = 0x000000E0
	ATTR_PROPERTY_SET          AttributeType = 0x000000F0
	ATTR_LOGGED_UTILITY_STREAM AttributeType = 0x00000100
	ATTR_END_OF_ATTRIBUTES     AttributeType = 0xFFFFFFFF
)

func (AttributeType) IsGood

func (self AttributeType) IsGood() bool

func (AttributeType) NewAttribute

func (self AttributeType) NewAttribute() interface{}

func (AttributeType) String

func (self AttributeType) String() string

type AttributeTypeFilter

type AttributeTypeFilter map[AttributeType]bool

func MakeAttributeTypeFilter

func MakeAttributeTypeFilter(first AttributeType, others []AttributeType) AttributeTypeFilter

type AttributeValue

type AttributeValue struct {
	Desc     *AttributeDesc
	FirstLCN ClusterNumber
	Content  DataZone
	Data     DataZone
	Size     int
	Value    interface{}
}

func (*AttributeValue) GetFilename

func (self *AttributeValue) GetFilename() string

func (*AttributeValue) GetFirstEntry

func (self *AttributeValue) GetFirstEntry() (*DirectoryEntry, error)

func (*AttributeValue) GetIndexBlock

func (self *AttributeValue) GetIndexBlock(entry_position uint) (IndexValue, error)

func (*AttributeValue) GetIndexBlockFromEntry

func (self *AttributeValue) GetIndexBlockFromEntry(entry *DirectoryEntry) (IndexValue, error)

func (*AttributeValue) GetNextEntry

func (self *AttributeValue) GetNextEntry(entry *DirectoryEntry) (*DirectoryEntry, error)

func (*AttributeValue) GetParent

func (self *AttributeValue) GetParent() data.FileRef

func (*AttributeValue) IsLongName

func (self *AttributeValue) IsLongName() bool

type Boolean

type Boolean byte
const (
	BOOL_FALSE Boolean = iota
	BOOL_TRUE
)

func (Boolean) Value

func (b Boolean) Value() bool

type BootBlock

type BootBlock struct {
	Jump                  [3]Byte
	Format                BootFormat
	BytesPerSector        uint16
	SectorsPerCluster     uint8
	BootSectors           uint16
	Mbz1                  uint8
	Mbz2                  uint16
	Reserved1             uint16
	MediaType             uint8
	Mbz3                  uint16
	SectorsPerTrack       uint16
	NumberOfHeads         uint16
	PartitionOffset       uint32
	Reserved2             [2]uint32
	TotalSectors          uint64
	MftStartLcn           ClusterNumber
	Mft2StartLcn          ClusterNumber
	ClustersPerFileRecord uint32
	ClustersPerIndexBlock uint32
	VolumeSerialNumber    uint64
	Code                  BootCode
	BootSignature         uint16
}

type BootCode

type BootCode [0x1AE]byte

func (BootCode) String

func (bc BootCode) String() string

type BootFormat

type BootFormat [8]byte

func (BootFormat) String

func (bf BootFormat) String() string

type Byte

type Byte byte

func (Byte) String

func (self Byte) String() string

type Char

type Char uint16

type ClusterNumber

type ClusterNumber uint64

func (ClusterNumber) GetPosition

func (self ClusterNumber) GetPosition(d *DiskIO) int64

func (ClusterNumber) String

func (self ClusterNumber) String() string

type DataZone

type DataZone []byte

func (DataZone) String

func (dz DataZone) String() string

type DirEntryFlag

type DirEntryFlag uint32
const (
	DEFLAG_NONE DirEntryFlag = iota
	DEFLAG_HAS_TRAILING
	DEFLAG_LAST_ENTRY
)

func (DirEntryFlag) String

func (self DirEntryFlag) String() string

type DirFlag

type DirFlag uint32
const (
	DFLAG_SMALL_DIR DirFlag = iota
	DFLAG_LARGE_DIR
)

type DirectoryEntry

type DirectoryEntry struct {
	DirectoryEntryExtendedHeader

	Index       *DirectoryIndex
	Name        string
	BlockOffset uint
	EntryOffset uint
}

type DirectoryEntryExtendedHeader

type DirectoryEntryExtendedHeader struct {
	DirectoryEntryHeader

	Vcn ClusterNumber // VCN in IndexAllocation of earlier entries
}

func (*DirectoryEntryExtendedHeader) MakeEntry

func (self *DirectoryEntryExtendedHeader) MakeEntry(block_offset, entry_offset uint) *DirectoryEntry

type DirectoryEntryHeader

type DirectoryEntryHeader struct {
	FileReferenceNumber data.FileRef
	Length              uint16
	AttributeLength     uint16
	Flags               DirEntryFlag
	ParentFileRefNum    data.FileRef
	CreationTime        Timestamp
	LastModifiedTime    Timestamp
	MFTRecordChangeTime Timestamp
	LastAccessTime      Timestamp
	PhysicalSize        uint64
	LogicalSize         uint64
	FileFlags           FileAttrFlag
	ExtendedAttributes  uint32
	FilenameLength      uint8
	FilenameType        uint8
}

func (*DirectoryEntryHeader) DecodeFilename

func (self *DirectoryEntryHeader) DecodeFilename(data []byte) string

func (*DirectoryEntryHeader) ExtendsHeader

func (self *DirectoryEntryHeader) ExtendsHeader() *DirectoryEntryExtendedHeader

func (*DirectoryEntryHeader) ExtendsHeaderFromData

func (self *DirectoryEntryHeader) ExtendsHeaderFromData(data []byte) (*DirectoryEntryExtendedHeader, error)

func (*DirectoryEntryHeader) ExtendsHeaderWithVcn

func (self *DirectoryEntryHeader) ExtendsHeaderWithVcn(vcn ClusterNumber) *DirectoryEntryExtendedHeader

func (*DirectoryEntryHeader) MakeEntry

func (self *DirectoryEntryHeader) MakeEntry(block_offset, entry_offset uint) *DirectoryEntry

type DirectoryIndex

type DirectoryIndex struct {
	EntriesOffset    uint32
	IndexBlockLength uint32
	AllocatedSize    uint32
	Flags            DirFlag
}

type DiskIO

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

func OpenDisk

func OpenDisk(name string) (*DiskIO, error)

func (*DiskIO) Close

func (self *DiskIO) Close() error

func (*DiskIO) GetOffset

func (self *DiskIO) GetOffset() int64

func (*DiskIO) ReadCluster

func (self *DiskIO) ReadCluster(position int64, data []byte) error

func (*DiskIO) ReadClusters

func (self *DiskIO) ReadClusters(position, count int64, data []byte) error

func (*DiskIO) ReadSector

func (self *DiskIO) ReadSector(position int64, data []byte) error

func (*DiskIO) ReadSectors

func (self *DiskIO) ReadSectors(position, count int64, data []byte) error

func (*DiskIO) ReadStruct

func (self *DiskIO) ReadStruct(position int64, ptr interface{}) error

func (*DiskIO) SetOffset

func (self *DiskIO) SetOffset(offset int64)

func (*DiskIO) Shift

func (self *DiskIO) Shift(offset int64) *DiskIO

type EaAttribute

type EaAttribute struct {
	NextEntryOffset uint32
	Flags           uint8
	EaNameLength    uint8
	EaValueLength   uint16
}

type EaInformationAttribute

type EaInformationAttribute struct {
	EaLength      uint32
	EaQueryLength uint32
}

type FileAttrFlag

type FileAttrFlag uint32
const (
	FAFLAG_NONE                    FileAttrFlag = 0x00000000
	FAFLAG_READONLY                FileAttrFlag = 0x00000001
	FAFLAG_HIDDEN                  FileAttrFlag = 0x00000002
	FAFLAG_SYSTEM                  FileAttrFlag = 0x00000004
	FAFLAG_DIRECTORY               FileAttrFlag = 0x00000010
	FAFLAG_ARCHIVE                 FileAttrFlag = 0x00000020
	FAFLAG_DEVICE                  FileAttrFlag = 0x00000040
	FAFLAG_NORMAL                  FileAttrFlag = 0x00000080
	FAFLAG_TEMPORARY               FileAttrFlag = 0x00000100
	FAFLAG_SPARSE_FILE             FileAttrFlag = 0x00000200
	FAFLAG_REPARSE_POINT           FileAttrFlag = 0x00000400
	FAFLAG_COMPRESSED              FileAttrFlag = 0x00000800
	FAFLAG_OFFLINE                 FileAttrFlag = 0x00001000
	FAFLAG_NOT_CONTENT_INDEXED     FileAttrFlag = 0x00002000
	FAFLAG_ENCRYPTED               FileAttrFlag = 0x00004000
	FAFLAG_INTEGRITY_STREAM        FileAttrFlag = 0x00008000
	FAFLAG_VIRTUAL                 FileAttrFlag = 0x00010000
	FAFLAG_NO_SCRUB_DATA           FileAttrFlag = 0x00020000
	FAFLAG_DUP_FNAME_INDEX_PRESENT FileAttrFlag = 0x10000000
	FAFLAG_DUP_VIEW_INDEX_PRESENT  FileAttrFlag = 0x20000000
)

func (FileAttrFlag) String

func (self FileAttrFlag) String() string

type FileFlag

type FileFlag uint16
const (
	FFLAG_NONE FileFlag = iota
	FFLAG_IN_USE
	FFLAG_DIRECTORY
)

func (FileFlag) String

func (self FileFlag) String() string

type FileRecord

type FileRecord struct {
	RecordHeader

	SequenceNumber      uint16
	LinkCount           uint16
	AttributesOffset    uint16
	Flags               FileFlag
	BytesInUse          uint32
	BytesAllocated      uint32
	BaseFileRecord      uint64
	NextAttributeNumber uint16
	Reserved            uint16
	MftRecordNumber     uint32
	Data                FileRecordData
}

func (*FileRecord) FileRef

func (self *FileRecord) FileRef() data.FileRef

func (*FileRecord) GetAttributeFilteredList

func (self *FileRecord) GetAttributeFilteredList(attr_type AttributeType, other_types ...AttributeType) []int

func (*FileRecord) GetAttributes

func (self *FileRecord) GetAttributes(filter bool) (map[int]*AttributeHeader, error)

func (*FileRecord) GetFilename

func (self *FileRecord) GetFilename(disk *DiskIO) (string, error)

func (*FileRecord) IsDir

func (self *FileRecord) IsDir() bool

func (*FileRecord) MakeAttributeFromHeader

func (self *FileRecord) MakeAttributeFromHeader(header *AttributeHeader) (*AttributeDesc, error)

func (*FileRecord) MakeAttributeFromOffset

func (self *FileRecord) MakeAttributeFromOffset(offset int) (*AttributeDesc, error)

func (*FileRecord) PrefixSize

func (self *FileRecord) PrefixSize() int

type FileRecordData

type FileRecordData [976]byte

func (FileRecordData) String

func (FileRecordData) String() string

type FilenameAttribute

type FilenameAttribute struct {
	DirectoryFileReferenceNumber data.FileRef
	CreationTime                 Timestamp
	ChangeTime                   Timestamp
	LastWriteTime                Timestamp
	LastAccessTime               Timestamp
	AllocatedSize                uint64
	DataSize                     uint64
	FileAttributes               FileAttrFlag
	AlignmentOrReserved          uint32
	NameLength                   uint8
	NameType                     NameType
}

type Handler

type Handler func() error

type IDecoder

type IDecoder interface {
	Decode() (interface{}, error)
}

type IEncoder

type IEncoder interface {
	Encode(interface{}) error
}

type IndexBlockHeader

type IndexBlockHeader struct {
	RecordHeader

	IndexBlockVcn  ClusterNumber
	DirectoryIndex DirectoryIndex
}

func (*IndexBlockHeader) Entries

func (self *IndexBlockHeader) Entries(data []byte) (map[int]*DirectoryEntryExtendedHeader, error)

func (*IndexBlockHeader) IndexType

func (*IndexBlockHeader) IndexType() IndexType

func (*IndexBlockHeader) PrefixSize

func (self *IndexBlockHeader) PrefixSize() int

type IndexRootAttribute

type IndexRootAttribute struct {
	Type                  AttributeType
	CollationRule         uint32
	BytesPerIndexBlock    uint32
	ClustersPerIndexBlock uint32
	DirectoryIndex        DirectoryIndex
}

func (*IndexRootAttribute) IndexType

func (*IndexRootAttribute) IndexType() IndexType

type IndexType

type IndexType uint8
const (
	INDEX_TYPE_NONE IndexType = iota
	INDEX_TYPE_ROOT
	INDEX_TYPE_BLOCK
)

func (IndexType) String

func (self IndexType) String() string

type IndexValue

type IndexValue interface {
	IndexType() IndexType
}

type NameType

type NameType uint8
const (
	NANE_TYPE_EXTENDED NameType = iota // POSIX (largest namespace)
	NAME_TYPE_LONG                     // WIN32
	NAME_TYPE_SHORT                    // DOS
	NAME_TYPE_SAME                     // WIN32 and DOS
)

func (NameType) String

func (self NameType) String() string

type NonResidentAttribute

type NonResidentAttribute struct {
	AttributeHeader

	LowVcn              ClusterNumber
	HighVcn             ClusterNumber
	RunArrayOffset      uint16
	CompressionUnit     uint8
	AlignmentOrReserved [5]uint8
	AllocatedSize       uint64
	DataSize            uint64
	InitializedSize     uint64
	CompressedSize      uint64
}

type OpenMode

type OpenMode byte
const (
	OPEN_RDONLY OpenMode = iota
	OPEN_WRONLY
	OPEN_RDWR
	OPEN_APPEND
)

type RecordHeader

type RecordHeader struct {
	Type      RecordType
	UsaOffset uint16
	UsaCount  uint16
	Usn       Usn
}

type RecordType

type RecordType uint32
const (
	RECTYP_NONE RecordType = 0x00000000
	RECTYP_FILE RecordType = 0x454C4946 // 'FILE'
	RECTYP_INDX RecordType = 0x58444E49 // 'INDX'
	RECTYP_BAAD RecordType = 0x44414142 // 'BAAD'
	RECTYP_HOLE RecordType = 0x454C4F48 // 'HOLE'
	RECTYP_CHKD RecordType = 0x444B4843 // 'CHKD'
)

func RecordTypeFromBytes

func RecordTypeFromBytes(s []byte) RecordType

func RecordTypeFromString

func RecordTypeFromString(s string) RecordType

func (RecordType) Bytes

func (self RecordType) Bytes() ([]byte, error)

func (RecordType) IsGood

func (self RecordType) IsGood() bool

func (RecordType) String

func (self RecordType) String() string

type ReparsePointAttribute

type ReparsePointAttribute struct {
	ReparseTag        uint32
	ReparseDataLength uint16
	Reserved          uint16
	ReparseData       [1]byte
}

type ResidentAttrFlag

type ResidentAttrFlag uint16
const (
	RAFLAG_NONE ResidentAttrFlag = iota
	RAFLAG_INDEXED
)

type ResidentAttribute

type ResidentAttribute struct {
	AttributeHeader

	ValueLength uint32
	ValueOffset uint16
	Flags       ResidentAttrFlag
}

type RunEntry

type RunEntry struct {
	Start ClusterNumber
	Count int64
	Zero  bool
}

func (*RunEntry) GetLast

func (self *RunEntry) GetLast() ClusterNumber

func (*RunEntry) GetNext

func (self *RunEntry) GetNext() ClusterNumber

func (*RunEntry) String

func (self *RunEntry) String() string

type RunList

type RunList []*RunEntry

type StandardInformationAttribute

type StandardInformationAttribute struct {
	CreationTime                 Timestamp
	ChangeTime                   Timestamp
	LastWriteTime                Timestamp
	LastAccessTime               Timestamp
	FileAttributes               FileAttrFlag
	AlignmentOrReservedOrUnknown [3]uint32
	QuotaId                      uint32
	SecurityId                   uint32
	QuotaCharge                  uint64
	USN                          Usn
}

type Timestamp

type Timestamp uint64

func (Timestamp) Decode

func (self Timestamp) Decode() (sec, nano int64)

func (Timestamp) String

func (self Timestamp) String() string

func (Timestamp) Time

func (self Timestamp) Time() time.Time

type Usn

type Usn uint64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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