mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
3396c97da9
Now that the new CMake build system is encouraging us to lay out the code like a set of libraries, it seems like a good idea to make them look more _like_ libraries, by putting things into separate modules as far as possible. This fixes several previous annoyances in which you had to link against some object in order to get a function you needed, but that object also contained other functions you didn't need which included link-time symbol references you didn't want to have to deal with. The usual offender was subsidiary supporting programs including misc.c for some innocuous function and then finding they had to deal with the requirements of buildinfo(). This big reorganisation introduces three new subdirectories called 'utils', one at the top level and one in each platform subdir. In each case, the directory contains basically the same files that were previously placed in the 'utils' build-time library, except that the ones that were extremely miscellaneous (misc.c, utils.c, uxmisc.c, winmisc.c, winmiscs.c, winutils.c) have been split up into much smaller pieces.
41 lines
1.6 KiB
C
41 lines
1.6 KiB
C
#include "putty.h"
|
|
|
|
DWORD osMajorVersion, osMinorVersion, osPlatformId;
|
|
|
|
void init_winver(void)
|
|
{
|
|
OSVERSIONINFO osVersion;
|
|
static HMODULE kernel32_module;
|
|
DECL_WINDOWS_FUNCTION(static, BOOL, GetVersionExA, (LPOSVERSIONINFO));
|
|
|
|
if (!kernel32_module) {
|
|
kernel32_module = load_system32_dll("kernel32.dll");
|
|
/* Deliberately don't type-check this function, because that
|
|
* would involve using its declaration in a header file which
|
|
* triggers a deprecation warning. I know it's deprecated (see
|
|
* below) and don't need telling. */
|
|
GET_WINDOWS_FUNCTION_NO_TYPECHECK(kernel32_module, GetVersionExA);
|
|
}
|
|
|
|
ZeroMemory(&osVersion, sizeof(osVersion));
|
|
osVersion.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
|
|
if (p_GetVersionExA && p_GetVersionExA(&osVersion)) {
|
|
osMajorVersion = osVersion.dwMajorVersion;
|
|
osMinorVersion = osVersion.dwMinorVersion;
|
|
osPlatformId = osVersion.dwPlatformId;
|
|
} else {
|
|
/*
|
|
* GetVersionEx is deprecated, so allow for it perhaps going
|
|
* away in future API versions. If it's not there, simply
|
|
* assume that's because Windows is too _new_, so fill in the
|
|
* variables we care about to a value that will always compare
|
|
* higher than any given test threshold.
|
|
*
|
|
* Normally we should be checking against the presence of a
|
|
* specific function if possible in any case.
|
|
*/
|
|
osMajorVersion = osMinorVersion = UINT_MAX; /* a very high number */
|
|
osPlatformId = VER_PLATFORM_WIN32_NT; /* not Win32s or Win95-like */
|
|
}
|
|
}
|