| 1 | /* $Id: version.cpp,v 1.2 2000-10-02 18:39:36 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 <builtin.h>
|
|---|
| 33 | #include "heap.h"
|
|---|
| 34 | #include "handlemanager.h"
|
|---|
| 35 | #include "wprocess.h"
|
|---|
| 36 | #include "oslibdos.h"
|
|---|
| 37 | #include <versionos2.h>
|
|---|
| 38 | #include "profile.h"
|
|---|
| 39 |
|
|---|
| 40 | #define DBG_LOCALLOG DBG_version
|
|---|
| 41 | #include "dbglocal.h"
|
|---|
| 42 |
|
|---|
| 43 | typedef struct
|
|---|
| 44 | {
|
|---|
| 45 | LONG getVersion;
|
|---|
| 46 | OSVERSIONINFOA getVersionEx;
|
|---|
| 47 | } VERSION_DATA;
|
|---|
| 48 |
|
|---|
| 49 | static VERSION_DATA VersionData[WINVERSION_MAX] =
|
|---|
| 50 | {
|
|---|
| 51 | // Win98
|
|---|
| 52 | {
|
|---|
| 53 | 0xC0000A04,
|
|---|
| 54 | {
|
|---|
| 55 | sizeof(OSVERSIONINFOA), 4, 10, 0x40A07CE,
|
|---|
| 56 | VER_PLATFORM_WIN32_WINDOWS, "Win98"
|
|---|
| 57 | }
|
|---|
| 58 | },
|
|---|
| 59 | // NT40
|
|---|
| 60 | {
|
|---|
| 61 | ODINNT_VERSION,
|
|---|
| 62 | {
|
|---|
| 63 | sizeof(OSVERSIONINFOA), ODINNT_MAJOR_VERSION, ODINNT_MINOR_VERSION,
|
|---|
| 64 | ODINNT_BUILD_NR, VER_PLATFORM_WIN32_NT, ODINNT_CSDVERSION
|
|---|
| 65 | }
|
|---|
| 66 | },
|
|---|
| 67 | // Windows 2000 TODO!!!!!!!!!!!!!!!!!
|
|---|
| 68 | {
|
|---|
| 69 | ODINNT_VERSION,
|
|---|
| 70 | {
|
|---|
| 71 | sizeof(OSVERSIONINFOA), ODINNT_MAJOR_VERSION, ODINNT_MINOR_VERSION,
|
|---|
| 72 | ODINNT_BUILD_NR, VER_PLATFORM_WIN32_NT, ODINNT_CSDVERSION
|
|---|
| 73 | }
|
|---|
| 74 | }
|
|---|
| 75 | };
|
|---|
| 76 |
|
|---|
| 77 | static BOOL fCheckVersion = FALSE;
|
|---|
| 78 | static int winversion = WINVERSION_NT40;
|
|---|
| 79 |
|
|---|
| 80 | //******************************************************************************
|
|---|
| 81 | //******************************************************************************
|
|---|
| 82 | void CheckVersion()
|
|---|
| 83 | {
|
|---|
| 84 | char szVersion[16];
|
|---|
| 85 |
|
|---|
| 86 | if(PROFILE_GetOdinIniString(PROFILE_WINVERSION_SECTION, PROFILE_WINVERSION_KEY,
|
|---|
| 87 | "", szVersion, sizeof(szVersion)-1) > 1)
|
|---|
| 88 | {
|
|---|
| 89 | if(!stricmp(szVersion, PROFILE_WINVERSION_WIN98)) {
|
|---|
| 90 | winversion = WINVERSION_WIN98;
|
|---|
| 91 | }
|
|---|
| 92 | else
|
|---|
| 93 | if(!stricmp(szVersion, PROFILE_WINVERSION_WIN2000)) {
|
|---|
| 94 | winversion = WINVERSION_WIN2000;
|
|---|
| 95 | }
|
|---|
| 96 | }
|
|---|
| 97 | fCheckVersion = TRUE;
|
|---|
| 98 | }
|
|---|
| 99 | //******************************************************************************
|
|---|
| 100 | //******************************************************************************
|
|---|
| 101 | BOOL WIN32API GetVersionExA(OSVERSIONINFOA *lpVersionInformation)
|
|---|
| 102 | {
|
|---|
| 103 | dprintf(("KERNEL32: GetVersionExA %x", lpVersionInformation));
|
|---|
| 104 |
|
|---|
| 105 | if(lpVersionInformation == NULL)
|
|---|
| 106 | {
|
|---|
| 107 | dprintf(("ERROR: invalid parameter"));
|
|---|
| 108 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 109 | return(FALSE);
|
|---|
| 110 | }
|
|---|
| 111 | if(lpVersionInformation->dwOSVersionInfoSize != sizeof(OSVERSIONINFOA))
|
|---|
| 112 | {
|
|---|
| 113 | dprintf(("ERROR: buffer too small"));
|
|---|
| 114 | SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|---|
| 115 | return(FALSE);
|
|---|
| 116 | }
|
|---|
| 117 |
|
|---|
| 118 | if(fCheckVersion == FALSE) {
|
|---|
| 119 | CheckVersion();
|
|---|
| 120 | }
|
|---|
| 121 | lpVersionInformation->dwMajorVersion = VersionData[winversion].getVersionEx.dwMajorVersion;
|
|---|
| 122 | lpVersionInformation->dwMinorVersion = VersionData[winversion].getVersionEx.dwMinorVersion;
|
|---|
| 123 | lpVersionInformation->dwBuildNumber = VersionData[winversion].getVersionEx.dwBuildNumber;
|
|---|
| 124 | lpVersionInformation->dwPlatformId = VersionData[winversion].getVersionEx.dwPlatformId;
|
|---|
| 125 | strcpy(lpVersionInformation->szCSDVersion, VersionData[winversion].getVersionEx.szCSDVersion );
|
|---|
| 126 |
|
|---|
| 127 | SetLastError(ERROR_SUCCESS);
|
|---|
| 128 | return(TRUE);
|
|---|
| 129 | }
|
|---|
| 130 | //******************************************************************************
|
|---|
| 131 | //******************************************************************************
|
|---|
| 132 | BOOL WIN32API GetVersionExW(OSVERSIONINFOW *lpVersionInformation)
|
|---|
| 133 | {
|
|---|
| 134 | dprintf(("KERNEL32: GetVersionExW %x", lpVersionInformation));
|
|---|
| 135 |
|
|---|
| 136 | if(lpVersionInformation == NULL)
|
|---|
| 137 | {
|
|---|
| 138 | dprintf(("ERROR: invalid parameter"));
|
|---|
| 139 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 140 | return(FALSE);
|
|---|
| 141 | }
|
|---|
| 142 | if(lpVersionInformation->dwOSVersionInfoSize != sizeof(OSVERSIONINFOW))
|
|---|
| 143 | {
|
|---|
| 144 | dprintf(("ERROR: buffer too small"));
|
|---|
| 145 | SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|---|
| 146 | return(FALSE);
|
|---|
| 147 | }
|
|---|
| 148 |
|
|---|
| 149 | if(fCheckVersion == FALSE) {
|
|---|
| 150 | CheckVersion();
|
|---|
| 151 | }
|
|---|
| 152 | lpVersionInformation->dwMajorVersion = VersionData[winversion].getVersionEx.dwMajorVersion;
|
|---|
| 153 | lpVersionInformation->dwMinorVersion = VersionData[winversion].getVersionEx.dwMinorVersion;
|
|---|
| 154 | lpVersionInformation->dwBuildNumber = VersionData[winversion].getVersionEx.dwBuildNumber;
|
|---|
| 155 | lpVersionInformation->dwPlatformId = VersionData[winversion].getVersionEx.dwPlatformId;
|
|---|
| 156 | lstrcpyAtoW(lpVersionInformation->szCSDVersion, VersionData[winversion].getVersionEx.szCSDVersion);
|
|---|
| 157 | SetLastError(ERROR_SUCCESS);
|
|---|
| 158 | return(TRUE);
|
|---|
| 159 | }
|
|---|
| 160 | //******************************************************************************
|
|---|
| 161 | //******************************************************************************
|
|---|
| 162 | LONG WIN32API GetVersion()
|
|---|
| 163 | {
|
|---|
| 164 | dprintf(("KERNEL32: GetVersion"));
|
|---|
| 165 | // highword 0 = NT, lowword high byte major ver, low byte minor ver
|
|---|
| 166 | /* @@@PH 98/04/04 MFC30 makes assumptions about process control block */
|
|---|
| 167 | /* structures that lead to crashes if we don't identify as NT */
|
|---|
| 168 |
|
|---|
| 169 | if(fCheckVersion == FALSE) {
|
|---|
| 170 | CheckVersion();
|
|---|
| 171 | }
|
|---|
| 172 | return VersionData[winversion].getVersion;
|
|---|
| 173 | }
|
|---|
| 174 | //******************************************************************************
|
|---|
| 175 | //******************************************************************************
|
|---|