serz

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JAVA_BASE_WRITE_HANDLE uint32 = 0x7e0000

JAVA_BASE_WRITE_HANDLE First wire handle to be assigned.

View Source
var JAVA_SC_BLOCK_DATA byte = 0x08

JAVA_SC_BLOCK_DATA Bit mask for ObjectStreamClass flag. Indicates Externalizable data written in Block Data mode. Added for PROTOCOL_VERSION_2.

View Source
var JAVA_SC_ENUM byte = 0x10

JAVA_SC_ENUM Bit mask for ObjectStreamClass flag. Indicates class is an enum type.

View Source
var JAVA_SC_EXTERNALIZABLE byte = 0x04

JAVA_SC_EXTERNALIZABLE Bit mask for ObjectStreamClass flag. Indicates class is Externalizable.

View Source
var JAVA_SC_SERIALIZABLE byte = 0x02

JAVA_SC_SERIALIZABLE Bit mask for ObjectStreamClass flag. Indicates class is Serializable.

View Source
var JAVA_SC_WRITE_METHOD byte = 0x01

JAVA_SC_WRITE_METHOD Bit mask for ObjectStreamClass flag. Indicates a Serializable class defines its own writeObject method.

View Source
var JAVA_STREAM_MAGIC = []byte{0xAC, 0xED}

JAVA_STREAM_MAGIC Magic Number

View Source
var JAVA_STREAM_VERSION = []byte{0x00, 0x05}

JAVA_STREAM_VERSION Version number that is written to the stream header.

View Source
var JAVA_TC_ARRAY byte = 0x75

JAVA_TC_ARRAY new Array.

View Source
var JAVA_TC_BASE byte = 0x70

JAVA_TC_BASE First tag value.

View Source
var JAVA_TC_BLOCKDATA byte = 0x77

JAVA_TC_BLOCKDATA Block of optional data. Byte following tag indicates number of bytes in this block data.

View Source
var JAVA_TC_BLOCKDATALONG byte = 0x7A

JAVA_TC_BLOCKDATALONG long Block data. The long following the tag indicates the number of bytes in this block data.

View Source
var JAVA_TC_CLASS byte = 0x76

JAVA_TC_CLASS Reference to Class.

View Source
var JAVA_TC_CLASSDESC byte = 0x72

JAVA_TC_CLASSDESC new Class Descriptor.

View Source
var JAVA_TC_ENDBLOCKDATA byte = 0x78

JAVA_TC_ENDBLOCKDATA End of optional block data blocks for an object.

View Source
var JAVA_TC_ENUM byte = 0x7E

JAVA_TC_ENUM new Enum constant.

View Source
var JAVA_TC_EXCEPTION byte = 0x7B

JAVA_TC_EXCEPTION Exception during write.

View Source
var JAVA_TC_LONGSTRING byte = 0x7C

TC_LONGSTRING Long string.

View Source
var JAVA_TC_MAX byte = 0x7F

JAVA_TC_MAX Last tag value.

View Source
var JAVA_TC_NULL byte = 0x70

JAVA_TC_NULL Null object reference.

View Source
var JAVA_TC_OBJECT byte = 0x73

JAVA_TC_OBJECT new Object.

View Source
var JAVA_TC_PROXYCLASSDESC byte = 0x7D

TC_PROXYCLASSDESC new Proxy Class Descriptor.

View Source
var JAVA_TC_REFERENCE byte = 0x71

JAVA_TC_REFERENCE Reference to an object already written into the stream.

View Source
var JAVA_TC_RESET byte = 0x79

JAVA_TC_RESET Reset stream context. All handles written into stream are reset.

View Source
var JAVA_TC_STRING byte = 0x74

JAVA_TC_STRING new String.

View Source
var NoFieldError = fmt.Errorf("Oops!")
View Source
var ObjectTypecode = []string{"[", "L"}
View Source
var PrimitiveTypecode = []string{"B", "C", "D", "F", "I", "J", "S", "Z"}
View Source
var SizeTable = map[string]int{
	"B": 1,
	"C": 2,
	"D": 8,
	"F": 4,
	"I": 4,
	"J": 8,
	"S": 2,
	"Z": 1,
}

