Language Reference
Documentation

Language

Objects
Internet Objects

MemoryBlock Class

Has Constructor: NO, Can Create Instance: YES
Can Subclass: YES

Use the memoryblock object to manipulate an allocated memory space. Use the NewMemoryBlock(Size as integer) function to create a new memoryblock. The memoryblock will be use to pass data to DLL and OS libraries (API).

Methods

SetByteValue
Syntax: MemoryBlock.SetByteValue(offset as string, value as integer)

Sets a byte with at offset with an integer with a value of 0 to 255.

SetDoubleValue
Syntax: MemoryBlock.SetDoubleValue(offset as integer, value as float)

Sets a double at offset.

SetSingleValue, SetLongValue
Syntax: MemoryBlock.SetSingleValue(offset as integer, value as integer)
Syntax: MemoryBlock.SetLongValue(offset as integer, value as integer)

Sets a single or long (4 bytes) at offset.

SetShortValue
Syntax: MemoryBlock.SetSingleValue(offset as integer, value as integer)

Sets a short (2 bytes) at offset.

SetUShortValue
Syntax: MemoryBlock.SetUShortValue(offset as integer, value as integer)

Sets an unsigned short (2 bytes) at offset.

SetPString
Syntax: MemoryBlock.SetPString(offset as integer, value as string)

Sets a Pascal string at offset.

SetCString
Syntax: MemoryBlock.SetCString(offset as integer, value as string)

Sets a "C" string at offset.

SetStringValue
Syntax: MemoryBlock.SetStringValue(offset as integer, length as integer, value as string)

Sets the contents of the memoryblock at offset with the content of value. May contain Nulls. If length is greater that the string the content will be padded with zeros.

GetByteValue
Syntax: MemoryBlock.GetByteValue(offset as string) as integer

Returns a byte from offset as an integer with a value of 0 to 255.

GetDoubleValue
Syntax: MemoryBlock.GetDoubleValue(offset as integer) as float

Returns a float from offset.

GetSingleValue, GetLongValue
Syntax: MemoryBlock.GetSingleValue(offset as integer) as integer
Syntax: MemoryBlock.GetLongValue(offset as integer) as integer

Returns a single or long (4 bytes) from offset.

GetShortValue
Syntax: MemoryBlock.GetSingleValue(offset as integer) as integer

Returns a short (2 bytes) from offset.

GetUShortValue
Syntax: MemoryBlock.GetUShortValue(offset as integer) as integer

Returns an unsigned short (2 bytes) from offset.

GetPString
Syntax: MemoryBlock.GetPString(offset as integer) as string

Returns a Pascal string from offset.

GetCString
Syntax: MemoryBlock.GetCString(offset as integer) as string

Returns a "C" string from offset.

GetStringValue
Syntax: MemoryBlock.GetStringValue(offset as integer, length as integer) as string

Returns the contents of the memoryblock from offset up to lenght.

LeftB
Syntax: MemoryBlock.LeftB(length as integer)

Returns length bytes as string from the left.

RightB
Syntax: MemoryBlock.RightB(length as integer)

Returns length bytes as string from the right.

MidB
Syntax: MemoryBlock.MidB(offset as integer, length as integer)

Returns length bytes as string from the offset.

Properties

LittleEndian
Data Type: Integer

Sets or Gets the endianess of the memoryblock. The default value is the default for the OS where bOSL is running.

Size
Data Type: Integer

Returns or sets the size of the memoryblock in bytes.

Sample Code

Sub Main()
    dim m as memoryblock

    m = NewMemoryBlock(13)
    m.SetByteValue(0, 12)
    m.SetByteValue(1, 72)
    m.SetByteValue(2, 101)
    m.SetByteValue(3, 108)
    m.SetByteValue(4, 108)
    m.SetByteValue(5, 111)
    m.SetByteValue(6, 32)
    m.SetByteValue(7, 87)
    m.SetByteValue(8, 111)
    m.SetByteValue(9, 114)
    m.SetByteValue(10, 108)
    m.SetByteValue(11, 100)
    m.SetByteValue(12, 33)


    MsgBox(m.GetPString(0))
end sub