Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``_ctypes`` module: improve UWP compatibility.
9 changes: 7 additions & 2 deletions Modules/_ctypes/callproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1082,8 +1082,7 @@ void _ctypes_extend_error(PyObject *exc_class, const char *fmt, ...)
}


#ifdef MS_WIN32

#ifdef MS_WINDOWS_DESKTOP
static PyObject *
GetComError(ctypes_state *st, HRESULT errcode, GUID *riid, IUnknown *pIunk)
{
Expand Down Expand Up @@ -1337,9 +1336,11 @@ PyObject *_ctypes_callproc(ctypes_state *st,

#ifdef MS_WIN32
if (iid && pIunk) {
#ifdef MS_WINDOWS_DESKTOP
if (*(int *)resbuf & 0x80000000)
retval = GetComError(st, *(HRESULT *)resbuf, iid, pIunk);
else
#endif
retval = PyLong_FromLong(*(int *)resbuf);
} else if (flags & FUNCFLAG_HRESULT) {
if (*(int *)resbuf & 0x80000000)
Expand Down Expand Up @@ -1417,10 +1418,14 @@ static PyObject *load_library(PyObject *self, PyObject *args)
return NULL;

Py_BEGIN_ALLOW_THREADS
#ifndef MS_WINDOWS_DESKTOP
hMod = LoadPackagedLibrary(name, 0);
#else
/* bpo-36085: Limit DLL search directories to avoid pre-loading
* attacks and enable use of the AddDllDirectory function.
*/
hMod = LoadLibraryExW(name, NULL, (DWORD)load_flags);
#endif
err = hMod ? 0 : GetLastError();
Py_END_ALLOW_THREADS

Expand Down
Loading