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.

126 lines
3.7 KiB

  1. #include "precomp.h"
  2. #pragma hdrstop
  3. extern CHAR ReturnTextBuffer[1024];
  4. /*
  5. GetMCABusInformation - Get the real MCA bus number from the data structure.
  6. The user must passed 3 arguments to the function.
  7. 1st argument - the registry key handle
  8. 2nd argument - registry field name, i.e. "Configuration Data"
  9. 3rd argument - the index of the MCA bus.
  10. The function will look at the MCA data structure and find out the
  11. real bus number. If it cannot find the real bus number, it will
  12. return the index of the MCA bus (which will match the real bus number
  13. in a single bus machine).
  14. */
  15. BOOL
  16. GetMCABusInformation(
  17. IN DWORD cArgs,
  18. IN LPSTR Args[],
  19. OUT LPSTR *TextOut
  20. )
  21. {
  22. PCM_FULL_RESOURCE_DESCRIPTOR pFullResourceDescriptor;
  23. PCM_PARTIAL_RESOURCE_DESCRIPTOR pPartialDescriptor;
  24. CHAR szNum[10];
  25. BOOL fOkay;
  26. HKEY hKey;
  27. DWORD cbData;
  28. DWORD ValueType;
  29. PVOID ValueData;
  30. LONG Status;
  31. char szKClass[ MAX_PATH ];
  32. DWORD cbKClass;
  33. DWORD KSubKeys;
  34. DWORD cbKMaxSubKeyLen;
  35. DWORD cbKMaxClassLen;
  36. DWORD KValues;
  37. DWORD cbKMaxValueNameLen;
  38. DWORD SizeSecurityDescriptor;
  39. FILETIME KLastWriteTime;
  40. lstrcpy( ReturnTextBuffer, "{" );
  41. hKey = (HKEY)LongToHandle(atol( &(Args[0][1])));
  42. cbKClass = MAX_PATH;
  43. /*
  44. ** Get the registry handle information
  45. */
  46. fOkay = !( Status = RegQueryInfoKey ( hKey,
  47. szKClass,
  48. &cbKClass,
  49. NULL,
  50. &KSubKeys,
  51. &cbKMaxSubKeyLen,
  52. &cbKMaxClassLen,
  53. &KValues,
  54. &cbKMaxValueNameLen,
  55. &cbData,
  56. &SizeSecurityDescriptor,
  57. &KLastWriteTime ) );
  58. if ( !fOkay ) {
  59. lstrcat( ReturnTextBuffer, Args[2] );
  60. lstrcat( ReturnTextBuffer, "}" );
  61. *TextOut = ReturnTextBuffer;
  62. OutputDebugString("RegQueryInfoKey error.\n\r");
  63. return(FALSE);
  64. } else {
  65. //
  66. // Allocate the buffer and get the data
  67. //
  68. // add some space for the margin
  69. while ( (ValueData = (PVOID)SAlloc( (CB)( cbData+10 ))) == NULL ) {
  70. lstrcat( ReturnTextBuffer, Args[2] );
  71. lstrcat( ReturnTextBuffer, "}" );
  72. *TextOut = ReturnTextBuffer;
  73. OutputDebugString("Malloc error.\n\r");
  74. return(FALSE);
  75. }
  76. if ( fOkay ) {
  77. fOkay = !( Status = RegQueryValueEx( hKey,
  78. Args[1],
  79. NULL,
  80. &ValueType,
  81. ValueData,
  82. &cbData ) );
  83. if ( !fOkay ) {
  84. SFree( ValueData );
  85. lstrcat( ReturnTextBuffer, Args[2] );
  86. lstrcat( ReturnTextBuffer, "}" );
  87. *TextOut = ReturnTextBuffer;
  88. OutputDebugString("RegQueryValueEx error.\n\r");
  89. return(FALSE);
  90. }
  91. }
  92. }
  93. // save the bus number and return
  94. pFullResourceDescriptor = (PCM_FULL_RESOURCE_DESCRIPTOR) ValueData;
  95. wsprintf(szNum, "\"%d\"", pFullResourceDescriptor->BusNumber);
  96. lstrcat( ReturnTextBuffer, szNum);
  97. lstrcat( ReturnTextBuffer, "}" );
  98. *TextOut = ReturnTextBuffer;
  99. SFree( ValueData );
  100. return TRUE;
  101. }