📄 rdp.java
字号:
data.setLittleEndian32(BMPCACHE2_C2_CELLS);
}
data.incrementPosition(20); // out_uint8s(s, 20); /* other bitmap caches
// not used */
}
private void sendColorcacheCaps(RdpPacket_Localised data) {
data.setLittleEndian16(RDP_CAPSET_COLCACHE);
data.setLittleEndian16(RDP_CAPLEN_COLCACHE);
data.setLittleEndian16(6); /* cache size */
data.setLittleEndian16(0); /* pad */
}
private void sendActivateCaps(RdpPacket_Localised data) {
data.setLittleEndian16(RDP_CAPSET_ACTIVATE);
data.setLittleEndian16(RDP_CAPLEN_ACTIVATE);
data.setLittleEndian16(0); /* Help key */
data.setLittleEndian16(0); /* Help index key */
data.setLittleEndian16(0); /* Extended help key */
data.setLittleEndian16(0); /* Window activate */
}
private void sendControlCaps(RdpPacket_Localised data) {
data.setLittleEndian16(RDP_CAPSET_CONTROL);
data.setLittleEndian16(RDP_CAPLEN_CONTROL);
data.setLittleEndian16(0); /* Control capabilities */
data.setLittleEndian16(0); /* Remote detach */
data.setLittleEndian16(2); /* Control interest */
data.setLittleEndian16(2); /* Detach interest */
}
private void sendPointerCaps(RdpPacket_Localised data) {
data.setLittleEndian16(RDP_CAPSET_POINTER);
data.setLittleEndian16(RDP_CAPLEN_POINTER);
data.setLittleEndian16(0); /* Colour pointer */
data.setLittleEndian16(20); /* Cache size */
}
private void sendShareCaps(RdpPacket_Localised data) {
data.setLittleEndian16(RDP_CAPSET_SHARE);
data.setLittleEndian16(RDP_CAPLEN_SHARE);
data.setLittleEndian16(0); /* userid */
data.setLittleEndian16(0); /* pad */
}
private void sendUnknownCaps(RdpPacket_Localised data, int id, int length,
byte[] caps) {
data.setLittleEndian16(id /* RDP_CAPSET_UNKNOWN */);
data.setLittleEndian16(length /* 0x58 */);
data.copyFromByteArray(caps, 0, data.getPosition(), /* RDP_CAPLEN_UNKNOWN */
length - 4);
data.incrementPosition(/* RDP_CAPLEN_UNKNOWN */length - 4);
}
private void sendSynchronize() throws RdesktopException, IOException,
CryptoException {
RdpPacket_Localised data = this.initData(4);
data.setLittleEndian16(1); // type
data.setLittleEndian16(1002);
data.markEnd();
logger.debug("sync");
this.sendData(data, RDP_DATA_PDU_SYNCHRONISE);
}
private void sendControl(int action) throws RdesktopException, IOException,
CryptoException {
RdpPacket_Localised data = this.initData(8);
data.setLittleEndian16(action);
data.setLittleEndian16(0); // userid
data.setLittleEndian32(0); // control id
data.markEnd();
logger.debug("control");
this.sendData(data, RDP_DATA_PDU_CONTROL);
}
public void sendInput(int time, int message_type, int device_flags,
int param1, int param2) {
RdpPacket_Localised data = null;
try {
data = this.initData(16);
} catch (RdesktopException e) {
Rdesktop.error(e, this, frame, false);
}
data.setLittleEndian16(1); /* number of events */
data.setLittleEndian16(0); /* pad */
data.setLittleEndian32(time);
data.setLittleEndian16(message_type);
data.setLittleEndian16(device_flags);
data.setLittleEndian16(param1);
data.setLittleEndian16(param2);
data.markEnd();
// logger.info("input");
// if(logger.isInfoEnabled()) logger.info(data);
try {
this.sendData(data, RDP_DATA_PDU_INPUT);
} catch (RdesktopException r) {
if (Common.rdp.isConnected())
Rdesktop.error(r, Common.rdp, Common.frame, true);
Common.exit();
} catch (CryptoException c) {
if (Common.rdp.isConnected())
Rdesktop.error(c, Common.rdp, Common.frame, true);
Common.exit();
} catch (IOException i) {
if (Common.rdp.isConnected())
Rdesktop.error(i, Common.rdp, Common.frame, true);
Common.exit();
}
}
private void sendFonts(int seq) throws RdesktopException, IOException,
CryptoException {
RdpPacket_Localised data = this.initData(8);
data.setLittleEndian16(0); /* number of fonts */
data.setLittleEndian16(0x3e); /* unknown */
data.setLittleEndian16(seq); /* unknown */
data.setLittleEndian16(0x32); /* entry size */
data.markEnd();
logger.debug("fonts");
this.sendData(data, RDP_DATA_PDU_FONT2);
}
private void processPointer(RdpPacket_Localised data)
throws RdesktopException {
int message_type = 0;
int x = 0, y = 0;
message_type = data.getLittleEndian16();
data.incrementPosition(2);
switch (message_type) {
case (Rdp.RDP_POINTER_MOVE):
logger.debug("Rdp.RDP_POINTER_MOVE");
x = data.getLittleEndian16();
y = data.getLittleEndian16();
if (data.getPosition() <= data.getEnd()) {
surface.movePointer(x, y);
}
break;
case (Rdp.RDP_POINTER_COLOR):
process_colour_pointer_pdu(data);
break;
case (Rdp.RDP_POINTER_CACHED):
process_cached_pointer_pdu(data);
break;
case RDP_POINTER_SYSTEM:
process_system_pointer_pdu(data);
break;
default:
break;
}
}
private void process_system_pointer_pdu(RdpPacket_Localised data) {
int system_pointer_type = 0;
data.getLittleEndian16(system_pointer_type); // in_uint16(s,
// system_pointer_type);
switch (system_pointer_type) {
case RDP_NULL_POINTER:
logger.debug("RDP_NULL_POINTER");
surface.setCursor(null);
break;
default:
logger.warn("Unimplemented system pointer message 0x"
+ Integer.toHexString(system_pointer_type));
// unimpl("System pointer message 0x%x\n", system_pointer_type);
}
}
protected void processBitmapUpdates(RdpPacket_Localised data)
throws RdesktopException {
// logger.info("processBitmapUpdates");
int n_updates = 0;
int left = 0, top = 0, right = 0, bottom = 0, width = 0, height = 0;
int cx = 0, cy = 0, bitsperpixel = 0, compression = 0, buffersize = 0, size = 0;
byte[] pixel = null;
int minX, minY, maxX, maxY;
maxX = maxY = 0;
minX = surface.getWidth();
minY = surface.getHeight();
n_updates = data.getLittleEndian16();
for (int i = 0; i < n_updates; i++) {
left = data.getLittleEndian16();
top = data.getLittleEndian16();
right = data.getLittleEndian16();
bottom = data.getLittleEndian16();
width = data.getLittleEndian16();
height = data.getLittleEndian16();
bitsperpixel = data.getLittleEndian16();
int Bpp = (bitsperpixel + 7) / 8;
compression = data.getLittleEndian16();
buffersize = data.getLittleEndian16();
cx = right - left + 1;
cy = bottom - top + 1;
if (minX > left)
minX = left;
if (minY > top)
minY = top;
if (maxX < right)
maxX = right;
if (maxY < bottom)
maxY = bottom;
/* Server may limit bpp - this is how we find out */
if (Options.server_bpp != bitsperpixel) {
logger.warn("Server limited colour depth to " + bitsperpixel
+ " bits");
Options.set_bpp(bitsperpixel);
}
if (compression == 0) {
// logger.info("compression == 0");
pixel = new byte[width * height * Bpp];
for (int y = 0; y < height; y++) {
data.copyToByteArray(pixel, (height - y - 1)
* (width * Bpp), data.getPosition(), width * Bpp);
data.incrementPosition(width * Bpp);
}
surface.displayImage(Bitmap.convertImage(pixel, Bpp), width,
height, left, top, cx, cy);
continue;
}
if ((compression & 0x400) != 0) {
// logger.info("compression & 0x400 != 0");
size = buffersize;
} else {
// logger.info("compression & 0x400 == 0");
data.incrementPosition(2); // pad
size = data.getLittleEndian16();
data.incrementPosition(4); // line size, final size
}
if (Bpp == 1) {
pixel = Bitmap.decompress(width, height, size, data, Bpp);
if (pixel != null)
surface.displayImage(Bitmap.convertImage(pixel, Bpp),
width, height, left, top, cx, cy);
else
logger.warn("Could not decompress bitmap");
} else {
if (Options.bitmap_decompression_store == Options.INTEGER_BITMAP_DECOMPRESSION) {
int[] pixeli = Bitmap.decompressInt(width, height, size,
data, Bpp);
if (pixeli != null)
surface.displayImage(pixeli, width, height, left, top,
cx, cy);
else
logger.warn("Could not decompress bitmap");
} else if (Options.bitmap_decompression_store == Options.BUFFEREDIMAGE_BITMAP_DECOMPRESSION) {
Image pix = Bitmap.decompressImg(width, height, size, data,
Bpp, null);
if (pix != null)
surface.displayImage(pix, left, top);
else
logger.warn("Could not decompress bitmap");
} else {
surface.displayCompressed(left, top, width, height, size,
data, Bpp, null);
}
}
}
surface.repaint(minX, minY, maxX - minX + 1, maxY - minY + 1);
}
protected void processPalette(RdpPacket_Localised data) {
int n_colors = 0;
IndexColorModel cm = null;
byte[] palette = null;
byte[] red = null;
byte[] green = null;
byte[] blue = null;
int j = 0;
data.incrementPosition(2); // pad
n_colors = data.getLittleEndian16(); // Number of Colors in Palette
data.incrementPosition(2); // pad
palette = new byte[n_colors * 3];
red = new byte[n_colors];
green = new byte[n_colors];
blue = new byte[n_colors];
data.copyToByteArray(palette, 0, data.getPosition(), palette.length);
data.incrementPosition(palette.length);
for (int i = 0; i < n_colors; i++) {
red[i] = palette[j];
green[i] = palette[j + 1];
blue[i] = palette[j + 2];
j += 3;
}
cm = new IndexColorModel(8, n_colors, red, green, blue);
surface.registerPalette(cm);
}
public void registerDrawingSurface(RdesktopFrame fr) {
this.frame = fr;
RdesktopCanvas ds = fr.getCanvas();
this.surface = ds;
orders.registerDrawingSurface(ds);
}
/* Process a null system pointer PDU */
protected void process_null_system_pointer_pdu(RdpPacket_Localised s)
throws RdesktopException {
// FIXME: We should probably set another cursor here,
// like the X window system base cursor or something.
surface.setCursor(cache.getCursor(0));
}
protected void process_colour_pointer_pdu(RdpPacket_Localised data)
throws RdesktopException {
logger.debug("Rdp.RDP_POINTER_COLOR");
int x = 0, y = 0, width = 0, height = 0, cache_idx = 0, masklen = 0, datalen = 0;
byte[] mask = null, pixel = null;
Cursor cursor = null;
cache_idx = data.getLittleEndian16();
x = data.getLittleEndian16();
y = data.getLittleEndian16();
width = data.getLittleEndian16();
height = data.getLittleEndian16();
masklen = data.getLittleEndian16();
datalen = data.getLittleEndian16();
mask = new byte[masklen];
pixel = new byte[datalen];
data.copyToByteArray(pixel, 0, data.getPosition(), datalen);
data.incrementPosition(datalen);
data.copyToByteArray(mask, 0, data.getPosition(), masklen);
data.incrementPosition(masklen);
cursor = surface.createCursor(x, y, width, height, mask, pixel,
cache_idx);
// logger.info("Creating and setting cursor " + cache_idx);
surface.setCursor(cursor);
cache.putCursor(cache_idx, cursor);
}
protected void process_cached_pointer_pdu(RdpPacket_Localised data)
throws RdesktopException {
logger.debug("Rdp.RDP_POINTER_CACHED");
int cache_idx = data.getLittleEndian16();
// logger.info("Setting cursor "+cache_idx);
surface.setCursor(cache.getCursor(cache_idx));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -