Search in sources :

Example 21 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class ServerNtlmsspChallenge method parseAttribute.

public void parseAttribute(ByteBuffer buf, int type, int length) {
    switch(type) {
        case MSV_AV_NETBIOS_DOMAIN_NAME:
            ntlmState.serverNetbiosDomainName = buf.readString(length, RdpConstants.CHARSET_16);
            break;
        case MSV_AV_NETBIOS_COMPUTER_NAME:
            ntlmState.serverNetbiosComputerName = buf.readString(length, RdpConstants.CHARSET_16);
            break;
        case MSV_AV_DNS_DOMAIN_NAME:
            ntlmState.serverDnsDomainName = buf.readString(length, RdpConstants.CHARSET_16);
            break;
        case MSV_AV_DNS_COMPUTER_NAME:
            ntlmState.serverDnsComputerName = buf.readString(length, RdpConstants.CHARSET_16);
            break;
        case MSV_AV_DNS_TREE_NAME:
            ntlmState.serverDnsTreeName = buf.readString(length, RdpConstants.CHARSET_16);
            break;
        case MSV_AV_TIMESTAMP:
            ByteBuffer tmp = buf.readBytes(length);
            ntlmState.serverTimestamp = tmp.toByteArray();
            // *DEBUG*/System.out.println("Server timestamp: "+tmp.toPlainHexString());
            tmp.unref();
            break;
        default:
    }
}
Also used : ByteBuffer(streamer.ByteBuffer)

Example 22 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class ServerNtlmsspChallenge method readStringByDescription.

/**
 * Read NTLM wide string, by it description. Buffer offset must point to
 * beginning of NTLM message signature.
 *
 * @param buf
 *          buffer with cursor pointing to description
 * @return
 */
public static String readStringByDescription(ByteBuffer buf) {
    ByteBuffer block = readBlockByDescription(buf);
    String value = block.readString(block.length, RdpConstants.CHARSET_16);
    block.unref();
    return value;
}
Also used : ByteBuffer(streamer.ByteBuffer)

Example 23 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class RLEBitmapDecompression method flipRawImage.

/**
 * Flip image in vertical direction.
 */
public static ByteBuffer flipRawImage(ByteBuffer src, int width, int height, int bpp) {
    if (width * height * bpp != src.length)
        throw new RuntimeException("Incorrect size of buffer. Expected size (imageWidth*imageHeight*bpp): " + (width * height * bpp) + ", actual size: " + src.length + ".");
    ByteBuffer dest = new ByteBuffer(new byte[src.length]);
    int scanLine = width * bpp;
    for (int i = 0; i < height; i++) {
        // Copy one row
        System.arraycopy(src.data, (height - i - 1) * scanLine, dest.data, i * scanLine, scanLine);
    }
    return dest;
}
Also used : ByteBuffer(streamer.ByteBuffer) AssertingByteBuffer(streamer.debug.AssertingByteBuffer)

Example 24 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class RLEBitmapDecompression method rleDecompress.

/**
 * Decompress a RLE compressed bitmap and flip decompressed image.
 *
 * @param srcBuf
 *          source buffer containing compressed bitmap
 * @param imageWidth
 *          width of destination image in pixels
 * @param imageHeight
 *          height of destination image in pixels
 * @param colorDepth
 *          bits per pixel
 * @return destination image buffer
 */
public static ByteBuffer rleDecompress(ByteBuffer srcBuf, int imageWidth, int imageHeight, int colorDepth) {
    int bpp = getPixelSize(colorDepth);
    // Decompress image
    ByteBuffer destBuf = new ByteBuffer(new byte[imageWidth * imageHeight * bpp]);
    rleDecompress(srcBuf, destBuf, imageWidth, imageHeight, colorDepth);
    // Flip image
    return flipRawImage(destBuf, imageWidth, imageHeight, bpp);
}
Also used : ByteBuffer(streamer.ByteBuffer) AssertingByteBuffer(streamer.debug.AssertingByteBuffer)

Example 25 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class ServerIOChannelRouter method handleDataPdu.

/**
 * @see http://msdn.microsoft.com/en-us/library/cc240577.aspx
 */
