diff --git a/agents/MeshCmd-signed.exe b/agents/MeshCmd-signed.exe index b34623f0..f7ea3e60 100644 Binary files a/agents/MeshCmd-signed.exe and b/agents/MeshCmd-signed.exe differ diff --git a/agents/MeshCmd64-signed.exe b/agents/MeshCmd64-signed.exe index 9fa5496c..cb48de60 100644 Binary files a/agents/MeshCmd64-signed.exe and b/agents/MeshCmd64-signed.exe differ diff --git a/agents/MeshService-signed.exe b/agents/MeshService-signed.exe index 965f06ca..e4be50b6 100644 Binary files a/agents/MeshService-signed.exe and b/agents/MeshService-signed.exe differ diff --git a/agents/MeshService.exe b/agents/MeshService.exe index a1f6a2ac..056bbba8 100644 Binary files a/agents/MeshService.exe and b/agents/MeshService.exe differ diff --git a/agents/MeshService64-signed.exe b/agents/MeshService64-signed.exe index 765e5cd9..4d249962 100644 Binary files a/agents/MeshService64-signed.exe and b/agents/MeshService64-signed.exe differ diff --git a/agents/MeshService64.exe b/agents/MeshService64.exe index bb5586d2..47333b81 100644 Binary files a/agents/MeshService64.exe and b/agents/MeshService64.exe differ diff --git a/agents/meshagent_arm b/agents/meshagent_arm index 38ac7c8b..8cff5af3 100644 Binary files a/agents/meshagent_arm and b/agents/meshagent_arm differ diff --git a/agents/meshagent_arm64 b/agents/meshagent_arm64 index 5047e995..40df0512 100644 Binary files a/agents/meshagent_arm64 and b/agents/meshagent_arm64 differ diff --git a/agents/meshagent_armhf b/agents/meshagent_armhf index db0b06d8..b7479dd1 100644 Binary files a/agents/meshagent_armhf and b/agents/meshagent_armhf differ diff --git a/agents/meshagent_mips b/agents/meshagent_mips index a00626bd..156bd163 100644 Binary files a/agents/meshagent_mips and b/agents/meshagent_mips differ diff --git a/agents/meshagent_pogo b/agents/meshagent_pogo index 7a4f6526..3532e55c 100644 Binary files a/agents/meshagent_pogo and b/agents/meshagent_pogo differ diff --git a/agents/meshagent_poky b/agents/meshagent_poky index b1e6759e..7ec97c38 100644 Binary files a/agents/meshagent_poky and b/agents/meshagent_poky differ diff --git a/agents/meshagent_poky64 b/agents/meshagent_poky64 index 630ad419..1856e00e 100644 Binary files a/agents/meshagent_poky64 and b/agents/meshagent_poky64 differ diff --git a/agents/meshagent_x86 b/agents/meshagent_x86 index d5222f01..1597a8cc 100644 Binary files a/agents/meshagent_x86 and b/agents/meshagent_x86 differ diff --git a/agents/meshagent_x86-64 b/agents/meshagent_x86-64 index 958ac12c..68c8a7b0 100644 Binary files a/agents/meshagent_x86-64 and b/agents/meshagent_x86-64 differ diff --git a/agents/meshagent_x86-64_nokvm b/agents/meshagent_x86-64_nokvm index b4765b95..aa9bafb2 100644 Binary files a/agents/meshagent_x86-64_nokvm and b/agents/meshagent_x86-64_nokvm differ diff --git a/agents/meshagent_x86_nokvm b/agents/meshagent_x86_nokvm index babfb0c6..95388805 100644 Binary files a/agents/meshagent_x86_nokvm and b/agents/meshagent_x86_nokvm differ diff --git a/agents/meshcore.js b/agents/meshcore.js index d867e9ac..ae9ce056 100644 --- a/agents/meshcore.js +++ b/agents/meshcore.js @@ -1165,7 +1165,6 @@ function createMeshCore(agent) { this.httprequest._dispatcher.ws = this; this.httprequest._dispatcher.on('connection', function (c) { - console.log('client connected'); this.ws._term = c; c.pipe(this.ws, { dataTypeSkip: 1 }); this.ws.pipe(c, { dataTypeSkip: 1 }); diff --git a/agents/modules_meshcore/win-terminal.js b/agents/modules_meshcore/win-terminal.js index ac6ad3e4..29234222 100644 --- a/agents/modules_meshcore/win-terminal.js +++ b/agents/modules_meshcore/win-terminal.js @@ -146,6 +146,10 @@ function windows_terminal() { this.StartEx = function Start(CONSOLE_SCREEN_WIDTH, CONSOLE_SCREEN_HEIGHT, terminalTarget) { + // The older windows terminal does not support + CONSOLE_SCREEN_WIDTH = 80; + CONSOLE_SCREEN_HEIGHT = 25; + if (this._stream != null) { throw ('Concurrent terminal sessions are not supported on Windows.'); diff --git a/agents/modules_meshcore/win-virtual-terminal.js b/agents/modules_meshcore/win-virtual-terminal.js index f459ad95..13479ff1 100644 --- a/agents/modules_meshcore/win-virtual-terminal.js +++ b/agents/modules_meshcore/win-virtual-terminal.js @@ -1,5 +1,5 @@ /* -Copyright 2019-2020 Intel Corporation +Copyright 2019 Intel Corporation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -47,12 +47,16 @@ function vt() var GM = require('_GenericMarshal'); var k32 = GM.CreateNativeProxy('kernel32.dll'); + k32.CreateMethod('CancelIoEx'); k32.CreateMethod('CreatePipe'); k32.CreateMethod('CreateProcessW'); k32.CreateMethod('CreatePseudoConsole'); + k32.CreateMethod('CloseHandle'); + k32.CreateMethod('ClosePseudoConsole'); k32.CreateMethod('GetProcessHeap'); k32.CreateMethod('HeapAlloc'); k32.CreateMethod('InitializeProcThreadAttributeList'); + k32.CreateMethod('ResizePseudoConsole'); k32.CreateMethod('UpdateProcThreadAttribute'); k32.CreateMethod('WriteFile'); k32.CreateMethod('ReadFile'); @@ -101,16 +105,46 @@ function vt() { if (this.terminal._process) { - this.terminal.k32.TerminateProcess(this.terminal._process, 0); this.terminal._process = null; - this.terminal.k32.ReadFile.async.abort(); + k32.ClosePseudoConsole(this._obj._h.Deref()); } flush(); } }); + ds._obj = ret; ret._waiter = require('DescriptorEvents').addDescriptor(pi.Deref(0)); ret._waiter.ds = ds; - ret._waiter.on('signaled', function () { this.ds.push(null); }); + ret._waiter._obj = ret; + ret._waiter.on('signaled', function () + { + k32.CancelIoEx(this._obj._output.Deref(), 0); + + // Child process has exited + this.ds.push(null); + + if (this._obj._process) + { + this._obj._process = null; + k32.ClosePseudoConsole(this._obj._h.Deref()); + } + k32.CloseHandle(this._obj._input.Deref()); + k32.CloseHandle(this._obj._output.Deref()); + + k32.CloseHandle(this._obj._consoleInput.Deref()); + k32.CloseHandle(this._obj._consoleOutput.Deref()); + }); + ds.resizeTerminal = function (w, h) + { + console.setDestination(console.Destinations.LOGFILE); + console.log('resizeTerminal(' + w + ', ' + h + ')'); + var hr; + if((hr=k32.ResizePseudoConsole(this._obj._h.Deref(), (h << 16) | w).Val) != 0) + { + console.log('HResult=' + hr); + throw ('Resize returned HRESULT: ' + hr); + } + console.log('SUCCESS'); + }; ds.terminal = ret; ds._rpbuf = GM.CreateVariable(4096); @@ -121,6 +155,8 @@ function vt() this._rp.then(function () { var len = this.parent._rpbufRead.toBuffer().readUInt32LE(); + if (len <= 0) { return; } + this.parent.push(this.parent._rpbuf.toBuffer().slice(0, len)); this.parent.__read(); }); @@ -131,7 +167,6 @@ function vt() } else { - console.log('FAILED!'); } }