mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-15 07:43:50 +00:00
1. Added 'global' polyfill
2. Updated service-manager in Native and JS, to add '_installedBy' on Windows
This commit is contained in:
@@ -108,6 +108,27 @@ BOOL RunAsAdmin(char* args) {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdateOwnerData()
|
||||||
|
{
|
||||||
|
WCHAR str[_MAX_PATH];
|
||||||
|
DWORD strLen;
|
||||||
|
strLen = GetModuleFileNameW(NULL, str, _MAX_PATH);
|
||||||
|
|
||||||
|
int exePathLen = WideCharToMultiByte(CP_UTF8, 0, (LPCWCH)str, -1, NULL, 0, NULL, NULL);
|
||||||
|
char *exePath = (char*)ILibMemory_SmartAllocate(exePathLen);
|
||||||
|
WideCharToMultiByte(CP_UTF8, 0, (LPCWCH)str, -1, exePath, exePathLen, NULL, NULL);
|
||||||
|
|
||||||
|
void *chain = ILibCreateChain();
|
||||||
|
duk_context *ctx = ILibDuktape_ScriptContainer_InitializeJavaScriptEngineEx(0, 0, chain, NULL, NULL, exePath, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
duk_peval_string_noresult(ctx, "global._noMessagePump=true;var key=require('win-registry').usernameToUserKey(require('user-sessions').getProcessOwnerName(process.pid).name);var reg=require('win-registry');reg.WriteKey(reg.HKEY.LocalMachine, 'SYSTEM\\\\CurrentControlSet\\\\Services\\\\Mesh Agent', '_InstalledBy', key);");
|
||||||
|
|
||||||
|
duk_destroy_heap(ctx);
|
||||||
|
ILibChain_DestroyEx(chain);
|
||||||
|
ILibMemory_Free(exePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DWORD WINAPI ServiceControlHandler( DWORD controlCode, DWORD eventType, void *eventData, void* eventContext )
|
DWORD WINAPI ServiceControlHandler( DWORD controlCode, DWORD eventType, void *eventData, void* eventContext )
|
||||||
{
|
{
|
||||||
switch (controlCode)
|
switch (controlCode)
|
||||||
@@ -874,6 +895,7 @@ void fullinstall(int uninstallonly, char* proxy, int proxylen, char* tag, int ta
|
|||||||
|
|
||||||
// Add the uninstall icon in the control panel
|
// Add the uninstall icon in the control panel
|
||||||
AddUninstallIcon();
|
AddUninstallIcon();
|
||||||
|
UpdateOwnerData();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#if defined(_LINKVM)
|
#if defined(_LINKVM)
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -618,6 +618,21 @@ function serviceManager()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Object.defineProperty(retVal, 'installedBy',
|
||||||
|
{
|
||||||
|
get: function()
|
||||||
|
{
|
||||||
|
var reg = require('win-registry');
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return(reg.QueryKey(reg.HKEY.LocalMachine, 'SYSTEM\\CurrentControlSet\\Services\\' + this.name, '_InstalledBy'));
|
||||||
|
}
|
||||||
|
catch(xx)
|
||||||
|
{
|
||||||
|
return (null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
if (retVal.status.state != 'UNKNOWN')
|
if (retVal.status.state != 'UNKNOWN')
|
||||||
{
|
{
|
||||||
require('events').EventEmitter.call(retVal);
|
require('events').EventEmitter.call(retVal);
|
||||||
@@ -1532,6 +1547,7 @@ function serviceManager()
|
|||||||
|
|
||||||
if (process.platform == 'win32')
|
if (process.platform == 'win32')
|
||||||
{
|
{
|
||||||
|
var reg = require('win-registry');
|
||||||
if (!this.isAdmin()) { throw ('Installing as Service, requires admin'); }
|
if (!this.isAdmin()) { throw ('Installing as Service, requires admin'); }
|
||||||
|
|
||||||
// Before we start, we need to copy the binary to the right place
|
// Before we start, we need to copy the binary to the right place
|
||||||
@@ -1616,13 +1632,24 @@ function serviceManager()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (options.parameters)
|
if (options.parameters)
|
||||||
{
|
{
|
||||||
var reg = require('win-registry');
|
|
||||||
var imagePath = reg.QueryKey(reg.HKEY.LocalMachine, 'SYSTEM\\CurrentControlSet\\Services\\' + options.name, 'ImagePath');
|
var imagePath = reg.QueryKey(reg.HKEY.LocalMachine, 'SYSTEM\\CurrentControlSet\\Services\\' + options.name, 'ImagePath');
|
||||||
imagePath += (' ' + options.parameters.join(' '));
|
imagePath += (' ' + options.parameters.join(' '));
|
||||||
reg.WriteKey(reg.HKEY.LocalMachine, 'SYSTEM\\CurrentControlSet\\Services\\' + options.name, 'ImagePath', imagePath);
|
reg.WriteKey(reg.HKEY.LocalMachine, 'SYSTEM\\CurrentControlSet\\Services\\' + options.name, 'ImagePath', imagePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
reg.WriteKey(reg.HKEY.LocalMachine, 'SYSTEM\\CurrentControlSet\\Services\\' + options.name, '_InstalledBy', reg.usernameToUserKey(require('user-sessions').getProcessOwnerName(process.pid).name));
|
||||||
|
}
|
||||||
|
catch (xx)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (process.platform == 'freebsd')
|
if (process.platform == 'freebsd')
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -320,7 +320,8 @@ function UserSessions()
|
|||||||
return (retVal);
|
return (retVal);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!global._noMessagePump)
|
||||||
|
{
|
||||||
// We need to spin up a message pump, and fetch a window handle
|
// We need to spin up a message pump, and fetch a window handle
|
||||||
var message_pump = require('win-message-pump');
|
var message_pump = require('win-message-pump');
|
||||||
this._messagepump = new message_pump({ filter: WM_WTSSESSION_CHANGE }); this._messagepump.parent = this;
|
this._messagepump = new message_pump({ filter: WM_WTSSESSION_CHANGE }); this._messagepump.parent = this;
|
||||||
@@ -430,6 +431,7 @@ function UserSessions()
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if(process.platform == 'linux' || process.platform == 'freebsd')
|
else if(process.platform == 'linux' || process.platform == 'freebsd')
|
||||||
{
|
{
|
||||||
if (process.platform == 'linux')
|
if (process.platform == 'linux')
|
||||||
|
|||||||
Reference in New Issue
Block a user