protected void handleDataPdu(ByteBuffer buf) {
    // (4 bytes): A 32-bit, unsigned integer. Share identifier for the packet.
    long shareId = buf.readUnsignedIntLE();
    if (shareId != state.serverShareId)
        throw new RuntimeException("Unexpected share ID: " + shareId + ".");
    // buf.skipBytes(4);
    // Padding.
    buf.skipBytes(1);
    // (1 byte): An 8-bit, unsigned integer. The stream identifier for the
    // packet.
    // int streamId = buf.readUnsignedByte();
    buf.skipBytes(1);
    // (2 bytes): A 16-bit, unsigned integer. The uncompressed length of the
    // packet in bytes.
    int uncompressedLength = buf.readUnsignedShortLE();
    // (1 byte): An 8-bit, unsigned integer. The type of Data PDU.
    int type2 = buf.readUnsignedByte();
    // (1 byte): An 8-bit, unsigned integer. The compression type and flags
    // specifying the data following the Share Data Header
    int compressedType = buf.readUnsignedByte();
    if (compressedType != 0)
        throw new RuntimeException("Compression of protocol packets is not supported. Data: " + buf + ".");
    // (2 bytes): A 16-bit, unsigned integer. The compressed length of the
    // packet in bytes.
    int compressedLength = buf.readUnsignedShortLE();
    if (compressedLength != 0)
        throw new RuntimeException("Compression of protocol packets is not supported. Data: " + buf + ".");
    ByteBuffer data = buf.readBytes(uncompressedLength - 18);
    buf.unref();
    switch(type2) {
        case PDUTYPE2_UPDATE:
            {
                // (2 bytes): A 16-bit, unsigned integer. Type of the graphics update.
                int updateType = data.readUnsignedShortLE();
                ByteBuffer payload = data.readBytes(data.length - data.cursor);
                data.unref();
                switch(updateType) {
                    case UPDATETYPE_ORDERS:
                        pushDataToPad("orders", payload);
                        break;
                    case UPDATETYPE_BITMAP:
                        pushDataToPad("bitmap", payload);
                        break;
                    case UPDATETYPE_PALETTE:
                        pushDataToPad("palette", payload);
                        break;
                    case UPDATETYPE_SYNCHRONIZE:
                        // Ignore
                        payload.unref();
                        break;
                }
                break;
            }
        case PDUTYPE2_CONTROL:
            if (verbose)
                System.out.println("[" + this + "] INFO: Packet PDUTYPE2_CONTROL ignored.");
            // Ignore
            data.unref();
            break;
        case PDUTYPE2_POINTER:
            if (verbose)
                System.out.println("[" + this + "] INFO: Packet PDUTYPE2_POINTER ignored.");
            // Ignore
            data.unref();
            break;
        case PDUTYPE2_INPUT:
            if (verbose)
                System.out.println("[" + this + "] INFO: Packet PDUTYPE2_INPUT ignored.");
            // Ignore
            data.unref();
            break;
        case PDUTYPE2_SYNCHRONIZE:
            if (verbose)
                System.out.println("[" + this + "] INFO: Packet PDUTYPE2_SYNCHRONIZE ignored.");
            // Ignore
            data.unref();
            break;
        case PDUTYPE2_REFRESH_RECT:
            if (verbose)
                System.out.println("[" + this + "] INFO: Packet PDUTYPE2_REFRESH_RECT ignored.");
            // Ignore
            data.unref();
            break;
        case PDUTYPE2_PLAY_SOUND:
            if (verbose)
                System.out.println("[" + this + "] INFO: Packet PDUTYPE2_PLAY_SOUND ignored.");
            // Ignore
            data.unref();
            break;
        case PDUTYPE2_SUPPRESS_OUTPUT:
            if (verbose)
                System.out.println("[" + this + "] INFO: Packet PDUTYPE2_SUPPRESS_OUTPUT ignored.");
            // Ignore
            data.unref();
            break;
        case PDUTYPE2_SHUTDOWN_REQUEST:
            if (verbose)
                System.out.println("[" + this + "] INFO: Packet PDUTYPE2_SHUTDOWN_REQUEST ignored.");
            // Ignore
            data.unref();
            break;
        case PDUTYPE2_SHUTDOWN_DENIED:
            if (verbose)
                System.out.println("[" + this + "] INFO: Packet PDUTYPE2_SHUTDOWN_DENIED ignored.");
            // Ignore
            data.unref();
            break;
        case PDUTYPE2_SAVE_SESSION_INFO:
            if (verbose)
                System.out.println("[" + this + "] INFO: Packet PDUTYPE2_SAVE_SESSION_INFO ignored.");
            // Ignore
            data.unref();
            break;
        case PDUTYPE2_FONTLIST:
            if (verbose)
                System.out.println("[" + this + "] INFO: Packet PDUTYPE2_FONTLIST ignored.");
            // Ignore
            data.unref();
            break;
        case PDUTYPE2_FONTMAP:
            if (verbose)
                System.out.println("[" + this + "] INFO: Packet PDUTYPE2_FONTMAP ignored.");
            // Ignore
            data.unref();
            break;
        case PDUTYPE2_SET_KEYBOARD_INDICATORS:
            if (verbose)
                System.out.println("[" + this + "] INFO: Packet PDUTYPE2_SET_KEYBOARD_INDICATORS ignored.");
            // Ignore
            data.unref();
            break;
        case PDUTYPE2_BITMAPCACHE_PERSISTENT_LIST:
            if (verbose)
                System.out.println("[" + this + "] INFO: Packet PDUTYPE2_BITMAPCACHE_PERSISTENT_LIST ignored.");
            // Ignore
            data.unref();
            break;
        case PDUTYPE2_BITMAPCACHE_ERROR_PDU:
            if (verbose)
                System.out.println("[" + this + "] INFO: Packet PDUTYPE2_BITMAPCACHE_ERROR_PDU ignored.");
            // Ignore
            data.unref();
            break;
        case PDUTYPE2_SET_KEYBOARD_IME_STATUS:
            if (verbose)
                System.out.println("[" + this + "] INFO: Packet PDUTYPE2_SET_KEYBOARD_IME_STATUS ignored.");
            // Ignore
            data.unref();
            break;
        case PDUTYPE2_OFFSCRCACHE_ERROR_PDU:
            if (verbose)
                System.out.println("[" + this + "] INFO: Packet PDUTYPE2_OFFSCRCACHE_ERROR_PDU ignored.");
            // Ignore
            data.unref();
            break;
        case PDUTYPE2_SET_ERROR_INFO_PDU:
            if (verbose)
                System.out.println("[" + this + "] INFO: Packet PDUTYPE2_SET_ERROR_INFO_PDU ignored.");
            // Ignore
            data.unref();
            break;
        case PDUTYPE2_DRAWNINEGRID_ERROR_PDU:
            if (verbose)
                System.out.println("[" + this + "] INFO: Packet PDUTYPE2_DRAWNINEGRID_ERROR_PDU ignored.");
            // Ignore
            data.unref();
            break;
        case PDUTYPE2_DRAWGDIPLUS_ERROR_PDU:
            if (verbose)
                System.out.println("[" + this + "] INFO: Packet PDUTYPE2_DRAWGDIPLUS_ERROR_PDU ignored.");
            // Ignore
            data.unref();
            break;
        case PDUTYPE2_ARC_STATUS_PDU:
            if (verbose)
                System.out.println("[" + this + "] INFO: Packet PDUTYPE2_ARC_STATUS_PDU ignored.");
            // Ignore
            data.unref();
            break;
        case PDUTYPE2_STATUS_INFO_PDU:
            if (verbose)
                System.out.println("[" + this + "] INFO: Packet PDUTYPE2_STATUS_INFO_PDU ignored.");
            // Ignore
            data.unref();
            break;
        case PDUTYPE2_MONITOR_LAYOUT_PDU:
            if (verbose)
                System.out.println("[" + this + "] INFO: Packet PDUTYPE2_MONITOR_LAYOUT_PDU ignored.");
            // Ignore
            data.unref();
            break;
        default:
            throw new RuntimeException("Unknow data PDU type: " + type2 + ", data: " + buf + ".");
    }
}
Also used : ByteBuffer(streamer.ByteBuffer)

Aggregations

ByteBuffer (streamer.ByteBuffer)110 Element (streamer.Element)12 BaseElement (streamer.BaseElement)9 Pipeline (streamer.Pipeline)7 PipelineImpl (streamer.PipelineImpl)7 TSRequest (rdpclient.ntlmssp.asn1.TSRequest)6 MockSink (streamer.debug.MockSink)5 MockSource (streamer.debug.MockSource)5 BitmapRectangle (common.BitmapRectangle)3 ScreenDescription (common.ScreenDescription)3 SyncLink (streamer.SyncLink)3 AssertingByteBuffer (streamer.debug.AssertingByteBuffer)3 BitmapOrder (common.BitmapOrder)2 KeyOrder (common.KeyOrder)2 MouseOrder (common.MouseOrder)2 NegoItem (rdpclient.ntlmssp.asn1.NegoItem)2 Link (streamer.Link)2 FakeSink (streamer.debug.FakeSink)2 BufferedImageCanvas (common.BufferedImageCanvas)1 CopyRectOrder (common.CopyRectOrder)1