1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-03-09 15:40:18 +00:00

Updated MeshAgents, all except FreeBSD and MacOS.

This commit is contained in:
Ylian Saint-Hilaire 2020-01-30 14:31:32 -08:00
parent 76c67aeb82
commit efb7ac9dba
20 changed files with 44 additions and 6 deletions

View file

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