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

Last change on this file since 4372 was 4372, checked in by sandervl, 25 years ago

version changes + misc fixes/changes

File size: 5.4 KB
Line 
1/* $Id: version.cpp,v 1.1 2000-10-02 13:39:18 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
43typedef struct
44{
45 LONG getVersion;
46 OSVERSIONINFOA getVersionEx;
47} VERSION_DATA;
48
49static 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
77static BOOL fCheckVersion = FALSE;
78static int winversion = WINVERSION_NT40;
79
80//******************************************************************************
81//******************************************************************************
82void CheckVersion()
83{
84 char szVersion[16];
85
86 if(ODIN_PROFILE_GetOdinIniString(PROFILE_WINVERSION_SECTION, PROFILE_WINVERSION_KEY,
87 "", szVersion,
88 sizeof(szVersion)-1) > 1)
89 {
90 if(!stricmp(szVersion, PROFILE_WINVERSION_WIN98)) {
91 winversion = WINVERSION_WIN98;
92 }
93 else
94 if(!stricmp(szVersion, PROFILE_WINVERSION_WIN2000)) {
95 winversion = WINVERSION_WIN2000;
96 }
97 }
98 fCheckVersion = TRUE;
99}
100//******************************************************************************
101//******************************************************************************
102BOOL WIN32API GetVersionExA(OSVERSIONINFOA *lpVersionInformation)
103{
104 dprintf(("KERNEL32: GetVersionExA %x", lpVersionInformation));
105
106 if(lpVersionInformation == NULL)
107 {
108 dprintf(("ERROR: invalid parameter"));
109 SetLastError(ERROR_INVALID_PARAMETER);
110 return(FALSE);
111 }
112 if(lpVersionInformation->dwOSVersionInfoSize != sizeof(OSVERSIONINFOA))
113 {
114 dprintf(("ERROR: buffer too small"));
115 SetLastError(ERROR_INSUFFICIENT_BUFFER);
116 return(FALSE);
117 }
118
119 if(fCheckVersion == FALSE) {
120 CheckVersion();
121 }
122 lpVersionInformation->dwMajorVersion = VersionData[winversion].getVersionEx.dwMajorVersion;
123 lpVersionInformation->dwMinorVersion = VersionData[winversion].getVersionEx.dwMinorVersion;
124 lpVersionInformation->dwBuildNumber = VersionData[winversion].getVersionEx.dwBuildNumber;
125 lpVersionInformation->dwPlatformId = VersionData[winversion].getVersionEx.dwPlatformId;
126 strcpy(lpVersionInformation->szCSDVersion, VersionData[winversion].getVersionEx.szCSDVersion );
127
128 SetLastError(ERROR_SUCCESS);
129 return(TRUE);
130}
131//******************************************************************************
132//******************************************************************************
133BOOL WIN32API GetVersionExW(OSVERSIONINFOW *lpVersionInformation)
134{
135 dprintf(("KERNEL32: GetVersionExW %x", lpVersionInformation));
136
137 if(lpVersionInformation == NULL)
138 {
139 dprintf(("ERROR: invalid parameter"));
140 SetLastError(ERROR_INVALID_PARAMETER);
141 return(FALSE);
142 }
143 if(lpVersionInformation->dwOSVersionInfoSize != sizeof(OSVERSIONINFOW))
144 {
145 dprintf(("ERROR: buffer too small"));
146 SetLastError(ERROR_INSUFFICIENT_BUFFER);
147 return(FALSE);
148 }
149
150 if(fCheckVersion == FALSE) {
151 CheckVersion();
152 }
153 lpVersionInformation->dwMajorVersion = VersionData[winversion].getVersionEx.dwMajorVersion;
154 lpVersionInformation->dwMinorVersion = VersionData[winversion].getVersionEx.dwMinorVersion;
155 lpVersionInformation->dwBuildNumber = VersionData[winversion].getVersionEx.dwBuildNumber;
156 lpVersionInformation->dwPlatformId = VersionData[winversion].getVersionEx.dwPlatformId;
157 lstrcpyAtoW(lpVersionInformation->szCSDVersion, VersionData[winversion].getVersionEx.szCSDVersion);
158 SetLastError(ERROR_SUCCESS);
159 return(TRUE);
160}
161//******************************************************************************
162//******************************************************************************
163LONG WIN32API GetVersion()
164{
165 dprintf(("KERNEL32: GetVersion"));
166 // highword 0 = NT, lowword high byte major ver, low byte minor ver
167/* @@@PH 98/04/04 MFC30 makes assumptions about process control block */
168/* structures that lead to crashes if we don't identify as NT */
169
170 if(fCheckVersion == FALSE) {
171 CheckVersion();
172 }
173 return VersionData[winversion].getVersion;
174}
175//******************************************************************************
176//******************************************************************************
Note: See TracBrowser for help on using the repository browser.