diff Python/dynload_win.c @ 51130:0522cfee879a 3.0

Merged revisions 69041 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r69041 | mark.hammond | 2009-01-28 10:46:57 +1100 (Wed, 28 Jan 2009) | 10 lines Merged revisions 69038 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r69038 | mark.hammond | 2009-01-28 10:12:23 +1100 (Wed, 28 Jan 2009) | 3 lines On Windows, use the Python 'Activation Context' when loading extensions to avoid problems loading the CRT from a private assembly. Via bug 4566. ........ ................
author Mark Hammond <mhammond@skippinet.com.au>
date Tue, 27 Jan 2009 23:50:56 +0000
parents b833a40098c0
children cab14be0ada1
line wrap: on
line diff
--- a/Python/dynload_win.c	Tue Jan 27 20:28:36 2009 +0000
+++ b/Python/dynload_win.c	Tue Jan 27 23:50:56 2009 +0000
@@ -11,6 +11,10 @@
 #include "importdl.h"
 #include <windows.h>
 
+// "activation context" magic - see dl_nt.c...
+extern ULONG_PTR _Py_ActivateActCtx();
+void _Py_DeactivateActCtx(ULONG_PTR cookie);
+
 const struct filedescr _PyImport_DynLoadFiletab[] = {
 #ifdef _DEBUG
 	{"_d.pyd", "rb", C_EXTENSION},
@@ -172,6 +176,7 @@
 		char pathbuf[260];
 		LPTSTR dummy;
 		unsigned int old_mode;
+		ULONG_PTR cookie = 0;
 		/* We use LoadLibraryEx so Windows looks for dependent DLLs 
 		    in directory of pathname first.  However, Windows95
 		    can sometimes not work correctly unless the absolute
@@ -184,10 +189,13 @@
 		if (GetFullPathName(pathname,
 				    sizeof(pathbuf),
 				    pathbuf,
-				    &dummy))
+				    &dummy)) {
+			ULONG_PTR cookie = _Py_ActivateActCtx();
 			/* XXX This call doesn't exist in Windows CE */
 			hDLL = LoadLibraryEx(pathname, NULL,
 					     LOAD_WITH_ALTERED_SEARCH_PATH);
+			_Py_DeactivateActCtx(cookie);
+		}
 
 		/* restore old error mode settings */
 		SetErrorMode(old_mode);