* init.cc (respawn_wow64_process): Make inline function. Remove
"noreturn" attribute. Add additional check if parent process is actually a 64 bit process. (dll_entry): Only test WOW64 processes with a stack in the usual "dangerous" process space area.
This commit is contained in:
		| @@ -1,3 +1,11 @@ | ||||
| 2005-08-14  Corinna Vinschen  <corinna@vinschen.de> | ||||
|  | ||||
| 	* init.cc (respawn_wow64_process): Make inline function.  Remove | ||||
| 	"noreturn" attribute.  Add additional check if parent process is | ||||
| 	actually a 64 bit process. | ||||
| 	(dll_entry): Only test WOW64 processes with a stack in the usual | ||||
| 	"dangerous" process space area. | ||||
|  | ||||
| 2005-08-11  Troy Curtiss  <trcurtiss@gmail.com> | ||||
|  | ||||
| 	* fhandler_serial.cc (fhandler_serial::tcgetattr): Return current baud | ||||
|   | ||||
| @@ -15,6 +15,8 @@ details. */ | ||||
| #include "perprocess.h" | ||||
| #include "cygtls.h" | ||||
| #include "pinfo.h" | ||||
| #include <ntdef.h> | ||||
| #include "ntdll.h" | ||||
|  | ||||
| int NO_COPY dynamically_loaded; | ||||
| static char *search_for = (char *) cygthread::stub; | ||||
| @@ -88,9 +90,33 @@ munge_threadfunc () | ||||
|     } | ||||
| } | ||||
|  | ||||
| static void __attribute__ ((noreturn)) | ||||
| inline static void | ||||
| respawn_wow64_process () | ||||
| { | ||||
|   NTSTATUS ret; | ||||
|   PROCESS_BASIC_INFORMATION pbi; | ||||
|   HANDLE parent; | ||||
|  | ||||
|   BOOL is_wow64_proc = TRUE;	/* Opt on the safe side. */ | ||||
|  | ||||
|   /* Unfortunately there's no simpler way to retrieve the | ||||
|      parent process in NT, as far as I know.  Hints welcome. */ | ||||
|   ret = NtQueryInformationProcess (GetCurrentProcess (), | ||||
| 				   ProcessBasicInformation, | ||||
| 				   (PVOID) &pbi, | ||||
| 				   sizeof pbi, NULL); | ||||
|   if (ret == STATUS_SUCCESS | ||||
|       && (parent = OpenProcess (PROCESS_QUERY_INFORMATION, | ||||
| 				FALSE, | ||||
| 				pbi.InheritedFromUniqueProcessId))) | ||||
|     { | ||||
|       IsWow64Process (parent, &is_wow64_proc); | ||||
|       CloseHandle (parent); | ||||
|     } | ||||
|  | ||||
|   /* The parent is a real 64 bit process?  Respawn! */ | ||||
|   if (!is_wow64_proc) | ||||
|     { | ||||
|       PROCESS_INFORMATION pi; | ||||
|       STARTUPINFO si; | ||||
|       GetStartupInfo (&si); | ||||
| @@ -104,6 +130,7 @@ respawn_wow64_process () | ||||
| 	api_fatal ("Waiting for process %d failed, %E", pi.dwProcessId); | ||||
|       CloseHandle (pi.hProcess); | ||||
|       ExitProcess (0); | ||||
|     } | ||||
| } | ||||
|  | ||||
| extern void __stdcall dll_crt0_0 (); | ||||
| @@ -113,18 +140,23 @@ HMODULE NO_COPY cygwin_hmodule; | ||||
| extern "C" int WINAPI | ||||
| dll_entry (HANDLE h, DWORD reason, void *static_load) | ||||
| { | ||||
|   BOOL is_64bit_machine = FALSE; | ||||
|   BOOL is_wow64_proc = FALSE; | ||||
|  | ||||
|   switch (reason) | ||||
|     { | ||||
|     case DLL_PROCESS_ATTACH: | ||||
|       cygwin_hmodule = (HMODULE) h; | ||||
|       dynamically_loaded = (static_load == NULL); | ||||
|       /* Is the stack at an unusual high address?  Check if we're running on | ||||
| 	 a 64 bit machine.  If so, respawn. */ | ||||
|       if (&is_64bit_machine >= (PBOOL) 0x400000 | ||||
| 	  && IsWow64Process (hMainProc, &is_64bit_machine) | ||||
| 	  && is_64bit_machine) | ||||
|  | ||||
|       /* Is the stack at an unusual address?  This is, an address which | ||||
|          is in the usual space occupied by the process image, but below | ||||
| 	 the auto load address of DLLs? | ||||
| 	 Check if we're running in WOW64 on a 64 bit machine *and* are | ||||
| 	 spawned by a genuine 64 bit process.  If so, respawn. */ | ||||
|       if (&is_wow64_proc >= (PBOOL) 0x400000 | ||||
|           && &is_wow64_proc <= (PBOOL) 0x10000000 | ||||
|           && IsWow64Process (hMainProc, &is_wow64_proc) | ||||
| 	  && is_wow64_proc) | ||||
| 	respawn_wow64_process (); | ||||
|  | ||||
|       prime_threads (); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user