Skip to content

Insonsitencies with usage of _WIN32_WINNT #24367

Open
@edo9300

Description

@edo9300

Openssl has some logic in e_os.h to define the macro _WIN32_WINNT if not set by externally by the compiler, and then takes care of including windows.h.

# if !defined(_WIN32_WCE) && !defined(_WIN32_WINNT)
/*
* Defining _WIN32_WINNT here in e_os.h implies certain "discipline."
* Most notably we ought to check for availability of each specific
* routine that was introduced after denoted _WIN32_WINNT with
* GetProcAddress(). Normally newer functions are masked with higher
* _WIN32_WINNT in SDK headers. So that if you wish to use them in
* some module, you'd need to override _WIN32_WINNT definition in
* the target module in order to "reach for" prototypes, but replace
* calls to new functions with indirect calls. Alternatively it
* might be possible to achieve the goal by /DELAYLOAD-ing .DLLs
* and check for current OS version instead.
*/
# define _WIN32_WINNT 0x0501
# endif
# if defined(_WIN32_WINNT) || defined(_WIN32_WCE)

Supposedly this file should be the only one to be used internally by openssl to include windows headers, but in various places windows.h is included directly on top of the file, for example
#if defined(_WIN32)
# include <windows.h>
# if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600
# define USE_RWLOCK
# endif
#endif

In other cases, depending on other internal headers included beforehand, either windows.h is manually included first, or it's included through e_os.h due to chain dependencies, in this case e_os.h is included by time-h
# include <openssl/configuration.h>
# include <openssl/e_os2.h>
# include "internal/time.h"
# if defined(_WIN32)
# include <windows.h>
# endif

These inconsistencies could lead to some files being possibly built with _WIN32_WINNT defined as 0x501 (if e_os is inclded first and it's not changed externally), while others being built with whatever the current sdk sets as default.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions