absdb

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package absdb reads ComponentAce Absolute Database (.abs) files.

The binary format is reverse-engineered from real .abs files and the C++ header files shipped with the Absolute Database SDK.

Index

Constants

View Source
const (
	PageTypeSystemDir = 2  // System directory
	PageTypeFileHdr   = 3  // File header (page 0)
	PageTypeSchema    = 8  // Schema metadata (zlib-compressed column defs)
	PageTypeData      = 10 // Data page (row storage)
	PageTypeIndex     = 12 // B-tree index page
)

Page type constants from the TABSDiskPageHeader.PageType field.

View Source
const (
	// PageTypeBlob is the page type for BLOB data storage.
	PageTypeBlob = 11
)

Variables

View Source
var (
	ErrNotABS         = errors.New("absdb: not an Absolute Database file")
	ErrTruncated      = errors.New("absdb: file is truncated")
	ErrPageOutOfRange = errors.New("absdb: page number out of range")
)
View Source
var (
	ErrBlobNotFound = fmt.Errorf("absdb: BLOB data not found")
	ErrBlobTrunc    = fmt.Errorf("absdb: BLOB data truncated")
)
View Source
var (
	ErrNoIndex     = errors.New("absdb: no index found")
	ErrKeyNotFound = errors.New("absdb: key not found")
)
View Source
var (
	ErrNoData     = errors.New("absdb: no data pages found")
	ErrNoMoreRows = errors.New("absdb: no more rows")
)
View Source
var (
	ErrNoSchema    = errors.New("absdb: no schema page found")
	ErrBadSchema   = errors.New("absdb: malformed schema data")
	ErrCompression = errors.New("absdb: decompression failed")
)
View Source
var ErrUnsupportedCipher = errors.New("absdb: unsupported encryption algorithm")

ErrUnsupportedCipher indicates an unsupported encryption algorithm.

View Source
var ErrWrongPassword = errors.New("absdb: incorrect password")

ErrWrongPassword indicates the provided password does not match.

View Source
var Magic = [16]byte{
	'A', 'B', 'S', '0', 'L', 'U', 'T', 'E',
	'D', 'A', 'T', 'A', 'B', 'A', 'S', 'E',
}

Magic is the 16-byte file signature: "ABS0LUTEDATABASE" (note: zero, not letter O).

Functions

This section is empty.

Types

type BTreeEntry

type BTreeEntry struct {
	Key    []byte // key bytes (KeyPrefixSize bytes)
	PageNo int32  // referenced page number
	ItemNo uint16 // referenced item number within the page
}

BTreeEntry is a single entry in an index page.

func (BTreeEntry) RecordID

func (e BTreeEntry) RecordID() (int32, uint16)

RecordID returns the entry's reference as a (PageNo, ItemNo) pair.

type BTreePageHeader

type BTreePageHeader struct {
	IsRoot         bool
	IsLeaf         bool
	LeftPageNo     int32 // left sibling page (-1 = none)
	RightPageNo    int32 // right sibling page (-1 = none)
	HasKeys        bool
	HasSuffixes    bool
	KeyPrefixSize  uint16 // key size per entry (short key)
	EntryCount     uint16 // number of entries on this page
	PagePrefixSize uint16 // page-level prefix size
}

BTreePageHeader is the on-disk header at the start of every index page body.

type BaseFieldType

type BaseFieldType byte

BaseFieldType represents the low-level storage type (TABSBaseFieldType).

const (
	BftUnknown     BaseFieldType = 0
	BftChar        BaseFieldType = 1
	BftWideChar    BaseFieldType = 2
	BftVarchar     BaseFieldType = 3
	BftWideVarchar BaseFieldType = 4
	BftInt8        BaseFieldType = 5
	BftInt16       BaseFieldType = 6
	BftInt32       BaseFieldType = 7
	BftInt64       BaseFieldType = 8
	BftUint8       BaseFieldType = 9
	BftUint16      BaseFieldType = 10
	BftUint32      BaseFieldType = 11
	BftSingle      BaseFieldType = 12
	BftDouble      BaseFieldType = 13
	BftExtended    BaseFieldType = 14
	BftDate        BaseFieldType = 15
	BftTime        BaseFieldType = 16
	BftDateTime    BaseFieldType = 17
	BftBlob        BaseFieldType = 18
	BftClob        BaseFieldType = 19
	BftWideClob    BaseFieldType = 20
	BftLogical     BaseFieldType = 21
	BftCurrency    BaseFieldType = 22
	BftBytes       BaseFieldType = 23
	BftVarBytes    BaseFieldType = 24
)

type BlobRef

type BlobRef struct {
	PageNo int32  // page number where BLOB data starts
	ItemNo uint16 // item number within the page (usually 0)
}

BlobRef is a reference to BLOB data stored in a record field.

func (BlobRef) IsNull

func (ref BlobRef) IsNull() bool

IsNull returns true if the BLOB reference points to no data.

type Column

type Column struct {
	Name      string        // column name
	ID        uint32        // internal column ID
	BaseType  BaseFieldType // low-level storage type
	FieldType FieldType     // high-level field type
	Size      uint32        // max size for variable-length types (string length, etc.)
	Position  int           // 0-based position in the column list
}

Column describes a single column in a table.

func (Column) IsBLOB

func (c Column) IsBLOB() bool

IsBLOB returns true if this column stores BLOB data (Memo, Graphic, etc.).

type CryptoAlgorithm

type CryptoAlgorithm byte

CryptoAlgorithm identifies the encryption algorithm (TABSCryptoAlgorithm).

const (
	CryptoRijndael128 CryptoAlgorithm = 0
	CryptoRijndael256 CryptoAlgorithm = 1
	CryptoDESSingle   CryptoAlgorithm = 2
	CryptoDESTriple   CryptoAlgorithm = 3
	CryptoBlowfish    CryptoAlgorithm = 4
	CryptoTwofish128  CryptoAlgorithm = 5
	CryptoTwofish256  CryptoAlgorithm = 6
	CryptoSquare      CryptoAlgorithm = 7
)

type CryptoHeader

type CryptoHeader struct {
	HeaderSize   int16
	Algorithm    CryptoAlgorithm
	Mode         byte
	ControlBlock [controlBlockSize]byte
	ControlCRC   uint32
}

CryptoHeader holds the parsed TABSCryptoHeader from page 0.

type DiskPageHeader

type DiskPageHeader struct {
	State      int32  // page state
	PageType   uint16 // page type (see PageType* constants)
	NextPageNo int32  // next page in chain (-1 = none)
	CRC32      uint32 // CRC32 checksum
	CRCType    byte
	HashType   byte
	CipherType byte
	MACType    byte
	ObjectID   int32  // table/object this page belongs to (-1 = system)
	RecPageNo  int32  // record ID: page number
	RecItemNo  uint16 // record ID: item number within page
}

DiskPageHeader is the 40-byte TABSDiskPageHeader found at offset 0x17C in every page.

type FieldType

type FieldType byte

FieldType represents the high-level field type (TABSAdvancedFieldType).

