Skip to content

Remove dynamic function loading checks for old Windows versions#2711

Open
Avasam wants to merge 2 commits intomhammond:mainfrom
Avasam:stop-dynamically-loading-old-functions
Open

Remove dynamic function loading checks for old Windows versions#2711
Avasam wants to merge 2 commits intomhammond:mainfrom
Avasam:stop-dynamically-loading-old-functions

Conversation

@Avasam
Copy link
Collaborator

@Avasam Avasam commented Feb 16, 2026

Follow-up to #2667 + #2400 + #2669

  • Removes all runtime pointer function dynamic loading for functions that should exist on all supported Windows versions.
  • This also fixes C types issues that could lead to bugs, as the functions can now be checked statically at compile time.
  • Explicitly account for Windows 8.1 in some comments
  • Confirmed this builds locally on Windows 8.1.9200, Python 3.10.11, Windows SDK 10.0.18362 (oldest available on VS 17.6, which itself is the newest VS2022 that can be installed on Windows 8.1)

These were found by searching for CHECK_\w+?P(TR|FN), #define CHECK_, pfn\w+?\s?=\sNULL, this version of Windows, on this platform, available on, GetProcAddress(

@Avasam Avasam force-pushed the stop-dynamically-loading-old-functions branch from 58b2278 to 9b8a083 Compare February 16, 2026 20:09
@Avasam Avasam force-pushed the stop-dynamically-loading-old-functions branch 2 times, most recently from 396a1e3 to 15bb312 Compare February 17, 2026 01:33
("CRYPT_DECRYPT_MESSAGE_PARA_HAS_EXTRA_FIELDS", None),
# Minimum Windows version supported (Windows 7)
# https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt
# Technically official Python 3.9 builds require at least Windows 8.1, but we had no reason to bump this
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everywhere online, including official docs, it's mentioned that Python 3.9 dropped Windows 7, but I guess they just jumped over 8.0

Image

@Avasam Avasam force-pushed the stop-dynamically-loading-old-functions branch from 15bb312 to cf2e344 Compare February 17, 2026 04:24
@raedrizqie

This comment was marked as resolved.

// This totally sucks - a single .cpp file can't #include both winhttp.h
// and wininet.h! SWIG doesn't allow multiple .i files to build a single
// module! Which leaves us with C++.
// and wininet.h on Windows 8.1! (ok on 10 and 11?) SWIG doesn't allow
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whilst working on this, Both the CI (Windows 10 and 11), and my local Windows 10 machine worked with both includes (likely the type definitions are now the same), but failed in a Windows 8.1 VM.


// @pymethod |PyConsoleScreenBuffer|SetConsoleFont|Changes the font used by the screen buffer
// @comm Function is not documented on MSDN
// @comm Function is not documented on MSDN and removed in Windows 10.0.1607
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SetConsoleFont is not available at all in the Win 10 SDK. So we can't do this check at build time.
Since it's undocumented, the only reference I could find to this being removed specifically in Build 1607 comes Wine: https://list.winehq.org/archives/list/wine-devel@list.winehq.org/thread/IJ23HD6IDQDEA3ZX2UPZ6B6W4DN2AD3F/#UT22YE2HDV367XMCIDS72X2P2CPCKXF5

@Avasam Avasam marked this pull request as ready for review February 22, 2026 19:18
@Avasam Avasam requested a review from mhammond February 22, 2026 19:19
@@ -27,24 +27,11 @@ PyObject *PyLoadPerfCounterTextStrings(PyObject *self, PyObject *args)
{
BOOL bQuiet = 1;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the bQuiet param in PyLoadPerfCounterTextStrings and PyUnloadPerfCounterTextStrings completely unused ?

@Avasam Avasam force-pushed the stop-dynamically-loading-old-functions branch 2 times, most recently from 2ed117a to 079ee80 Compare February 22, 2026 22:40
@Avasam Avasam force-pushed the stop-dynamically-loading-old-functions branch from 079ee80 to ab4f801 Compare February 22, 2026 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants