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.

87 lines
1.9 KiB

  1. #include "precomp.h"
  2. #pragma hdrstop
  3. typedef DWORD (APIENTRY *T_PCIINFO)(
  4. ULONG BusNumber,
  5. ULONG SlotNumber,
  6. ULONG Offset,
  7. ULONG Length,
  8. PVOID Data );
  9. typedef struct _PCI_SLOT_NUMBER {
  10. union {
  11. struct {
  12. ULONG DeviceNumber:5;
  13. ULONG FunctionNumber:3;
  14. ULONG Reserved:24;
  15. } bits;
  16. ULONG AsULONG;
  17. } u;
  18. } PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER;
  19. extern CHAR ReturnTextBuffer[1024];
  20. /*
  21. GetPCISlotInformation - Get PCI information.
  22. The user must passed 3 arguments to the function.
  23. 1st argument - bus number
  24. 2rd argument - slot number
  25. It will return a string as:
  26. {VendorID, DeviceID}
  27. */
  28. BOOL
  29. GetPciInformation(
  30. IN DWORD cArgs,
  31. IN LPSTR Args[],
  32. OUT LPSTR *TextOut
  33. )
  34. {
  35. static HMODULE mDtect = NULL;
  36. static T_PCIINFO pProc = NULL;
  37. ULONG BusNum = atol( Args[0] );
  38. ULONG Device = atol( Args[1] );
  39. ULONG Function = atol( Args[2] );
  40. USHORT usVendor = 0;
  41. USHORT usDevice = 0;
  42. TCHAR buf[100];
  43. lstrcpy( ReturnTextBuffer, "{" );
  44. if ( mDtect == NULL )
  45. mDtect = LoadLibrary("netdtect.dll");
  46. if ( mDtect != NULL )
  47. {
  48. if ( pProc == NULL )
  49. pProc = (T_PCIINFO)GetProcAddress( mDtect, "DetectReadPciSlotInformation" );
  50. if ( pProc != NULL )
  51. {
  52. PCI_SLOT_NUMBER pciSlot;
  53. pciSlot.u.AsULONG = Device;
  54. pciSlot.u.bits.DeviceNumber = Device;
  55. pciSlot.u.bits.FunctionNumber = Function;
  56. (*(T_PCIINFO)pProc)( BusNum, pciSlot.u.AsULONG, 0, sizeof(USHORT), &usVendor);
  57. (*(T_PCIINFO)pProc)( BusNum, pciSlot.u.AsULONG, sizeof(USHORT), sizeof(USHORT), &usDevice);
  58. }
  59. }
  60. wsprintf( buf, "\"%d\",\"%d\"", usVendor, usDevice );
  61. lstrcat( ReturnTextBuffer, buf );
  62. lstrcat( ReturnTextBuffer, "}" );
  63. *TextOut = ReturnTextBuffer;
  64. return TRUE;
  65. }