MBS Plugin Documentation

Search:

Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchie

New in Version 7.0 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 8.0 8.1 8.2 8.3 8.4 8.5 8.6 8.7 9.0

The list of the   themes,   classes,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

MemoryBlock.AddressMBS(offset as Integer) as Integer
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Returns the adress of the byte at offset inside the memoryblock.

Some examples which use this method:

MemoryBlock.AppendMBS(other as memoryblock) as memoryblock
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Plugin version: 3.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Returns a new memoryblock with the bytes of the two given memoryblocks.
Notes:
This function will not work if the memoryblock has an unknown size.
If one memoryblock is nil than you get a copy of the other memoryblock.
MemoryBlock.BytesEqualMBS(srcOfs as Integer, numBytes as Integer, destBlk as memoryBlock, destOfs as Integer) as Boolean
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Returns true if equal byte data.

Some examples which use this method:

MemoryBlock.BytesMBS as integer
property, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: The size of the memoryblock.
Notes:
Some newer RB version introduced a size property which is read and writeable, but older RB versions didn't have even a readable size property, so this bytes property will help there.
Also it should as a property be viewable in the debugging windows.
(Read only property)
class Memoryblock
class, MemoryBlock, MBS QuickTime Plugin (QTImporter), class MemoryBlock, Console safe, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Extends Realbasic's Memoryblock class.
MemoryBlock.CopyBytesFromMacHandleMBS(srcHandle as Integer, numBytes as Integer, destOfs as Integer)
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Mac OS X: Works, Windows: Does nothing, Linux x86: Does nothing, Feedback.

Function: Copies bytes from Mac Handle into your memoryblock.
Notes: Same as CopyBytesFromMacPtr, only that the memory address is a so-called Handle (see documentation about the MacOS memory Manager), which is double-referenced.
MemoryBlock.CopyBytesFromMacPtrMBS(srcPtr as Integer, numBytes as Integer, destOfs as Integer)
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Copies the given amount of bytes from the given address in the Mac's memory address space into the memoryBlock.
Notes: Make sure that the destination block is large enough to hold the copied bytes (if not, your application or even the whole system can crash).
MemoryBlock.CopyBytesMBS(srcOfs as Integer, numBytes as Integer, destBlk as memoryBlock, destOfs as Integer)
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Copies the specified amount of bytes into a second memoryBlock.
Example:
dim m as MemoryBlock
dim n as MemoryBlock

m=NewMemoryBlock(100)
n=NewMemoryBlock(100)

m.Long(0)=12345

m.CopyBytesMBS(0,4,n,0)

MsgBox str(n.long(0))

Notes: You must make sure that the destination block is large enough to hold the copied bytes (if not, your application or even the whole system can crash).

Some examples which use this method:

