diff options
author | Mark Hammond <mhammond@skippinet.com.au> | 2009-01-27 23:12:23 (GMT) |
---|---|---|
committer | Mark Hammond <mhammond@skippinet.com.au> | 2009-01-27 23:12:23 (GMT) |
commit | 9f4f56d4e8c6c4a0221a24a6013b04b02e7916b6 (patch) | |
tree | e262164178b8a80c5386064bdf52933986b8707d /Python | |
parent | 560f9a8a9004ba0a2ee064e9ad83f413d091b2fa (diff) | |
download | cpython-9f4f56d4e8c6c4a0221a24a6013b04b02e7916b6.zip cpython-9f4f56d4e8c6c4a0221a24a6013b04b02e7916b6.tar.gz cpython-9f4f56d4e8c6c4a0221a24a6013b04b02e7916b6.tar.bz2 |
On Windows, use the Python 'Activation Context' when loading extensions
to avoid problems loading the CRT from a private assembly. Via bug 4566.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/dynload_win.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Python/dynload_win.c b/Python/dynload_win.c index 7c71d9c..907a5a3 100644 --- a/Python/dynload_win.c +++ b/Python/dynload_win.c @@ -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 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, 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 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, 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); |