Package streamer

Examples of streamer.ByteBuffer


    @Override
    protected void onStart() {
        super.onStart();

        // Length of packet
        ByteBuffer buf = new ByteBuffer(1024, true);

        // MCS Send Data Request PDU
        buf.writeByte(0x64);

        // Initiator: 0x03 + 1001 = 1004
        buf.writeShort(3);

        // Channel ID: 1003
        buf.writeShort(1003);

        // Data priority: high, segmentation: begin | end (0x40 | 0x20 | 0x10 = 0x70)
        buf.writeByte(0x70);

        // User data length: (variable length field)
        int length = 224 + userName.length + password.length + alternateShell.length + domain.length + workingDir.length + clientAddress.length + clientDir.length;
        buf.writeShort(length | 0x8000);

        // Flags: SEC_INFO_PKT (0x4000)
        buf.writeShort(0x4000);

        // TS_SECURITY_HEADER::flagsHi - ignored
        buf.writeShort(0x0000);

        // Codepage: 0 (UNKNOWN, LE) (use  0x04090409  (1033,1033) for EN_US)
        buf.writeIntLE(0x0000);

        // Flags
        buf.writeIntLE(INFO_MOUSE | INFO_DISABLECTRLALTDEL | INFO_UNICODE |
                INFO_MAXIMIZESHELL | INFO_LOGONNOTIFY | INFO_ENABLEWINDOWSKEY |
                INFO_MOUSE_HAS_WHEEL | INFO_NOAUDIOPLAYBACK);

        //
        // Lengths
        //

        // cbDomain length: 0 bytes (LE) (NOT including size of mandatory NULL terminator)
        buf.writeShortLE(domain.length);

        // cbUserName length: 16 bytes (0x10, LE) (NOT including size of mandatory NULL terminator)
        buf.writeShortLE(userName.length);

        // cbPassword length: (LE) (NOT including size of mandatory NULL terminator)
        buf.writeShortLE(password.length);

        // cbAlternateShell:  (LE) (NOT including size of mandatory NULL terminator)
        buf.writeShortLE(alternateShell.length);

        // cbWorkingDir: (LE) (NOT including size of mandatory NULL terminator)
        buf.writeShortLE(workingDir.length);

        //
        // Values
        //

        // Domain: (UCS2), see cbDomain
        buf.writeBytes(domain);
        buf.writeShort(0);

        // User name: (UCS2), see cbUserName
        buf.writeBytes(userName);
        buf.writeShort(0);

        // Password: (UCS2), see cbPassword
        buf.writeBytes(password);
        buf.writeShort(0);

        // Alternate shell: (UCS2), see cbAlternateShell
        buf.writeBytes(alternateShell);
        buf.writeShort(0);

        // Working directory: (UCS2), see cbWorkingDir
        buf.writeBytes(workingDir);
        buf.writeShort(0);

        // Client address family: 2 (AF_INET, LE)
        buf.writeShortLE(2);

        // cbClientAddress: ( LE) (including the size of the mandatory NULL terminator)
        buf.writeShortLE(clientAddress.length + 2);

        // Client address: (UCS2)
        buf.writeBytes(clientAddress);
        buf.writeShort(0);

        // cbClientDir: 64 bytes (0x40, LE) (including the size of the mandatory NULL terminator)
        buf.writeShortLE(clientDir.length + 2);

        // Client directory: (UCS2)
        buf.writeBytes(clientDir);
        buf.writeShort(0);

        //
        // Client time zone:
        //

        // Bias: 0 minutes (LE)
        buf.writeIntLE(0);

        // Standard name: "EET, Standard Time" (fixed string: 64 bytes, UCS2)
        buf.writeFixedString(62, standardTimeZoneName, RdpConstants.CHARSET_16);
        buf.writeShort(0);

        // Standard date
        buf.writeBytes(new byte[] {
                // wYear: 0 (LE)
                (byte)0x00, (byte)0x00,
                // wMonth: unknown (LE)
                (byte)0x00, (byte)0x00,
                // wDayOfWeek: Sunday (LE)
                (byte)0x00, (byte)0x00,
                // wDay: unknown (LE)
                (byte)0x00, (byte)0x00,
                // wHour: 0 (LE)
                (byte)0x00, (byte)0x00,
                // wMinute: 0 (LE)
                (byte)0x00, (byte)0x00,
                // wSecond: 0 (LE)
                (byte)0x00, (byte)0x00,
                // wMilliseconds: 0
                (byte)0x00, (byte)0x00,

        });

        // StandardBias: 0 minutes (LE)
        buf.writeIntLE(standardTimeZoneBias);

        // Daylight name: "EET, Summer Time" (fixed string: 64 bytes, UCS2)
        buf.writeFixedString(62, daylightTimeZoneName, RdpConstants.CHARSET_16);
        buf.writeShort(0);

        // Daylight date
        buf.writeBytes(new byte[] {
                // wYear: 0 (LE)
                (byte)0x00, (byte)0x00,
                // wMonth: unknown (LE)
                (byte)0x00, (byte)0x00,
                // wDayOfWeek: Sunday (LE)
                (byte)0x00, (byte)0x00,
                // wDay: unknown (LE)
                (byte)0x00, (byte)0x00,
                // wHour: 0 (LE)
                (byte)0x00, (byte)0x00,
                // wMinute: 0 (LE)
                (byte)0x00, (byte)0x00,
                // wSecond: 0 (LE)
                (byte)0x00, (byte)0x00,
                // wMilliseconds: 0
                (byte)0x00, (byte)0x00,

        });

        // Daylight bias: 60 minutes (LE)
        buf.writeIntLE(daylightTimeZoneBias);

        // Client session ID: 0x00000000 (LE)
        buf.writeIntLE(0);

        // Performance flags: 0x7 (LE) = PERF_DISABLE_WALLPAPER (0x1), PERF_DISABLE_FULLWINDOWDRAG (0x2), PERF_DISABLE_MENUANIMATIONS (0x4)
        buf.writeIntLE(PERF_DISABLE_WALLPAPER | PERF_DISABLE_FULLWINDOWDRAG | PERF_DISABLE_MENUANIMATIONS);

        // cbAutoReconnectCookie: 0 bytes (LE)
        buf.writeShortLE(0);

        // Trim buffer to actual length of data written
        buf.trimAtCursor();

        pushDataToOTOut(buf);

        switchOff();
    }
