From e1d1d34c9d1992db4c98b6a8ba5502f2c949cac4 Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Fri, 29 Oct 2004 21:26:33 +0000 Subject: [PATCH] Kill all wine processes when doing ExitWindowsEx. --- windows/user.c | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/windows/user.c b/windows/user.c index 85d5227fc50..4e57bdf04c3 100644 --- a/windows/user.c +++ b/windows/user.c @@ -30,6 +30,7 @@ #include "wine/winuser16.h" #include "winreg.h" #include "winternl.h" +#include "tlhelp32.h" #include "user.h" #include "win.h" #include "controls.h" @@ -294,6 +295,124 @@ BOOL16 WINAPI ExitWindowsExec16( LPCSTR lpszExe, LPCSTR lpszParams ) /*********************************************************************** + * USER_GetProcessHandleList(Internal) + */ +static HANDLE *USER_GetProcessHandleList(void) +{ + DWORD count, i, n; + HANDLE *list; + PROCESSENTRY32 pe; + HANDLE hSnapshot; + BOOL r; + + hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ); + if (!hSnapshot) + { + ERR("cannot create snapshot\n"); + return FALSE; + } + + /* count the number of processes plus one */ + for (count=0; ;count++) + { + pe.dwSize = sizeof pe; + if (count) + r = Process32Next( hSnapshot, &pe ); + else + r = Process32First( hSnapshot, &pe ); + if (!r) + break; + } + + /* allocate memory make a list of the process handles */ + list = HeapAlloc( GetProcessHeap(), 0, (count+1)*sizeof(HANDLE) ); + n=0; + for (i=0; iMAXIMUM_WAIT_OBJECTS) ? MAXIMUM_WAIT_OBJECTS : (n-i); + r = WaitForMultipleObjects( n_objs, &handles[i], TRUE, dwShutdownTimeout ); + if (r==WAIT_TIMEOUT) + ERR("wait failed!\n"); + } + + /* close the handles */ + for (i=0; i