mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-15 07:43:50 +00:00
1. Added process.pid on windows
2. Added user-sessions.consoleUid() on windows 3. updated message-box to dispatch to consoleUid when necessary on Windows
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1047,8 +1047,11 @@ void ILibDuktape_ScriptContainer_Process_Init(duk_context *ctx, char **argList)
|
|||||||
|
|
||||||
#ifdef _POSIX
|
#ifdef _POSIX
|
||||||
duk_push_int(ctx, (duk_int_t)getpid());
|
duk_push_int(ctx, (duk_int_t)getpid());
|
||||||
ILibDuktape_CreateReadonlyProperty(ctx, "pid");
|
#else
|
||||||
|
duk_push_int(ctx, (duk_int_t)GetCurrentProcessId());
|
||||||
#endif
|
#endif
|
||||||
|
ILibDuktape_CreateReadonlyProperty(ctx, "pid");
|
||||||
|
|
||||||
|
|
||||||
emitter = ILibDuktape_EventEmitter_Create(ctx);
|
emitter = ILibDuktape_EventEmitter_Create(ctx);
|
||||||
ILibDuktape_EventEmitter_CreateEventEx(emitter, "exit");
|
ILibDuktape_EventEmitter_CreateEventEx(emitter, "exit");
|
||||||
|
|||||||
@@ -74,12 +74,33 @@ function messageBox()
|
|||||||
this._ObjectID = 'message-box';
|
this._ObjectID = 'message-box';
|
||||||
this.create = function create(title, caption, timeout)
|
this.create = function create(title, caption, timeout)
|
||||||
{
|
{
|
||||||
|
var GM = require('_GenericMarshal');
|
||||||
|
var kernel32 = GM.CreateNativeProxy('kernel32.dll');
|
||||||
|
kernel32.CreateMethod('ProcessIdToSessionId');
|
||||||
|
var psid = GM.CreateVariable(4);
|
||||||
|
if (kernel32.ProcessIdToSessionId(process.pid, psid).Val == 0)
|
||||||
|
{
|
||||||
|
ret._rej('Internal Error');
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
if (timeout == null) { timeout = 10; }
|
if (timeout == null) { timeout = 10; }
|
||||||
var ret = new promise(function (res, rej) { this._res = res; this._rej = rej; });
|
var ret = new promise(function (res, rej) { this._res = res; this._rej = rej; });
|
||||||
|
var options = { executionTimeout: timeout };
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
options.sessionId = require('user-sessions').consoleUid();
|
||||||
|
if (options.sessionId == psid.toBuffer().readUInt32LE()) { delete options.sessionId; }
|
||||||
|
}
|
||||||
|
catch(ee)
|
||||||
|
{
|
||||||
|
ret._rej('No logged on users');
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
ret._title = title;
|
ret._title = title;
|
||||||
ret._caption = caption;
|
ret._caption = caption;
|
||||||
|
ret._container = require('ScriptContainer').Create(options);
|
||||||
ret._container = require('ScriptContainer').Create(timeout, ContainerPermissions.DEFAULT);
|
|
||||||
ret._container.promise = ret;
|
ret._container.promise = ret;
|
||||||
ret._container.on('data', function (j)
|
ret._container.on('data', function (j)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ function UserSessions()
|
|||||||
this._marshal = require('_GenericMarshal');
|
this._marshal = require('_GenericMarshal');
|
||||||
this._kernel32 = this._marshal.CreateNativeProxy('Kernel32.dll');
|
this._kernel32 = this._marshal.CreateNativeProxy('Kernel32.dll');
|
||||||
this._kernel32.CreateMethod('GetLastError');
|
this._kernel32.CreateMethod('GetLastError');
|
||||||
|
this._kernel32.CreateMethod('WTSGetActiveConsoleSessionId')
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -202,7 +203,12 @@ function UserSessions()
|
|||||||
this._wts.WTSFreeMemory(buffer.Deref());
|
this._wts.WTSFreeMemory(buffer.Deref());
|
||||||
return (retVal);
|
return (retVal);
|
||||||
};
|
};
|
||||||
|
this.consoleUid = function consoleUid()
|
||||||
|
{
|
||||||
|
var id = this._kernel32.WTSGetActiveConsoleSessionId().Val;
|
||||||
|
if(id==0xFFFFFFFF) {throw('Nobody logged in');}
|
||||||
|
return (id);
|
||||||
|
};
|
||||||
this.Current = function Current(cb)
|
this.Current = function Current(cb)
|
||||||
{
|
{
|
||||||
var retVal = {};
|
var retVal = {};
|
||||||
|
|||||||
Reference in New Issue
Block a user