Beispiel #1
0
        /// <summary>
        /// Create a packet from the stream.
        /// </summary>
        /// <param name="header">The first 11 bytes of the data.</param>
        /// <param name="stream">The stream with the data</param>
        /// <returns>a new Packet</returns>
        /// <exception cref="IOException">If the data in the stream are invalid.</exception>
        internal static Packet Read(byte[] header, Stream stream)
        {
            Packet packet = new Packet();

            packet.data = header;
            int len = packet.ReadInt();

            if (len < 11)
            {
                throw new IOException("protocol error - invalid length");
            }
            packet.id = packet.ReadInt();
            int flags = packet.ReadByte();

            if ((flags & Reply) == 0)
            {
                packet.cmdSet = packet.ReadByte();
                packet.cmd    = packet.ReadByte();
            }
            else
            {
                packet.errorCode = packet.ReadShort();
            }
            packet.data = new byte[len - 11];
            DebuggerUtils.ReadFully(stream, packet.data);
            packet.offset = 0;
            return(packet);
        }
Beispiel #2
0
 internal Packet ReadPacket()
 {
     lock (readHeader)
     {
         DebuggerUtils.ReadFully(stream, readHeader);
         return(Packet.Read(readHeader, stream));
     }
 }
Beispiel #3
0
        internal int GetTypeID(String jniClassName)
        {
            String className = DebuggerUtils.ConvertJniClassName(jniClassName);
            int    id;

            try
            {
                DebugType type = typeMap[className];
                id = (int)type.Token;
            }
            catch (KeyNotFoundException)
            {
                id = 0;
            }
            Console.Error.WriteLine("GetTypeID:" + jniClassName + " " + className + " " + id);
            return(id);
        }