indent with astyle v1.15.3: --style=ansi -c -s3 -S --convert-tabs
[reactos.git] / reactos / lib / ntdll / rtl / misc.c
1 /* $Id$
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * PURPOSE: Various functions
6 * FILE: lib/ntdll/rtl/misc.c
7 * PROGRAMER: Eric Kohl <ekohl@zr-online.de>
8 * REVISION HISTORY:
9 * 10/08/2000: Created
10 */
11
12 /* INCLUDES *****************************************************************/
13
14 #include <ntdll.h>
15 #define NDEBUG
16 #include <debug.h>
17
18 /**********************************************************************
19 * NAME EXPORTED
20 * RtlGetNtProductType
21 *
22 * DESCRIPTION
23 * Retrieves the OS product type.
24 *
25 * ARGUMENTS
26 * ProductType Pointer to the product type variable.
27 *
28 * RETURN VALUE
29 * TRUE if successful, otherwise FALSE
30 *
31 * NOTE
32 * ProductType can be one of the following values:
33 * 1 Workstation (Winnt)
34 * 2 Server (Lanmannt)
35 * 3 Advanced Server (Servernt)
36 *
37 * REVISIONS
38 * 2000-08-10 ekohl
39 *
40 * @implemented
41 */
42
43 BOOLEAN STDCALL
44 RtlGetNtProductType(PNT_PRODUCT_TYPE ProductType)
45 {
46 *ProductType = SharedUserData->NtProductType;
47 return(TRUE);
48 }
49
50 /**********************************************************************
51 * NAME EXPORTED
52 * RtlGetNtVersionNumbers
53 *
54 * DESCRIPTION
55 * Get the version numbers of the run time library.
56 *
57 * ARGUMENTS
58 * major [OUT] Destination for the Major version
59 * minor [OUT] Destination for the Minor version
60 * build [OUT] Destination for the Build version
61 *
62 * RETURN VALUE
63 * Nothing.
64 *
65 * NOTE
66 * Introduced in Windows XP (NT5.1)
67 *
68 * @implemented
69 */
70
71 void STDCALL
72 RtlGetNtVersionNumbers(LPDWORD major, LPDWORD minor, LPDWORD build)
73 {
74 PPEB pPeb = NtCurrentPeb();
75
76 if (major)
77 {
78 /* msvcrt.dll as released with XP Home fails in DLLMain() if the
79 * major version is not 5. So, we should never set a version < 5 ...
80 * This makes sense since this call didn't exist before XP anyway.
81 */
82 *major = pPeb->OSMajorVersion < 5 ? 5 : pPeb->OSMajorVersion;
83 }
84
85 if (minor)
86 {
87 if (pPeb->OSMinorVersion <= 5)
88 *minor = pPeb->OSMinorVersion < 1 ? 1 : pPeb->OSMinorVersion;
89 else
90 *minor = pPeb->OSMinorVersion;
91 }
92
93 if (build)
94 {
95 /* FIXME: Does anybody know the real formula? */
96 *build = (0xF0000000 | pPeb->OSBuildNumber);
97 }
98 }
99
100 /*
101 * @implemented
102 */
103 ULONG
104 STDCALL
105 RtlGetNtGlobalFlags(VOID)
106 {
107 PPEB pPeb = NtCurrentPeb();
108 return pPeb->NtGlobalFlag;
109 }
110
111
112 /*
113 * @implemented
114 */
115 PVOID
116 STDCALL
117 RtlEncodePointer(IN PVOID Pointer)
118 {
119 ULONG Cookie;
120 NTSTATUS Status;
121
122 Status = NtQueryInformationProcess(NtCurrentProcess(),
123 ProcessCookie,
124 &Cookie,
125 sizeof(Cookie),
126 NULL);
127
128 if(!NT_SUCCESS(Status))
129 {
130 DPRINT1("Failed to receive the process cookie! Status: 0x%x\n", Status);
131 return Pointer;
132 }
133
134 return (PVOID)((ULONG_PTR)Pointer ^ Cookie);
135 }
136