This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Thrameos
Recipients Thrameos, WildCard65, eryksun, paul.moore, steve.dower, tim.golden, zach.ware
Date 2020-12-19.19:19:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1608405543.16.0.153210429295.issue42529@roundup.psfhosted.org>
In-reply-to
Content
I will look through the list of samples in Detours to see if there is something that can give us better stacktrace information.   If we really need a stack trace I can make Detours bust by creating an intentional segfault and see if we can attach the debugger after the source of the problem has been triggered.  Unfortunately as my windows programming knowledge is all from 1994 I may be missing something obvious.

In the meantime I am upgrading the sample with some more hooks for any other potential LoadLibrary variants and FlsGetValue.  Though given the GetProcAddress calls I think that it must be something in the chain leading up so the variants are likely not envolved.

The other thing I can do is look at instrumenting SetErrorMode so that I can give myself a marker of when we are entering and leaving the dyload code.

```

        /* Don't display a message box when Python can't load a DLL */
        old_mode = SetErrorMode(SEM_FAILCRITICALERRORS);

        /* bpo-36085: We use LoadLibraryEx with restricted search paths
           to avoid DLL preloading attacks and enable use of the
           AddDllDirectory function. We add SEARCH_DLL_LOAD_DIR to
           ensure DLLs adjacent to the PYD are preferred. */
        Py_BEGIN_ALLOW_THREADS
        hDLL = LoadLibraryExW(wpathname, NULL,
                              LOAD_LIBRARY_SEARCH_DEFAULT_DIRS |
                              LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR);
        Py_END_ALLOW_THREADS
#if !USE_UNICODE_WCHAR_CACHE
        PyMem_Free(wpathname);
#endif /* USE_UNICODE_WCHAR_CACHE */

        /* restore old error mode settings */
        SetErrorMode(old_mode);
```

I will post back once I get some results.
History
Date User Action Args
2020-12-19 19:19:03Thrameossetrecipients: + Thrameos, paul.moore, tim.golden, zach.ware, eryksun, steve.dower, WildCard65
2020-12-19 19:19:03Thrameossetmessageid: <1608405543.16.0.153210429295.issue42529@roundup.psfhosted.org>
2020-12-19 19:19:03Thrameoslinkissue42529 messages
2020-12-19 19:19:02Thrameoscreate