Functions

func DumpToGoStruct

func DumpToGoStruct(ser *Serialization)

Types

type AllowWalked added in v1.3.0

type AllowWalked interface {
	Walk(callback WalkCallback) error
}

type ClassBag

type ClassBag struct {
	Classes []*TCClassDesc
}

func (*ClassBag) Add

func (bag *ClassBag) Add(classDesc *TCClassDesc)

func (*ClassBag) Merge

func (bag *ClassBag) Merge(newBag *ClassBag)

type FindCallback added in v1.3.0

type FindCallback func(object Object) bool

type Object

type Object interface {
	ToBytes() []byte
	ToString() string
	AllowWalked
}

func FindObject added in v1.3.0

func FindObject(orig AllowWalked, callback FindCallback) Object

type ObjectStream

type ObjectStream struct {
	*commons.Stream
	// contains filtered or unexported fields
}

func NewObjectStream

func NewObjectStream(bs []byte) *ObjectStream

func NewObjectStreamFromReadSeeker added in v1.4.0

func NewObjectStreamFromReadSeeker(r io.ReadSeeker) *ObjectStream

func (*ObjectStream) AddReference

func (s *ObjectStream) AddReference(obj Object)

func (*ObjectStream) FindReferenceId

func (s *ObjectStream) FindReferenceId(find Object) uint32

func (*ObjectStream) GetReference

func (s *ObjectStream) GetReference(handler uint32) Object

type OverlongOption added in v1.4.0

type OverlongOption int
const (
	OverlongEncodingTwoBytes   OverlongOption = 2
	OverlongEncodingThreeBytes OverlongOption = 3
)

type ReferenceClassInformation

type ReferenceClassInformation struct {
	ClassName  string
	Attributes []string
}

type Serialization

type Serialization struct {
	MagicNumber   []byte
	StreamVersion []byte
	Contents      []*TCContent
}

func FromBytes

func FromBytes(data []byte) (*Serialization, error)

func FromJDK8u20Bytes added in v1.2.0

func FromJDK8u20Bytes(data []byte) (*Serialization, error)

func FromReadSeeker added in v1.4.0

func FromReadSeeker(r io.ReadSeeker) (*Serialization, error)

func (*Serialization) ToBytes

func (ois *Serialization) ToBytes() []byte

func (*Serialization) ToJDK8u20Bytes added in v1.2.0

func (ois *Serialization) ToJDK8u20Bytes() []byte

func (*Serialization) ToString

func (ois *Serialization) ToString() string

func (*Serialization) Walk added in v1.3.0

func (ois *Serialization) Walk(callback WalkCallback) error

type StopWalkError added in v1.3.0

type StopWalkError struct{}

func (*StopWalkError) Error added in v1.3.0

func (s *StopWalkError) Error() string

type TCArray

type TCArray struct {
	TypeCode     byte
	ClassPointer *TCClassPointer
	ArrayData    []*TCValue
	Handler      uint32
}

func (*TCArray) DumpByteArray

func (t *TCArray) DumpByteArray() string

func (*TCArray) ToBytes

func (t *TCArray) ToBytes() []byte

func (*TCArray) ToString

func (t *TCArray) ToString() string

func (*TCArray) Walk added in v1.3.0

func (t *TCArray) Walk(callback WalkCallback) error

type TCBlockData

type TCBlockData struct {
	Data []byte
}

func (*TCBlockData) ToBytes

func (bd *TCBlockData) ToBytes() []byte

func (*TCBlockData) ToString

func (bd *TCBlockData) ToString() string

func (*TCBlockData) Walk added in v1.3.0

func (bd *TCBlockData) Walk(callback WalkCallback) error

type TCClass

type TCClass struct {
	ClassPointer *TCClassPointer
	Handler      uint32
}

func (*TCClass) ToBytes

func (c *TCClass) ToBytes() []byte

func (*TCClass) ToString

func (c *TCClass) ToString() string

func (*TCClass) Walk added in v1.3.0

func (c *TCClass) Walk(callback WalkCallback) error

type TCClassData

