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

Last change on this file since 5308 was 5308, checked in by sandervl, 24 years ago

removed builtin.h include + initterm update

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