Class SetupApiFFM


public final class SetupApiFFM extends WindowsForeignFunctions
  • Field Details

    • SP_DEVICE_INTERFACE_DATA

      public static final StructLayout SP_DEVICE_INTERFACE_DATA
      SP_DEVICE_INTERFACE_DATA: cbSize (DWORD) + InterfaceClassGuid (GUID=16 bytes) + Flags (DWORD) + Reserved (ULONG_PTR=8 bytes on 64-bit)
    • DIGCF_PRESENT

      public static final int DIGCF_PRESENT
      See Also:
    • DIGCF_DEVICEINTERFACE

      public static final int DIGCF_DEVICEINTERFACE
      See Also:
    • SP_DEVINFO_DATA_SIZE

      public static final int SP_DEVINFO_DATA_SIZE
      SP_DEVINFO_DATA: cbSize(4) + ClassGuid(16) + DevInst(4) + Reserved(8 on x64) = 32 bytes.
      See Also:
    • SP_DEVINFO_DATA_DEVINST_OFFSET

      public static final long SP_DEVINFO_DATA_DEVINST_OFFSET
      See Also:
    • DICS_FLAG_GLOBAL

      public static final int DICS_FLAG_GLOBAL
      See Also:
    • DIREG_DEV

      public static final int DIREG_DEV
      See Also:
  • Constructor Details

    • SetupApiFFM

      public SetupApiFFM()
  • Method Details

    • SetupDiGetClassDevs

      public static Optional<MemorySegment> SetupDiGetClassDevs(MemorySegment classGuid, int flags)
    • SetupDiEnumDeviceInterfaces

      public static int SetupDiEnumDeviceInterfaces(MemorySegment hDevInfo, MemorySegment classGuid, int memberIndex, MemorySegment deviceInterfaceData)
      Parameters:
      hDevInfo - the device info set handle
      classGuid - the interface class GUID
      memberIndex - zero-based index of the interface to retrieve
      deviceInterfaceData - receives information about the device interface
      Returns:
      0 if no more items, 1 if success, -1 on other error
    • SetupDiGetDeviceInterfaceDetailSize

      public static int SetupDiGetDeviceInterfaceDetailSize(MemorySegment hDevInfo, MemorySegment deviceInterfaceData, Arena arena)
      First call with null detail buffer to get required size.
      Parameters:
      hDevInfo - the device info set handle
      deviceInterfaceData - the device interface data
      arena - the arena to allocate the size buffer from
      Returns:
      required buffer size, or 0 on unexpected error
    • SetupDiGetDeviceInterfaceDetail

      public static Optional<String> SetupDiGetDeviceInterfaceDetail(MemorySegment hDevInfo, MemorySegment deviceInterfaceData, int requiredSize, Arena arena)
      Second call with allocated buffer to get device path. The detail buffer layout is: cbSize (DWORD=4) + DevicePath (WCHAR[]). On 64-bit, cbSize field value must be 8; on 32-bit it is 5 or 6.
      Parameters:
      hDevInfo - the device info set handle
      deviceInterfaceData - the device interface data
      requiredSize - the buffer size returned by SetupDiGetDeviceInterfaceDetailSize(MemorySegment, MemorySegment, Arena)
      arena - the arena to allocate buffers from
      Returns:
      the device path string, or empty if failed
    • SetupDiDestroyDeviceInfoList

      public static OptionalInt SetupDiDestroyDeviceInfoList(MemorySegment hDevInfo)
    • SetupDiEnumDeviceInfo

      public static boolean SetupDiEnumDeviceInfo(MemorySegment hDevInfo, int memberIndex, MemorySegment devInfoData)
      Enumerates device info elements in a device info set.
      Parameters:
      hDevInfo - the device info set handle
      memberIndex - zero-based index
      devInfoData - receives the device info data (must be pre-allocated with cbSize set)
      Returns:
      true if successful, false if no more items or error
    • SetupDiOpenDevRegKey

      public static MemorySegment SetupDiOpenDevRegKey(MemorySegment hDevInfo, MemorySegment devInfoData, int scope, int hwProfile, int keyType, int samDesired)
      Opens a registry key for device-specific configuration information.
      Parameters:
      hDevInfo - the device info set handle
      devInfoData - the device info data
      scope - DICS_FLAG_GLOBAL or DICS_FLAG_CONFIGSPECIFIC
      hwProfile - hardware profile (0 for current)
      keyType - DIREG_DEV or DIREG_DRV
      samDesired - registry access mask (e.g. KEY_QUERY_VALUE)
      Returns:
      registry key handle, or null if failed