type TCClassData struct {
	HasAnnotation    bool
	ReferenceClass   *ReferenceClassInformation
	FieldDatas       []*TCValue
	ObjectAnnotation []*TCContent
}

func (*TCClassData) ToBytes

func (cd *TCClassData) ToBytes() []byte

func (*TCClassData) ToString

func (cd *TCClassData) ToString() string

func (*TCClassData) Walk added in v1.3.0

func (cd *TCClassData) Walk(callback WalkCallback) error

type TCClassDesc

type TCClassDesc struct {
	ClassName         *TCUtf
	SerialVersionUID  int64
	ClassDescFlags    byte
	Fields            []*TCFieldDesc
	ClassAnnotation   []*TCContent
	SuperClassPointer *TCClassPointer
	Handler           uint32
}

func FindClassDesc added in v1.3.0

func FindClassDesc(orig AllowWalked, name string) *TCClassDesc

func SimpleClassDesc

func SimpleClassDesc(className string, svuid int64, flags byte, handler uint32, super *TCClassPointer, fields [][3]string) *TCClassDesc

func (*TCClassDesc) FlagString

func (desc *TCClassDesc) FlagString() string

func (*TCClassDesc) HasFlag

func (desc *TCClassDesc) HasFlag(flag byte) bool

HasFlag Check if a TCClassDesc object has a flag

func (*TCClassDesc) ToBytes

func (desc *TCClassDesc) ToBytes() []byte

func (*TCClassDesc) ToString

func (desc *TCClassDesc) ToString() string

func (*TCClassDesc) Walk added in v1.3.0

func (desc *TCClassDesc) Walk(callback WalkCallback) error

type TCClassPointer

type TCClassPointer struct {
	Flag            byte
	NormalClassDesc *TCClassDesc
	ProxyClassDesc  *TCProxyClassDesc
	Null            *TCNull
	Reference       *TCReference
}

func NewNullPointer

func NewNullPointer() *TCClassPointer

func (*TCClassPointer) FindClassBag

func (cp *TCClassPointer) FindClassBag(stream *ObjectStream) (*ClassBag, error)

func (*TCClassPointer) ToBytes

func (cp *TCClassPointer) ToBytes() []byte

func (*TCClassPointer) ToString

func (cp *TCClassPointer) ToString() string

func (*TCClassPointer) Walk added in v1.3.0

func (cp *TCClassPointer) Walk(callback WalkCallback) error

type TCContent

type TCContent struct {
	Flag            byte
	Object          *TCObject
	String          *TCString
	Array           *TCArray
	BlockData       *TCBlockData
	Class           *TCClass
	NormalClassDesc *TCClassDesc
	ProxyClassDesc  *TCProxyClassDesc
	Null            *TCNull
	Enum            *TCEnum
	Reference       *TCReference
}

func ReadTCContent added in v1.4.0

func ReadTCContent(stream *ObjectStream) (*TCContent, error)

func (*TCContent) ToBytes

func (c *TCContent) ToBytes() []byte

func (*TCContent) ToString

func (c *TCContent) ToString() string

func (*TCContent) Walk added in v1.3.0

func (c *TCContent) Walk(callback WalkCallback) error

type TCEnum

type TCEnum struct {
	ClassPointer *TCClassPointer
	ConstantName *TCStringPointer
	Handler      uint32
}

func (*TCEnum) ToBytes

func (e *TCEnum) ToBytes() []byte

func (*TCEnum) ToString

func (e *TCEnum) ToString() string

func (*TCEnum) Walk added in v1.3.0

func (e *TCEnum) Walk(callback WalkCallback) error

type TCFieldDesc

type TCFieldDesc struct {
	TypeCode  string
	FieldName *TCUtf
	ClassName *TCStringPointer
}

func (*TCFieldDesc) ToBytes

func (f *TCFieldDesc) ToBytes() []byte

func (*TCFieldDesc) ToString

func (f *TCFieldDesc) ToString() string

func (*TCFieldDesc) Walk added in v1.3.0

func (f *TCFieldDesc) Walk(callback WalkCallback) error

type TCNull

type TCNull struct {
}

func (*TCNull) ToBytes

func (n *TCNull) ToBytes() []byte

func (*TCNull) ToString

