1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2026-01-07 02:53:58 +00:00

Added UAC elevation for Temporary Agent when run from connect button on installer UI

This commit is contained in:
Bryan Roe
2020-05-17 23:07:11 -07:00
parent 66122d43c1
commit 19fb0163d5
2 changed files with 26 additions and 2 deletions

View File

@@ -3949,6 +3949,11 @@ void MeshAgent_AgentInstallerCTX_Finalizer(duk_context *ctx, void *user)
}
}
BOOL MeshAgent_PidWaiter(void *chain, HANDLE h, ILibWaitHandle_ErrorStatus status, void* user)
{
ILibStopChain(chain);
return(FALSE);
}
int MeshAgent_AgentMode(MeshAgentHostContainer *agentHost, int paramLen, char **param, int parseCommands)
{
int resetNodeId = 0;
@@ -4567,6 +4572,18 @@ int MeshAgent_AgentMode(MeshAgentHostContainer *agentHost, int paramLen, char **
}
}
#ifdef WIN32
if (ILibSimpleDataStore_Get(agentHost->masterDb, "exitPID", NULL, 0) > 0)
{
int pidLen = ILibSimpleDataStore_Get(agentHost->masterDb, "exitPID", ILibScratchPad, (int)sizeof(ILibScratchPad));
HANDLE h = OpenProcess(SYNCHRONIZE, FALSE, (DWORD)atoi(ILibScratchPad));
if (h != NULL) { ILibChain_AddWaitHandle(agentHost->chain, h, -1, MeshAgent_PidWaiter, agentHost); }
}
if (ILibSimpleDataStore_Get(agentHost->masterDb, "hideConsole", NULL, 0) > 0 && agentHost->meshCoreCtx != NULL)
{
duk_peval_string_noresult(agentHost->meshCoreCtx, "require('win-console').hide()");
}
#endif
ILibIPAddressMonitor_Create(agentHost->chain, MeshAgent_AgentMode_IPAddressChanged_Handler, agentHost);
MeshServer_Connect(agentHost);