source: trunk/src/kernel32/version.cpp@ 21470

Last change on this file since 21470 was 21470, checked in by ydario, 15 years ago

Make WinXP the default system version.

File size: 8.4 KB
Line 
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
42typedef struct
43{
44 LONG getVersion16;
45 LONG getVersion;
46 OSVERSIONINFOEXA getVersionEx;
47} VERSION_DATA;
48
49static 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
103static BOOL fCheckVersion = FALSE;
104static int winversion = WINVERSION_WINXP;
105
106//******************************************************************************
107//******************************************************************************
108void 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//******************************************************************************
125void 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//******************************************************************************
156BOOL 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 dprintf(("version %x.%x", lpVersionInformation->dwMajorVersion, lpVersionInformation->dwMinorVersion));
183 dprintf(("build nr %x", lpVersionInformation->dwBuildNumber));
184 dprintf(("Platform Id %x", lpVersionInformation->dwPlatformId));
185 dprintf(("szCSDVersion %s", lpVersionInformation->szCSDVersion));
186
187 if(lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXA))
188 {//Windows 2000 (and up) extension
189 LPOSVERSIONINFOEXA lpVersionExInformation = (LPOSVERSIONINFOEXA)lpVersionInformation;
190
191 lpVersionExInformation->wServicePackMajor = VersionData[winversion].getVersionEx.wServicePackMajor;
192 lpVersionExInformation->wServicePackMinor = VersionData[winversion].getVersionEx.wServicePackMinor;
193 lpVersionExInformation->wReserved[0] = VersionData[winversion].getVersionEx.wReserved[0];
194 lpVersionExInformation->wReserved[1] = VersionData[winversion].getVersionEx.wReserved[1];
195
196 dprintf(("service pack version %x.%x", lpVersionExInformation->wServicePackMajor, lpVersionExInformation->wServicePackMinor));
197 }
198
199 SetLastError(ERROR_SUCCESS);
200 return(TRUE);
201}
202//******************************************************************************
203//******************************************************************************
204BOOL WIN32API GetVersionExW(OSVERSIONINFOW *lpVersionInformation)
205{
206 dprintf(("KERNEL32: GetVersionExW %x", lpVersionInformation));
207
208 if(lpVersionInformation == NULL)
209 {
210 dprintf(("ERROR: invalid parameter"));
211 SetLastError(ERROR_INVALID_PARAMETER);
212 return(FALSE);
213 }
214 if(lpVersionInformation->dwOSVersionInfoSize < sizeof(OSVERSIONINFOW))
215 {
216 dprintf(("ERROR: buffer too small"));
217 SetLastError(ERROR_INSUFFICIENT_BUFFER);
218 return(FALSE);
219 }
220
221 if(fCheckVersion == FALSE) {
222 CheckVersion();
223 }
224 lpVersionInformation->dwMajorVersion = VersionData[winversion].getVersionEx.dwMajorVersion;
225 lpVersionInformation->dwMinorVersion = VersionData[winversion].getVersionEx.dwMinorVersion;
226 lpVersionInformation->dwBuildNumber = VersionData[winversion].getVersionEx.dwBuildNumber;
227 lpVersionInformation->dwPlatformId = VersionData[winversion].getVersionEx.dwPlatformId;
228 lstrcpyAtoW(lpVersionInformation->szCSDVersion, VersionData[winversion].getVersionEx.szCSDVersion);
229
230 if(lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXW))
231 {//Windows 2000 (and up) extension
232 LPOSVERSIONINFOEXW lpVersionExInformation = (LPOSVERSIONINFOEXW)lpVersionInformation;
233
234 lpVersionExInformation->wServicePackMajor = VersionData[winversion].getVersionEx.wServicePackMajor;
235 lpVersionExInformation->wServicePackMinor = VersionData[winversion].getVersionEx.wServicePackMinor;
236 lpVersionExInformation->wReserved[0] = VersionData[winversion].getVersionEx.wReserved[0];
237 lpVersionExInformation->wReserved[1] = VersionData[winversion].getVersionEx.wReserved[1];
238 }
239 SetLastError(ERROR_SUCCESS);
240 return(TRUE);
241}
242//******************************************************************************
243//******************************************************************************
244LONG WIN32API GetVersion()
245{
246 dprintf(("KERNEL32: GetVersion"));
247 if(fCheckVersion == FALSE) {
248 CheckVersion();
249 }
250 return VersionData[winversion].getVersion;
251}
252//******************************************************************************
253//******************************************************************************
Note: See TracBrowser for help on using the repository browser.