[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 370
  • Last Modified:

Enumerating PciBusNumber PciDeviceNumber PciFunctionNumber in C++


Hi,

I know how to enumerate all network cards using the SetupDiGetClassDevs, SetupDiGetDeviceInstanceId and SetupDiGetDeviceRegistryProperty API calls. However I need to go a step further and get the PciBusNumber PciDeviceNumber PciFunctionNumber for each network adapter installed - any ideas?

Many thanks in advance, if you can please try to include sample code - I'm rather new to C++ ...
0
dcx45
Asked:
dcx45
  • 2
1 Solution
 
dcx45Author Commented:
Found the function - it's called

NTSTATUS
  IoGetDeviceProperty(
    IN PDEVICE_OBJECT  DeviceObject,
    IN DEVICE_REGISTRY_PROPERTY  DeviceProperty,
    IN ULONG  BufferLength,
    OUT PVOID  PropertyBuffer,
    OUT PULONG  ResultLength
    );

Now, how do I get hold of PDEVICE_OBJECT???? (Ok that changes my initial question a bit, but hopefully I'll get there...)
0
 
dcx45Author Commented:
Right  foiund the funtction to get the pointer

NTSTATUS
  IoGetDeviceObjectPointer(
    IN PUNICODE_STRING  ObjectName,
    IN ACCESS_MASK  DesiredAccess,
    OUT PFILE_OBJECT  *FileObject,
    OUT PDEVICE_OBJECT  *DeviceObject
    );

What format does the ObjectName need to be in - it's frustrating that MSDN doesn't include code samples for this
0
 
Svetlin_PanayotovCommented:
For example
RtlInitUnicodeString(&ObjName, L"\\Device\\00000050");
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now