static string DecodeString (byte[] buffer, ref int index, bool unicode)
{
var encoding = unicode ? Encoding.Unicode : Encoding.UTF8;
var length = BitConverterLE.ToInt16 (buffer, index);
var value = encoding.GetString (buffer, index + 2, length);
index += 2 + length;
return value;
}