const (
	FieldUnknown       FieldType = 0
	FieldChar          FieldType = 1
	FieldString        FieldType = 2
	FieldWideChar      FieldType = 3
	FieldWideString    FieldType = 4
	FieldShortInt      FieldType = 5
	FieldSmallInt      FieldType = 6
	FieldInteger       FieldType = 7
	FieldLargeInt      FieldType = 8
	FieldByte          FieldType = 9
	FieldWord          FieldType = 10
	FieldCardinal      FieldType = 11
	FieldAutoInc       FieldType = 12
	FieldAutoIncInt8   FieldType = 13
	FieldAutoIncInt16  FieldType = 14
	FieldAutoIncInt32  FieldType = 15
	FieldAutoIncInt64  FieldType = 16
	FieldAutoIncUint8  FieldType = 17
	FieldAutoIncUint16 FieldType = 18
	FieldAutoIncUint32 FieldType = 19
	FieldSingle        FieldType = 20
	FieldDouble        FieldType = 21
	FieldExtended      FieldType = 22
	FieldBoolean       FieldType = 23
	FieldCurrency      FieldType = 24
	FieldDate          FieldType = 25
	FieldTime          FieldType = 26
	FieldDateTime      FieldType = 27
	FieldTimeStamp     FieldType = 28
	FieldBytes         FieldType = 29
	FieldVarBytes      FieldType = 30
	FieldBLOB          FieldType = 31
	FieldGraphic       FieldType = 32
	FieldMemo          FieldType = 33
	FieldFmtMemo       FieldType = 34
	FieldWideMemo      FieldType = 35
	FieldGUID          FieldType = 36
)

func (FieldType) String

func (ft FieldType) String() string

String returns the field type name.

type File

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

File represents an opened Absolute Database file.

func Open

func Open(path string) (*File, error)

Open opens an Absolute Database file for reading.

func OpenWithPassword

func OpenWithPassword(path, password string) (*File, error)

OpenWithPassword opens an encrypted Absolute Database file. If the file is not encrypted, the password is ignored. Returns ErrWrongPassword if the password doesn't match.

func (*File) Close

func (db *File) Close() error

Close closes the database file.

func (*File) CryptoHeader

func (db *File) CryptoHeader() *CryptoHeader

CryptoHeader returns the parsed crypto header, or nil if the file is not encrypted.

func (*File) Encrypted

func (db *File) Encrypted() bool

Encrypted returns true if the database is encrypted.

func (*File) OpenIndex

func (db *File) OpenIndex() (*IndexReader, error)

OpenIndex creates an IndexReader by scanning all index pages.

func (*File) OpenTable

func (db *File) OpenTable() (*Reader, error)

OpenTable creates a Reader for the table's data records.

func (*File) PageCount

func (db *File) PageCount() int

PageCount returns the total number of pages in the file.

func (*File) PageSize

func (db *File) PageSize() int

PageSize returns the page size in bytes.

func (*File) ReadBlob

func (db *File) ReadBlob(ref BlobRef) ([]byte, error)

ReadBlob reads the BLOB data for the given reference from the database. Returns the raw (decompressed) bytes. For Memo fields, convert to string.

func (*File) ReadPage

func (db *File) ReadPage(n int) (Page, error)

ReadPage reads a single page by its zero-based page number.

func (*File) ScanPages

func (db *File) ScanPages() ([]PageSummary, error)

ScanPages reads all pages and returns their disk page headers.

func (*File) Schema

func (db *File) Schema() (*TableSchema, error)

Schema reads and parses the table schema from the database file. For single-table databases, this returns the schema of the only table.

func (*File) VerifyPassword

func (db *File) VerifyPassword(password string) bool

VerifyPassword checks whether the given password is correct for this encrypted database. It decrypts the ControlBlock and compares its CRC32 with the stored value.

func (*File) Version

func (db *File) Version() float64

Version returns the database engine version (e.g. 5.13, 7.10, 7.61).

type IndexInfo

type IndexInfo struct {
	RootPageNo int  // root page of the B-tree
	KeySize    int  // key size in bytes
	EntryCount int  // total entries (for root-only trees)
	IsInternal bool // true for system indexes (RecordPage, BlobPage)
}

IndexInfo describes a discovered index.

type IndexReader

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

IndexReader provides index-based lookups on a table.

func (*IndexReader) FindByPrimaryKey

func (ir *IndexReader) FindByPrimaryKey(key int32) (dataPageNo int32, itemNo uint16, err error)

FindByPrimaryKey looks up a record by its primary key (AutoInc/RecNo value). Returns the data page number and item number, or ErrKeyNotFound.

func (*IndexReader) FindByStringKey

