You are viewing a plain text version of this content. The canonical link for it is here.
Posted to win32-msi-cvs@httpd.apache.org by wr...@apache.org on 2007/12/22 01:34:20 UTC
svn commit: r606358 - in /httpd/httpd/win32-msi/trunk/src: readme.txt
real_features.c real_features.dsp
Author: wrowe
Date: Fri Dec 21 16:34:19 2007
New Revision: 606358
URL: http://svn.apache.org/viewvc?rev=606358&view=rev
Log:
Add the StopApacheMonitor feature.
Added:
httpd/httpd/win32-msi/trunk/src/readme.txt (with props)
Modified:
httpd/httpd/win32-msi/trunk/src/real_features.c
httpd/httpd/win32-msi/trunk/src/real_features.dsp
Added: httpd/httpd/win32-msi/trunk/src/readme.txt
URL: http://svn.apache.org/viewvc/httpd/httpd/win32-msi/trunk/src/readme.txt?rev=606358&view=auto
==============================================================================
--- httpd/httpd/win32-msi/trunk/src/readme.txt (added)
+++ httpd/httpd/win32-msi/trunk/src/readme.txt Fri Dec 21 16:34:19 2007
@@ -0,0 +1,23 @@
+real_features.dll must be compiled to provide .msi extentions
+that are used for the httpd installer. These are;
+
+ ResolveServerName
+
+ Sets RESOLVED_WINSOCK2 to "1" and fills in SERVERDOMAIN,
+ SERVERNAME and SERVERADMIN default values from lookup.
+
+ ValidateServerName
+
+ Sets INVALIDFIELD and INVALIDMESSAGE to correspond to an
+ error in the SERVERDOMAIN, SERVERNAME or SERVERADMIN values.
+
+ StopApacheMonitor
+
+ Shuts down the taskbar instance of ApacheMonitor, and then
+ agressively kills additional instances running in other
+ sessions on Terminal Server for Windows 2000 and later.
+
+In order to build real_features.dll in place, simply;
+
+msdev /useenv real_features.dsp /make "real_features - Win32 Release"
+
Propchange: httpd/httpd/win32-msi/trunk/src/readme.txt
------------------------------------------------------------------------------
svn:eol-style = native
Modified: httpd/httpd/win32-msi/trunk/src/real_features.c
URL: http://svn.apache.org/viewvc/httpd/httpd/win32-msi/trunk/src/real_features.c?rev=606358&r1=606357&r2=606358&view=diff
==============================================================================
--- httpd/httpd/win32-msi/trunk/src/real_features.c (original)
+++ httpd/httpd/win32-msi/trunk/src/real_features.c Fri Dec 21 16:34:19 2007
@@ -1,59 +1,17 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Copyright (c) 2000 The Apache Software Foundation. All rights
- * reserved.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- * Portions of this software are based upon public domain software
- * originally written at the National Center for Supercomputing Applications,
- * University of Illinois, Urbana-Champaign.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
#define WINDOWS_LEAN_AND_MEAN
@@ -61,7 +19,8 @@
#include <stdio.h>
#include <tchar.h>
#include <ctype.h>
-#include "MsiQuery.h"
+#include <WtsApi32.h>
+#include <MsiQuery.h>
#define MAXHOSTNAMELEN 255
@@ -252,5 +211,93 @@
/* Reset to assure we can leave the Server Information panel
*/
MsiSetPropertyA(hInstall, "INVALIDFIELD", "");
+ return ERROR_SUCCESS;
+}
+
+int isAtLeastWin2k(void)
+{
+ OSVERSIONINFO osvi;
+ memset(&osvi, 0, sizeof(OSVERSIONINFO));
+ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+
+ if (GetVersionEx(&osvi))
+ if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT
+ && osvi.dwMajorVersion >= 5)
+ return 1;
+
+ return 0;
+}
+
+#define IDM_EXIT 105
+
+static int KillAWindow(HWND appwindow)
+{
+ HANDLE appproc;
+ DWORD procid;
+ BOOL postres;
+
+ SetLastError(0);
+ GetWindowThreadProcessId(appwindow, &procid);
+ if (GetLastError())
+ return(2);
+
+ appproc = OpenProcess(SYNCHRONIZE, 0, procid);
+ postres = PostMessage(appwindow, WM_COMMAND, IDM_EXIT, 0);
+ if (appproc && postres) {
+ if (WaitForSingleObject(appproc, 10 /* seconds */ * 1000)
+ == WAIT_OBJECT_0) {
+ CloseHandle(appproc);
+ return (0);
+ }
+ }
+ if (appproc)
+ CloseHandle(appproc);
+
+ if ((appproc = OpenProcess(PROCESS_TERMINATE, 0, procid)) != NULL) {
+ if (TerminateProcess(appproc, 0)) {
+ CloseHandle(appproc);
+ return (0);
+ }
+ CloseHandle(appproc);
+ }
+
+ /* Perhaps we were short of permissions? */
+ return (2);
+}
+
+UINT __declspec(dllexport) __stdcall StopApacheMonitor(MSIHANDLE hInstall)
+{
+ HWND appwindow;
+ PWTS_PROCESS_INFO tsProcs;
+ DWORD tsProcCount, i;
+ DWORD thisProcId;
+
+ /* This is graceful, this desktop's window, clearing the icon */
+ if ((appwindow = FindWindow("ApacheServiceMonitorClass",
+ "Apache Service Monitor")) != NULL)
+ KillAWindow(appwindow);
+
+ if (!isAtLeastWin2k())
+ return ERROR_SUCCESS;
+
+ thisProcId = GetCurrentProcessId();
+
+ if (!WTSEnumerateProcesses(WTS_CURRENT_SERVER_HANDLE, 0, 1,
+ &tsProcs, &tsProcCount))
+ return ERROR_SUCCESS;
+
+ /* This is ungraceful; close other Windows, with a lingering icon.
+ * Since on terminal server it's not possible to post the message
+ * to exit across sessions, we have to suffer this side effect
+ * of a taskbar 'icon' which will evaporate the next time that
+ * the user hovers over it or when the taskbar area is updated.
+ */
+ for (i = 0; i < tsProcCount; ++i) {
+ if (stricmp(tsProcs[i].pProcessName, "ApacheMonitor.exe") == 0
+ && tsProcs[i].ProcessId != thisProcId)
+ WTSTerminateProcess(WTS_CURRENT_SERVER_HANDLE,
+ tsProcs[i].ProcessId, 1);
+ }
+ WTSFreeMemory(tsProcs);
return ERROR_SUCCESS;
}
Modified: httpd/httpd/win32-msi/trunk/src/real_features.dsp
URL: http://svn.apache.org/viewvc/httpd/httpd/win32-msi/trunk/src/real_features.dsp?rev=606358&r1=606357&r2=606358&view=diff
==============================================================================
--- httpd/httpd/win32-msi/trunk/src/real_features.dsp (original)
+++ httpd/httpd/win32-msi/trunk/src/real_features.dsp Fri Dec 21 16:34:19 2007
@@ -42,8 +42,8 @@
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fd"Release\real_features" /FD /c
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /Zi /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /Zi /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fd"Release\real_features" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
@@ -52,8 +52,8 @@
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib msi.lib user32.lib wsock32.lib /nologo /subsystem:windows /dll /machine:I386
-# ADD LINK32 kernel32.lib msi.lib user32.lib wsock32.lib /nologo /subsystem:windows /dll /machine:I386
+# ADD BASE LINK32 kernel32.lib user32.lib msi.lib wsock32.lib wtsapi32.lib delayimp.lib /nologo /subsystem:windows /dll /debug /machine:I386 /opt:ref /incremental:no /delayload:wtsapi32.dll
+# ADD LINK32 kernel32.lib user32.lib msi.lib wsock32.lib wtsapi32.lib delayimp.lib /nologo /subsystem:windows /dll /debug /machine:I386 /opt:ref /incremental:no /delayload:wtsapi32.dll
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "real_features - Win32 Debug"
@@ -79,9 +79,8 @@
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib msi.lib user32.lib wsock32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib msi.lib user32.lib wsock32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
-# SUBTRACT LINK32 /pdb:none
+# ADD BASE LINK32 kernel32.lib user32.lib msi.lib wsock32.lib wtsapi32.lib delayimp.lib /nologo /subsystem:windows /dll /debug /machine:I386 /delayload:wtsapi32.dll
+# ADD LINK32 kernel32.lib user32.lib msi.lib wsock32.lib wtsapi32.lib delayimp.lib /nologo /subsystem:windows /dll /debug /machine:I386 /delayload:wtsapi32.dll
!ENDIF
---------------------------------------------------------------------
To unsubscribe, e-mail: win32-msi-cvs-unsubscribe@httpd.apache.org
For additional commands, e-mail: win32-msi-cvs-help@httpd.apache.org