diff --git a/src/iscguard/iscguard.cpp b/src/iscguard/iscguard.cpp index 901ec4c72c..93de77bedf 100644 --- a/src/iscguard/iscguard.cpp +++ b/src/iscguard/iscguard.cpp @@ -87,7 +87,6 @@ LRESULT CALLBACK GeneralPage(HWND, UINT, WPARAM, LPARAM); HINSTANCE hInstance_gbl; HWND hPSDlg, hWndGbl; -static DWORD ServerPid = 0; static int nRestarts = 0; /* the number of times the server was restarted */ bool service_flag = true; /* unsigned short shutdown_flag = FALSE; */ @@ -115,7 +114,6 @@ int WINAPI WinMain( * **************************************/ - OSVERSIONINFO OsVersionInfo; /* need to set the sizeof this structure for NT to work */ @@ -184,10 +182,9 @@ static bool parse_args(LPCSTR lpszArgs, bool* pserver_flag) bool return_value = true; for (const char* p = lpszArgs; *p; p++) { - if (*p++ == '-') + if (*p++ == '-') { while (c = *p++) { - switch (c) { - case 'a': + switch (UPPER(c)) { case 'A': return_value = false; break; @@ -197,6 +194,7 @@ static bool parse_args(LPCSTR lpszArgs, bool* pserver_flag) break; } } + } } return return_value; } @@ -394,10 +392,6 @@ static LRESULT CALLBACK WindowFunc( PostMessage(hTmpWnd, WM_COMMAND, (WPARAM) IDM_PROPERTIES, 0); } return TRUE; - - case IDM_SET_SERVER_PID: - ServerPid = (DWORD) lParam; - return TRUE; } break; @@ -587,7 +581,7 @@ THREAD_ENTRY_DECLARE start_and_watch_server(THREAD_ENTRY_PARAM) success = StartService(hService, 0, NULL); if (success != TRUE) error = GetLastError(); - /* if the server is alrady running, then inform it that it should + /* if the server is already running, then inform it that it should * open the guardian mutex so that it may be governed. */ if ((!error) || (error == ERROR_SERVICE_ALREADY_RUNNING)) { /* Make sure that it is actually ready to receive commands. @@ -622,17 +616,18 @@ THREAD_ENTRY_DECLARE start_and_watch_server(THREAD_ENTRY_PARAM) CloseHandle(pi.hThread); } else { - SendMessage(hTmpWnd, WM_COMMAND, (WPARAM) IDM_GUARDED, - (LPARAM) hWndGbl); - if ( - (procHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, - ServerPid)) == NULL) - { + SendMessage(hTmpWnd, WM_COMMAND, (WPARAM) IDM_GUARDED, 0); + DWORD server_pid; + GetWindowThreadProcessId(hTmpWnd, &server_pid); + procHandle = OpenProcess(SYNCHRONIZE | PROCESS_QUERY_INFORMATION, + FALSE, server_pid); + if (procHandle == NULL) { error = GetLastError(); success = FALSE; } - else + else { success = TRUE; + } } } diff --git a/src/iscguard/iscguard.rh b/src/iscguard/iscguard.rh index b915e7e7ea..1bf4931941 100644 --- a/src/iscguard/iscguard.rh +++ b/src/iscguard/iscguard.rh @@ -50,7 +50,6 @@ iscguard.rh #define IDM_INTRSVRPROPERTIES 12 #define IDM_SVRPROPERTIES 13 #define IDM_GUARDED 14 -#define IDM_SET_SERVER_PID 15 /* Defines for String Table */ #define IDS_QUIT 201 diff --git a/src/remote/os/win32/window.cpp b/src/remote/os/win32/window.cpp index 7ba8154e8e..32dcd885b5 100644 --- a/src/remote/os/win32/window.cpp +++ b/src/remote/os/win32/window.cpp @@ -289,9 +289,6 @@ LRESULT CALLBACK WindowFunc(HWND hWnd, nid.uFlags = 0; Shell_NotifyIcon(NIM_DELETE, &nid); } - SendMessage((HWND) lParam, WM_COMMAND, - (WPARAM) IDM_SET_SERVER_PID, - (LPARAM) GetCurrentProcessId()); return TRUE; } break; diff --git a/src/remote/os/win32/window.rh b/src/remote/os/win32/window.rh index 73b3096efe..b327e59b7b 100644 --- a/src/remote/os/win32/window.rh +++ b/src/remote/os/win32/window.rh @@ -37,7 +37,6 @@ produced by Borland Resource Workshop #define IDM_PROPERTIES 10 #define IDM_STARTUPCFG 11 #define IDM_GUARDED 14 -#define IDM_SET_SERVER_PID 15 /* Defines for String Table */ #define IDS_PNP1 200