| 1 | /* $Id: version.cpp,v 1.9 2002-07-05 14:48:06 sandervl Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * Win32 compatibility file functions for OS/2
|
|---|
| 5 | *
|
|---|
| 6 | * Copyright 1998-2000 Sander van Leeuwen
|
|---|
| 7 | * Copyright 1998 Patrick Haller
|
|---|
| 8 | *
|
|---|
| 9 | * Based on Wine code: (misc\version.c)
|
|---|
| 10 | * Copyright 1997 Alexandre Julliard
|
|---|
| 11 | * Copyright 1997 Marcus Meissner
|
|---|
| 12 | * Copyright 1998 Patrik Stridvall
|
|---|
| 13 | * Copyright 1998 Andreas Mohr
|
|---|
| 14 | *
|
|---|
| 15 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 16 | *
|
|---|
| 17 | */
|
|---|
| 18 |
|
|---|
| 19 | #include <odin.h>
|
|---|
| 20 | #include <odinwrap.h>
|
|---|
| 21 | #include <os2sel.h>
|
|---|
| 22 |
|
|---|
| 23 | #include <os2win.h>
|
|---|
| 24 | #include <winnt.h>
|
|---|
| 25 | #include <winnls.h>
|
|---|
| 26 | #include <stdlib.h>
|
|---|
| 27 | #include <string.h>
|
|---|
| 28 | #include <ctype.h>
|
|---|
| 29 | #include <heapstring.h>
|
|---|
| 30 |
|
|---|
| 31 | #include <misc.h>
|
|---|
| 32 | #include "heap.h"
|
|---|
| 33 | #include <handlemanager.h>
|
|---|
| 34 | #include "wprocess.h"
|
|---|
| 35 | #include "oslibdos.h"
|
|---|
| 36 | #include <versionos2.h>
|
|---|
| 37 | #include "profile.h"
|
|---|
| 38 |
|
|---|
| 39 | #define DBG_LOCALLOG DBG_version
|
|---|
| 40 | #include "dbglocal.h"
|
|---|
| 41 | #include "debugtools.h"
|
|---|
| 42 |
|
|---|
| 43 | typedef struct
|
|---|
| 44 | {
|
|---|
| 45 | LONG getVersion16;
|
|---|
| 46 | LONG getVersion;
|
|---|
| 47 | OSVERSIONINFOEXA getVersionEx;
|
|---|
| 48 | } VERSION_DATA;
|
|---|
| 49 |
|
|---|
| 50 | static VERSION_DATA VersionData[WINVERSION_MAX] =
|
|---|
| 51 | {
|
|---|
| 52 | // Windows 98
|
|---|
| 53 | {
|
|---|
| 54 | 0x070A5F03,
|
|---|
| 55 | 0xC0000A04,
|
|---|
| 56 | {
|
|---|
| 57 | sizeof(OSVERSIONINFOA), 4, 10, 0x40A07CE,
|
|---|
| 58 | VER_PLATFORM_WIN32_WINDOWS, "Win98",
|
|---|
| 59 | 0, 0, 0, 0
|
|---|
| 60 | }
|
|---|
| 61 | },
|
|---|
| 62 | // Windows ME
|
|---|
| 63 | {
|
|---|
| 64 | 0x07005F03, /* Assuming DOS 7 like the other Win9x */
|
|---|
| 65 | 0xC0005A04,
|
|---|
| 66 | {
|
|---|
| 67 | sizeof(OSVERSIONINFOA), 4, 90, 0x45A0BB8,
|
|---|
| 68 | VER_PLATFORM_WIN32_WINDOWS, " ",
|
|---|
| 69 | 0, 0, 0, 0
|
|---|
| 70 | }
|
|---|
| 71 | },
|
|---|
| 72 | // Windows NT 4.0 (SP6)
|
|---|
| 73 | {
|
|---|
| 74 | 0x05000A03,
|
|---|
| 75 | ODINNT_VERSION,
|
|---|
| 76 | {
|
|---|
| 77 | sizeof(OSVERSIONINFOA), ODINNT_MAJOR_VERSION, ODINNT_MINOR_VERSION,
|
|---|
| 78 | ODINNT_BUILD_NR, VER_PLATFORM_WIN32_NT, ODINNT_CSDVERSION,
|
|---|
| 79 | 6, 0, 0, 0
|
|---|
| 80 | }
|
|---|
| 81 | },
|
|---|
| 82 | // Windows 2000 (SP2)
|
|---|
| 83 | {
|
|---|
| 84 | 0x05005F03,
|
|---|
| 85 | 0x08930005,
|
|---|
| 86 | {
|
|---|
| 87 | sizeof(OSVERSIONINFOA), 5, 0, 0x893,
|
|---|
| 88 | VER_PLATFORM_WIN32_NT, "Service Pack 2",
|
|---|
| 89 | 2, 0, 0, 0
|
|---|
| 90 | }
|
|---|
| 91 | },
|
|---|
| 92 | // Windows XP
|
|---|
| 93 | {
|
|---|
| 94 | 0x05005F03, /* Assuming DOS 5 like the other NT */
|
|---|
| 95 | 0x0A280105,
|
|---|
| 96 | {
|
|---|
| 97 | sizeof(OSVERSIONINFOA), 5, 1, 0xA28,
|
|---|
| 98 | VER_PLATFORM_WIN32_NT, "",
|
|---|
| 99 | 0, 0, 0, 0
|
|---|
| 100 | }
|
|---|
| 101 | },
|
|---|
| 102 | // Windows XP SP3
|
|---|
| 103 | {
|
|---|
| 104 | 0x05005F03, /* Assuming DOS 5 like the other NT */
|
|---|
| 105 | 0x0A280105,
|
|---|
| 106 | {
|
|---|
| 107 | sizeof(OSVERSIONINFOA), 5, 1, 0xA28,
|
|---|
| 108 | VER_PLATFORM_WIN32_NT, "Service Pack 3",
|
|---|
| 109 | +3, 0, 0, 0
|
|---|
| 110 | }
|
|---|
| 111 | }
|
|---|
| 112 | };
|
|---|
| 113 |
|
|---|
| 114 | static BOOL fCheckVersion = FALSE;
|
|---|
| 115 | static int winversion = WINVERSION_WINXPSP3;
|
|---|
| 116 |
|
|---|
| 117 | //******************************************************************************
|
|---|
| 118 | //******************************************************************************
|
|---|
| 119 | void WIN32API OdinSetVersion(ULONG version)
|
|---|
| 120 | {
|
|---|
| 121 | switch(version) {
|
|---|
| 122 | case WINVERSION_WIN98:
|
|---|
| 123 | case WINVERSION_WINME:
|
|---|
| 124 | case WINVERSION_NT40:
|
|---|
| 125 | case WINVERSION_WIN2000:
|
|---|
| 126 | case WINVERSION_WINXP:
|
|---|
| 127 | case WINVERSION_WINXPSP3:
|
|---|
| 128 | break;
|
|---|
| 129 | default:
|
|---|
| 130 | DebugInt3();
|
|---|
| 131 | return;
|
|---|
| 132 | }
|
|---|
| 133 | winversion = version;
|
|---|
| 134 | }
|
|---|
| 135 | //******************************************************************************
|
|---|
| 136 | //******************************************************************************
|
|---|
| 137 | void CheckVersion()
|
|---|
| 138 | {
|
|---|
| 139 | char szVersion[16];
|
|---|
| 140 |
|
|---|
| 141 | if(PROFILE_GetOdinIniString(PROFILE_WINVERSION_SECTION, PROFILE_WINVERSION_KEY,
|
|---|
| 142 | "", szVersion, sizeof(szVersion)-1) > 1)
|
|---|
| 143 | {
|
|---|
| 144 | if(!stricmp(szVersion, PROFILE_WINVERSION_WIN98)) {
|
|---|
| 145 | winversion = WINVERSION_WIN98;
|
|---|
| 146 | }
|
|---|
| 147 | else
|
|---|
| 148 | if(!stricmp(szVersion, PROFILE_WINVERSION_WINME)) {
|
|---|
| 149 | winversion = WINVERSION_WINME;
|
|---|
| 150 | }
|
|---|
| 151 | else
|
|---|
| 152 | if(!stricmp(szVersion, PROFILE_WINVERSION_NT40)) {
|
|---|
| 153 | winversion = WINVERSION_NT40;
|
|---|
| 154 | }
|
|---|
| 155 | else
|
|---|
| 156 | if(!stricmp(szVersion, PROFILE_WINVERSION_WIN2000)) {
|
|---|
| 157 | winversion = WINVERSION_WIN2000;
|
|---|
| 158 | }
|
|---|
| 159 | else
|
|---|
| 160 | if(!stricmp(szVersion, PROFILE_WINVERSION_WINXP)) {
|
|---|
| 161 | winversion = WINVERSION_WINXP;
|
|---|
| 162 | }
|
|---|
| 163 | else
|
|---|
| 164 | if(!stricmp(szVersion, PROFILE_WINVERSION_WINXPSP3)) {
|
|---|
| 165 | winversion = WINVERSION_WINXPSP3;
|
|---|
| 166 | }
|
|---|
| 167 | }
|
|---|
| 168 | fCheckVersion = TRUE;
|
|---|
| 169 | }
|
|---|
| 170 | //******************************************************************************
|
|---|
| 171 | //******************************************************************************
|
|---|
| 172 | BOOL WIN32API GetVersionExA(OSVERSIONINFOA *lpVersionInformation)
|
|---|
| 173 | {
|
|---|
| 174 | dprintf(("KERNEL32: GetVersionExA %x", lpVersionInformation));
|
|---|
| 175 |
|
|---|
| 176 | if(lpVersionInformation == NULL)
|
|---|
| 177 | {
|
|---|
| 178 | dprintf(("ERROR: invalid parameter"));
|
|---|
| 179 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 180 | return(FALSE);
|
|---|
| 181 | }
|
|---|
| 182 | if(lpVersionInformation->dwOSVersionInfoSize < sizeof(OSVERSIONINFOA))
|
|---|
| 183 | {
|
|---|
| 184 | dprintf(("ERROR: buffer too small (%d != %d)", lpVersionInformation->dwOSVersionInfoSize, sizeof(OSVERSIONINFOA)));
|
|---|
| 185 | SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|---|
| 186 | return(FALSE);
|
|---|
| 187 | }
|
|---|
| 188 |
|
|---|
| 189 | if(fCheckVersion == FALSE) {
|
|---|
| 190 | CheckVersion();
|
|---|
| 191 | }
|
|---|
| 192 | lpVersionInformation->dwMajorVersion = VersionData[winversion].getVersionEx.dwMajorVersion;
|
|---|
| 193 | lpVersionInformation->dwMinorVersion = VersionData[winversion].getVersionEx.dwMinorVersion;
|
|---|
| 194 | lpVersionInformation->dwBuildNumber = VersionData[winversion].getVersionEx.dwBuildNumber;
|
|---|
| 195 | lpVersionInformation->dwPlatformId = VersionData[winversion].getVersionEx.dwPlatformId;
|
|---|
| 196 | strcpy(lpVersionInformation->szCSDVersion, VersionData[winversion].getVersionEx.szCSDVersion );
|
|---|
| 197 |
|
|---|
| 198 | dprintf(("version %x.%x", lpVersionInformation->dwMajorVersion, lpVersionInformation->dwMinorVersion));
|
|---|
| 199 | dprintf(("build nr %x", lpVersionInformation->dwBuildNumber));
|
|---|
| 200 | dprintf(("Platform Id %x", lpVersionInformation->dwPlatformId));
|
|---|
| 201 | dprintf(("szCSDVersion %s", lpVersionInformation->szCSDVersion));
|
|---|
| 202 |
|
|---|
| 203 | if(lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXA))
|
|---|
| 204 | {//Windows 2000 (and up) extension
|
|---|
| 205 | LPOSVERSIONINFOEXA lpVersionExInformation = (LPOSVERSIONINFOEXA)lpVersionInformation;
|
|---|
| 206 |
|
|---|
| 207 | lpVersionExInformation->wServicePackMajor = VersionData[winversion].getVersionEx.wServicePackMajor;
|
|---|
| 208 | lpVersionExInformation->wServicePackMinor = VersionData[winversion].getVersionEx.wServicePackMinor;
|
|---|
| 209 | /*
|
|---|
| 210 | lpVersionExInformation->wReserved[0] = VersionData[winversion].getVersionEx.wReserved[0];
|
|---|
| 211 | lpVersionExInformation->wReserved[1] = VersionData[winversion].getVersionEx.wReserved[1];
|
|---|
| 212 | */
|
|---|
| 213 | ///-------------------------------------------------------------------[swt-os2]
|
|---|
| 214 | lpVersionExInformation->wSuiteMask = VersionData[winversion].getVersionEx.wSuiteMask;
|
|---|
| 215 | lpVersionExInformation->wProductType = VersionData[winversion].getVersionEx.wProductType;
|
|---|
| 216 | lpVersionExInformation->wReserved = VersionData[winversion].getVersionEx.wReserved;
|
|---|
| 217 | ///----------------------------------------------------------------------------
|
|---|
| 218 |
|
|---|
| 219 | dprintf(("service pack version %x.%x", lpVersionExInformation->wServicePackMajor, lpVersionExInformation->wServicePackMinor));
|
|---|
| 220 | }
|
|---|
| 221 |
|
|---|
| 222 | SetLastError(ERROR_SUCCESS);
|
|---|
| 223 | return(TRUE);
|
|---|
| 224 | }
|
|---|
| 225 | //******************************************************************************
|
|---|
| 226 | //******************************************************************************
|
|---|
| 227 | BOOL WIN32API GetVersionExW(OSVERSIONINFOW *lpVersionInformation)
|
|---|
| 228 | {
|
|---|
| 229 | dprintf(("KERNEL32: GetVersionExW %x", lpVersionInformation));
|
|---|
| 230 |
|
|---|
| 231 | if(lpVersionInformation == NULL)
|
|---|
| 232 | {
|
|---|
| 233 | dprintf(("ERROR: invalid parameter"));
|
|---|
| 234 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 235 | return(FALSE);
|
|---|
| 236 | }
|
|---|
| 237 | if(lpVersionInformation->dwOSVersionInfoSize < sizeof(OSVERSIONINFOW))
|
|---|
| 238 | {
|
|---|
| 239 | dprintf(("ERROR: buffer too small"));
|
|---|
| 240 | SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|---|
| 241 | return(FALSE);
|
|---|
| 242 | }
|
|---|
| 243 |
|
|---|
| 244 | if(fCheckVersion == FALSE) {
|
|---|
| 245 | CheckVersion();
|
|---|
| 246 | }
|
|---|
| 247 | lpVersionInformation->dwMajorVersion = VersionData[winversion].getVersionEx.dwMajorVersion;
|
|---|
| 248 | lpVersionInformation->dwMinorVersion = VersionData[winversion].getVersionEx.dwMinorVersion;
|
|---|
| 249 | lpVersionInformation->dwBuildNumber = VersionData[winversion].getVersionEx.dwBuildNumber;
|
|---|
| 250 | lpVersionInformation->dwPlatformId = VersionData[winversion].getVersionEx.dwPlatformId;
|
|---|
| 251 | lstrcpyAtoW(lpVersionInformation->szCSDVersion, VersionData[winversion].getVersionEx.szCSDVersion);
|
|---|
| 252 |
|
|---|
| 253 | if(lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXW))
|
|---|
| 254 | {//Windows 2000 (and up) extension
|
|---|
| 255 | LPOSVERSIONINFOEXW lpVersionExInformation = (LPOSVERSIONINFOEXW)lpVersionInformation;
|
|---|
| 256 |
|
|---|
| 257 | lpVersionExInformation->wServicePackMajor = VersionData[winversion].getVersionEx.wServicePackMajor;
|
|---|
| 258 | lpVersionExInformation->wServicePackMinor = VersionData[winversion].getVersionEx.wServicePackMinor;
|
|---|
| 259 | /*
|
|---|
| 260 | lpVersionExInformation->wReserved[0] = VersionData[winversion].getVersionEx.wReserved[0];
|
|---|
| 261 | lpVersionExInformation->wReserved[1] = VersionData[winversion].getVersionEx.wReserved[1];
|
|---|
| 262 | */
|
|---|
| 263 | ///-------------------------------------------------------------------[swt-os2]
|
|---|
| 264 | lpVersionExInformation->wSuiteMask = VersionData[winversion].getVersionEx.wSuiteMask;
|
|---|
| 265 | lpVersionExInformation->wProductType = VersionData[winversion].getVersionEx.wProductType;
|
|---|
| 266 | lpVersionExInformation->wReserved = VersionData[winversion].getVersionEx.wReserved;
|
|---|
| 267 | ///----------------------------------------------------------------------------
|
|---|
| 268 | }
|
|---|
| 269 | SetLastError(ERROR_SUCCESS);
|
|---|
| 270 | return(TRUE);
|
|---|
| 271 | }
|
|---|
| 272 | //******************************************************************************
|
|---|
| 273 | //******************************************************************************
|
|---|
| 274 | LONG WIN32API GetVersion()
|
|---|
| 275 | {
|
|---|
| 276 | dprintf(("KERNEL32: GetVersion"));
|
|---|
| 277 | if(fCheckVersion == FALSE) {
|
|---|
| 278 | CheckVersion();
|
|---|
| 279 | }
|
|---|
| 280 | return VersionData[winversion].getVersion;
|
|---|
| 281 | }
|
|---|
| 282 | //******************************************************************************
|
|---|
| 283 | //******************************************************************************
|
|---|
| 284 | /******************************************************************************
|
|---|
| 285 | * VerifyVersionInfoW (KERNEL32.@)
|
|---|
| 286 | */
|
|---|
| 287 | BOOL WINAPI VerifyVersionInfoW( /* LPOSVERSIONINFOEXW */ LPVOID lpVersionInfo, DWORD dwTypeMask,
|
|---|
| 288 | DWORDLONG dwlConditionMask)
|
|---|
| 289 | {
|
|---|
| 290 | FIXME("%p %lu %llx\n", lpVersionInfo, dwTypeMask, dwlConditionMask);
|
|---|
| 291 | return TRUE;
|
|---|
| 292 | }
|
|---|
| 293 |
|
|---|