예제 #1
0
 public void handlePacket(byte[] packet)
 {
     ByteBuffer rawBuffer = new ByteBuffer(packet);
     // Check if the size is the realsize
     short size = rawBuffer.ReadInt16();
     rawBuffer.SetIndex(0);
     if (size < rawBuffer.Length())
     {
         byte[] pck1;
         pck1 = rawBuffer.ReadBytes(size);
         buffer.Enqueue(pck1);
         short size2;
         size2 = rawBuffer.ReadInt16();
         rawBuffer.SetIndex(size);
         byte[] pck2;
         pck2 = rawBuffer.ReadBytes(size2);
         buffer.Enqueue(pck2);
     }
     else
     {
         buffer.Enqueue(packet);
     }
 }
예제 #2
0
        public ImageDebugDirectory GetDebugHeader(out byte[] header)
        {
            var section = GetSectionAtVirtualAddress(Debug.VirtualAddress);
            var buffer = new ByteBuffer(section.Data);
            buffer.position = (int)(Debug.VirtualAddress - section.VirtualAddress);

            var directory = new ImageDebugDirectory
            {
                Characteristics = buffer.ReadInt32(),
                TimeDateStamp = buffer.ReadInt32(),
                MajorVersion = buffer.ReadInt16(),
                MinorVersion = buffer.ReadInt16(),
                Type = buffer.ReadInt32(),
                SizeOfData = buffer.ReadInt32(),
                AddressOfRawData = buffer.ReadInt32(),
                PointerToRawData = buffer.ReadInt32(),
            };

            if (directory.SizeOfData == 0 || directory.PointerToRawData == 0)
            {
                header = Empty<byte>.Array;
                return directory;
            }

            buffer.position = (int)(directory.PointerToRawData - section.PointerToRawData);

            header = new byte[directory.SizeOfData];
            Buffer.BlockCopy(buffer.buffer, buffer.position, header, 0, header.Length);

            return directory;
        }