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

Last change on this file since 22018 was 21848, checked in by abwillis, 14 years ago

Ticket #52

File size: 8.8 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#include "debugtools.h"
42
43typedef struct
44{
45 LONG getVersion16;
46 LONG getVersion;
47 OSVERSIONINFOEXA getVersionEx;
48} VERSION_DATA;
49
50static 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};
103
104static BOOL fCheckVersion = FALSE;
105static int winversion = WINVERSION_WIN2000;
106
107//******************************************************************************
108//******************************************************************************
109void WIN32API OdinSetVersion(ULONG version)
110{
111 switch(version) {
112 case WINVERSION_WIN98:
113 case WINVERSION_WINME:
114 case WINVERSION_NT40:
115 case WINVERSION_WIN2000:
116 case WINVERSION_WINXP:
117 break;
118 default:
119 DebugInt3();
120 return;
121 }
122 winversion = version;
123}
124//******************************************************************************
125//******************************************************************************
126void CheckVersion()
127{
128 char szVersion[16];
129
130 if(PROFILE_GetOdinIniString(PROFILE_WINVERSION_SECTION, PROFILE_WINVERSION_KEY,
131 "", szVersion, sizeof(szVersion)-1) > 1)
132 {
133 if(!stricmp(szVersion, PROFILE_WINVERSION_WIN98)) {
134 winversion = WINVERSION_WIN98;
135 }
136 else
137 if(!stricmp(szVersion, PROFILE_WINVERSION_WINME)) {
138 winversion = WINVERSION_WINME;
139 }
140 else
141 if(!stricmp(szVersion, PROFILE_WINVERSION_NT40)) {
142 winversion = WINVERSION_NT40;
143 }
144 else
145 if(!stricmp(szVersion, PROFILE_WINVERSION_WIN2000)) {
146 winversion = WINVERSION_WIN2000;
147 }
148 else
149 if(!stricmp(szVersion, PROFILE_WINVERSION_WINXP)) {
150 winversion = WINVERSION_WINXP;
151 }
152 }
153 fCheckVersion = TRUE;
154}
155//******************************************************************************
156//******************************************************************************
157BOOL WIN32API GetVersionExA(OSVERSIONINFOA *lpVersionInformation)
158{
159 dprintf(("KERNEL32: GetVersionExA %x", lpVersionInformation));
160
161 if(lpVersionInformation == NULL)
162 {
163 dprintf(("ERROR: invalid parameter"));
164 SetLastError(ERROR_INVALID_PARAMETER);
165 return(FALSE);
166 }
167 if(lpVersionInformation->dwOSVersionInfoSize < sizeof(OSVERSIONINFOA))
168 {
169 dprintf(("ERROR: buffer too small (%d != %d)", lpVersionInformation->dwOSVersionInfoSize, sizeof(OSVERSIONINFOA)));
170 SetLastError(ERROR_INSUFFICIENT_BUFFER);
171 return(FALSE);
172 }
173
174 if(fCheckVersion == FALSE) {
175 CheckVersion();
176 }
177 lpVersionInformation->dwMajorVersion = VersionData[winversion].getVersionEx.dwMajorVersion;
178 lpVersionInformation->dwMinorVersion = VersionData[winversion].getVersionEx.dwMinorVersion;
179 lpVersionInformation->dwBuildNumber = VersionData[winversion].getVersionEx.dwBuildNumber;
180 lpVersionInformation->dwPlatformId = VersionData[winversion].getVersionEx.dwPlatformId;
181 strcpy(lpVersionInformation->szCSDVersion, VersionData[winversion].getVersionEx.szCSDVersion );
182
183 dprintf(("version %x.%x", lpVersionInformation->dwMajorVersion, lpVersionInformation->dwMinorVersion));
184 dprintf(("build nr %x", lpVersionInformation->dwBuildNumber));
185 dprintf(("Platform Id %x", lpVersionInformation->dwPlatformId));
186 dprintf(("szCSDVersion %s", lpVersionInformation->szCSDVersion));
187
188 if(lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXA))
189 {//Windows 2000 (and up) extension
190 LPOSVERSIONINFOEXA lpVersionExInformation = (LPOSVERSIONINFOEXA)lpVersionInformation;
191
192 lpVersionExInformation->wServicePackMajor = VersionData[winversion].getVersionEx.wServicePackMajor;
193 lpVersionExInformation->wServicePackMinor = VersionData[winversion].getVersionEx.wServicePackMinor;
194 lpVersionExInformation->wReserved[0] = VersionData[winversion].getVersionEx.wReserved[0];
195 lpVersionExInformation->wReserved[1] = VersionData[winversion].getVersionEx.wReserved[1];
196
197 dprintf(("service pack version %x.%x", lpVersionExInformation->wServicePackMajor, lpVersionExInformation->wServicePackMinor));
198 }
199
200 SetLastError(ERROR_SUCCESS);
201 return(TRUE);
202}
203//******************************************************************************
204//******************************************************************************
205BOOL WIN32API GetVersionExW(OSVERSIONINFOW *lpVersionInformation)
206{
207 dprintf(("KERNEL32: GetVersionExW %x", lpVersionInformation));
208
209 if(lpVersionInformation == NULL)
210 {
211 dprintf(("ERROR: invalid parameter"));
212 SetLastError(ERROR_INVALID_PARAMETER);
213 return(FALSE);
214 }
215 if(lpVersionInformation->dwOSVersionInfoSize < sizeof(OSVERSIONINFOW))
216 {
217 dprintf(("ERROR: buffer too small"));
218 SetLastError(ERROR_INSUFFICIENT_BUFFER);
219 return(FALSE);
220 }
221
222 if(fCheckVersion == FALSE) {
223 CheckVersion();
224 }
225 lpVersionInformation->dwMajorVersion = VersionData[winversion].getVersionEx.dwMajorVersion;
226 lpVersionInformation->dwMinorVersion = VersionData[winversion].getVersionEx.dwMinorVersion;
227 lpVersionInformation->dwBuildNumber = VersionData[winversion].getVersionEx.dwBuildNumber;
228 lpVersionInformation->dwPlatformId = VersionData[winversion].getVersionEx.dwPlatformId;
229 lstrcpyAtoW(lpVersionInformation->szCSDVersion, VersionData[winversion].getVersionEx.szCSDVersion);
230
231 if(lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXW))
232 {//Windows 2000 (and up) extension
233 LPOSVERSIONINFOEXW lpVersionExInformation = (LPOSVERSIONINFOEXW)lpVersionInformation;
234
235 lpVersionExInformation->wServicePackMajor = VersionData[winversion].getVersionEx.wServicePackMajor;
236 lpVersionExInformation->wServicePackMinor = VersionData[winversion].getVersionEx.wServicePackMinor;
237 lpVersionExInformation->wReserved[0] = VersionData[winversion].getVersionEx.wReserved[0];
238 lpVersionExInformation->wReserved[1] = VersionData[winversion].getVersionEx.wReserved[1];
239 }
240 SetLastError(ERROR_SUCCESS);
241 return(TRUE);
242}
243//******************************************************************************
244//******************************************************************************
245LONG WIN32API GetVersion()
246{
247 dprintf(("KERNEL32: GetVersion"));
248 if(fCheckVersion == FALSE) {
249 CheckVersion();
250 }
251 return VersionData[winversion].getVersion;
252}
253//******************************************************************************
254//******************************************************************************
255 /******************************************************************************
256 * VerifyVersionInfoW (KERNEL32.@)
257 */
258BOOL WINAPI VerifyVersionInfoW( /* LPOSVERSIONINFOEXW */ LPVOID lpVersionInfo, DWORD dwTypeMask,
259 DWORDLONG dwlConditionMask)
260 {
261 FIXME("%p %lu %llx\n", lpVersionInfo, dwTypeMask, dwlConditionMask);
262 return TRUE;
263}
264
Note: See TracBrowser for help on using the repository browser.