Documentation ¶
Overview ¶
package cfb implement a (MicroSoft) Compound File Binary File reader. Note that the focus is on access to data in CFBs so stuff concerning writing CFBs is omitted. This package rely on the document from https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/SupportTech/WindowsCompoundBinaryFileFormatSpecification.pdf Naming will be matched as closely as possible, though hungarian notation (default MS) is omitted.
Index ¶
- Constants
- Variables
- func FilePos(r io.Reader) (pos int64)
- func SortDirectories(dir []*DirectoryEntry)
- func UTF16String(b []uint16) (d string)
- type Directory
- type DirectoryEntry
- func (d *DirectoryEntry) Children() []*DirectoryEntry
- func (d *DirectoryEntry) FullName() string
- func (d *DirectoryEntry) ID() uint32
- func (d *DirectoryEntry) Level() uint32
- func (d *DirectoryEntry) Parent() *DirectoryEntry
- func (d *DirectoryEntry) Stream() (s *Stream, err error)
- func (d *DirectoryEntry) Walk(f func(d *DirectoryEntry))
- type Document
- type FILETIME
- type Fat
- type GUID
- type Header
- type Sector
- type Stream
- func (s *Stream) AsUnicode() (r io.Reader)
- func (s *Stream) Close() (err error)
- func (s *Stream) Len() uint32
- func (s *Stream) Read(dst []byte) (n int, err error)
- func (s *Stream) ReadString() (v string, err error)
- func (s *Stream) ReadUint16() (v uint16, err error)
- func (s *Stream) ReadUint32() (v uint32, err error)
- func (s *Stream) ReadUint64() (v uint64, err error)
- func (s *Stream) ReadUint8() (v uint8, err error)
- func (s *Stream) ReadUnicode() (v string, err error)
- func (s *Stream) Sectors() uint32
- func (s *Stream) Seek(offset int64, whence int) (n int64, err error)
Constants ¶
View Source
const ( // REGSECT 0x00000000 - 0xFFFFFFF9 Regular sector number. MAXREGSECT uint32 = 0xFFFFFFFA // Maximum regular sector number. NotApplicable = 0xFFFFFFFB // Reserved for future use. DIFSECT = 0xFFFFFFFC // Specifies a DIFAT sector in the FAT. FATSECT = 0xFFFFFFFD // Specifies a FAT sector in the FAT. ENDOFCHAIN = 0xFFFFFFFE // End of a linked chain of sectors. FREESECT = 0xFFFFFFFF // Specifies an unallocated sector in the FAT, Mini FAT, or DIFAT. )
View Source
const ( STGTY_INVALID byte = 0 // empty directory entry STGTY_STORAGE = 1 // element is a storage object STGTY_STREAM = 2 // element is a stream object STGTY_LOCKBYTES = 3 // element is an ILockBytes object STGTY_PROPERTY = 4 // element is an IPropertyStorage object STGTY_ROOT = 5 // element is a root storage )
Object types in storage (from AAF specifications)
View Source
const ( DE_RED byte = 0 DE_BLACK = 1 )
View Source
const ( MAXREGSID uint32 = 0xFFFFFFFA // (-6) maximum directory entry ID NOSTREAM uint32 = 0xFFFFFFFF // (-1) unallocated directory entry )
Directory Entry IDs (from AAF specifications)
Variables ¶
View Source
var ( ErrDoNotUse = errors.New("Do not use") ErrSignature = errors.New("Bad signature") ErrCLSID = errors.New("Bad header CLSID") ErrVersion = errors.New("Bad version") ErrSectorShift = errors.New("Invalid sector shift, expected 9 or 12") ErrMiniSectorShift = errors.New("Invalid mini sector shift, expected 6") ErrMiniSectorCutoff = errors.New("Incorrect MiniStreamCutoffSize") ErrStorageType = errors.New("Unknown storage type") ErrStorageSize = errors.New("Unknown storage size") ErrNameLength = errors.New("Invalid name property length") ErrSeekIndex = errors.New("Bad seek index") ErrSectorSize = errors.New("Bad sector read") ErrRootSibling = errors.New("Root directory has illegal siblings") ErrNotStream = errors.New("Entry is not a stream") )
View Source
var Signature = [8]byte{0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1}
Functions ¶
func SortDirectories ¶
func SortDirectories(dir []*DirectoryEntry)
func UTF16String ¶
Types ¶
type Directory ¶
type Directory struct { NameUTF16 [32]uint16 NameLength uint16 Type byte Flags byte // DECOLOR (Red/Black-tree color, red=0) LeftSibling uint32 RightSibling uint32 Child uint32 CLSID GUID // If Type=STGTY_STORAGE UserFlags uint32 // If Type=STGTY_STORAGE Time [2]FILETIME Start uint32 Size uint32 PropType uint16 }
Directory is an OLE directory entry header. Names are not really kept here as they are not clearly descibing the field.
type DirectoryEntry ¶
type DirectoryEntry struct { Directory // contains filtered or unexported fields }
func NewDirectoryEntry ¶
func NewDirectoryEntry(d *Document, s *Stream) (dir *DirectoryEntry, err error)
func (*DirectoryEntry) Children ¶
func (d *DirectoryEntry) Children() []*DirectoryEntry
func (*DirectoryEntry) FullName ¶
func (d *DirectoryEntry) FullName() string
func (*DirectoryEntry) ID ¶
func (d *DirectoryEntry) ID() uint32
func (*DirectoryEntry) Level ¶
func (d *DirectoryEntry) Level() uint32
func (*DirectoryEntry) Parent ¶
func (d *DirectoryEntry) Parent() *DirectoryEntry
func (*DirectoryEntry) Stream ¶
func (d *DirectoryEntry) Stream() (s *Stream, err error)
func (*DirectoryEntry) Walk ¶
func (d *DirectoryEntry) Walk(f func(d *DirectoryEntry))
type Document ¶
type Document struct { Header // contains filtered or unexported fields }
func NewFromFile ¶
func (*Document) Root ¶
func (d *Document) Root() (root *DirectoryEntry, err error)
func (*Document) Walk ¶
func (d *Document) Walk(f func(d *DirectoryEntry))
type Header ¶
type Header struct { Signature [8]byte CLSID GUID MinorVersion uint16 MajorVersion uint16 ByteOrder uint16 SectorShift uint16 MiniSectorShift uint16 SectFAT uint32 SectDirStart uint32 MiniSectorCutoff uint32 MiniFatStart uint32 MiniFat uint32 DifStart uint32 Dif uint32 Fat [109]uint32 // Double Indexed Fat // contains filtered or unexported fields }
Header the OLE file header.
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
func (*Stream) ReadString ¶
func (*Stream) ReadUint16 ¶
func (*Stream) ReadUint32 ¶
func (*Stream) ReadUint64 ¶
func (*Stream) ReadUnicode ¶
Click to show internal directories.
Click to hide internal directories.