| 1 | /* $Id: version.cpp,v 1.7 2001-12-08 16:17:34 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 |
|
|---|
| 42 | typedef struct
|
|---|
| 43 | {
|
|---|
| 44 | LONG getVersion16;
|
|---|
| 45 | LONG getVersion;
|
|---|
| 46 | OSVERSIONINFOEXA getVersionEx;
|
|---|
| 47 | } VERSION_DATA;
|
|---|
| 48 |
|
|---|
| 49 | static VERSION_DATA VersionData[WINVERSION_MAX] =
|
|---|
| 50 | {
|
|---|
| 51 | // Windows 98
|
|---|
| 52 | {
|
|---|
| 53 | 0x070A5F03,
|
|---|
| 54 | 0xC0000A04,
|
|---|
| 55 | {
|
|---|
| 56 | sizeof(OSVERSIONINFOA), 4, 10, 0x40A07CE,
|
|---|
| 57 | VER_PLATFORM_WIN32_WINDOWS, "Win98",
|
|---|
| 58 | 0, 0, 0, 0
|
|---|
| 59 | }
|
|---|
| 60 | },
|
|---|
| 61 | // Windows ME
|
|---|
| 62 | {
|
|---|
| 63 | 0x07005F03, /* Assuming DOS 7 like the other Win9x */
|
|---|
| 64 | 0xC0005A04,
|
|---|
| 65 | {
|
|---|
| 66 | sizeof(OSVERSIONINFOA), 4, 90, 0x45A0BB8,
|
|---|
| 67 | VER_PLATFORM_WIN32_WINDOWS, " ",
|
|---|
| 68 | 0, 0, 0, 0
|
|---|
| 69 | }
|
|---|
| 70 | },
|
|---|
| 71 | // Windows NT 4.0 (SP6)
|
|---|
| 72 | {
|
|---|
| 73 | 0x05000A03,
|
|---|
| 74 | ODINNT_VERSION,
|
|---|
| 75 | {
|
|---|
| 76 | sizeof(OSVERSIONINFOA), ODINNT_MAJOR_VERSION, ODINNT_MINOR_VERSION,
|
|---|
| 77 | ODINNT_BUILD_NR, VER_PLATFORM_WIN32_NT, ODINNT_CSDVERSION,
|
|---|
| 78 | 6, 0, 0, 0
|
|---|
| 79 | }
|
|---|
| 80 | },
|
|---|
| 81 | // Windows 2000 (SP2)
|
|---|
| 82 | {
|
|---|
| 83 | 0x05005F03,
|
|---|
| 84 | 0x08930005,
|
|---|
| 85 | {
|
|---|
| 86 | sizeof(OSVERSIONINFOA), 5, 0, 0x893,
|
|---|
| 87 | VER_PLATFORM_WIN32_NT, "Service Pack 2",
|
|---|
| 88 | 2, 0, 0, 0
|
|---|
| 89 | }
|
|---|
| 90 | },
|
|---|
| 91 | // Windows XP
|
|---|
| 92 | {
|
|---|
| 93 | 0x05005F03, /* Assuming DOS 5 like the other NT */
|
|---|
| 94 | 0x0A280105,
|
|---|
| 95 | {
|
|---|
| 96 | sizeof(OSVERSIONINFOA), 5, 1, 0xA28,
|
|---|
| 97 | VER_PLATFORM_WIN32_NT, "",
|
|---|
| 98 | 0, 0, 0, 0
|
|---|
| 99 | }
|
|---|
| 100 | }
|
|---|
| 101 | };
|
|---|
| 102 |
|
|---|
| 103 | static BOOL fCheckVersion = FALSE;
|
|---|
| 104 | static int winversion = WINVERSION_WIN2000;
|
|---|
| 105 |
|
|---|
| 106 | //******************************************************************************
|
|---|
| 107 | //******************************************************************************
|
|---|
| 108 | void WIN32API OdinSetVersion(ULONG version)
|
|---|
| 109 | {
|
|---|
| 110 | switch(version) {
|
|---|
| 111 | case WINVERSION_WIN98:
|
|---|
| 112 | case WINVERSION_WINME:
|
|---|
| 113 | case WINVERSION_NT40:
|
|---|
| 114 | case WINVERSION_WIN2000:
|
|---|
| 115 | case WINVERSION_WINXP:
|
|---|
| 116 | break;
|
|---|
| 117 | default:
|
|---|
| 118 | DebugInt3();
|
|---|
| 119 | return;
|
|---|
| 120 | }
|
|---|
| 121 | winversion = version;
|
|---|
| 122 | }
|
|---|
| 123 | //******************************************************************************
|
|---|
| 124 | //******************************************************************************
|
|---|
| 125 | void CheckVersion()
|
|---|
| 126 | {
|
|---|
| 127 | char szVersion[16];
|
|---|
| 128 |
|
|---|
| 129 | if(PROFILE_GetOdinIniString(PROFILE_WINVERSION_SECTION, PROFILE_WINVERSION_KEY,
|
|---|
| 130 | "", szVersion, sizeof(szVersion)-1) > 1)
|
|---|
| 131 | {
|
|---|
| 132 | if(!stricmp(szVersion, PROFILE_WINVERSION_WIN98)) {
|
|---|
| 133 | winversion = WINVERSION_WIN98;
|
|---|
| 134 | }
|
|---|
| 135 | else
|
|---|
| 136 | if(!stricmp(szVersion, PROFILE_WINVERSION_WINME)) {
|
|---|
| 137 | winversion = WINVERSION_WINME;
|
|---|
| 138 | }
|
|---|
| 139 | else
|
|---|
| 140 | if(!stricmp(szVersion, PROFILE_WINVERSION_NT40)) {
|
|---|
| 141 | winversion = WINVERSION_NT40;
|
|---|
| 142 | }
|
|---|
| 143 | else
|
|---|
| 144 | if(!stricmp(szVersion, PROFILE_WINVERSION_WIN2000)) {
|
|---|
| 145 | winversion = WINVERSION_WIN2000;
|
|---|
| 146 | }
|
|---|
| 147 | else
|
|---|
| 148 | if(!stricmp(szVersion, PROFILE_WINVERSION_WINXP)) {
|
|---|
| 149 | winversion = WINVERSION_WINXP;
|
|---|
| 150 | }
|
|---|
| 151 | }
|
|---|
| 152 | fCheckVersion = TRUE;
|
|---|
| 153 | }
|
|---|
| 154 | //******************************************************************************
|
|---|
| 155 | //******************************************************************************
|
|---|
| 156 | BOOL WIN32API GetVersionExA(OSVERSIONINFOA *lpVersionInformation)
|
|---|
| 157 | {
|
|---|
| 158 | dprintf(("KERNEL32: GetVersionExA %x", lpVersionInformation));
|
|---|
| 159 |
|
|---|
| 160 | if(lpVersionInformation == NULL)
|
|---|
| 161 | {
|
|---|
| 162 | dprintf(("ERROR: invalid parameter"));
|
|---|
| 163 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 164 | return(FALSE);
|
|---|
| 165 | }
|
|---|
| 166 | if(lpVersionInformation->dwOSVersionInfoSize < sizeof(OSVERSIONINFOA))
|
|---|
| 167 | {
|
|---|
| 168 | dprintf(("ERROR: buffer too small (%d != %d)", lpVersionInformation->dwOSVersionInfoSize, sizeof(OSVERSIONINFOA)));
|
|---|
| 169 | SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|---|
| 170 | return(FALSE);
|
|---|
| 171 | }
|
|---|
| 172 |
|
|---|
| 173 | if(fCheckVersion == FALSE) {
|
|---|
| 174 | CheckVersion();
|
|---|
| 175 | }
|
|---|
| 176 | lpVersionInformation->dwMajorVersion = VersionData[winversion].getVersionEx.dwMajorVersion;
|
|---|
| 177 | lpVersionInformation->dwMinorVersion = VersionData[winversion].getVersionEx.dwMinorVersion;
|
|---|
| 178 | lpVersionInformation->dwBuildNumber = VersionData[winversion].getVersionEx.dwBuildNumber;
|
|---|
| 179 | lpVersionInformation->dwPlatformId = VersionData[winversion].getVersionEx.dwPlatformId;
|
|---|
| 180 | strcpy(lpVersionInformation->szCSDVersion, VersionData[winversion].getVersionEx.szCSDVersion );
|
|---|
| 181 |
|
|---|
| 182 | if(lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXA))
|
|---|
| 183 | {//Windows 2000 (and up) extension
|
|---|
| 184 | LPOSVERSIONINFOEXA lpVersionExInformation = (LPOSVERSIONINFOEXA)lpVersionInformation;
|
|---|
| 185 |
|
|---|
| 186 | lpVersionExInformation->wServicePackMajor = VersionData[winversion].getVersionEx.wServicePackMajor;
|
|---|
| 187 | lpVersionExInformation->wServicePackMinor = VersionData[winversion].getVersionEx.wServicePackMinor;
|
|---|
| 188 | lpVersionExInformation->wReserved[0] = VersionData[winversion].getVersionEx.wReserved[0];
|
|---|
| 189 | lpVersionExInformation->wReserved[1] = VersionData[winversion].getVersionEx.wReserved[1];
|
|---|
| 190 | }
|
|---|
| 191 | SetLastError(ERROR_SUCCESS);
|
|---|
| 192 | return(TRUE);
|
|---|
| 193 | }
|
|---|
| 194 | //******************************************************************************
|
|---|
| 195 | //******************************************************************************
|
|---|
| 196 | BOOL WIN32API GetVersionExW(OSVERSIONINFOW *lpVersionInformation)
|
|---|
| 197 | {
|
|---|
| 198 | dprintf(("KERNEL32: GetVersionExW %x", lpVersionInformation));
|
|---|
| 199 |
|
|---|
| 200 | if(lpVersionInformation == NULL)
|
|---|
| 201 | {
|
|---|
| 202 | dprintf(("ERROR: invalid parameter"));
|
|---|
| 203 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 204 | return(FALSE);
|
|---|
| 205 | }
|
|---|
| 206 | if(lpVersionInformation->dwOSVersionInfoSize < sizeof(OSVERSIONINFOW))
|
|---|
| 207 | {
|
|---|
| 208 | dprintf(("ERROR: buffer too small"));
|
|---|
| 209 | SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|---|
| 210 | return(FALSE);
|
|---|
| 211 | }
|
|---|
| 212 |
|
|---|
| 213 | if(fCheckVersion == FALSE) {
|
|---|
| 214 | CheckVersion();
|
|---|
| 215 | }
|
|---|
| 216 | lpVersionInformation->dwMajorVersion = VersionData[winversion].getVersionEx.dwMajorVersion;
|
|---|
| 217 | lpVersionInformation->dwMinorVersion = VersionData[winversion].getVersionEx.dwMinorVersion;
|
|---|
| 218 | lpVersionInformation->dwBuildNumber = VersionData[winversion].getVersionEx.dwBuildNumber;
|
|---|
| 219 | lpVersionInformation->dwPlatformId = VersionData[winversion].getVersionEx.dwPlatformId;
|
|---|
| 220 | lstrcpyAtoW(lpVersionInformation->szCSDVersion, VersionData[winversion].getVersionEx.szCSDVersion);
|
|---|
| 221 |
|
|---|
| 222 | if(lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXW))
|
|---|
| 223 | {//Windows 2000 (and up) extension
|
|---|
| 224 | LPOSVERSIONINFOEXW lpVersionExInformation = (LPOSVERSIONINFOEXW)lpVersionInformation;
|
|---|
| 225 |
|
|---|
| 226 | lpVersionExInformation->wServicePackMajor = VersionData[winversion].getVersionEx.wServicePackMajor;
|
|---|
| 227 | lpVersionExInformation->wServicePackMinor = VersionData[winversion].getVersionEx.wServicePackMinor;
|
|---|
| 228 | lpVersionExInformation->wReserved[0] = VersionData[winversion].getVersionEx.wReserved[0];
|
|---|
| 229 | lpVersionExInformation->wReserved[1] = VersionData[winversion].getVersionEx.wReserved[1];
|
|---|
| 230 | }
|
|---|
| 231 | SetLastError(ERROR_SUCCESS);
|
|---|
| 232 | return(TRUE);
|
|---|
| 233 | }
|
|---|
| 234 | //******************************************************************************
|
|---|
| 235 | //******************************************************************************
|
|---|
| 236 | LONG WIN32API GetVersion()
|
|---|
| 237 | {
|
|---|
| 238 | dprintf(("KERNEL32: GetVersion"));
|
|---|
| 239 | // highword 0 = NT, lowword high byte major ver, low byte minor ver
|
|---|
| 240 | /* @@@PH 98/04/04 MFC30 makes assumptions about process control block */
|
|---|
| 241 | /* structures that lead to crashes if we don't identify as NT */
|
|---|
| 242 |
|
|---|
| 243 | if(fCheckVersion == FALSE) {
|
|---|
| 244 | CheckVersion();
|
|---|
| 245 | }
|
|---|
| 246 | return VersionData[winversion].getVersion;
|
|---|
| 247 | }
|
|---|
| 248 | //******************************************************************************
|
|---|
| 249 | //******************************************************************************
|
|---|