mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-11 13:53:37 +00:00
Added UAC elevation for Temporary Agent when run from connect button on installer UI
This commit is contained in:
@@ -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 MeshAgent_AgentMode(MeshAgentHostContainer *agentHost, int paramLen, char **param, int parseCommands)
|
||||||
{
|
{
|
||||||
int resetNodeId = 0;
|
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);
|
ILibIPAddressMonitor_Create(agentHost->chain, MeshAgent_AgentMode_IPAddressChanged_Handler, agentHost);
|
||||||
MeshServer_Connect(agentHost);
|
MeshServer_Connect(agentHost);
|
||||||
|
|
||||||
|
|||||||
@@ -1377,12 +1377,19 @@ INT_PTR CALLBACK DialogHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lP
|
|||||||
|
|
||||||
return (INT_PTR)TRUE;
|
return (INT_PTR)TRUE;
|
||||||
}
|
}
|
||||||
else if (LOWORD(wParam) == IDC_CONNECTBUTTON) {
|
else if (LOWORD(wParam) == IDC_CONNECTBUTTON)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Temporary Agent
|
||||||
|
//
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_INSTALLBUTTON), FALSE);
|
EnableWindow(GetDlgItem(hDlg, IDC_INSTALLBUTTON), FALSE);
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_UNINSTALLBUTTON), FALSE);
|
EnableWindow(GetDlgItem(hDlg, IDC_UNINSTALLBUTTON), FALSE);
|
||||||
EnableWindow(GetDlgItem(hDlg, IDC_CONNECTBUTTON), FALSE);
|
EnableWindow(GetDlgItem(hDlg, IDC_CONNECTBUTTON), FALSE);
|
||||||
SetWindowTextA(GetDlgItem(hDlg, IDC_STATUSTEXT), "Running as temporary agent");
|
SetWindowTextA(GetDlgItem(hDlg, IDC_STATUSTEXT), "Running as temporary agent");
|
||||||
CreateThread(NULL, 0, &StartTempAgent, NULL, 0, NULL);
|
|
||||||
|
DWORD pid = GetCurrentProcessId();
|
||||||
|
sprintf_s(ILibScratchPad, sizeof(ILibScratchPad), "connect --disableUpdate=1 --hideConsole=1 --exitPID=%u", pid);
|
||||||
|
RunAsAdmin(ILibScratchPad, IsAdmin() == TRUE);
|
||||||
return (INT_PTR)TRUE;
|
return (INT_PTR)TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user