00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
#include "ntrtlp.h"
00023
00024
#if defined(ALLOC_PRAGMA) && defined(NTOS_KERNEL_RUNTIME)
00025
#pragma alloc_text(PAGE,RtlGetNtProductType)
00026
#endif
00027
00028
00029 BOOLEAN
00030 RtlGetNtProductType(
00031 OUT PNT_PRODUCT_TYPE NtProductType
00032 )
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 {
00053
00054
NTSTATUS Status;
00055 OBJECT_ATTRIBUTES
ObjectAttributes;
00056 HANDLE KeyHandle;
00057 PKEY_VALUE_FULL_INFORMATION KeyValueInformation;
00058 ULONG KeyValueInfoLength;
00059 ULONG ResultLength;
00060 UNICODE_STRING
KeyPath;
00061 UNICODE_STRING
ValueName;
00062 UNICODE_STRING Value;
00063 UNICODE_STRING WinNtValue;
00064 UNICODE_STRING LanmanNtValue;
00065 UNICODE_STRING ServerNtValue;
00066 BOOLEAN Result;
00067
00068
RTL_PAGED_CODE();
00069
00070
00071
00072
00073
00074
00075
00076
if ( USER_SHARED_DATA->ProductTypeIsValid ) {
00077 *NtProductType = USER_SHARED_DATA->NtProductType;
00078
return TRUE;
00079 }
00080
00081
00082
00083
00084
00085 *NtProductType = NtProductWinNt;
00086 Result =
FALSE;
00087
00088
RtlInitUnicodeString( &
KeyPath,
L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\ProductOptions" );
00089
RtlInitUnicodeString( &
ValueName,
L"ProductType" );
00090
00091 InitializeObjectAttributes( &
ObjectAttributes,
00092 &
KeyPath,
00093 OBJ_CASE_INSENSITIVE,
00094
NULL,
00095
NULL
00096 );
00097
Status =
NtOpenKey( &KeyHandle,
00098 MAXIMUM_ALLOWED,
00099 &
ObjectAttributes
00100 );
00101 KeyValueInformation =
NULL;
00102
if (
NT_SUCCESS(
Status )) {
00103 KeyValueInfoLength = 256;
00104 KeyValueInformation =
RtlAllocateHeap( RtlProcessHeap(), 0,
00105 KeyValueInfoLength
00106 );
00107
if (KeyValueInformation ==
NULL) {
00108
Status = STATUS_NO_MEMORY;
00109 }
else {
00110
Status =
NtQueryValueKey( KeyHandle,
00111 &
ValueName,
00112 KeyValueFullInformation,
00113 KeyValueInformation,
00114 KeyValueInfoLength,
00115 &ResultLength
00116 );
00117 }
00118 }
else {
00119 KeyHandle =
NULL;
00120 }
00121
00122
if (
NT_SUCCESS(
Status ) && KeyValueInformation->Type == REG_SZ) {
00123
00124
00125
00126
00127
00128 Value.Buffer = (PWSTR)((PCHAR)KeyValueInformation + KeyValueInformation->DataOffset);
00129 Value.Length = (
USHORT)(KeyValueInformation->DataLength -
sizeof( UNICODE_NULL ));
00130 Value.MaximumLength = (
USHORT)(KeyValueInformation->DataLength);
00131
RtlInitUnicodeString(&WinNtValue,
L"WinNt");
00132
RtlInitUnicodeString(&LanmanNtValue,
L"LanmanNt");
00133
RtlInitUnicodeString(&ServerNtValue,
L"ServerNt");
00134
00135
if (
RtlEqualUnicodeString(&Value, &WinNtValue,
TRUE)) {
00136 *NtProductType = NtProductWinNt;
00137 Result =
TRUE;
00138 }
else if (
RtlEqualUnicodeString(&Value, &LanmanNtValue,
TRUE)) {
00139 *NtProductType = NtProductLanManNt;
00140 Result =
TRUE;
00141 }
else if (
RtlEqualUnicodeString(&Value, &ServerNtValue,
TRUE)) {
00142 *NtProductType = NtProductServer;
00143 Result =
TRUE;
00144 }
else {
00145
#if DBG
00146
DbgPrint(
"RtlGetNtProductType: Product type unrecognised <%wZ>\n", &Value);
00147
#endif // DBG
00148
}
00149 }
else {
00150
#if DBG
00151
DbgPrint(
"RtlGetNtProductType: %wZ\\%wZ not found or invalid type\n", &
KeyPath, &
ValueName );
00152
#endif // DBG
00153
}
00154
00155
00156
00157
00158
00159
if (KeyValueInformation !=
NULL) {
00160
RtlFreeHeap( RtlProcessHeap(), 0, KeyValueInformation );
00161 }
00162
00163
if (KeyHandle !=
NULL) {
00164
NtClose( KeyHandle );
00165 }
00166
00167
00168
00169
00170
00171
return(Result);
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184 }