Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

hard.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1985 - 1999, Microsoft Corporation 00004 00005 Module Name: 00006 00007 NtHard.c 00008 00009 Abstract: 00010 00011 Author: 00012 00013 Revision History: 00014 00015 --*/ 00016 00017 #include "precomp.h" 00018 #pragma hdrstop 00019 00020 #if defined(i386) 00021 00022 00023 #define REGISTRY_HARDWARE_DESCRIPTION \ 00024 TEXT("\\Registry\\Machine\\Hardware\\DESCRIPTION\\System") 00025 00026 #define REGISTRY_MACHINE_IDENTIFIER \ 00027 TEXT("Identifier") 00028 00029 #define FUJITSU_FMR_NAME TEXT("FUJITSU FMR-") 00030 #define NEC_PC98_NAME TEXT("NEC PC-98") 00031 00032 00033 00034 #define KEY_WORK_AREA ((sizeof(KEY_VALUE_FULL_INFORMATION) + \ 00035 sizeof(ULONG)) + 256) 00036 00037 NTSTATUS 00038 NtGetMachineIdentifierValue( 00039 IN OUT PULONG Value 00040 ) 00041 00042 /*++ 00043 00044 Routine Description: 00045 00046 Given a unicode value name this routine will go into the registry 00047 location for the machine identifier information and get the 00048 value. 00049 00050 Arguments: 00051 00052 ValueName - the unicode name for the registry value located in the 00053 identifier location of the registry. 00054 Value - a pointer to the ULONG for the result. 00055 00056 Return Value: 00057 00058 NTSTATUS 00059 00060 If STATUS_SUCCESSFUL is returned, the location *Value will be 00061 updated with the DWORD value from the registry. If any failing 00062 status is returned, this value is untouched. 00063 00064 --*/ 00065 00066 { 00067 HANDLE Handle; 00068 NTSTATUS Status; 00069 ULONG RequestLength; 00070 ULONG ResultLength; 00071 UCHAR Buffer[KEY_WORK_AREA]; 00072 UNICODE_STRING KeyName; 00073 UNICODE_STRING ValueName; 00074 OBJECT_ATTRIBUTES ObjectAttributes; 00075 PKEY_VALUE_FULL_INFORMATION KeyValueInformation; 00076 00077 // 00078 // Set default as PC/AT 00079 // 00080 00081 *Value = MACHINEID_MS_PCAT; 00082 00083 KeyName.Buffer = REGISTRY_HARDWARE_DESCRIPTION; 00084 KeyName.Length = sizeof(REGISTRY_HARDWARE_DESCRIPTION) - sizeof(WCHAR); 00085 KeyName.MaximumLength = sizeof(REGISTRY_HARDWARE_DESCRIPTION); 00086 00087 InitializeObjectAttributes(&ObjectAttributes, 00088 &KeyName, 00089 OBJ_CASE_INSENSITIVE, 00090 NULL, 00091 NULL); 00092 00093 Status = NtOpenKey(&Handle, 00094 KEY_READ, 00095 &ObjectAttributes); 00096 00097 if (!NT_SUCCESS(Status)) { 00098 00099 return Status; 00100 } 00101 00102 ValueName.Buffer = REGISTRY_MACHINE_IDENTIFIER; 00103 ValueName.Length = sizeof(REGISTRY_MACHINE_IDENTIFIER) - sizeof(WCHAR); 00104 ValueName.MaximumLength = sizeof(REGISTRY_MACHINE_IDENTIFIER); 00105 00106 RequestLength = KEY_WORK_AREA; 00107 00108 KeyValueInformation = (PKEY_VALUE_FULL_INFORMATION)Buffer; 00109 00110 Status = NtQueryValueKey(Handle, 00111 &ValueName, 00112 KeyValueFullInformation, 00113 KeyValueInformation, 00114 RequestLength, 00115 &ResultLength); 00116 00117 ASSERT( Status != STATUS_BUFFER_OVERFLOW ); 00118 00119 NtClose(Handle); 00120 00121 if (NT_SUCCESS(Status)) { 00122 00123 if (KeyValueInformation->DataLength != 0) { 00124 00125 PWCHAR DataPtr; 00126 UNICODE_STRING DetectedString, TargetString1, TargetString2; 00127 00128 // 00129 // Return contents to the caller. 00130 // 00131 00132 DataPtr = (PWCHAR) 00133 ((PUCHAR)KeyValueInformation + KeyValueInformation->DataOffset); 00134 00135 // 00136 // Initialize strings. 00137 // 00138 00139 RtlInitUnicodeString( &DetectedString, DataPtr ); 00140 RtlInitUnicodeString( &TargetString1, FUJITSU_FMR_NAME ); 00141 RtlInitUnicodeString( &TargetString2, NEC_PC98_NAME ); 00142 00143 // 00144 // Check the hardware platform 00145 // 00146 00147 if (RtlPrefixUnicodeString( &TargetString1 , &DetectedString , TRUE)) { 00148 00149 // 00150 // Fujitsu FMR Series. 00151 // 00152 00153 *Value = MACHINEID_FUJITSU_FMR; 00154 00155 } else if (RtlPrefixUnicodeString( &TargetString2 , &DetectedString , TRUE)) { 00156 00157 // 00158 // NEC PC-9800 Seriss 00159 // 00160 00161 *Value = MACHINEID_NEC_PC98; 00162 00163 } else { 00164 00165 // 00166 // Standard PC/AT comapatibles 00167 // 00168 00169 *Value = MACHINEID_MS_PCAT; 00170 00171 } 00172 00173 } else { 00174 00175 // 00176 // Treat as if no value was found 00177 // 00178 00179 Status = STATUS_OBJECT_NAME_NOT_FOUND; 00180 } 00181 00182 } 00183 00184 return Status; 00185 } 00186 #endif // defined(i386)

Generated on Sat May 15 19:40:14 2004 for test by doxygen 1.3.7