IOKitUtil (JNA API)
Description: declaration: package: com.sun.jna.platform.mac, class: IOKitUtil

Package com.sun.jna.platform.mac

# Class IOKitUtil

java.lang.Object
com.sun.jna.platform.mac.IOKitUtil

public class IOKitUtil extends Object
Provides utilities for IOKit.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static CoreFoundation.CFMutableDictionaryRef`
  `getBSDNameMatchingDict(String bsdName)`
  Convenience method to get the IO dictionary matching a bsd name.
  `static int`
  `getMasterPort()`
  Gets a pointer to the Mach Master Port.
  `static IOKit.IOService`
  `getMatchingService(CoreFoundation.CFDictionaryRef matchingDictionary)`
  Opens a the first IOService matching a dictionary.
  `static IOKit.IOService`
  `getMatchingService(String serviceName)`
  Opens a the first IOService matching a service name.
  `static IOKit.IOIterator`
  `getMatchingServices(CoreFoundation.CFDictionaryRef matchingDictionary)`
  Convenience method to get IOService objects matching a dictionary.
  `static IOKit.IOIterator`
  `getMatchingServices(String serviceName)`
  Convenience method to get IOService objects matching a service name.
  `static IOKit.IORegistryEntry`
  `getRoot()`
  Gets the IO Registry root.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### getMasterPort

    public static int getMasterPort()
    Gets a pointer to the Mach Master Port.
    Returns:
      The master port.

      Multiple calls to `getMasterPort()` will not result in leaking ports (each call to `IOKit.IOMasterPort(int, com.sun.jna.ptr.IntByReference)` adds another send right to the port) but it is considered good programming practice to deallocate the port when you are finished with it, using `SystemB.mach_port_deallocate(int, int)`.

  - ### getRoot

    public static IOKit.IORegistryEntry getRoot()
    Gets the IO Registry root.
    Returns:
      a handle to the IORoot. Callers should release when finished, using `IOKit.IOObjectRelease(com.sun.jna.platform.mac.IOKit.IOObject)`.

  - ### getMatchingService

    public static IOKit.IOService getMatchingService(String serviceName)
    Opens a the first IOService matching a service name.
    Parameters:
      `serviceName` - The service name to match
    Returns:
      a handle to an IOService if successful, `null` if failed. Callers should release when finished, using `IOKit.IOObjectRelease(com.sun.jna.platform.mac.IOKit.IOObject)`.

  - ### getMatchingService

    public static IOKit.IOService getMatchingService(CoreFoundation.CFDictionaryRef matchingDictionary)
    Opens a the first IOService matching a dictionary.
    Parameters:
      `matchingDictionary` - The dictionary to match. This method will consume a reference to the dictionary.
    Returns:
      a handle to an IOService if successful, `null` if failed. Callers should release when finished, using `IOKit.IOObjectRelease(com.sun.jna.platform.mac.IOKit.IOObject)`.

  - ### getMatchingServices

    public static IOKit.IOIterator getMatchingServices(String serviceName)
    Convenience method to get IOService objects matching a service name.
    Parameters:
      `serviceName` - The service name to match
    Returns:
      a handle to an IOIterator if successful, `null` if failed. Callers should release when finished, using `IOKit.IOObjectRelease(com.sun.jna.platform.mac.IOKit.IOObject)`.

  - ### getMatchingServices

    public static IOKit.IOIterator getMatchingServices(CoreFoundation.CFDictionaryRef matchingDictionary)
    Convenience method to get IOService objects matching a dictionary.
    Parameters:
      `matchingDictionary` - The dictionary to match. This method will consume a reference to the dictionary.
    Returns:
      a handle to an IOIterator if successful, `null` if failed. Callers should release when finished, using `IOKit.IOObjectRelease(com.sun.jna.platform.mac.IOKit.IOObject)`.

  - ### getBSDNameMatchingDict

    public static CoreFoundation.CFMutableDictionaryRef getBSDNameMatchingDict(String bsdName)
    Convenience method to get the IO dictionary matching a bsd name.
    Parameters:
      `bsdName` - The bsd name of the registry entry
    Returns:
      The dictionary ref if successful, `null` if failed. Callers should release when finished, using `IOKit.IOObjectRelease(com.sun.jna.platform.mac.IOKit.IOObject)`.