wmio

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const Inherited uint32 = 0x4000
View Source
const NULLRef = uint32(0xFFFFFFFF)

The NULL reference.

Variables

This section is empty.

Functions

func IsASCII

func IsASCII(data string) bool

IsASCII.

func LookupDictionary

func LookupDictionary(ref uint32) string

func Marshal

func Marshal(obj *Object) ([]byte, error)

func QualifierSetSize

func QualifierSetSize(qs []*Qualifier) int

func ReverseLookupDictionary

func ReverseLookupDictionary(s string) uint32

Types

type CIMType

type CIMType uint32
const CIMArray CIMType = 0x2000
var (
	Int8           CIMType = 16
	Uint8          CIMType = 17
	Int16          CIMType = 2
	Uint16         CIMType = 18
	Int32          CIMType = 3
	Uint32         CIMType = 19
	Int64          CIMType = 20
	Uint64         CIMType = 21
	Float32        CIMType = 4
	Float64        CIMType = 5
	Bool           CIMType = 11
	String         CIMType = 8
	DateTime       CIMType = 101
	Ref            CIMType = 102
	Rune           CIMType = 103
	CIMObject      CIMType = 13
	Int8Array      CIMType = Int8 | CIMArray
	Uint8Array     CIMType = Uint8 | CIMArray
	Int16Array     CIMType = Int16 | CIMArray
	Uint16Array    CIMType = Uint16 | CIMArray
	Int32Array     CIMType = Int32 | CIMArray
	Uint32Array    CIMType = Uint32 | CIMArray
	Int64Array     CIMType = Int64 | CIMArray
	Uint64Array    CIMType = Uint64 | CIMArray
	Float32Array   CIMType = Float32 | CIMArray
	Float64Array   CIMType = Float64 | CIMArray
	BoolArray      CIMType = Bool | CIMArray
	StringArray    CIMType = String | CIMArray
	DateTimeArray  CIMType = DateTime | CIMArray
	RefArray       CIMType = Ref | CIMArray
	RuneArray      CIMType = Rune | CIMArray
	CIMObjectArray CIMType = CIMObject | CIMArray
)

func ValueType

func ValueType(value any) (CIMType, error)

func (CIMType) IsArray

func (o CIMType) IsArray() bool

func (CIMType) MarshalJSON

func (o CIMType) MarshalJSON() ([]byte, error)

func (CIMType) String

func (o CIMType) String() string

type Class

type Class struct {
	Raw         []byte       `json:"-"`
	Name        string       `json:"name,omitempty"`
	NDValueSize uint32       `json:"-"`
	Derivation  []string     `json:"derivation,omitempty"`
	Qualifiers  []*Qualifier `json:"qualifiers,omitempty"`
	Properties  []*Property  `json:"properties,omitempty"`
}

func (*Class) Decode

func (o *Class) Decode(r *Codec) error

func (*Class) Encode

func (o *Class) Encode(r *Codec) error

type Codec

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

The WMIO encoder/decoder.

func NewCodec

func NewCodec(b []byte) *Codec

NewCodec function returns the new encoder/decoder for the WMIO objects.

func (*Codec) Begin

func (c *Codec) Begin(s any)

Begin function is used to start the debugging context.

func (*Codec) DecodeHeap

func (c *Codec) DecodeHeap() error

DecodeHeap function decodes the references on the current heap. If decoded data has more references, they will be decoded as well.

func (*Codec) DecodeWithBytes

func (c *Codec) DecodeWithBytes(b []byte, data any) error

DecodeWithBytes function decodes the `data` within given byte chunk `b`.

func (*Codec) DecodeWithLength32

func (c *Codec) DecodeWithLength32(data any) error

DecodeWithLength32 function reads the uint32 data length prefix (length is calculated as len + size_of(len)).

func (*Codec) DecodeWithSize32

func (c *Codec) DecodeWithSize32(sz uint32, data any) error

DecodeWithSize32 function reads the sized chunk and decodes the data within it.

func (*Codec) Done

func (c *Codec) Done() error

Done function is used to pop the debugging context.

func (*Codec) EncodeBytesWithSize32

func (c *Codec) EncodeBytesWithSize32(sz *uint32, data any) ([]byte, error)

