@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();
}