Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2004-07-24 13:41:34 +0400
committerCorinna Vinschen <corinna@vinschen.de>2004-07-24 13:41:34 +0400
commit65c5aa77fbd14e8571ffcefb731748954bc2f4df (patch)
tree1b00e362d620e645a61f54541a4154ee6233ff2a /winsup/cygwin/init.cc
parent61e6420f325111a3b596a324c6adddfebd7d53d1 (diff)
* autoload.cc (GetNativeSystemInfo): Add.
(IsWow64Process): Add. * init.cc (respawn_wow64_process): New function. (dll_entry): If process has been started from a 64 bit process, call respawn_wow64_process. * uname.cc (uname): On 64 bit systems, use GetNativeSystemInfo. Show actual CPU type.
Diffstat (limited to 'winsup/cygwin/init.cc')
-rw-r--r--winsup/cygwin/init.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/winsup/cygwin/init.cc b/winsup/cygwin/init.cc
index e42698e36..c1e98a8a6 100644
--- a/winsup/cygwin/init.cc
+++ b/winsup/cygwin/init.cc
@@ -87,14 +87,41 @@ munge_threadfunc ()
}
}
+static void __attribute__ ((noreturn))
+respawn_wow64_process ()
+{
+ PROCESS_INFORMATION pi;
+ STARTUPINFO si;
+ GetStartupInfo (&si);
+ if (!CreateProcessA (NULL, GetCommandLineA (), NULL, NULL, TRUE,
+ CREATE_DEFAULT_ERROR_MODE
+ | GetPriorityClass (GetCurrentProcess ()),
+ NULL, NULL, &si, &pi))
+ api_fatal ("Failed to create process <%s>: %E", GetCommandLineA ());
+ CloseHandle (pi.hThread);
+ if (WaitForSingleObject (pi.hProcess, INFINITE) == WAIT_FAILED)
+ api_fatal ("Waiting for process %d failed: %E", pi.dwProcessId);
+ CloseHandle (pi.hProcess);
+ ExitProcess (0);
+}
+
extern void __stdcall dll_crt0_0 ();
extern "C" int WINAPI
dll_entry (HANDLE h, DWORD reason, void *static_load)
{
+ BOOL is_64bit_machine = FALSE;
+
switch (reason)
{
case DLL_PROCESS_ATTACH:
+ /* 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)
+ respawn_wow64_process ();
+
prime_threads ();
dynamically_loaded = (static_load == NULL);
dll_crt0_0 ();