EncodeBytesWithSize32 function writes the data and saves the captured length into the value `sz`.

func (*Codec) EncodeWithLength32

func (c *Codec) EncodeWithLength32(data any) error

EncodeWithLength32 function encodes the data and length prefix.

func (*Codec) Err

func (c *Codec) Err(err ...error) error

Err.

func (*Codec) Errf

func (c *Codec) Errf(frmt string, args ...interface{}) error

Errf.

func (*Codec) Len

func (c *Codec) Len() int

Len.

func (*Codec) Read

func (c *Codec) Read(p []byte) error

Read.

func (*Codec) ReadData

func (c *Codec) ReadData(data any) error

ReadData function reads the generic data from the buffer.

func (*Codec) ReadHeap

func (c *Codec) ReadHeap() error

ReadHeap function reads the heap data. (size of heap is calculated by inverting the left-most bit).

func (*Codec) ReadRef

func (c *Codec) ReadRef(data any, debug ...string) error

ReadRef function reads the reference for the data, and if reference is not NULL, appends the reference to the list of heap references.

func (*Codec) Write

func (c *Codec) Write(p []byte) error

Write.

func (*Codec) WriteData

func (c *Codec) WriteData(data any) error

WriteData function writes the generic data into the buffer.

func (*Codec) WriteDataOnHeap

func (c *Codec) WriteDataOnHeap(sz int, data any) error

WriteDataOnHeap function is used to write reference and refered value to the heap. First, we allocate space for the reference (or data that includes a reference), and then we write the actual referred data right after the reference.

func (*Codec) WriteHeap

func (c *Codec) WriteHeap() error

WriteHeap function writes the heap binary data to the buffer.

func (*Codec) WriteRef

func (c *Codec) WriteRef(data any, debug ...string) error

WriteRef function writes the reference on the current heap. NOTE: for situations when written value is a reference itself, WriteDataOnHeap must be used, to allocate enough space for the reference itself, and the value it is referred by.

type Decoration

type Decoration struct {
	ServerName string `json:"server_name,omitempty"`
	Namespace  string `json:"namespace,omitempty"`
}

func (*Decoration) Decode

func (d *Decoration) Decode(r *Codec) error

func (*Decoration) Encode

func (d *Decoration) Encode(r *Codec) error

type Flavor

type Flavor uint8
var (
	PropagateToInstance     Flavor = 0x01
	PropagateToDerivedClass Flavor = 0x02 // ToSubclass
	NotOverridable          Flavor = 0x10 // EnableOverride
	OriginPropagated        Flavor = 0x20
	OriginSystem            Flavor = 0x40
	Amended                 Flavor = 0x80 // Translatable
)

func (Flavor) String

func (o Flavor) String() string

type Heap

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

The heap stack element.

type HeapRef

type HeapRef struct {
	// The offset on the heap.
	Offset uint32
	// The value to encode/decode.
	Value any
	// The debug information associated with the
	// reference.
	Debug []string
}

The heap reference.

type Heaps

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

Heaps represent the stack of heaps, top-level (last) element represents the current heap.

func (*Heaps) Append

func (r *Heaps) Append(ref *HeapRef)

Append function appends the reference to the top-level (last) heap.

func (*Heaps) Head

func (r *Heaps) Head() []*HeapRef

Head function returns the list of references on the top-level (last) heap.

func (*Heaps) Heap

func (r *Heaps) Heap() []byte

Heap function returns the top-level (last) heap bytes.

func (*Heaps) HeapBuffer

func (r *Heaps) HeapBuffer() *bytes.Buffer

HeapBuffer function returns the top-level (last) heap bytes.Buffer.

func (*Heaps) Pop

func (r *Heaps) Pop()

Pop function removes the top-level (last) heap from the heap stack.

func (*Heaps) Push

func (r *Heaps) Push()

Push function allocates a new heap on the heap stack.

func (*Heaps) SetHeap

func (r *Heaps) SetHeap(h []byte)

SetHeap function sets the current (last) heap element buffer to the bytes `h`.

func (*Heaps) Truncate

func (r *Heaps) Truncate() []*HeapRef

Truncate function removes the list of references from the top-level (last) heap but leaves the heap as-is.

type Instance

