+libcaptive/rtl/version.c
[captive.git] / src / libcaptive / rtl / version.c
1 /* $Id$
2  * Internal (rtl/) reactos versioning functions of libcaptive
3  * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
4  * 
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; exactly version 2 of June 1991 is required
8  * 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19
20 #include "config.h"
21
22 /* no include file for RtlGetVersion() in reactos */
23 #include <glib/gmessages.h>
24 #include "reactos/ntos/types.h"
25 #include "reactos/ddk/status.h"
26 #include "captive/macros.h"
27
28
29 typedef struct _OSVERSIONINFOW {
30         ULONG dwOSVersionInfoSize;
31         ULONG dwMajorVersion;
32         ULONG dwMinorVersion;
33         ULONG dwBuildNumber;
34         ULONG dwPlatformId;
35         WCHAR szCSDVersion[128];
36         } RTL_OSVERSIONINFOW,*PRTL_OSVERSIONINFOW;
37  
38 typedef struct _OSVERSIONINFOEXW {      /* sizeof==284 */
39         ULONG dwOSVersionInfoSize;
40         ULONG dwMajorVersion;
41         ULONG dwMinorVersion;
42         ULONG dwBuildNumber;
43         ULONG dwPlatformId;
44         WCHAR szCSDVersion[128];
45         USHORT wServicePackMajor;
46         USHORT wServicePackMinor;
47         USHORT wSuiteMask;
48         UCHAR wProductType;
49         UCHAR wReserved;
50 } RTL_OSVERSIONINFOEXW,*PRTL_OSVERSIONINFOEXW;
51
52
53 /**
54  * RtlGetVersion:
55  * @lpVersionInformation: Returns system version information.
56  *
57  * Functions looks at field #dwOSVersionInfoSize of @lpVersionInformation
58  * containing sizeof() of the passed structure to autodetect what it should
59  * in fact fill in.
60  * libcaptive currently supports only #RTL_OSVERSIONINFOEXW.
61  * libcaptive returns version info corresponding to Microsoft Windows XP Service Pack 1.
62  *
63  * Returns: %STATUS_SUCCESS if @lpVersionInformation was filled successfuly.
64  */
65 NTSTATUS RtlGetVersion(OUT PRTL_OSVERSIONINFOW lpVersionInformation)
66 {
67         g_return_val_if_fail(lpVersionInformation!=NULL,STATUS_INVALID_PARAMETER);
68
69         switch (lpVersionInformation->dwOSVersionInfoSize) {
70                 case sizeof(RTL_OSVERSIONINFOEXW): {
71 RTL_OSVERSIONINFOEXW *verinfoexw=(RTL_OSVERSIONINFOEXW *)lpVersionInformation;
72
73                         verinfoexw->dwMajorVersion=5;   /* NT-5.1 == Microsoft Windows XP */
74                         verinfoexw->dwMinorVersion=1;
75                         verinfoexw->dwBuildNumber=2600;
76                         verinfoexw->dwPlatformId=2;     /* ==Wine::VER_PLATFORM_WIN32_NT */
77                         CAPTIVE_MEMZERO(verinfoexw->szCSDVersion);      /* FIXME: should be L"Service Pack 1" ? */
78                         verinfoexw->wServicePackMajor=1;        /* Wine uses 0 */
79                         verinfoexw->wServicePackMinor=0;
80                         verinfoexw->wSuiteMask=0;
81                         verinfoexw->wProductType=1;     /* ==Wine::VER_NT_WORKSTATION, possible also VER_NT_DOMAIN_CONTROLLER or VER_NT_SERVER */
82                         verinfoexw->wReserved=0;
83                         } break;
84                 default:
85                         g_assert_not_reached(); /* NOT YET IMPLEMENTED */
86                 }
87
88         return STATUS_SUCCESS;
89 }