Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

186 lines
4.1 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. OEMHard.c
  5. Abstract:
  6. Author:
  7. Revision History:
  8. --*/
  9. #ifndef UNICODE
  10. #define UNICODE
  11. #endif
  12. #ifndef _UNICODE
  13. #define _UNICODE
  14. #endif
  15. #include "msgina.h"
  16. #include "machinep.h"
  17. #if defined(_X86_)
  18. ULONG
  19. RegGetMachineIdentifierValue(
  20. IN OUT PULONG Value
  21. )
  22. /*++
  23. Routine Description:
  24. Given a unicode value name this routine will go into the registry
  25. location for the machine identifier information and get the
  26. value.
  27. Arguments:
  28. Value - a pointer to the ULONG for the result.
  29. Return Value:
  30. NTSTATUS
  31. If STATUS_SUCCESSFUL is returned, the location *Value will be
  32. updated with the DWORD value from the registry. If any failing
  33. status is returned, this value is untouched.
  34. --*/
  35. {
  36. LONG lRet;
  37. HKEY hKey;
  38. DWORD dwType;
  39. TCHAR tchData[100];
  40. PTCHAR ptchData = tchData;
  41. DWORD dwData = sizeof(tchData);
  42. int cchCompareF, cchCompareN;
  43. LCID lcid;
  44. //
  45. // Set default as PC/AT
  46. //
  47. *Value = MACHINEID_MS_PCAT;
  48. //
  49. // Open registry key
  50. //
  51. lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE, // hRootKey
  52. REGISTRY_HARDWARE_SYSTEM, // SubKey
  53. 0, // Reserved
  54. KEY_READ, // Read Op.
  55. &hKey ); // hKey
  56. if( lRet != ERROR_SUCCESS ) return( lRet );
  57. //
  58. // Read registry key
  59. //
  60. ReTryRead:
  61. lRet = RegQueryValueEx( hKey, // kKey
  62. REGISTRY_MACHINE_IDENTIFIER, // ValueName
  63. NULL, // Reserved
  64. &dwType, // Data Type
  65. (LPBYTE)ptchData, // Data buffer
  66. &dwData ); // Data buffer size
  67. if( lRet != ERROR_SUCCESS ) {
  68. if( lRet != ERROR_MORE_DATA ) goto Exit1;
  69. //
  70. // the Buffer is too small to store the data, we retry with
  71. // large buffer.
  72. //
  73. dwData += 2;
  74. ptchData = LocalAlloc( LMEM_FIXED , dwData );
  75. if( ptchData == NULL ) {
  76. lRet = ERROR_NOT_ENOUGH_MEMORY;
  77. goto Exit1;
  78. }
  79. goto ReTryRead;
  80. }
  81. //
  82. // Determine platform.
  83. //
  84. lcid = MAKELCID( MAKELANGID( LANG_NEUTRAL, SUBLANG_SYS_DEFAULT ),
  85. SORT_DEFAULT );
  86. cchCompareF = lstrlen( FUJITSU_FMR_NAME );
  87. cchCompareN = lstrlen( NEC_PC98_NAME );
  88. if( CompareString( lcid, // Locale id
  89. NORM_IGNORECASE, // Ignoare case
  90. ptchData, // String A.
  91. cchCompareF, // length of string A to compare
  92. FUJITSU_FMR_NAME, // String B.
  93. cchCompareF ) // length of string B to compare
  94. == 2 // String A == String B
  95. ) {
  96. //
  97. // Fujitsu FMR Series.
  98. //
  99. *Value = MACHINEID_FUJITSU_FMR;
  100. } else if( CompareString( lcid, // Locale id
  101. NORM_IGNORECASE, // Igonre case
  102. ptchData, // String A.
  103. cchCompareN, // length of string A to compare
  104. NEC_PC98_NAME, // String B.
  105. cchCompareN ) // length of string B to compare
  106. == 2 // String A == String B
  107. ) {
  108. //
  109. // NEC PC-9800 Seriss
  110. //
  111. *Value = MACHINEID_NEC_PC98;
  112. } else {
  113. //
  114. // Standard PC/AT comapatibles
  115. //
  116. *Value = MACHINEID_MS_PCAT;
  117. }
  118. Exit1:
  119. RegCloseKey( hKey );
  120. return( lRet );
  121. }
  122. DWORD dwMachineId = MACHINEID_MS_PCAT;
  123. VOID InitializeOEMId(VOID)
  124. {
  125. RegGetMachineIdentifierValue(&dwMachineId);
  126. }
  127. BOOL IsNEC_PC9800(VOID)
  128. {
  129. return((dwMachineId & PC_9800_COMPATIBLE) ? TRUE : FALSE);
  130. }
  131. #endif // defined(_X86_)