type Instance struct {
	CurrentClass Class        `json:"current_class,omitempty"`
	Flags        uint8        `json:"flags,omitempty"`
	ClassName    string       `json:"class_name,omitempty"`
	Properties   []*Property  `json:"properties,omitempty"`
	Qualifiers   []*Qualifier `json:"qualifiers,omitempty"`
}

func (*Instance) Decode

func (o *Instance) Decode(r *Codec) error

func (*Instance) Encode

func (o *Instance) Encode(r *Codec) error

type Method

type Method struct {
	Name            string       `json:"name,omitempty"`
	Flags           uint8        `json:"flags,omitempty"`
	Origin          uint32       `json:"origin,omitempty"`
	Qualifiers      []*Qualifier `json:"qualifiers,omitempty"`
	InputSignature  Object       `json:"input_signature,omitempty"`
	OutputSignature Object       `json:"output_signature,omitempty"`
}

func (*Method) Decode

func (o *Method) Decode(r *Codec) error

func (*Method) Encode

func (o *Method) Encode(r *Codec) error

type Methods

type Methods struct {
	Methods []*Method `json:"methods,omitempty"`
}

func (*Methods) Decode

func (o *Methods) Decode(r *Codec) error

func (*Methods) Encode

func (o *Methods) Encode(r *Codec) error

type Object

type Object struct {
	Decoration *Decoration  `json:"decoration,omitempty"`
	Class      *ObjectClass `json:"class,omitempty"`
	Instance   *Instance    `json:"instance,omitempty"`
}

func Unmarshal

func Unmarshal(b []byte) (*Object, error)

func (*Object) Decode

func (o *Object) Decode(r *Codec) error

func (*Object) Encode

func (o *Object) Encode(r *Codec) error

func (*Object) Method

func (o *Object) Method(n string) (*Object, *Object, error)

func (*Object) New

func (o *Object) New(values Values) (*Object, error)

type ObjectClass

type ObjectClass struct {
	ParentClass         Class   `json:"parent_class,omitempty"`
	ParentClassMethods  Methods `json:"parent_class_methods,omitempty"`
	CurrentClass        Class   `json:"current_class,omitempty"`
	CurrentClassMethods Methods `json:"current_class_methods,omitempty"`
}

func (*ObjectClass) Decode

func (o *ObjectClass) Decode(r *Codec) error

func (*ObjectClass) Encode

func (o *ObjectClass) Encode(r *Codec) error

type ObjectFlag

type ObjectFlag uint8
const (
	ObjectFlagClass      ObjectFlag = 0x01
	ObjectFlagInstance   ObjectFlag = 0x02
	ObjectFlagDecoration ObjectFlag = 0x04
)

type Property

type Property struct {
	Name           string       `json:"name,omitempty"`
	Order          uint16       `json:"order"`
	Offset         uint32       `json:"offset,omitempty"`
	ClassOfOrigin  uint32       `json:"class_of_origin,omitempty"`
	Qualifiers     []*Qualifier `json:"qualifiers,omitempty"`
	Nullable       bool         `json:"nullable,omitempty"`
	InheritDefault bool         `json:"inherit_default,omitempty"`
	Inherited      bool         `json:"inherited,omitempty"`
	Value          Value        `json:"value,omitempty"`
}

func (*Property) Decode

func (o *Property) Decode(r *Codec) error

func (*Property) Encode

func (o *Property) Encode(r *Codec) error

type Qualifier

type Qualifier struct {
	Name   string `json:"name,omitempty"`
	Flavor Flavor `json:"flavour,omitempty"`
	Value  Value  `json:"value,omitempty"`
}

func (*Qualifier) Decode

func (o *Qualifier) Decode(r *Codec) error

func (*Qualifier) Encode

func (o *Qualifier) Encode(r *Codec) error

func (*Qualifier) String

func (o *Qualifier) String() string

type Value

type Value struct {
	Type  CIMType `json:"type"`
	Value any     `json:"value"`
}

func (*Value) Decode

func (o *Value) Decode(r *Codec) error

func (*Value) Encode

func (o *Value) Encode(r *Codec) error

func (Value) EncodeValueSize

func (o Value) EncodeValueSize() int

func (Value) String

func (o Value) String() string

type Values

type Values map[string]any

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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