MemoryBlock.CopyBytesMBS(srcOfs as Integer, numBytes as Integer, destOfs as Integer)
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Copies the specified amount of bytes inside the memoryBlock.
Notes: You must make sure that the copied bytes fit inside the block (if they don't, your application or even the whole system can crash).

Some examples which use this method:

MemoryBlock.CopyBytesToMacHandleMBS(srcOfs as Integer, numBytes as Integer, destHandle as Integer)
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Mac OS X: Works, Windows: Does nothing, Linux x86: Does nothing, Feedback.

Function: Copies byte data from the memoryblock into the memory the handle is pointing to.
Notes: Same as CopyBytesToMacPtr, only that the memory address is a so-called Handle (see documentation about the MacOS memory Manager), which is double-referenced.
MemoryBlock.CopyBytesToMacPtrMBS(srcOfs as Integer, numBytes as Integer, destPtr as Integer)
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Copies the given amount of bytes from the memoryBlock to the given address in the Mac's memory address space.
Notes: Be careful where you copy the data to - you can easily crash your computer if you write to the wrong address space.
MemoryBlock.CopyByteToUShortMBS(dest as memoryblock, SourceOffset as integer, DestinationOffset as integer, ByteCount as integer, divisor as integer)
method, MemoryBlock, MBS Util Plugin (MemoryCopy), class MemoryBlock, Console safe, Plugin version: 4.1, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Copies bytes in a memoryblock to another memoryblock converting the 8bit values to 16bit values.
Notes:
Common values for divisor are 256 and 257.
No bound checking. Crashes with invalid values. Optimized for special divisor values.

Some examples which use this method:

MemoryBlock.CopyNthBitsMBS(source as memoryblock, SourceOffsetBits as integer, DestinationOffsetBits as integer, BitCount as integer, StepCount as integer, NumberOfSteps as integer) as boolean
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Plugin version: 6.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Copies every nth bits in the source memoryblock to the current memoryblock.
Notes:
BitCount = the number of bits to copy from each step.
StepCount = the number of bits to not copy.
NumberOfSteps = the number of steps to do.
There is no bound checking. The function will crash with invalid parameters!
MemoryBlock.CopyNthBytesMBS(source as memoryblock, SourceOffsetBytes as integer, DestinationOffsetBytes as integer, ByteCount as integer, StepCount as integer, NumberOfSteps as integer) as boolean
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Plugin version: 4.1, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Copies every nth bytes in the source memoryblock to the current memoryblock.
Example:
dim s,d as memoryBlock

s=NewmemoryBlock(100)
d=NewmemoryBlock(100)

s.CString(0)="Hello World!"

d.CopyNthBytesMBS s,0,0,2,4,3

MsgBox d.CString(0) // "Heo rl"

Notes:
ByteCount = the number of bytes to copy from each step.
StepCount = the number of bytes to not copy.
NumberOfSteps = the number of steps to do.
There is no bound checking. The function will crash with invalid parameters!
MemoryBlock.CopyUShortToByteMBS(dest as memoryblock, SourceOffset as integer, DestinationOffset as integer, ByteCount as integer, divisor as integer)
method, MemoryBlock, MBS Util Plugin (MemoryCopy), class MemoryBlock, Console safe, Plugin version: 4.1, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Copies shorts in a memoryblock to another memoryblock converting the 16bit values to 8bit values.
Notes:
Common values for divisor are 256 and 257.
No bound checking. Crashes with invalid values. Optimized for special divisor values.

Some examples which use this method:

MemoryBlock.FillBytesMBS(offset as integer, count as integer, value as integer)
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Plugin version: 3.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Fills memory with a specific byte value.
Notes: Caution: No bounds checking.

Some examples which use this method:

MemoryBlock.FindBytesMBS(srcOfs as Integer, maxBytes as Integer, target as memoryBlock, targOfs as Integer, targLen as Integer) as Integer
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Finds some bytes from the target memoryblock inside the current memoryblock.
MemoryBlock.FindStringMBS(srcOfs as Integer, maxBytes as Integer, target as String) as Integer
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Finds a string inside a memoryblock.
MemoryBlock.FSSpecMBS(offset as Integer) as FolderItem
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Mac OS X: Works, Windows: Does nothing, Linux x86: Does nothing, Feedback.

Function: Read/Write a FSSpec.
Notes:
Interprets 70 bytes starting at the given offset as a FSSpec record.
(Read and Write runtime property)
MemoryBlock.GetStringMBS(offset as Integer, numBytes as Integer) as String
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Returns a string from the memoryblock.
Notes: With newer RB versions you may better use StringValue.
MemoryBlock.Int64DoubleEndianMBS(offset as Integer, LittleEndian as boolean) as Double
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Plugin version: 5.4, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Same as Int64DoubleMBS, but you can specify the endian setting.
Notes: (Read and Write runtime property)
MemoryBlock.Int64DoubleMBS(offset as Integer) as Double
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Plugin version: 4.1, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Read/Write an 64bit Integer as a double value.
Example:
dim m as memoryBlock

m=NewmemoryBlock(100)

m.Long( 0)=&h12345678
m.Long( 4)=&h87654321

m.Long( 8)=&h11111111
m.Long(12)=&h11111111

// double has not the precision
MsgBox m.Int64StrMBS(0)+" vs. "+Format(m.Int64DoubleMBS(0),"0")+chr(13)+m.Int64StrMBS(8)+" vs. "+Format(m.Int64DoubleMBS(8),"0")

Notes:
Interprets 8 bytes starting at the given offset as a 64 bit signed integer value. This method converts the value into a double value.
Does not take care on the LittleEndian property.
(Read and Write runtime property)
MemoryBlock.Int64StrEndianMBS(offset as Integer, LittleEndian as boolean) as String
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Plugin version: 5.4, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Same as Int64StrMBS, but you can specify the endian setting.
Notes: (Read and Write runtime property)
MemoryBlock.Int64StrMBS(offset as Integer) as String
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Read/Write an 64bit Integer as binary String.
Notes:
Interprets 8 bytes starting at the given offset as a 64 bit signed integer value. This method converts the value into a String representing its decimal value.
Improved in 2.7 to work faster.
Does not take care on the LittleEndian property.
(Read and Write runtime property)
MemoryBlock.InvertBytesMBS(offset as integer, count as integer)
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Plugin version: 7.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Inverts the given number of bytes in a memoryblock.
Example:
dim m as memoryblock
m=newmemoryblock(100)
' do something
m.InvertBytesMBS(0,100) // invert all bytes

Notes: Does work faster if count is a multiply of 4.
MemoryBlock.LeftMBS(length as integer) as memoryblock
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Plugin version: 3.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Returns a memoryblock with the first given number of bytes.
Notes:
If length is greater than the size of the memoryblock then then length is set to size.
Returns nil if length<=0 or on low memory.
This function will not work if the memoryblock has an unknown size.

Some examples which use this method:

MemoryBlock.MidMBS(offset as integer) as memoryblock
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Plugin version: 3.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Returns a memoryblock with the bytes of the given memoryblock from the given offset on.
Notes:
Offset is 0 based.
Returns nil if offset<0 or on low memory.
This function will not work if the memoryblock has an unknown size.

Some examples which use this method:

MemoryBlock.MidMBS(offset As Integer, length As Integer) as memoryblock
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Plugin version: 3.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Returns a memoryblock with the given bytes from the middle of the memoryblock.
Notes:
Offset is 0 based.
Returns nil if offset<0 or on low memory.
If length is too long then length is set to a lower value.
This function will not work if the memoryblock has an unknown size.

Some examples which use this method:

MemoryBlock.MirrorBitsMBS(offsetBit as Integer, lengthBit as integer)
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Plugin version: 7.1, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Mirrors the bits in a memoryblock.
Notes:
e.g. "111100001" in the memoryblock would give "100001111"
This function is certainly not the fastest one, but faster than anything you can get written in Realbasic.
And make sure the bounds are matched, because on memory access outside the valid ranges, the function will crash.
0 ≤ offsetBit < mem.size*8 and 0 ≤ lengthBit ≤ mem.size*8 - offsetBit
MemoryBlock.MirrorBytesMBS(offsetByte as Integer, lengthByte as integer)
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Plugin version: 7.1, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Mirrors the bytes in the given range.
Notes:
e.g. "abcdefgh" in the memoryblock would give "hgfedcba"
This function is certainly not the fastest one, but faster than anything you can get written in Realbasic.
And make sure the bounds are matched, because on memory access outside the valid ranges, the function will crash.
0 ≤ offsetByte < mem.size and 0 ≤ lengthByte ≤ mem.size - offsetByte
NewMemoryBlockFromPtrMBS(ptr as integer) as memoryblock
global method, MemoryBlock, MBS Util Plugin (Memory), Console safe, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Creates a memoryblock for a given address in memory.

Some examples using this method:

MemoryBlock.OSTypeMBS(offset as Integer) as String
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Read/Write an OSType.
Notes:
Interprets 4 bytes starting at the given offset as a OSType value.
(Read and Write runtime property)
MemoryBlock.RightMBS(length As Integer) as memoryblock
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Plugin version: 3.3, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Returns a memoryblock with the given number of bytes from the right side of the memoryblock.
Example:
mem=m.RightMBS(5)

Notes:
If length is more than the memoryblock's size, than length is set to size.
Returns nil if length<=0 or on low memory.
This function will not work if the memoryblock has an unknown size.

Some examples which use this method:

MemoryBlock.SetStringMBS(str as String, offset as Integer)
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Sets a string inside the memoryblock.
Notes: With newer RB versions you may better use StringValue.
MemoryBlock.SwapBytes16MBS(offset as Integer, numBytes as Integer)
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Plugin version: 4.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Swaps words inside the given bounds inside the memoryblock.
Notes:
It should do something like this:

dim m as MemoryBlock

for i=0 to numbytes step 2
m.UShort(i)=EndianSwap16MBS(m.UShort(i))
next


Some examples which use this method:

MemoryBlock.SwapBytes32MBS(offset as Integer, numBytes as Integer)
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Plugin version: 4.0, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Swaps longs inside the given bounds inside the memoryblock.
Example:
// Test SwapBytes32MBS and SwapBytes16MBS:

const h11223344=&h11223344
const h22114411=&h22114433 // 16bit swap
const h44332211=&h44332211 // 32bit swap

dim m as memoryBlock
dim ok as integer

m=NewmemoryBlock(20)
m.Long(00)=h11223344
m.Long(04)=h11223344
m.Long(08)=h11223344
m.Long(12)=h11223344
m.Long(16)=h11223344

m.SwapBytes16MBS(4,4)
m.SwapBytes32MBS(12,4)

if m.Long(00)=h11223344 then
ok=ok+1
else
MsgBox "00: "+hex(m.Long(00))
end if

if m.Long(04)=h22114411 then
ok=ok+1
else
MsgBox "04: "+hex(m.Long(04))
end if

if m.Long(08)=h11223344 then
ok=ok+1
else
MsgBox "08: "+hex(m.Long(08))
end if

if m.Long(12)=h44332211 then
ok=ok+1
else
MsgBox "12: "+hex(m.Long(12))
end if

if m.Long(16)=h11223344 then
ok=ok+1
else
MsgBox "16: "+hex(m.Long(16))
end if

if ok=5 then
MsgBox "OK"
else
MsgBox "Fail"
end if

Notes:
It should do something like this:

dim m as memoryBlock

for i=0 to numbytes step 2
m.long(i)=EndianSwap32MBS(m.long(i))
next
MemoryBlock.SwapBytesMBS(offset as Integer, numBytes as Integer)
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Swaps bytes inside the given bounds inside the memoryblock.
Notes: Reverses the order of the bytes at the given offset and length in the memoryBlock. This is helpful to change representation of values from Little Endian (used in Windows) to Big Endian (used in Mac OS) and vice versa. Thanks to Franco Vaccari for the code of this routine.
MemoryBlock.UInt64DoubleEndianMBS(offset as Integer, LittleEndian as boolean) as Double
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Plugin version: 6.4, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Same as UInt64DoubleMBS, but you can specify the endian setting.
Notes: (Read and Write runtime property)
MemoryBlock.UInt64DoubleMBS(offset as Integer) as Double
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Plugin version: 6.4, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Read/Write an 64bit Integer as a double value.
Notes:
Interprets 8 bytes starting at the given offset as a 64 bit unsigned integer value. This method converts the value into a double value.
Does not take care on the LittleEndian property.
(Read and Write runtime property)
MemoryBlock.UInt64StrEndianMBS(offset as Integer, LittleEndian as boolean) as String
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Plugin version: 6.4, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Same as UInt64StrMBS, but you can specify the endian setting.
Notes: (Read and Write runtime property)
MemoryBlock.UInt64StrMBS(offset as Integer) as String
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Plugin version: 6.4, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Read/Write an 64bit Integer as binary String.
Notes:
Interprets 8 bytes starting at the given offset as a 64 bit unsigned integer value. This method converts the value into a String representing its decimal value.
Does not take care on the LittleEndian property.
(Read and Write runtime property)
MemoryBlock.ULongEndianMBS(offset as Integer, LittleEndian as boolean) as Double
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Plugin version: 5.4, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Same as ULongMBS, but you can specify the endian setting.
Notes: (Read and Write runtime property)
MemoryBlock.ULongMBS(offset as Integer) as Double
method, MemoryBlock, MBS Util Plugin (Memory), class MemoryBlock, Console safe, Mac OS X: Works, Windows: Works, Linux x86: Works, Feedback.

Function: Read/Write an unsigned long integer.
Notes:
Does not take care on the LittleEndian property.
(Read and Write runtime property)

The items on this page are in the following plugins: MBS QuickTime Plugin, MBS Util Plugin.