[22030] | 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;
|
---|
[22031] | 115 | static int winversion = WINVERSION_WINXPSP3;
|
---|
[22030] | 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 | lpVersionExInformation->wReserved[0] = VersionData[winversion].getVersionEx.wReserved[0];
|
---|
| 210 | lpVersionExInformation->wReserved[1] = VersionData[winversion].getVersionEx.wReserved[1];
|
---|
| 211 |
|
---|
| 212 | dprintf(("service pack version %x.%x", lpVersionExInformation->wServicePackMajor, lpVersionExInformation->wServicePackMinor));
|
---|
| 213 | }
|
---|
| 214 |
|
---|
| 215 | SetLastError(ERROR_SUCCESS);
|
---|
| 216 | return(TRUE);
|
---|
| 217 | }
|
---|
| 218 | //******************************************************************************
|
---|
| 219 | //******************************************************************************
|
---|
| 220 | BOOL WIN32API GetVersionExW(OSVERSIONINFOW *lpVersionInformation)
|
---|
| 221 | {
|
---|
| 222 | dprintf(("KERNEL32: GetVersionExW %x", lpVersionInformation));
|
---|
| 223 |
|
---|
| 224 | if(lpVersionInformation == NULL)
|
---|
| 225 | {
|
---|
| 226 | dprintf(("ERROR: invalid parameter"));
|
---|
| 227 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
| 228 | return(FALSE);
|
---|
| 229 | }
|
---|
| 230 | if(lpVersionInformation->dwOSVersionInfoSize < sizeof(OSVERSIONINFOW))
|
---|
| 231 | {
|
---|
| 232 | dprintf(("ERROR: buffer too small"));
|
---|
| 233 | SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
---|
| 234 | return(FALSE);
|
---|
| 235 | }
|
---|
| 236 |
|
---|
| 237 | if(fCheckVersion == FALSE) {
|
---|
| 238 | CheckVersion();
|
---|
| 239 | }
|
---|
| 240 | lpVersionInformation->dwMajorVersion = VersionData[winversion].getVersionEx.dwMajorVersion;
|
---|
| 241 | lpVersionInformation->dwMinorVersion = VersionData[winversion].getVersionEx.dwMinorVersion;
|
---|
| 242 | lpVersionInformation->dwBuildNumber = VersionData[winversion].getVersionEx.dwBuildNumber;
|
---|
| 243 | lpVersionInformation->dwPlatformId = VersionData[winversion].getVersionEx.dwPlatformId;
|
---|
| 244 | lstrcpyAtoW(lpVersionInformation->szCSDVersion, VersionData[winversion].getVersionEx.szCSDVersion);
|
---|
| 245 |
|
---|
| 246 | if(lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXW))
|
---|
| 247 | {//Windows 2000 (and up) extension
|
---|
| 248 | LPOSVERSIONINFOEXW lpVersionExInformation = (LPOSVERSIONINFOEXW)lpVersionInformation;
|
---|
| 249 |
|
---|
| 250 | lpVersionExInformation->wServicePackMajor = VersionData[winversion].getVersionEx.wServicePackMajor;
|
---|
| 251 | lpVersionExInformation->wServicePackMinor = VersionData[winversion].getVersionEx.wServicePackMinor;
|
---|
| 252 | lpVersionExInformation->wReserved[0] = VersionData[winversion].getVersionEx.wReserved[0];
|
---|
| 253 | lpVersionExInformation->wReserved[1] = VersionData[winversion].getVersionEx.wReserved[1];
|
---|
| 254 | }
|
---|
| 255 | SetLastError(ERROR_SUCCESS);
|
---|
| 256 | return(TRUE);
|
---|
| 257 | }
|
---|
| 258 | //******************************************************************************
|
---|
| 259 | //******************************************************************************
|
---|
| 260 | LONG WIN32API GetVersion()
|
---|
| 261 | {
|
---|
| 262 | dprintf(("KERNEL32: GetVersion"));
|
---|
| 263 | if(fCheckVersion == FALSE) {
|
---|
| 264 | CheckVersion();
|
---|
| 265 | }
|
---|
| 266 | return VersionData[winversion].getVersion;
|
---|
| 267 | }
|
---|
| 268 | //******************************************************************************
|
---|
| 269 | //******************************************************************************
|
---|
| 270 | /******************************************************************************
|
---|
| 271 | * VerifyVersionInfoW (KERNEL32.@)
|
---|
| 272 | */
|
---|
| 273 | BOOL WINAPI VerifyVersionInfoW( /* LPOSVERSIONINFOEXW */ LPVOID lpVersionInfo, DWORD dwTypeMask,
|
---|
| 274 | DWORDLONG dwlConditionMask)
|
---|
| 275 | {
|
---|
| 276 | FIXME("%p %lu %llx\n", lpVersionInfo, dwTypeMask, dwlConditionMask);
|
---|
| 277 | return TRUE;
|
---|
| 278 | }
|
---|
| 279 |
|
---|