func (ir *IndexReader) FindByStringKey(value string) (dataPageNo int32, itemNo uint16, err error)

FindByStringKey searches a secondary string index for the given value. Uses the first secondary index found with matching key size.

func (*IndexReader) Indexes

func (ir *IndexReader) Indexes() []IndexInfo

Indexes returns information about all discovered indexes.

func (*IndexReader) PrimaryKeyIndex

func (ir *IndexReader) PrimaryKeyIndex() (*indexRoot, error)

PrimaryKeyIndex returns the root page info for the primary key index. The primary key index has 5-byte keys (1 null flag + 4-byte int32).

func (*IndexReader) ScanIndex

func (ir *IndexReader) ScanIndex(rootPageNo int) ([]BTreeEntry, error)

ScanIndex reads all entries from the specified index root page, following the B-tree leaf chain for multi-page indexes.

func (*IndexReader) SecondaryIndexes

func (ir *IndexReader) SecondaryIndexes() []IndexInfo

SecondaryIndexes returns root pages for non-system, non-primary indexes.

type Page

type Page struct {
	Number int
	Data   []byte
	Header *DiskPageHeader // nil if no ABSP marker found
}

Page represents a single page read from the database file.

func (Page) IsEmpty

func (p Page) IsEmpty() bool

IsEmpty returns true if the page contains only zero bytes.

func (Page) PageData

func (p Page) PageData() []byte

PageData returns the usable data portion of the page (after the disk page header).

type PageSummary

type PageSummary struct {
	Number int
	Empty  bool
	Header *DiskPageHeader
}

PageSummary is a lightweight summary of a scanned page.

type Reader

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

Reader iterates over data records in a table.

func (*Reader) Err

func (r *Reader) Err() error

Err returns any error encountered during iteration.

func (*Reader) Next

func (r *Reader) Next() bool

Next advances to the next record. Returns false when no more records.

func (*Reader) Record

func (r *Reader) Record() Record

Record returns the current record.

func (*Reader) Schema

func (r *Reader) Schema() *TableSchema

Schema returns the table schema.

type Record

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

Record represents a single data record.

func (Record) Blob

func (rec Record) Blob(col int) ([]byte, error)

Blob reads the BLOB data for the given column from the database. Returns the raw bytes. Returns nil for NULL BLOBs.

func (Record) BlobRef

func (rec Record) BlobRef(col int) BlobRef

BlobRef returns the BLOB reference for a BLOB/Memo/Graphic column.

func (Record) Bool

func (rec Record) Bool(col int) bool

Bool returns the boolean value of the column.

func (Record) Bytes

func (rec Record) Bytes(col int) []byte

Bytes returns the raw bytes for the column.

func (Record) Float

func (rec Record) Float(col int) float64

Float returns the float64 value of the column.

func (Record) Int

func (rec Record) Int(col int) int32

Int returns the int32 value of the column.

func (Record) Int64

func (rec Record) Int64(col int) int64

Int64 returns the int64 value of the column.

func (Record) IsNull

func (rec Record) IsNull(col int) bool

IsNull returns true if the column at the given index is null.

func (Record) Memo

func (rec Record) Memo(col int) (string, error)

Memo reads a Memo (text BLOB) column and returns it as a string. Returns empty string for NULL values.

func (Record) String

func (rec Record) String(col int) string

String returns the string value of the column, decoded from Windows-1252.

func (Record) Time

func (rec Record) Time(col int) time.Time

Time returns the time.Time value of a Date, Time, or DateTime column.

func (Record) Uint32

func (rec Record) Uint32(col int) uint32

Uint32 returns the uint32 value of the column.

type TableSchema

type TableSchema struct {
	Columns []Column
}

TableSchema holds the parsed schema for one table.

Directories

Path Synopsis
cmd
absdb command
Command absdb inspects and dumps ComponentAce Absolute Database (.abs) files.
Command absdb inspects and dumps ComponentAce Absolute Database (.abs) files.

Jump to

Keyboard shortcuts

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