i am not sure if this topic is in the right place. if its not, my appologies.

Public Function ReadString(Optional MoveReadHead As Boolean = True) As String
    Dim sLength As Long
    Dim sBytes() As Byte
    sLength = ReadLong

    If sLength <= 0 Then Exit Function
    ReDim sBytes(sLength - 1)
    CopyMemory sBytes(0), Buffer(ReadHead), sLength
    ReadString = StrConv(sBytes, vbUnicode)

    If MoveReadHead Then ReadHead = ReadHead + sLength
End Function

if you pass MoveReadHead as False In this function, the buffer will crash.
after some time, i realized that it happen because the function do not restore the ReadHead changed by the “sLength = ReadLong” line.

i fixed it this way:

Public Function ReadString(Optional MoveReadHead As Boolean = True) As String
    Dim sLength As Long
    Dim sBytes() As Byte
    sLength = ReadLong

    If sLength <= 0 Then Exit Function
    ReDim sBytes(sLength - 1)
    CopyMemory sBytes(0), Buffer(ReadHead), sLength
    ReadString = StrConv(sBytes, vbUnicode)

    If MoveReadHead Then 
        ReadHead = ReadHead + sLength
    Else
        ReadHead = ReadHead - 4 ' restore the readlong changes
    End If
End Function

😉