ReactOS 0.4.16-dev-197-g92996da
image.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS user32.dll and win32k.sys
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: RtlGetExpWinVer function
5 * COPYRIGHT: Copyright 2019 James Tabor <james.tabor@reactos.org>
6 * Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
7 */
8
9#ifdef _WIN32K_
10#include <win32k.h>
11DBG_DEFAULT_CHANNEL(UserMisc);
12#else
13#include <user32.h>
14#include <wine/debug.h>
16#endif
17
18/* Get the expected OS version from the application module */
21{
22 ULONG dwMajorVersion = 3, dwMinorVersion = 10; /* Set default to Windows 3.10 (WINVER_WIN31) */
23 PIMAGE_NT_HEADERS pNTHeader;
24 ULONG_PTR AlignedAddress = (ULONG_PTR)BaseAddress;
25
26 TRACE("(%p)\n", BaseAddress);
27
28 /* Remove the magic flag for non-mapped images */
29 if (AlignedAddress & 1)
30 AlignedAddress = (AlignedAddress & ~1);
31
32 if (AlignedAddress && !LOWORD(AlignedAddress))
33 {
34 pNTHeader = RtlImageNtHeader((PVOID)AlignedAddress);
35 if (pNTHeader)
36 {
37 dwMajorVersion = pNTHeader->OptionalHeader.MajorSubsystemVersion;
38 if (dwMajorVersion == 1)
39 dwMajorVersion = 3;
40 else
41 dwMinorVersion = pNTHeader->OptionalHeader.MinorSubsystemVersion;
42 }
43 }
44
45 return MAKEWORD(dwMinorVersion, dwMajorVersion);
46}
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define DBG_DEFAULT_CHANNEL(ch)
Definition: debug.h:106
#define RtlImageNtHeader
Definition: compat.h:806
#define ULONG_PTR
Definition: config.h:101
#define _In_
Definition: ms_sal.h:308
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
#define LOWORD(l)
Definition: pedump.c:82
#define TRACE(s)
Definition: solgame.cpp:4
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
#define MAKEWORD(a, b)
Definition: typedefs.h:248
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
ULONG RtlGetExpWinVer(_In_ PVOID BaseAddress)
Definition: image.c:20