func (n *TCNull) ToString() string

func (*TCNull) Walk added in v1.3.0

func (n *TCNull) Walk(callback WalkCallback) error

type TCObject

type TCObject struct {
	ClassPointer *TCClassPointer
	ClassDatas   []*TCClassData
	Handler      uint32
}

func (*TCObject) ToBytes

func (oo *TCObject) ToBytes() []byte

func (*TCObject) ToString

func (oo *TCObject) ToString() string

func (*TCObject) Walk added in v1.3.0

func (oo *TCObject) Walk(callback WalkCallback) error

type TCProxyClassDesc

type TCProxyClassDesc struct {
	InterfaceNames    []*TCUtf
	ClassAnnotation   []*TCContent
	SuperClassPointer *TCClassPointer
	Handler           uint32
}

func (*TCProxyClassDesc) ToBytes

func (pc *TCProxyClassDesc) ToBytes() []byte

func (*TCProxyClassDesc) ToString

func (pc *TCProxyClassDesc) ToString() string

func (*TCProxyClassDesc) Walk added in v1.3.0

func (pc *TCProxyClassDesc) Walk(callback WalkCallback) error

type TCReference

type TCReference struct {
	Handler         uint32
	Flag            byte
	Object          *TCObject
	Class           *TCClass
	NormalClassDesc *TCClassDesc
	ProxyClassDesc  *TCProxyClassDesc
	String          *TCString
	Array           *TCArray
	Enum            *TCEnum
}

func (*TCReference) ToBytes

func (r *TCReference) ToBytes() []byte

func (*TCReference) ToString

func (r *TCReference) ToString() string

func (*TCReference) Walk added in v1.3.0

func (r *TCReference) Walk(callback WalkCallback) error

Walk We don't walk into TCReference, because it's field are all the pointer that walked before

type TCString

type TCString struct {
	Utf     *TCUtf
	Handler uint32
}

func NewTCString

func NewTCString(data string, handler uint32) *TCString

func (*TCString) ToBytes

func (so *TCString) ToBytes() []byte

func (*TCString) ToString

func (so *TCString) ToString() string

func (*TCString) Walk added in v1.3.0

func (so *TCString) Walk(callback WalkCallback) error

type TCStringPointer

type TCStringPointer struct {
	IsRef     bool
	String    *TCString
	Reference *TCReference
}

func NewTCStringPointer

func NewTCStringPointer(data string, handler uint32) *TCStringPointer

func (*TCStringPointer) ToBytes

func (sp *TCStringPointer) ToBytes() []byte

func (*TCStringPointer) ToString

func (sp *TCStringPointer) ToString() string

func (*TCStringPointer) Walk added in v1.3.0

func (sp *TCStringPointer) Walk(callback WalkCallback) error

type TCUtf

type TCUtf struct {
	Data string

	OverlongSize OverlongOption
}

func NewUtf

func NewUtf(data string) *TCUtf

func (*TCUtf) SetOverlongSize added in v1.4.0

func (u *TCUtf) SetOverlongSize(size OverlongOption)

func (*TCUtf) ToBytes

func (u *TCUtf) ToBytes() []byte

func (*TCUtf) ToString

func (u *TCUtf) ToString() string

func (*TCUtf) Walk added in v1.3.0

func (u *TCUtf) Walk(callback WalkCallback) error

type TCValue

type TCValue struct {
	TypeCode string
	Byte     byte    // byte in Java
	Char     uint16  // char in Java
	Double   float64 // double in Java
	Float    float32 // float in Java
	Integer  int32   // int in Java
	Long     int64   // long in Java
	Short    int16   // short in Java
	Boolean  bool    // bool in Java
	Object   Object  // object in Java
}

func NewTCValueBytes

func NewTCValueBytes(data []byte) []*TCValue

func (*TCValue) ToBytes

func (t *TCValue) ToBytes() []byte

func (*TCValue) ToString

func (t *TCValue) ToString() string

func (*TCValue) Walk added in v1.3.0

func (t *TCValue) Walk(callback WalkCallback) error

type WalkCallback added in v1.3.0

type WalkCallback func(object Object) error

Jump to

Keyboard shortcuts

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