View Full Code Here


                    + numberColors + ", data: " + buf + ".");

        // (variable): An array of palette entries in RGB triplet format packed on
        // byte boundaries. The number of triplet entries is given by the
        // numberColors field.
        ByteBuffer paletteEntries = buf.readBytes(numberColors * 3);

        // In the case of a Palette Update, the client MUST update the global
        // palette on all drawing surfaces
        screen.colorMap = new IndexColorModel(8, numberColors, paletteEntries.data, paletteEntries.offset, false);

View Full Code Here

            long length = buf.readBerLength();

            if (length > buf.length)
                throw new RuntimeException("BER value is too long: " + length + " bytes. Data: " + buf + ".");

            ByteBuffer value = buf.readBytes((int)length);

            readTagValue(value);

            value.unref();
        } else {

            readTagValue(buf, typeAndFlags);
        }
    }
View Full Code Here

    }

    @Override
    public Tag copyFrom(Tag tag) {
        super.copyFrom(tag);
        value = new ByteBuffer(((BitString)tag).value.toByteArray());
        return this;
    }
View Full Code Here

    @Override
    public Tag copyFrom(Tag tag) {
        super.copyFrom(tag);
        tagType = tag.tagType;
        value = new ByteBuffer(((Any)tag).value.toByteArray());
        return this;
    }
View Full Code Here

    }

    @Override
    public Tag copyFrom(Tag tag) {
        super.copyFrom(tag);
        value = new ByteBuffer(((ObjectID)tag).value.toByteArray());
        return this;
    }
View Full Code Here

        long length = buf.readBerLength();
        if (length > buf.remainderLength())
            throw new RuntimeException("BER sequence is too long: " + length + " bytes, while buffer remainder length is " + buf.remainderLength() + ". Data: " + buf
                    + ".");

        ByteBuffer value = buf.readBytes((int)length);
        parseContent(value);

        value.unref();
    }
View Full Code Here

        sendPreConnectionBlobData(data);
    }

    protected void sendPreConnectionBlobData(String data) {
        // Length of packet
        ByteBuffer buf = new ByteBuffer(1024, true);

        // Header
        buf.writeBytes(new byte[] {(byte)0x5e, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x02,
                (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,});

        // Length of string in wide characters + two wide \0 (LE)
        buf.writeShortLE(data.length() + 2);

        // Wide string + two wide '\0' characters
        buf.writeString(data + "\0\0", RdpConstants.CHARSET_16);

        // Trim buffer to actual length of data written
        buf.trimAtCursor();

        pushDataToOTOut(buf);

        switchOff();
    }
View Full Code Here

            System.out.println("[" + this + "] INFO: Data received: " + buf + ".");

        KeyOrder order = (KeyOrder)buf.getOrder();
        buf.unref();

        ByteBuffer outBuf = new ByteBuffer(2, true);

        int scanCode = map_en_us(order.event);

        // eventHeader (1 byte): An 8-bit, unsigned integer. The format of this
        // field is the same as the eventHeader byte field described in section
        // 2.2.8.1.2.2. The eventCode bitfield (3 bits in size) MUST be set to
        // FASTPATH_INPUT_EVENT_SCANCODE (0). The eventFlags bitfield (5 bits in
        // size) contains flags describing the keyboard event.
        outBuf.writeByte((scanCode >> 8) | (FASTPATH_INPUT_EVENT_SCANCODE << 5) | ((order.pressed) ? 0 : FASTPATH_INPUT_KBDFLAGS_RELEASE));

        // keyCode (1 byte): An 8-bit, unsigned integer. The scancode of the key
        // which triggered the event.
        outBuf.writeByte(scanCode);

        // Push buffer to one pad only, so it can be modified without copying of
        // data
        pushDataToPad(STDOUT, outBuf);
    }
View Full Code Here

            System.out.println("[" + this + "] INFO: Data received: " + buf + ".");

        // Get mouse event
        MouseOrder order = (MouseOrder)buf.getOrder();

        ByteBuffer outBuf = new ByteBuffer(7, true);

        // eventHeader (1 byte): An 8-bit, unsigned integer. EventCode bitfield (top
        // 3 bits) MUST be set to FASTPATH_INPUT_EVENT_MOUSE (1). The
        // eventFlags bitfield (low 5 bits) MUST be zeroed out.
        outBuf.writeByte(FASTPATH_INPUT_EVENT_MOUSE << 5);

        // pointerFlags (2 bytes): A 16-bit, unsigned integer.
        outBuf.writeShortLE(getPointerFlags(order));

        // xPos (2 bytes): A 16-bit, unsigned integer. The x-coordinate of the
        // pointer.
        outBuf.writeShortLE(order.event.getX());

        // yPos (2 bytes): A 16-bit, unsigned integer. The y-coordinate of the
        // pointer.
        outBuf.writeShortLE(order.event.getY());

        // Push buffer to one pad only, so it can be modified without copying of
        // data
        pushDataToPad(STDOUT, outBuf);
    }
View Full Code Here

TOP

Related Classes of streamer.ByteBuffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.