From: "Vincent Povirk" <vincent@codeweavers.com>
Subject: [1/3] msvcrt: Try to call CorExitProcess instead of ExitProcess on exit.
Message-Id: <33F6268AA99B6C448F07F03B2B6497D38CE4FF@taz.CodeWeavers.local>
Date: Wed, 23 Feb 2011 15:47:43 -0600

From 5d18fb8576b070e3a3b4b5831ec9ed0c583e2b8d Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent@codeweavers.com>
Date: Mon, 21 Feb 2011 15:49:59 -0600
Subject: [PATCH 1/3] msvcrt: Try to call CorExitProcess instead of ExitProcess on exit.

---
 dlls/msvcrt/exit.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/dlls/msvcrt/exit.c b/dlls/msvcrt/exit.c
index 6e5a58a..d7f28f1 100644
--- a/dlls/msvcrt/exit.c
+++ b/dlls/msvcrt/exit.c
@@ -265,8 +265,23 @@ MSVCRT__onexit_t CDECL MSVCRT__onexit(MSVCRT__onexit_t func)
  */
 void CDECL MSVCRT_exit(int exitcode)
 {
+  HMODULE hmscoree;
+  static const WCHAR mscoreeW[] = {'m','s','c','o','r','e','e',0};
+  void WINAPI (*pCorExitProcess)(int);
+
   TRACE("(%d)\n",exitcode);
   MSVCRT__cexit();
+
+  hmscoree = GetModuleHandleW(mscoreeW);
+
+  if (hmscoree)
+  {
+    pCorExitProcess = (void*)GetProcAddress(hmscoree, "CorExitProcess");
+
+    if (pCorExitProcess)
+      pCorExitProcess(exitcode);
+  }
+
   ExitProcess(exitcode);
 }
 
-- 
1.7.1