зеркало из https://github.com/mozilla/pjs.git
fixing bug 190816 - Running process causes Installer to hang until process is shut down via task manager. r=sgehani, sr=jag, a=sspitzer
This commit is contained in:
Родитель
e4738f5ca7
Коммит
ffd8d7ab0b
|
@ -273,15 +273,55 @@ exe_param=
|
|||
[Check Instance0]
|
||||
Class Name=MozillaMessageWindow
|
||||
Window Name=
|
||||
Process Name=Mozilla.exe
|
||||
Pretty Name=Mozilla
|
||||
;*** LOCALIZE ME BABY ***
|
||||
Message=Download of $ProductName$ was successful. $ProductNameInternal$ must be closed to proceed with installation. Click OK to exit $ProductNameInternal$ automatically and to begin installation.
|
||||
Message=Download of $ProductName$ was successful. However, Mozilla must be closed to proceed with this installation. Click OK to exit Mozilla automatically and to begin installation.
|
||||
;*** LOCALIZE ME BABY ***
|
||||
Message Full Installer=$ProductNameInternal$ must be closed to proceed with installation. Click OK to exit $ProductNameInternal$ automatically and to begin installation.
|
||||
Message Full Installer=Mozilla must be closed to proceed with this installation. Click OK to exit Mozilla automatically and to begin installation.
|
||||
;*** LOCALIZE ME BABY ***
|
||||
Message wait=Shutting down Mozilla. Please wait...
|
||||
|
||||
; This key indicates whether or not to close all the windows associated with
|
||||
; the process id of this app instance window found.
|
||||
Close All Process Windows=TRUE
|
||||
|
||||
; These keys are not normally necessary for checking instances. They are
|
||||
; set here because Mozilla requires a way to shut down it's turbo mode.
|
||||
Extra Cmd0 Reg Key Root=HKEY_LOCAL_MACHINE
|
||||
Extra Cmd0 Reg Key=Software\Microsoft\Windows\CurrentVersion\App Paths\Mozilla.exe
|
||||
Extra Cmd0 Reg Name=
|
||||
Extra Cmd0 Parameter=-kill
|
||||
|
||||
[Check Instance1]
|
||||
Class Name=Netscape6MessageWindow
|
||||
Window Name=
|
||||
Process Name=Netscp.exe
|
||||
Pretty Name=Netscape
|
||||
;*** LOCALIZE ME BABY ***
|
||||
Message=Download of $ProductName$ was successful. However, Netscape must be closed to proceed with this installation. Click OK to exit Netscape automatically and to begin installation.
|
||||
;*** LOCALIZE ME BABY ***
|
||||
Message Full Installer=Netscape must be closed to proceed with this installation. Click OK to exit Netscape automatically and to begin installation.
|
||||
;*** LOCALIZE ME BABY ***
|
||||
Message wait=Shutting down Netscape. Please wait...
|
||||
|
||||
; This key indicates whether or not to close all the windows associated with
|
||||
; the process id of this app instance window found.
|
||||
Close All Process Windows=TRUE
|
||||
|
||||
; These keys are not normally necessary for checking instances. They are
|
||||
; set here because Netscape 6 requires a way to shut down it's turbo mode.
|
||||
; This will stop at the first one that succeeds (key and file found).
|
||||
Extra Cmd0 Reg Key Root=HKEY_LOCAL_MACHINE
|
||||
Extra Cmd0 Reg Key=Software\Microsoft\Windows\CurrentVersion\App Paths\Netscp6.exe
|
||||
Extra Cmd0 Reg Name=
|
||||
Extra Cmd0 Parameter=-kill
|
||||
|
||||
Extra Cmd1 Reg Key Root=HKEY_LOCAL_MACHINE
|
||||
Extra Cmd1 Reg Key=Software\Microsoft\Windows\CurrentVersion\App Paths\Netscp.exe
|
||||
Extra Cmd1 Reg Name=
|
||||
Extra Cmd1 Parameter=-kill
|
||||
|
||||
;
|
||||
;DependeeX=Component A means
|
||||
; - if Component A gets checked this component gets checked
|
||||
|
|
|
@ -118,4 +118,6 @@ ERROR_DLL_LOAD=Could not load %s
|
|||
ERROR_STRING_LOAD=Could not load string resource ID %d
|
||||
ERROR_STRING_NULL=Null pointer encountered.
|
||||
ERROR_GLOBALALLOC=Memory allocation error.
|
||||
MSG_FORCE_QUIT_PROCESS=Setup has detected that %s (%s) is still running. Click OK to quit Mozilla and proceed with installation. Alternatively, use the Windows Task Manager to quit Mozilla, and then click OK to continue with installation.
|
||||
MSG_FORCE_QUIT_PROCESS_FAILED=Setup will now exit. Setup could not continue because %s (%s) is still running. Try manually quitting Mozilla using Windows Task Manager, and then run Setup again.
|
||||
|
||||
|
|
|
@ -314,15 +314,55 @@ exe_param=
|
|||
[Check Instance0]
|
||||
Class Name=MozillaMessageWindow
|
||||
Window Name=
|
||||
Process Name=Mozilla.exe
|
||||
Pretty Name=Mozilla
|
||||
;*** LOCALIZE ME BABY ***
|
||||
Message=Download of $ProductName$ was successful. $ProductNameInternal$ must be closed to proceed with installation. Click OK to exit $ProductNameInternal$ automatically and to begin installation.
|
||||
Message=Download of $ProductName$ was successful. However, Mozilla must be closed to proceed with this installation. Click OK to exit Mozilla automatically and to begin installation.
|
||||
;*** LOCALIZE ME BABY ***
|
||||
Message Full Installer=$ProductNameInternal$ must be closed to proceed with installation. Click OK to exit $ProductNameInternal$ automatically and to begin installation.
|
||||
Message Full Installer=Mozilla must be closed to proceed with this installation. Click OK to exit Mozilla automatically and to begin installation.
|
||||
;*** LOCALIZE ME BABY ***
|
||||
Message wait=Shutting down Mozilla. Please wait...
|
||||
|
||||
; This key indicates whether or not to close all the windows associated with
|
||||
; the process id of this app instance window found.
|
||||
Close All Process Windows=TRUE
|
||||
|
||||
; These keys are not normally necessary for checking instances. They are
|
||||
; set here because Mozilla requires a way to shut down it's turbo mode.
|
||||
Extra Cmd0 Reg Key Root=HKEY_LOCAL_MACHINE
|
||||
Extra Cmd0 Reg Key=Software\Microsoft\Windows\CurrentVersion\App Paths\Mozilla.exe
|
||||
Extra Cmd0 Reg Name=
|
||||
Extra Cmd0 Parameter=-kill
|
||||
|
||||
[Check Instance1]
|
||||
Class Name=Netscape6MessageWindow
|
||||
Window Name=
|
||||
Process Name=Netscp.exe
|
||||
Pretty Name=Netscape
|
||||
;*** LOCALIZE ME BABY ***
|
||||
Message=Download of $ProductName$ was successful. However, Netscape must be closed to proceed with this installation. Click OK to exit Netscape automatically and to begin installation.
|
||||
;*** LOCALIZE ME BABY ***
|
||||
Message Full Installer=Netscape must be closed to proceed with this installation. Click OK to exit Netscape automatically and to begin installation.
|
||||
;*** LOCALIZE ME BABY ***
|
||||
Message wait=Shutting down Netscape. Please wait...
|
||||
|
||||
; This key indicates whether or not to close all the windows associated with
|
||||
; the process id of this app instance window found.
|
||||
Close All Process Windows=TRUE
|
||||
|
||||
; These keys are not normally necessary for checking instances. They are
|
||||
; set here because Netscape 6 requires a way to shut down it's turbo mode.
|
||||
; This will stop at the first one that succeeds (key and file found).
|
||||
Extra Cmd0 Reg Key Root=HKEY_LOCAL_MACHINE
|
||||
Extra Cmd0 Reg Key=Software\Microsoft\Windows\CurrentVersion\App Paths\Netscp6.exe
|
||||
Extra Cmd0 Reg Name=
|
||||
Extra Cmd0 Parameter=-kill
|
||||
|
||||
Extra Cmd1 Reg Key Root=HKEY_LOCAL_MACHINE
|
||||
Extra Cmd1 Reg Key=Software\Microsoft\Windows\CurrentVersion\App Paths\Netscp.exe
|
||||
Extra Cmd1 Reg Name=
|
||||
Extra Cmd1 Parameter=-kill
|
||||
|
||||
;
|
||||
;DependeeX=Component A means
|
||||
; - if Component A gets checked this component gets checked
|
||||
|
@ -436,7 +476,7 @@ $InstallSize$:gre
|
|||
$InstallSizeSystem$
|
||||
$InstallSizeArchive$:gre-win32-installer.zip
|
||||
Attributes=SELECTED|UNCOMPRESS|SUPERSEDE|LAUNCHAPP|INVISIBLE
|
||||
Parameter=-mmi -ma -app $ProductName$ -app_path "[SETUP PATH]\$MainExeFile$"
|
||||
Parameter=-mmi -app $ProductName$ -app_path "[SETUP PATH]\$MainExeFile$"
|
||||
SupersedeType=GRE
|
||||
SupersedeWinReg0=HKEY_LOCAL_MACHINE\Software\mozilla.org\GRE
|
||||
SupersedeVersion0=$GreFileVersion$
|
||||
|
|
|
@ -118,4 +118,6 @@ ERROR_DLL_LOAD=Could not load %s
|
|||
ERROR_STRING_LOAD=Could not load string resource ID %d
|
||||
ERROR_STRING_NULL=Null pointer encountered.
|
||||
ERROR_GLOBALALLOC=Memory allocation error.
|
||||
MSG_FORCE_QUIT_PROCESS=Setup has detected that %s (%s) is still running. Click OK to quit Mozilla and proceed with installation. Alternatively, use the Windows Task Manager to quit Mozilla, and then click OK to continue with installation.
|
||||
MSG_FORCE_QUIT_PROCESS_FAILED=Setup will now exit. Setup could not continue because %s (%s) is still running. Try manually quitting Mozilla using Windows Task Manager, and then run Setup again.
|
||||
|
||||
|
|
|
@ -397,10 +397,14 @@ Show Dialog=AUTO
|
|||
[Check Instance0]
|
||||
Class Name=MozillaMessageWindow
|
||||
Window Name=
|
||||
Process Name=$MainExeFile$
|
||||
Pretty Name=$ProductNameInternal$
|
||||
;*** LOCALIZE ME BABY ***
|
||||
Message=Download of $ProductName$ was successful. $ProductNameInternal$ must be closed to proceed with installation. Click OK to exit $ProductNameInternal$ automatically and to begin installation.
|
||||
;*** LOCALIZE ME BABY ***
|
||||
Message Full Installer=$ProductNameInternal$ must be closed to proceed with installation. Click OK to exit $ProductNameInternal$ automatically and to begin installation.
|
||||
;*** LOCALIZE ME BABY ***
|
||||
Message wait=Shutting down $ProductNameInternal$. Please wait...
|
||||
|
||||
; This key indicates whether or not to close all the windows associated with
|
||||
; the process id of this app instance window found.
|
||||
|
@ -416,10 +420,14 @@ Extra Cmd0 Parameter=-kill
|
|||
[Check Instance1]
|
||||
Class Name=Netscape6MessageWindow
|
||||
Window Name=
|
||||
Process Name=Netscp.exe
|
||||
Pretty Name=Netscape
|
||||
;*** LOCALIZE ME BABY ***
|
||||
Message=Download of $ProductName$ was successful. However, Netscape must be closed to proceed with this installation. Click OK to exit Netscape automatically and to begin installation.
|
||||
;*** LOCALIZE ME BABY ***
|
||||
Message Full Installer=Netscape must be closed to proceed with this installation. Click OK to exit Netscape automatically and to begin installation.
|
||||
;*** LOCALIZE ME BABY ***
|
||||
Message wait=Shutting down Netscape. Please wait...
|
||||
|
||||
; This key indicates whether or not to close all the windows associated with
|
||||
; the process id of this app instance window found.
|
||||
|
@ -434,7 +442,7 @@ Extra Cmd0 Reg Name=
|
|||
Extra Cmd0 Parameter=-kill
|
||||
|
||||
Extra Cmd1 Reg Key Root=HKEY_LOCAL_MACHINE
|
||||
Extra Cmd1 Reg Key=Software\Microsoft\Windows\CurrentVersion\App Paths\Netscape.exe
|
||||
Extra Cmd1 Reg Key=Software\Microsoft\Windows\CurrentVersion\App Paths\Netscp.exe
|
||||
Extra Cmd1 Reg Name=
|
||||
Extra Cmd1 Parameter=-kill
|
||||
|
||||
|
@ -555,7 +563,7 @@ $InstallSizeSystem$
|
|||
$InstallSizeArchive$:gre-win32-installer.zip
|
||||
Attributes=SELECTED|UNCOMPRESS|SUPERSEDE|LAUNCHAPP|INVISIBLE
|
||||
;*** LOCALIZE ME BABY ***
|
||||
Parameter=-mmi -ma -app "$ProductNameInternal$ $UserAgent$" -app_path "[SETUP PATH]\$MainExeFile$"
|
||||
Parameter=-mmi -app "$ProductNameInternal$ $UserAgent$" -app_path "[SETUP PATH]\$MainExeFile$"
|
||||
SupersedeType=GRE
|
||||
SupersedeWinReg0=HKEY_LOCAL_MACHINE\Software\mozilla.org\GRE
|
||||
SupersedeVersion0=$GreFileVersion$
|
||||
|
|
|
@ -117,4 +117,6 @@ ERROR_DLL_LOAD=Could not load %s
|
|||
ERROR_STRING_LOAD=Could not load string resource ID %d
|
||||
ERROR_STRING_NULL=Null pointer encountered.
|
||||
ERROR_GLOBALALLOC=Memory allocation error.
|
||||
MSG_FORCE_QUIT_PROCESS=Setup has detected that %s (%s) is still running. Click OK to quit Mozilla and proceed with installation. Alternatively, use the Windows Task Manager to quit Mozilla, and then click OK to continue with installation.
|
||||
MSG_FORCE_QUIT_PROCESS_FAILED=Setup will now exit. Setup could not continue because %s (%s) is still running. Try manually quitting Mozilla using Windows Task Manager, and then run Setup again.
|
||||
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
dialogs.pdb
|
||||
extra.pdb
|
||||
ifuncns.pdb
|
||||
setup.exp
|
||||
setup.ilk
|
||||
setup.lib
|
||||
setup.pdb
|
||||
setup.res
|
||||
shortcut.pdb
|
||||
xpi.pdb
|
||||
xpnethook.pdb
|
||||
logging.pdb
|
||||
nsescape.pdb
|
||||
Makefile
|
||||
supersede.pdb
|
||||
version.pdb
|
|
@ -51,6 +51,7 @@ CSRCS = \
|
|||
logging.c \
|
||||
supersede.c \
|
||||
version.c \
|
||||
process.c \
|
||||
|
||||
CPPSRCS = \
|
||||
shortcut.cpp \
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include "extern.h"
|
||||
#include "extra.h"
|
||||
#include "process.h"
|
||||
#include "dialogs.h"
|
||||
#include "ifuncns.h"
|
||||
#include "xpnetHook.h"
|
||||
|
@ -35,8 +36,6 @@
|
|||
#include <logkeys.h>
|
||||
#include <winnls.h>
|
||||
#include <winver.h>
|
||||
#include <tlhelp32.h>
|
||||
#include <winperf.h>
|
||||
|
||||
// shellapi.h is needed to build with WIN32_LEAN_AND_MEAN
|
||||
#include <shellapi.h>
|
||||
|
@ -45,28 +44,12 @@
|
|||
#define LODWORD(l) ((DWORD) (l))
|
||||
|
||||
#define DEFAULT_ICON_SIZE 32
|
||||
#define INDEX_STR_LEN 10
|
||||
#define PN_PROCESS TEXT("Process")
|
||||
#define PN_THREAD TEXT("Thread")
|
||||
|
||||
/* CW: Close Window */
|
||||
#define CW_CLOSE_ALL 0x00000001
|
||||
#define CW_CLOSE_VISIBLE_ONLY 0x00000002
|
||||
#define CW_CHECK_VISIBLE_ONLY 0x00000003
|
||||
|
||||
#define FTPSTR_LEN (sizeof(szFtp) - 1)
|
||||
#define HTTPSTR_LEN (sizeof(szHttp) - 1)
|
||||
|
||||
ULONG (PASCAL *NS_GetDiskFreeSpace)(LPCTSTR, LPDWORD, LPDWORD, LPDWORD, LPDWORD);
|
||||
ULONG (PASCAL *NS_GetDiskFreeSpaceEx)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER);
|
||||
typedef BOOL (WINAPI *NS_ProcessWalk)(HANDLE hSnapshot, LPPROCESSENTRY32 lppe);
|
||||
typedef HANDLE (WINAPI *NS_CreateSnapshot)(DWORD dwFlags, DWORD th32ProcessID);
|
||||
typedef PERF_DATA_BLOCK PERF_DATA, *PPERF_DATA;
|
||||
typedef PERF_OBJECT_TYPE PERF_OBJECT, *PPERF_OBJECT;
|
||||
typedef PERF_INSTANCE_DEFINITION PERF_INSTANCE, *PPERF_INSTANCE;
|
||||
TCHAR INDEX_PROCTHRD_OBJ[2*INDEX_STR_LEN];
|
||||
DWORD PX_PROCESS;
|
||||
DWORD PX_THREAD;
|
||||
HRESULT InitGre(greInfo *gre);
|
||||
void DeInitGre(greInfo *gre);
|
||||
void UpdateGreInstallerCmdLine(char *aParameter, DWORD aParameterBufSize);
|
||||
|
@ -76,7 +59,6 @@ HRESULT GetInstalledGreConfigIni(greInfo *aGre, char *aGreConfigIni, DWORD aGreC
|
|||
HRESULT GetInfoFromInstalledGreConfigIni(greInfo *aGre);
|
||||
|
||||
static greInfo gGre;
|
||||
DWORD gCWState;
|
||||
|
||||
char *ArchiveExtensions[] = {"zip",
|
||||
"xpi",
|
||||
|
@ -98,17 +80,6 @@ LPFNDLLFUNC lpfnProgressUpd;
|
|||
HINSTANCE hGREAppInstallerProxyDLL;
|
||||
|
||||
BOOL gGreInstallerHasRun = FALSE;
|
||||
BOOL CheckProcessNT4(LPSTR szProcessName, DWORD dwProcessNameSize);
|
||||
DWORD GetTitleIdx(HWND hWnd, LPTSTR Title[], DWORD LastIndex, LPTSTR Name);
|
||||
PPERF_OBJECT FindObject (PPERF_DATA pData, DWORD TitleIndex);
|
||||
PPERF_OBJECT NextObject (PPERF_OBJECT pObject);
|
||||
PPERF_OBJECT FirstObject (PPERF_DATA pData);
|
||||
PPERF_INSTANCE NextInstance (PPERF_INSTANCE pInst);
|
||||
PPERF_INSTANCE FirstInstance (PPERF_OBJECT pObject);
|
||||
DWORD GetPerfData (HKEY hPerfKey,
|
||||
LPTSTR szObjectIndex,
|
||||
PPERF_DATA *ppData,
|
||||
DWORD *pDataSize);
|
||||
|
||||
BOOL InitDialogClass(HINSTANCE hInstance, HINSTANCE hSetupRscInst)
|
||||
{
|
||||
|
@ -2065,6 +2036,15 @@ void ParsePath(LPSTR szInput, LPSTR szOutput, DWORD dwOutputSize, BOOL bURLPath,
|
|||
*/
|
||||
void UpdateGreInstallerCmdLine(char *aParameter, DWORD aParameterBufSize)
|
||||
{
|
||||
/* Decide GRE installer's run mode. Default should be -ma (AUTO).
|
||||
* The only other possibility is -ms (SILENT). We don't want to allow
|
||||
* the GRE installer to run in NORMAL mode because we don't want to
|
||||
* let the user see more dialogs than they need to. */
|
||||
if(sgProduct.mode == SILENT)
|
||||
lstrcat(aParameter, " -ms");
|
||||
else
|
||||
lstrcat(aParameter, " -ma");
|
||||
|
||||
/* Force the install of GRE if '-greForce' is passed or if GRE
|
||||
* is to be local.
|
||||
*
|
||||
|
@ -5554,60 +5534,6 @@ void GetAlternateArchiveSearchPath(LPSTR lpszCmdLine)
|
|||
}
|
||||
}
|
||||
|
||||
BOOL CheckProcessWin95(NS_CreateSnapshot pCreateToolhelp32Snapshot, NS_ProcessWalk pProcessWalkFirst, NS_ProcessWalk pProcessWalkNext, LPSTR szProcessName)
|
||||
{
|
||||
BOOL bRv = FALSE;
|
||||
HANDLE hCreateSnapshot = NULL;
|
||||
PROCESSENTRY32 peProcessEntry;
|
||||
|
||||
hCreateSnapshot = pCreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||
if(hCreateSnapshot == (HANDLE)-1)
|
||||
return(bRv);
|
||||
|
||||
peProcessEntry.dwSize = sizeof(PROCESSENTRY32);
|
||||
if(pProcessWalkFirst(hCreateSnapshot, &peProcessEntry))
|
||||
{
|
||||
do
|
||||
{
|
||||
char szBuf[MAX_BUF];
|
||||
|
||||
ParsePath(peProcessEntry.szExeFile, szBuf, sizeof(szBuf), FALSE, PP_FILENAME_ONLY);
|
||||
|
||||
/* do process name string comparison here! */
|
||||
if(lstrcmpi(szBuf, szProcessName) == 0)
|
||||
{
|
||||
bRv = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
} while((bRv == FALSE) && pProcessWalkNext(hCreateSnapshot, &peProcessEntry));
|
||||
}
|
||||
|
||||
CloseHandle(hCreateSnapshot);
|
||||
return(bRv);
|
||||
}
|
||||
|
||||
BOOL CheckForProcess(LPSTR szProcessName, DWORD dwProcessName)
|
||||
{
|
||||
HANDLE hKernel = NULL;
|
||||
NS_CreateSnapshot pCreateToolhelp32Snapshot = NULL;
|
||||
NS_ProcessWalk pProcessWalkFirst = NULL;
|
||||
NS_ProcessWalk pProcessWalkNext = NULL;
|
||||
BOOL bDoWin95Check = TRUE;
|
||||
|
||||
if((hKernel = GetModuleHandle("kernel32.dll")) == NULL)
|
||||
return(FALSE);
|
||||
|
||||
pCreateToolhelp32Snapshot = (NS_CreateSnapshot)GetProcAddress(hKernel, "CreateToolhelp32Snapshot");
|
||||
pProcessWalkFirst = (NS_ProcessWalk)GetProcAddress(hKernel, "Process32First");
|
||||
pProcessWalkNext = (NS_ProcessWalk)GetProcAddress(hKernel, "Process32Next");
|
||||
|
||||
if(pCreateToolhelp32Snapshot && pProcessWalkFirst && pProcessWalkNext)
|
||||
return(CheckProcessWin95(pCreateToolhelp32Snapshot, pProcessWalkFirst, pProcessWalkNext, szProcessName));
|
||||
else
|
||||
return(CheckProcessNT4(szProcessName, dwProcessName));
|
||||
}
|
||||
|
||||
int PreCheckInstance(char *szSection, char *szIniFile)
|
||||
{
|
||||
char szBuf[MAX_BUF];
|
||||
|
@ -5709,81 +5635,78 @@ int PreCheckInstance(char *szSection, char *szIniFile)
|
|||
return(iRv);
|
||||
}
|
||||
|
||||
// Windows callback function that processes each window found to be running.
|
||||
// This function will close all the visible and invisible windows that
|
||||
// match a processes passed in from lParam.
|
||||
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
|
||||
HRESULT GetCheckInstanceQuitMessage(char *aSection, char *aMessage, DWORD aMessageBufSize)
|
||||
{
|
||||
BOOL rv = TRUE;
|
||||
DWORD dwProcessId;
|
||||
char messageFullInstaller[MAX_BUF];
|
||||
|
||||
GetWindowThreadProcessId(hwnd, &dwProcessId);
|
||||
if(dwProcessId == (DWORD)lParam)
|
||||
{
|
||||
switch(gCWState)
|
||||
{
|
||||
case CW_CLOSE_ALL:
|
||||
SendMessage(hwnd, WM_CLOSE, (WPARAM)1, (LPARAM)0);
|
||||
break;
|
||||
*aMessage = '\0';
|
||||
*messageFullInstaller = '\0';
|
||||
|
||||
case CW_CLOSE_VISIBLE_ONLY:
|
||||
// only close the windows that are visible
|
||||
if(GetWindowLong(hwnd, GWL_STYLE) & WS_VISIBLE)
|
||||
SendMessage(hwnd, WM_CLOSE, (WPARAM)1, (LPARAM)0);
|
||||
break;
|
||||
GetPrivateProfileString(aSection, "Message", "", aMessage, sizeof(aMessageBufSize), szFileIniConfig);
|
||||
GetPrivateProfileString(aSection, "Message Full Installer", "", messageFullInstaller, sizeof(messageFullInstaller), szFileIniConfig);
|
||||
if(!gbDownloadTriggered && !gbPreviousUnfinishedDownload && (*messageFullInstaller != '\0'))
|
||||
MozCopyStr(messageFullInstaller, aMessage, aMessageBufSize);
|
||||
|
||||
case CW_CHECK_VISIBLE_ONLY:
|
||||
/* Check for visible windows. If there are any, then the previous
|
||||
* call to close all visible windows had failed (most likely due
|
||||
* to user canceling a save request on a window) */
|
||||
if(GetWindowLong(hwnd, GWL_STYLE) & WS_VISIBLE)
|
||||
rv = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return(rv); // Returning TRUE will continue with the enumeration!
|
||||
// it will automatically stop when there's no more
|
||||
// windows to process.
|
||||
// Returning FALSE will stop immediately.
|
||||
return(WIZ_OK);
|
||||
}
|
||||
|
||||
|
||||
BOOL CloseAllWindowsOfWindowHandle(HWND hwndWindow)
|
||||
HRESULT ShowMessageAndQuitProcess(HWND aHwndFW, char *aMsgQuitProcess, char *aMsgWait, BOOL aCloseAllWindows, char *aProcessName, BOOL aForceQuit)
|
||||
{
|
||||
DWORD dwProcessId;
|
||||
BOOL rv = TRUE;
|
||||
|
||||
GetWindowThreadProcessId(hwndWindow, &dwProcessId);
|
||||
|
||||
/* only close the visible windows */
|
||||
gCWState = CW_CLOSE_VISIBLE_ONLY;
|
||||
EnumWindows(EnumWindowsProc, dwProcessId);
|
||||
|
||||
/* only check to make sure that the visible windows were closed */
|
||||
gCWState = CW_CHECK_VISIBLE_ONLY;
|
||||
rv = EnumWindows(EnumWindowsProc, dwProcessId);
|
||||
if(rv)
|
||||
switch(sgProduct.mode)
|
||||
{
|
||||
/* All visible windows have been closed. Close all remaining windows now */
|
||||
gCWState = CW_CLOSE_ALL;
|
||||
EnumWindows(EnumWindowsProc, dwProcessId);
|
||||
case NORMAL:
|
||||
char msgTitleStr[MAX_BUF];
|
||||
GetPrivateProfileString("Messages", "MB_ATTENTION_STR", "", msgTitleStr, sizeof(msgTitleStr), szFileIniInstall);
|
||||
MessageBox(hWndMain, aMsgQuitProcess, msgTitleStr, MB_ICONEXCLAMATION);
|
||||
break;
|
||||
|
||||
case AUTO:
|
||||
/* Setup mode is AUTO. Show message, timeout, then auto close
|
||||
* all the windows associated with the process */
|
||||
ShowMessage(aMsgQuitProcess, TRUE);
|
||||
Delay(5);
|
||||
ShowMessage(aMsgQuitProcess, FALSE);
|
||||
break;
|
||||
|
||||
case SILENT:
|
||||
break;
|
||||
}
|
||||
|
||||
return(rv);
|
||||
if(aForceQuit)
|
||||
{
|
||||
assert(aProcessName);
|
||||
FindAndKillProcess(aProcessName, KP_KILL_PROCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(aHwndFW);
|
||||
/* First try sending a WM_QUIT message to the window because this is the
|
||||
* preferred way to quit a process. If it works, then we're good and
|
||||
* CloseAllWindowsOfWindowHandle() will have nothing to do.
|
||||
* If it doesn't work, then CloseAllWindowsOfWindowHandle will try to
|
||||
* quit the process. */
|
||||
SendMessageTimeout(aHwndFW, WM_QUIT, (WPARAM)1, (LPARAM)0, SMTO_NORMAL, WM_CLOSE_TIMEOUT_VALUE, NULL);
|
||||
if(aCloseAllWindows)
|
||||
CloseAllWindowsOfWindowHandle(aHwndFW, aMsgWait);
|
||||
}
|
||||
return(WIZ_OK);
|
||||
}
|
||||
|
||||
HRESULT CheckInstances()
|
||||
{
|
||||
char szSection[MAX_BUF];
|
||||
char szProcessName[MAX_BUF];
|
||||
char szClassName[MAX_BUF];
|
||||
char szWindowName[MAX_BUF];
|
||||
char szCloseAllWindows[MAX_BUF];
|
||||
char szAttention[MAX_BUF];
|
||||
char szMessage[MAX_BUF];
|
||||
char szMessageFullInstaller[MAX_BUF];
|
||||
int iIndex;
|
||||
char section[MAX_BUF];
|
||||
char processName[MAX_BUF];
|
||||
char className[MAX_BUF];
|
||||
char windowName[MAX_BUF];
|
||||
char closeAllWindows[MAX_BUF];
|
||||
char message[MAX_BUF];
|
||||
char msgTitleStr[MAX_BUF];
|
||||
char prettyName[MAX_BUF];
|
||||
char buf[MAX_BUF];
|
||||
char msgWait[MAX_BUF];
|
||||
int index;
|
||||
int killProcessTries = 0;
|
||||
int instanceOfFoundProcess = 0;
|
||||
BOOL bContinue;
|
||||
BOOL bCloseAllWindows;
|
||||
HWND hwndFW;
|
||||
|
@ -5792,154 +5715,144 @@ HRESULT CheckInstances()
|
|||
DWORD dwRv0;
|
||||
DWORD dwRv1;
|
||||
|
||||
GetPrivateProfileString("Messages", "MB_ATTENTION_STR", "", msgTitleStr, sizeof(msgTitleStr), szFileIniInstall);
|
||||
bContinue = TRUE;
|
||||
iIndex = -1;
|
||||
index = -1;
|
||||
while(bContinue)
|
||||
{
|
||||
ZeroMemory(szClassName, sizeof(szClassName));
|
||||
ZeroMemory(szWindowName, sizeof(szWindowName));
|
||||
ZeroMemory(szMessage, sizeof(szMessage));
|
||||
ZeroMemory(szMessageFullInstaller, sizeof(szMessageFullInstaller));
|
||||
*className = '\0';
|
||||
*windowName = '\0';
|
||||
*message = '\0';
|
||||
|
||||
wsprintf(szSection, "Check Instance%d", ++iIndex);
|
||||
GetPrivateProfileString("Messages", "MB_ATTENTION_STR", "", szAttention, sizeof(szAttention), szFileIniInstall);
|
||||
GetPrivateProfileString(szSection, "Message", "", szMessage, sizeof(szMessage), szFileIniConfig);
|
||||
GetPrivateProfileString(szSection, "Message Full Installer", "", szMessageFullInstaller, sizeof(szMessageFullInstaller), szFileIniConfig);
|
||||
if(!gbDownloadTriggered && !gbPreviousUnfinishedDownload && (*szMessageFullInstaller != '\0'))
|
||||
lstrcpy(szMessage, szMessageFullInstaller);
|
||||
|
||||
if(GetPrivateProfileString(szSection, "Process Name", "", szProcessName, sizeof(szProcessName), szFileIniConfig) != 0L)
|
||||
{
|
||||
if(*szProcessName != '\0')
|
||||
{
|
||||
/* If an instance is found, call PreCheckInstance first */
|
||||
if(CheckForProcess(szProcessName, sizeof(szProcessName)) == TRUE)
|
||||
PreCheckInstance(szSection, szFileIniConfig);
|
||||
|
||||
if(CheckForProcess(szProcessName, sizeof(szProcessName)) == TRUE)
|
||||
{
|
||||
if(*szMessage != '\0')
|
||||
{
|
||||
switch(sgProduct.mode)
|
||||
{
|
||||
case NORMAL:
|
||||
switch(MessageBox(hWndMain, szMessage, szAttention, MB_ICONEXCLAMATION))
|
||||
{
|
||||
case IDCANCEL:
|
||||
/* User selected to cancel Setup */
|
||||
return(TRUE);
|
||||
|
||||
case IDRETRY:
|
||||
case IDOK:
|
||||
/* User selected to retry. Reset counter */
|
||||
iIndex = -1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case AUTO:
|
||||
ShowMessage(szMessage, TRUE);
|
||||
Delay(5);
|
||||
ShowMessage(szMessage, FALSE);
|
||||
|
||||
/* Setup mode is AUTO. Show message, timeout, then cancel because we can't allow user to continue */
|
||||
return(TRUE);
|
||||
|
||||
case SILENT:
|
||||
return(TRUE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* No message to display. Assume cancel because we can't allow user to continue */
|
||||
return(TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Process Name= key existed, and has been processed, so continue looking for more */
|
||||
continue;
|
||||
}
|
||||
|
||||
GetPrivateProfileString(szSection, "Close All Process Windows", "", szCloseAllWindows, sizeof(szCloseAllWindows), szFileIniConfig);
|
||||
if(lstrcmpi(szCloseAllWindows, "TRUE") == 0)
|
||||
wsprintf(section, "Check Instance%d", ++index);
|
||||
GetPrivateProfileString(section, "Process Name", "", processName, sizeof(processName), szFileIniConfig);
|
||||
GetPrivateProfileString(section, "Pretty Name", "", prettyName, sizeof(prettyName), szFileIniConfig);
|
||||
GetPrivateProfileString(section, "Message Wait", "", msgWait, sizeof(msgWait), szFileIniConfig);
|
||||
GetPrivateProfileString(section, "Close All Process Windows", "", closeAllWindows, sizeof(closeAllWindows), szFileIniConfig);
|
||||
if(lstrcmpi(closeAllWindows, "TRUE") == 0)
|
||||
bCloseAllWindows = TRUE;
|
||||
else
|
||||
bCloseAllWindows = FALSE;
|
||||
|
||||
/* Process Name= key did not exist, so look for other keys */
|
||||
dwRv0 = GetPrivateProfileString(szSection, "Class Name", "", szClassName, sizeof(szClassName), szFileIniConfig);
|
||||
dwRv1 = GetPrivateProfileString(szSection, "Window Name", "", szWindowName, sizeof(szWindowName), szFileIniConfig);
|
||||
if((dwRv0 == 0L) &&
|
||||
(dwRv1 == 0L))
|
||||
if(instanceOfFoundProcess != index)
|
||||
{
|
||||
killProcessTries = 0;
|
||||
instanceOfFoundProcess = index;
|
||||
}
|
||||
|
||||
if((killProcessTries == 1) && (*processName != '\0'))
|
||||
{
|
||||
if(FindAndKillProcess(processName, KP_DO_NOT_KILL_PROCESS))
|
||||
{
|
||||
/* found process, display warning message, then kill process */
|
||||
GetPrivateProfileString("Messages", "MSG_FORCE_QUIT_PROCESS", "", message, sizeof(message), szFileIniInstall);
|
||||
if(*message != '\0')
|
||||
{
|
||||
wsprintf(buf, message, prettyName, processName);
|
||||
ShowMessageAndQuitProcess(NULL, buf, msgWait, bCloseAllWindows, processName, CI_FORCE_QUIT_PROCESS);
|
||||
++killProcessTries;
|
||||
instanceOfFoundProcess = index--;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else if(killProcessTries == MAX_KILL_PROCESS_RETRIES)
|
||||
{
|
||||
GetPrivateProfileString("Messages", "MSG_FORCE_QUIT_PROCESS_FAILED", "", message, sizeof(message), szFileIniInstall);
|
||||
if(*message != '\0')
|
||||
{
|
||||
wsprintf(buf, message, prettyName, processName);
|
||||
switch(sgProduct.mode)
|
||||
{
|
||||
case NORMAL:
|
||||
MessageBox(hWndMain, buf, msgTitleStr, MB_ICONEXCLAMATION);
|
||||
break;
|
||||
|
||||
case AUTO:
|
||||
/* Setup mode is AUTO. Show message, timeout, then auto close
|
||||
* all the windows associated with the process */
|
||||
ShowMessage(buf, TRUE);
|
||||
Delay(5);
|
||||
ShowMessage(buf, FALSE);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* can't kill the process for some unknown reason. Stop the installation. */
|
||||
return(TRUE);
|
||||
}
|
||||
else if((killProcessTries > 1) &&
|
||||
(killProcessTries < MAX_KILL_PROCESS_RETRIES) &&
|
||||
(*processName != '\0'))
|
||||
{
|
||||
if(FindAndKillProcess(processName, KP_KILL_PROCESS))
|
||||
{
|
||||
++killProcessTries;
|
||||
instanceOfFoundProcess = index--;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
dwRv0 = GetPrivateProfileString(section, "Class Name", "", className, sizeof(className), szFileIniConfig);
|
||||
dwRv1 = GetPrivateProfileString(section, "Window Name", "", windowName, sizeof(windowName), szFileIniConfig);
|
||||
if((dwRv0 == 0L) && (dwRv1 == 0L) && (*processName == '\0'))
|
||||
{
|
||||
bContinue = FALSE;
|
||||
}
|
||||
else if((*szClassName != '\0') || (*szWindowName != '\0'))
|
||||
else if((*className != '\0') || (*windowName != '\0'))
|
||||
{
|
||||
if(*szClassName == '\0')
|
||||
if(*className == '\0')
|
||||
szCN = NULL;
|
||||
else
|
||||
szCN = szClassName;
|
||||
szCN = className;
|
||||
|
||||
if(*szWindowName == '\0')
|
||||
if(*windowName == '\0')
|
||||
szWN = NULL;
|
||||
else
|
||||
szWN = szWindowName;
|
||||
szWN = windowName;
|
||||
|
||||
/* If an instance is found, call PreCheckInstance first */
|
||||
/* If an instance is found, call PreCheckInstance first.
|
||||
* PreCheckInstance will try to disable the browser's
|
||||
* QuickLaunch feature. If the browser was in QuickLaunch
|
||||
* mode without any windows open, PreCheckInstance would
|
||||
* shutdown the browser, thus a second call to FindAndKillProcess
|
||||
* is required to see if the process is still around. */
|
||||
if((hwndFW = FindWindow(szCN, szWN)) != NULL)
|
||||
PreCheckInstance(szSection, szFileIniConfig);
|
||||
PreCheckInstance(section, szFileIniConfig);
|
||||
|
||||
if((hwndFW = FindWindow(szCN, szWN)) != NULL)
|
||||
{
|
||||
if(*szMessage != '\0')
|
||||
GetCheckInstanceQuitMessage(section, message, sizeof(message));
|
||||
if(*message != '\0')
|
||||
{
|
||||
BOOL rv = FALSE;
|
||||
switch(sgProduct.mode)
|
||||
{
|
||||
case NORMAL:
|
||||
switch(MessageBox(hWndMain, szMessage, szAttention, MB_ICONEXCLAMATION))
|
||||
{
|
||||
case IDCANCEL:
|
||||
/* User selected to cancel Setup */
|
||||
return(TRUE);
|
||||
ShowMessageAndQuitProcess(hwndFW, message, msgWait, bCloseAllWindows, processName, CI_CLOSE_PROCESS);
|
||||
++killProcessTries;
|
||||
instanceOfFoundProcess = index--;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* No message to display. Assume cancel because we can't allow user to continue */
|
||||
return(TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case IDRETRY:
|
||||
case IDOK:
|
||||
/* User selected to retry. Reset counter */
|
||||
if(bCloseAllWindows)
|
||||
CloseAllWindowsOfWindowHandle(hwndFW);
|
||||
|
||||
iIndex = -1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case AUTO:
|
||||
/* Setup mode is AUTO. Show message, timeout, then auto close
|
||||
* all the windows associated with the process */
|
||||
|
||||
ShowMessage(szMessage, TRUE);
|
||||
Delay(5);
|
||||
ShowMessage(szMessage, FALSE);
|
||||
|
||||
if(bCloseAllWindows)
|
||||
rv = !CloseAllWindowsOfWindowHandle(hwndFW);
|
||||
|
||||
return(rv);
|
||||
|
||||
case SILENT:
|
||||
/* Setup mode is SILENT. Just auto close
|
||||
* all the windows associated with the process */
|
||||
|
||||
if(bCloseAllWindows)
|
||||
/* return value of TRUE means all windows were
|
||||
* successfully closed, so do not auto quit the installer */
|
||||
rv = !CloseAllWindowsOfWindowHandle(hwndFW);
|
||||
|
||||
return(rv);
|
||||
}
|
||||
if((killProcessTries == 0) && (*processName != '\0'))
|
||||
{
|
||||
/* The first attempt used FindWindow(), but sometimes the browser can be
|
||||
* in a state where there's no window open and still not fully shutdown.
|
||||
* In this case, we need to check for the process itself and kill it. */
|
||||
if(FindAndKillProcess(processName, KP_DO_NOT_KILL_PROCESS))
|
||||
{
|
||||
GetCheckInstanceQuitMessage(section, message, sizeof(message));
|
||||
if(*message != '\0')
|
||||
{
|
||||
ShowMessageAndQuitProcess(hwndFW, message, msgWait, bCloseAllWindows, processName, CI_FORCE_QUIT_PROCESS);
|
||||
++killProcessTries;
|
||||
instanceOfFoundProcess = index--;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -8334,399 +8247,6 @@ int AddGrePathToApplicationAppPathsKey()
|
|||
return(rv);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// The functions below were copied from MSDN 6.0:
|
||||
//
|
||||
// \samples\vc98\sdk\sdktools\winnt\pviewer
|
||||
//
|
||||
// They were listed in the redist.txt file from the cd.
|
||||
// Only CheckProcessNT4() was modified to accomodate the setup needs.
|
||||
//
|
||||
/******************************************************************************\
|
||||
* * This is a part of the Microsoft Source Code Samples.
|
||||
* * Copyright (C) 1993-1997 Microsoft Corporation.
|
||||
* * All rights reserved.
|
||||
\******************************************************************************/
|
||||
BOOL CheckProcessNT4(LPSTR szProcessName, DWORD dwProcessNameSize)
|
||||
{
|
||||
BOOL bRv;
|
||||
HKEY hKey;
|
||||
DWORD dwType;
|
||||
DWORD dwSize;
|
||||
DWORD dwTemp;
|
||||
DWORD dwTitleLastIdx;
|
||||
DWORD dwIndex;
|
||||
DWORD dwLen;
|
||||
DWORD pDataSize = 50 * 1024;
|
||||
LPSTR szCounterValueName;
|
||||
LPSTR szTitle;
|
||||
LPSTR *szTitleSz;
|
||||
LPSTR szTitleBuffer;
|
||||
PPERF_DATA pData;
|
||||
PPERF_OBJECT pProcessObject;
|
||||
|
||||
bRv = FALSE;
|
||||
hKey = NULL;
|
||||
|
||||
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
||||
TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion\\perflib"),
|
||||
0,
|
||||
KEY_READ,
|
||||
&hKey) != ERROR_SUCCESS)
|
||||
return(bRv);
|
||||
|
||||
dwSize = sizeof(dwTitleLastIdx);
|
||||
if(RegQueryValueEx(hKey, TEXT("Last Counter"), 0, &dwType, (LPBYTE)&dwTitleLastIdx, &dwSize) != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return(bRv);
|
||||
}
|
||||
|
||||
|
||||
dwSize = sizeof(dwTemp);
|
||||
if(RegQueryValueEx(hKey, TEXT("Version"), 0, &dwType, (LPBYTE)&dwTemp, &dwSize) != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
szCounterValueName = TEXT("Counters");
|
||||
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
||||
TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion\\Perflib\\009"),
|
||||
0,
|
||||
KEY_READ,
|
||||
&hKey) != ERROR_SUCCESS)
|
||||
return(bRv);
|
||||
}
|
||||
else
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
szCounterValueName = TEXT("Counter 009");
|
||||
hKey = HKEY_PERFORMANCE_DATA;
|
||||
}
|
||||
|
||||
// Find out the size of the data.
|
||||
//
|
||||
dwSize = 0;
|
||||
if(RegQueryValueEx(hKey, szCounterValueName, 0, &dwType, 0, &dwSize) != ERROR_SUCCESS)
|
||||
return(bRv);
|
||||
|
||||
|
||||
// Allocate memory
|
||||
//
|
||||
szTitleBuffer = (LPTSTR)LocalAlloc(LMEM_FIXED, dwSize);
|
||||
if(!szTitleBuffer)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return(bRv);
|
||||
}
|
||||
|
||||
szTitleSz = (LPTSTR *)LocalAlloc(LPTR, (dwTitleLastIdx + 1) * sizeof(LPTSTR));
|
||||
if(!szTitleSz)
|
||||
{
|
||||
if(szTitleBuffer != NULL)
|
||||
{
|
||||
LocalFree(szTitleBuffer);
|
||||
szTitleBuffer = NULL;
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
return(bRv);
|
||||
}
|
||||
|
||||
// Query the data
|
||||
//
|
||||
if(RegQueryValueEx(hKey, szCounterValueName, 0, &dwType, (BYTE *)szTitleBuffer, &dwSize) != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
if(szTitleSz)
|
||||
LocalFree(szTitleSz);
|
||||
if(szTitleBuffer)
|
||||
LocalFree(szTitleBuffer);
|
||||
|
||||
return(bRv);
|
||||
}
|
||||
|
||||
// Setup the TitleSz array of pointers to point to beginning of each title string.
|
||||
// TitleBuffer is type REG_MULTI_SZ.
|
||||
//
|
||||
szTitle = szTitleBuffer;
|
||||
while(dwLen = lstrlen(szTitle))
|
||||
{
|
||||
dwIndex = atoi(szTitle);
|
||||
szTitle = szTitle + dwLen + 1;
|
||||
|
||||
if(dwIndex <= dwTitleLastIdx)
|
||||
szTitleSz[dwIndex] = szTitle;
|
||||
|
||||
szTitle = szTitle + lstrlen(szTitle) + 1;
|
||||
}
|
||||
|
||||
PX_PROCESS = GetTitleIdx (NULL, szTitleSz, dwTitleLastIdx, PN_PROCESS);
|
||||
PX_THREAD = GetTitleIdx (NULL, szTitleSz, dwTitleLastIdx, PN_THREAD);
|
||||
wsprintf(INDEX_PROCTHRD_OBJ, TEXT("%ld %ld"), PX_PROCESS, PX_THREAD);
|
||||
pData = NULL;
|
||||
if(GetPerfData(HKEY_PERFORMANCE_DATA, INDEX_PROCTHRD_OBJ, &pData, &pDataSize) == ERROR_SUCCESS)
|
||||
{
|
||||
PPERF_INSTANCE pInst;
|
||||
DWORD i = 0;
|
||||
|
||||
pProcessObject = FindObject(pData, PX_PROCESS);
|
||||
if(pProcessObject)
|
||||
{
|
||||
LPSTR szPtrStr;
|
||||
int iLen;
|
||||
char szProcessNamePruned[MAX_BUF];
|
||||
char szNewProcessName[MAX_BUF];
|
||||
|
||||
if(sizeof(szProcessNamePruned) < (lstrlen(szProcessName) + 1))
|
||||
{
|
||||
if(hKey)
|
||||
RegCloseKey(hKey);
|
||||
if(szTitleSz)
|
||||
LocalFree(szTitleSz);
|
||||
if(szTitleBuffer)
|
||||
LocalFree(szTitleBuffer);
|
||||
|
||||
return(bRv);
|
||||
}
|
||||
|
||||
/* look for .exe and remove from end of string because the Process names
|
||||
* under NT are returned without the extension */
|
||||
lstrcpy(szProcessNamePruned, szProcessName);
|
||||
iLen = lstrlen(szProcessNamePruned);
|
||||
szPtrStr = &szProcessNamePruned[iLen - 4];
|
||||
if((lstrcmpi(szPtrStr, ".exe") == 0) || (lstrcmpi(szPtrStr, ".dll") == 0))
|
||||
*szPtrStr = '\0';
|
||||
|
||||
pInst = FirstInstance(pProcessObject);
|
||||
for(i = 0; i < (DWORD)(pProcessObject->NumInstances); i++)
|
||||
{
|
||||
ZeroMemory(szNewProcessName, MAX_BUF);
|
||||
if(WideCharToMultiByte(CP_ACP,
|
||||
0,
|
||||
(LPCWSTR)((PCHAR)pInst + pInst->NameOffset),
|
||||
-1,
|
||||
szNewProcessName,
|
||||
MAX_BUF,
|
||||
NULL,
|
||||
NULL) != 0)
|
||||
{
|
||||
if(lstrcmpi(szNewProcessName, szProcessNamePruned) == 0)
|
||||
{
|
||||
bRv = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pInst = NextInstance(pInst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(hKey)
|
||||
RegCloseKey(hKey);
|
||||
if(szTitleSz)
|
||||
LocalFree(szTitleSz);
|
||||
if(szTitleBuffer)
|
||||
LocalFree(szTitleBuffer);
|
||||
|
||||
return(bRv);
|
||||
}
|
||||
|
||||
|
||||
//*********************************************************************
|
||||
//
|
||||
// GetPerfData
|
||||
//
|
||||
// Get a new set of performance data.
|
||||
//
|
||||
// *ppData should be NULL initially.
|
||||
// This function will allocate a buffer big enough to hold the
|
||||
// data requested by szObjectIndex.
|
||||
//
|
||||
// *pDataSize specifies the initial buffer size. If the size is
|
||||
// too small, the function will increase it until it is big enough
|
||||
// then return the size through *pDataSize. Caller should
|
||||
// deallocate *ppData if it is no longer being used.
|
||||
//
|
||||
// Returns ERROR_SUCCESS if no error occurs.
|
||||
//
|
||||
// Note: the trial and error loop is quite different from the normal
|
||||
// registry operation. Normally if the buffer is too small,
|
||||
// RegQueryValueEx returns the required size. In this case,
|
||||
// the perflib, since the data is dynamic, a buffer big enough
|
||||
// for the moment may not be enough for the next. Therefor,
|
||||
// the required size is not returned.
|
||||
//
|
||||
// One should start with a resonable size to avoid the overhead
|
||||
// of reallocation of memory.
|
||||
//
|
||||
DWORD GetPerfData (HKEY hPerfKey,
|
||||
LPTSTR szObjectIndex,
|
||||
PPERF_DATA *ppData,
|
||||
DWORD *pDataSize)
|
||||
{
|
||||
DWORD DataSize;
|
||||
DWORD dwR;
|
||||
DWORD Type;
|
||||
|
||||
|
||||
if (!*ppData)
|
||||
*ppData = (PPERF_DATA) LocalAlloc (LMEM_FIXED, *pDataSize);
|
||||
|
||||
|
||||
do {
|
||||
DataSize = *pDataSize;
|
||||
dwR = RegQueryValueEx (hPerfKey,
|
||||
szObjectIndex,
|
||||
NULL,
|
||||
&Type,
|
||||
(BYTE *)*ppData,
|
||||
&DataSize);
|
||||
|
||||
if (dwR == ERROR_MORE_DATA)
|
||||
{
|
||||
LocalFree (*ppData);
|
||||
*pDataSize += 1024;
|
||||
*ppData = (PPERF_DATA) LocalAlloc (LMEM_FIXED, *pDataSize);
|
||||
}
|
||||
|
||||
if (!*ppData)
|
||||
{
|
||||
LocalFree (*ppData);
|
||||
return ERROR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
|
||||
} while (dwR == ERROR_MORE_DATA);
|
||||
|
||||
return dwR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//*********************************************************************
|
||||
//
|
||||
// FirstInstance
|
||||
//
|
||||
// Returns pointer to the first instance of pObject type.
|
||||
// If pObject is NULL then NULL is returned.
|
||||
//
|
||||
PPERF_INSTANCE FirstInstance (PPERF_OBJECT pObject)
|
||||
{
|
||||
if (pObject)
|
||||
return (PPERF_INSTANCE)((PCHAR) pObject + pObject->DefinitionLength);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
//
|
||||
// NextInstance
|
||||
//
|
||||
// Returns pointer to the next instance following pInst.
|
||||
//
|
||||
// If pInst is the last instance, bogus data maybe returned.
|
||||
// The caller should do the checking.
|
||||
//
|
||||
// If pInst is NULL, then NULL is returned.
|
||||
//
|
||||
PPERF_INSTANCE NextInstance (PPERF_INSTANCE pInst)
|
||||
{
|
||||
PERF_COUNTER_BLOCK *pCounterBlock;
|
||||
|
||||
if (pInst)
|
||||
{
|
||||
pCounterBlock = (PERF_COUNTER_BLOCK *)((PCHAR) pInst + pInst->ByteLength);
|
||||
return (PPERF_INSTANCE)((PCHAR) pCounterBlock + pCounterBlock->ByteLength);
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
//
|
||||
// FirstObject
|
||||
//
|
||||
// Returns pointer to the first object in pData.
|
||||
// If pData is NULL then NULL is returned.
|
||||
//
|
||||
PPERF_OBJECT FirstObject (PPERF_DATA pData)
|
||||
{
|
||||
if (pData)
|
||||
return ((PPERF_OBJECT) ((PBYTE) pData + pData->HeaderLength));
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//*********************************************************************
|
||||
//
|
||||
// NextObject
|
||||
//
|
||||
// Returns pointer to the next object following pObject.
|
||||
//
|
||||
// If pObject is the last object, bogus data maybe returned.
|
||||
// The caller should do the checking.
|
||||
//
|
||||
// If pObject is NULL, then NULL is returned.
|
||||
//
|
||||
PPERF_OBJECT NextObject (PPERF_OBJECT pObject)
|
||||
{
|
||||
if (pObject)
|
||||
return ((PPERF_OBJECT) ((PBYTE) pObject + pObject->TotalByteLength));
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
//
|
||||
// FindObject
|
||||
//
|
||||
// Returns pointer to object with TitleIndex. If not found, NULL
|
||||
// is returned.
|
||||
//
|
||||
PPERF_OBJECT FindObject (PPERF_DATA pData, DWORD TitleIndex)
|
||||
{
|
||||
PPERF_OBJECT pObject;
|
||||
DWORD i = 0;
|
||||
|
||||
if (pObject = FirstObject (pData))
|
||||
while (i < pData->NumObjectTypes)
|
||||
{
|
||||
if (pObject->ObjectNameTitleIndex == TitleIndex)
|
||||
return pObject;
|
||||
|
||||
pObject = NextObject (pObject);
|
||||
i++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//********************************************************
|
||||
//
|
||||
// GetTitleIdx
|
||||
//
|
||||
// Searches Titles[] for Name. Returns the index found.
|
||||
//
|
||||
DWORD GetTitleIdx(HWND hWnd, LPTSTR Title[], DWORD LastIndex, LPTSTR Name)
|
||||
{
|
||||
DWORD Index;
|
||||
|
||||
for(Index = 0; Index <= LastIndex; Index++)
|
||||
if(Title[Index])
|
||||
if(!lstrcmpi (Title[Index], Name))
|
||||
return(Index);
|
||||
|
||||
MessageBox(hWnd, Name, TEXT("Pviewer cannot find index"), MB_OK);
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL ShowAdditionalOptionsDialog(void)
|
||||
{
|
||||
if(diAdditionalOptions.bShowDialog == FALSE)
|
||||
|
|
|
@ -120,6 +120,12 @@ typedef int PRInt32;
|
|||
#define WS_DO_NOT_WAIT FALSE
|
||||
#define WS_WAIT TRUE
|
||||
|
||||
#define MAX_KILL_PROCESS_RETRIES 10
|
||||
|
||||
/* CI: Check Instance */
|
||||
#define CI_FORCE_QUIT_PROCESS TRUE
|
||||
#define CI_CLOSE_PROCESS FALSE
|
||||
|
||||
#define BAR_MARGIN 1
|
||||
#define BAR_SPACING 0
|
||||
#define BAR_WIDTH 6
|
||||
|
|
Загрузка…
Ссылка в новой задаче