mirror of
https://github.com/Ylianst/MeshAgent
synced 2026-01-06 18:43:46 +00:00
Removed dead code
This commit is contained in:
@@ -197,106 +197,6 @@ DWORD WINAPI ServiceControlHandler( DWORD controlCode, DWORD eventType, void *ev
|
||||
}
|
||||
|
||||
|
||||
// Add the uninstallation icon in the Windows Control Panel.
|
||||
void WINAPI AddUninstallIcon()
|
||||
{
|
||||
/*
|
||||
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MeshAgent]
|
||||
"DisplayName"="Mesh Agent Service - Remote Control Software"
|
||||
"Publisher"="MeshCentral"
|
||||
"MajorVersion"="2"
|
||||
"MinorVersion"="13"
|
||||
"InstallLocation"="C:\\Program Files\\Mesh Agent"
|
||||
"UninstallString"="C:\\Program Files\\Mesh Agent\\meshuninstaller.bat"
|
||||
"DisplayIcon"="C:\\Program Files\\Mesh Agent\\MeshAgent.exe"
|
||||
"DisplayVersion"="2.1.3"
|
||||
"URLInfoAbout"="http://www.meshcentral.com/"
|
||||
"VersionMajor"=dword:00000002
|
||||
"VersionMinor"=dword:00000013
|
||||
"EstimatedSize"=dword:00208000
|
||||
"NoModify"=dword:00000001
|
||||
"NoRepair"=dword:00000001
|
||||
*/
|
||||
|
||||
int i;
|
||||
HKEY hKey;
|
||||
if (RegCreateKey(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Mesh Agent", &hKey) == ERROR_SUCCESS)
|
||||
{
|
||||
LPCTSTR str;
|
||||
char targetexe[_MAX_PATH + 40];
|
||||
size_t targetexelen = 0;
|
||||
|
||||
str = "MeshCentral Agent - Remote Control Software\0";
|
||||
RegSetValueEx(hKey, "DisplayName", 0, REG_SZ, (LPBYTE)str, (DWORD)strlen(str)+1);
|
||||
|
||||
str = "Open Source\0";
|
||||
RegSetValueEx(hKey, "Publisher", 0, REG_SZ, (LPBYTE)str, (DWORD)strlen(str) + 1);
|
||||
|
||||
str = "1\0";
|
||||
RegSetValueEx(hKey, "MajorVersion", 0, REG_SZ, (LPBYTE)str, (DWORD)strlen(str) + 1);
|
||||
|
||||
str = "0\0";
|
||||
RegSetValueEx(hKey, "MinorVersion", 0, REG_SZ, (LPBYTE)str, (DWORD)strlen(str) + 1);
|
||||
|
||||
// Install location
|
||||
if (SHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES | CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, targetexe) != S_FALSE) {
|
||||
targetexelen = strnlen_s(targetexe, _MAX_PATH + 40);
|
||||
if (targetexelen <= MAX_PATH) {
|
||||
memcpy_s(targetexe + targetexelen, _MAX_PATH + 40 - targetexelen, "\\Mesh Agent\\\0", 13);
|
||||
RegSetValueEx(hKey, "InstallLocation", 0, REG_SZ, (LPBYTE)targetexe, (DWORD)strlen(targetexe) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Uninstall command
|
||||
if (SHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES | CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, targetexe) != S_FALSE) {
|
||||
targetexelen = strnlen_s(targetexe, _MAX_PATH + 40);
|
||||
if (targetexelen <= MAX_PATH) {
|
||||
memcpy_s(targetexe + targetexelen, _MAX_PATH + 40 - targetexelen, "\\Mesh Agent\\MeshAgent.exe -fulluninstall\0", 41);
|
||||
RegSetValueEx(hKey, "UninstallString", 0, REG_SZ, (LPBYTE)targetexe, (DWORD)strlen(targetexe) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Display icon
|
||||
if (SHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES | CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, targetexe) != S_FALSE) {
|
||||
targetexelen = strnlen_s(targetexe, _MAX_PATH + 40);
|
||||
if (targetexelen <= MAX_PATH) {
|
||||
memcpy_s(targetexe + targetexelen, _MAX_PATH + 40 - targetexelen, "\\Mesh Agent\\MeshAgent.exe\0", 26);
|
||||
RegSetValueEx(hKey, "DisplayIcon", 0, REG_SZ, (LPBYTE)targetexe, (DWORD)strlen(targetexe) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
str = "1.0.0\0";
|
||||
RegSetValueEx(hKey, "DisplayVersion", 0, REG_SZ, (LPBYTE)str, (DWORD)strlen(str) + 1);
|
||||
|
||||
str = "http://www.meshcentral.com/\0"; // TODO - Change this to .msg content
|
||||
RegSetValueEx(hKey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)str, (DWORD)strlen(str) + 1);
|
||||
|
||||
i = 2;
|
||||
RegSetValueEx(hKey, "VersionMajor", 0, REG_DWORD, (BYTE*)&i, (DWORD)4);
|
||||
|
||||
i = 13;
|
||||
RegSetValueEx(hKey, "VersionMinor", 0, REG_DWORD, (BYTE*)&i, (DWORD)4);
|
||||
|
||||
i = 1;
|
||||
RegSetValueEx(hKey, "NoModify", 0, REG_DWORD, (BYTE*)&i, (DWORD)4);
|
||||
RegSetValueEx(hKey, "NoRepair", 0, REG_DWORD, (BYTE*)&i, (DWORD)4);
|
||||
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Error writing to registry, try running as administrator.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void WINAPI RemoveUninstallIcon()
|
||||
{
|
||||
RegDeleteKey(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MeshCentralAgent");
|
||||
}
|
||||
|
||||
|
||||
void WINAPI ServiceMain(DWORD argc, LPTSTR *argv)
|
||||
{
|
||||
ILib_DumpEnabledContext winException;
|
||||
@@ -1155,88 +1055,6 @@ char* getMshSettings(char* fileName, char* selfexe, char** meshname, char** mesh
|
||||
|
||||
#ifndef _MINCORE
|
||||
|
||||
// Start as a temporary mesh agent.
|
||||
DWORD WINAPI StartTempAgent(_In_ LPVOID lpParameter)
|
||||
{
|
||||
ILib_DumpEnabledContext winException;
|
||||
char selfexe[_MAX_PATH];
|
||||
char *selfexe_ptr[] = { selfexe, "--disableUpdate=1", "--serviceTemp=1" };
|
||||
WCHAR str[_MAX_PATH];
|
||||
char *integratedJavaScript;
|
||||
int integragedJavaScriptLen;
|
||||
char setup1[_MAX_PATH];
|
||||
int setup1len;
|
||||
|
||||
ILibDuktape_ScriptContainer_CheckEmbedded(&integratedJavaScript, &integragedJavaScriptLen);
|
||||
|
||||
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||
|
||||
// Get our own executable name
|
||||
if (GetModuleFileNameW(NULL, str, _MAX_PATH) > 5) { ILibWideToUTF8Ex(str, -1, selfexe, sizeof(selfexe)); }
|
||||
|
||||
// Setup proxy filenames
|
||||
if ((setup1len = (int)strnlen_s(selfexe, sizeof(selfexe))) >= 4) {
|
||||
memcpy_s(setup1, sizeof(setup1), selfexe, setup1len);
|
||||
memcpy_s(setup1 + (setup1len - 3), sizeof(setup1) - setup1len - 3, "proxy", 6);
|
||||
|
||||
// Try to setup the proxy file
|
||||
WINHTTP_CURRENT_USER_IE_PROXY_CONFIG proxyEx;
|
||||
if (WinHttpGetIEProxyConfigForCurrentUser(&proxyEx))
|
||||
{
|
||||
if (proxyEx.lpszProxy != NULL)
|
||||
{
|
||||
FILE *SourceFile = NULL;
|
||||
size_t len;
|
||||
if (wcstombs_s(&len, ILibScratchPad, 4095, proxyEx.lpszProxy, 2000) == 0)
|
||||
{
|
||||
char* ptr = strstr(ILibScratchPad, "https=");
|
||||
if (ptr != NULL)
|
||||
{
|
||||
char* ptr2 = strstr(ptr, ";");
|
||||
ptr += 6;
|
||||
if (ptr2 != NULL) ptr2[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr = ILibScratchPad;
|
||||
}
|
||||
_wfopen_s(&SourceFile, ILibUTF8ToWide(setup1, -1), L"wb");
|
||||
if (SourceFile != NULL)
|
||||
{
|
||||
if (fwrite(ptr, sizeof(char), strnlen_s(ptr, sizeof(ILibScratchPad)), SourceFile)) {}
|
||||
fclose(SourceFile);
|
||||
}
|
||||
}
|
||||
GlobalFree(proxyEx.lpszProxy);
|
||||
}
|
||||
|
||||
// Release the rest of the proxy settings
|
||||
if (proxyEx.lpszAutoConfigUrl != NULL) GlobalFree(proxyEx.lpszAutoConfigUrl);
|
||||
if (proxyEx.lpszProxyBypass != NULL) GlobalFree(proxyEx.lpszProxyBypass);
|
||||
}
|
||||
}
|
||||
|
||||
// Launch the temporary agent
|
||||
__try
|
||||
{
|
||||
agent = MeshAgent_Create(MeshCommand_AuthInfo_CapabilitiesMask_TEMPORARY);
|
||||
agent->meshCoreCtx_embeddedScript = integratedJavaScript;
|
||||
agent->meshCoreCtx_embeddedScriptLen = integragedJavaScriptLen;
|
||||
agent->runningAsConsole = 1;
|
||||
MeshAgent_Start(agent, 3, selfexe_ptr);
|
||||
//retCode = agent->exitCode;
|
||||
MeshAgent_Destroy(agent);
|
||||
agent = NULL;
|
||||
}
|
||||
__except (ILib_WindowsExceptionFilterEx(GetExceptionCode(), GetExceptionInformation(), &winException))
|
||||
{
|
||||
ILib_WindowsExceptionDebugEx(&winException);
|
||||
}
|
||||
|
||||
CoUninitialize();
|
||||
return(0);
|
||||
}
|
||||
|
||||
// Message handler for dialog box.
|
||||
INT_PTR CALLBACK DialogHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user