ole2

package
v0.0.0-...-39865ca Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Unlicense Imports: 6 Imported by: 0

README

ole2

Microsoft Compound Document File Format library in Golang

Forked from https://github.com/extrame/ole2.

The ole code had major bugs. Slice bounds were not checked and caused crashes.

The code was adapted to resemble https://github.com/ElevenPaths/FOCA/blob/master/MetadataExtractCore/Metadata/OleDocument.cs. Alternative implementation for reference: https://github.com/sassoftware/relic/blob/4db78dcc59ae33d7565f3927e4c7bc8a86ee146c/lib/comdoc/msat.go

Documentation

Index

Constants

View Source
const (
	EMPTY       = iota
	USERSTORAGE = iota
	USERSTREAM  = iota
	LOCKBYTES   = iota
	PROPERTY    = iota
	ROOT        = iota
)

constants for directory

View Source
const (
	MSATSecID = iota - 4
	SATSecID
	EOFSecID
	FreeSecID
)

SecIDType

Variables

View Source
var DEBUG = false

DEBUG enables debug

Functions

This section is empty.

Types

type File

type File struct {
	NameBts   [32]uint16
	Bsize     uint16
	Type      byte
	Flag      byte
	Left      uint32
	Right     uint32
	Child     uint32
	GUID      [8]uint16
	Userflags uint32
	Time      [2]uint64
	Sstart    int32
	Size      uint32
	Proptype  uint32
}

File is an OLE file

func (*File) Name

func (d *File) Name() string

Name returns the file name

type Header struct {
	Signature         [2]uint32
	Clid              [4]uint32
	RevisionNumber    uint16
	VersionNumber     uint16
	ByteOrder         uint16
	SizeOfSector      uint16
	SizeOfShortSector uint16

	NumberOfSectorsSAT  uint32 //Total number of sectors used for the sector allocation table
	FirstSecIDDirectory int32  //SecID of first sector of the directory stream

	MinSizeOfStandardStream uint32 //Minimum size of a standard stream
	FirstSecIDSSAT          int32  //SecID of first sector of the short-sector allocation table
	NumberOfSectorsSSAT     uint32 //Total number of sectors used for the short-sector allocation table
	FirstSecIDMSAT          int32  //SecID of first sector of the master sector allocation table
	NumberOfSectorsMSAT     uint32 //Total number of sectors used for the master sector allocation table
	FirstPartOfMSAT         [109]int32
	// contains filtered or unexported fields
}

Header represents the OLE header

type Ole

type Ole struct {
	Lsector  uint32
	Lssector uint32
	SecID    []int32
	SSecID   []int32
	Files    []File
	// contains filtered or unexported fields
}

Ole represents an OLE file

func Open

func Open(reader io.ReadSeeker, charset string) (ole *Ole, err error)

func (*Ole) ListDir

func (o *Ole) ListDir() (dir []*File, err error)

func (*Ole) OpenFile

func (o *Ole) OpenFile(file *File, root *File) io.ReadSeeker

type PSS

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

type Sector

type Sector []byte

func (*Sector) AllValues

func (s *Sector) AllValues(size uint32) []int32

func (*Sector) MsatValues

func (s *Sector) MsatValues(size uint32) []int32

func (*Sector) NextSid

func (s *Sector) NextSid(size uint32) int32

func (*Sector) Uint32

func (s *Sector) Uint32(bit uint32) uint32

type StreamReader

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

StreamReader is an OLE stream reader

func (*StreamReader) Read

func (r *StreamReader) Read(p []byte) (n int, err error)

Read reads data from the stream into p

func (*StreamReader) Seek

func (r *StreamReader) Seek(offset int64, whence int) (offsetResult int64, err error)

Seek seeks the stream to the given offset

Jump to

Keyboard shortcuts

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