1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-22 03:03:18 +00:00

Added 'exstate' parameter that returns the windows service manager service state as the status code

This commit is contained in:
Bryan Roe
2022-09-15 23:47:11 -07:00
parent 81c3253e05
commit e0044984e5
3 changed files with 13 additions and 6 deletions

View File

@@ -598,6 +598,12 @@ int wmain(int argc, char* wargv[])
integratedJavaScript = ILibString_Copy(script, sizeof(script) - 1);
integragedJavaScriptLen = (int)sizeof(script) - 1;
}
if (argc > 1 && (strcasecmp(argv[1], "exstate") == 0))
{
char script[] = "var r={rawState: -1, state: 'NOT INSTALLED'};try{r=require('service-manager').manager.getService(require('_agentNodeId').serviceName()).status;}catch(z){};console.log(r.state);process.exit(r.rawState);";
integratedJavaScript = ILibString_Copy(script, sizeof(script) - 1);
integragedJavaScriptLen = (int)sizeof(script) - 1;
}
if (argc > 1 && (strcasecmp(argv[1], "state") == 0))
{
char script[] = "try{console.log(require('service-manager').manager.getService(require('_agentNodeId').serviceName()).status.state);}catch(z){console.log('NOT INSTALLED');};process.exit();";

File diff suppressed because one or more lines are too long

View File

@@ -80,7 +80,8 @@ function parseServiceStatus(token)
j.isOwnProcess = ((serviceType & 0x00000010) == 0x00000010);
j.isInteractive = ((serviceType & 0x00000100) == 0x00000100);
j.waitHint = token.Deref((6 * 4), 4).toBuffer().readUInt32LE();
switch (token.Deref((1 * 4), 4).toBuffer().readUInt32LE())
j.rawState = token.Deref((1 * 4), 4).toBuffer().readUInt32LE();
switch (j.rawState)
{
case 0x00000005:
j.state = 'CONTINUE_PENDING';