Fixed remote desktop recording feature.

This commit is contained in:
Ylian Saint-Hilaire 2020-06-18 12:47:34 -07:00
parent 9d2fbcef50
commit c4217361a7
2 changed files with 21 additions and 2 deletions

View File

@ -198,6 +198,15 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
if ((cmd == 3) || (cmd == 4) || (cmd == 7)) { X = (view[4] << 8) + view[5]; Y = (view[6] << 8) + view[7]; }
//console.log('CMD', cmd, cmdsize, X, Y);
// Record the command if needed
if (obj.recordedData != null) {
if (cmdsize > 65000) {
obj.recordedData.push(recordingEntry(2, 1, obj.shortToStr(27) + obj.shortToStr(8) + obj.intToStr(cmdsize) + obj.shortToStr(cmd) + obj.shortToStr(0) + obj.shortToStr(0) + obj.shortToStr(0) + String.fromCharCode.apply(null, view)));
} else {
obj.recordedData.push(recordingEntry(2, 1, String.fromCharCode.apply(null, view)));
}
}
switch (cmd) {
case 3: // Tile
if (obj.FirstDraw) obj.onResize();
@ -756,7 +765,7 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
obj.recordedData.push(recordingEntry(1, 0, JSON.stringify({ magic: 'MeshCentralRelaySession', ver: 1, time: new Date().toLocaleString(), protocol: 2 }))); // Metadata (nodeid: obj.nodeid)
obj.recordedData.push(recordingEntry(2, 1, obj.shortToStr(7) + obj.shortToStr(8) + obj.shortToStr(obj.ScreenWidth) + obj.shortToStr(obj.ScreenHeight))); // Screen width and height
// Save a screenshot
var cmdlen = (4 + binary.length);
var cmdlen = (8 + binary.length);
if (cmdlen > 65000) {
// Jumbo Packet
obj.recordedData.push(recordingEntry(2, 1, obj.shortToStr(27) + obj.shortToStr(8) + obj.intToStr(cmdlen) + obj.shortToStr(3) + obj.shortToStr(0) + obj.shortToStr(0) + obj.shortToStr(0) + binary));

View File

@ -310,7 +310,17 @@
agentTerminal.ProcessData(data);
} else if (recFileProtocol == 2) {
// MeshCentral Remote Desktop
agentDesktop.ProcessData(data);
var view = new Uint8Array(data.length);
for (var i = 0; i < data.length; i++) { view[i] = data.charCodeAt(i); }
// Accumulator is not active
var cmd = (view[0] << 8) + view[1], cmdsize = (view[2] << 8) + view[3];
if ((cmd == 27) && (cmdsize == 8)) { cmd = (view[8] << 8) + view[9]; cmdsize = (view[5] << 16) + (view[6] << 8) + view[7]; view = view.slice(8); }
if (cmdsize != view.byteLength) {
console.log('Bad command size', cmd, cmdsize, view.byteLength);
} else {
agentDesktop.ProcessBinaryCommand(cmd, cmdsize, view.slice(0, cmdsize));
}
} else if (recFileProtocol == 101) {
// Intel AMT KVM
if ((readState == 0) && (rstr2hex(data) == '4100000000000000')) {