### Implement a Custom Start Method
Source: https://developer.apple.com/documentation/driverkit/impl
Example of using the IMPL macro to define a custom Start method in an IOService subclass without specifying parameters.
```c
kern_return_t IMPL(MyCustomService, Start)
{
// Custom code here...
}
```
--------------------------------
### virtual kern_return_t Start(IOService *provider)
Source: https://developer.apple.com/documentation/driverkit/ioservice/start
Starts the current service and associates it with the specified provider.
```APIDOC
## Start
### Description
Starts the current service and associates it with the specified provider. After matching the provider, the system instantiates the service object and calls this method to configure data structures and hardware.
### Method
Virtual Method
### Parameters
#### Path Parameters
- **provider** (IOService*) - Required - The provider object that matches the current service.
### Return Value
- **kIOReturnSuccess** - Returned on success, or another error code if an operation fails.
```
--------------------------------
### Implement Start Method for HIDKeyboardDriver
Source: https://developer.apple.com/documentation/driverkit/creating-a-driver-using-the-driverkit-sdk
Template for the Start method in a DriverKit service. It calls the superclass implementation, performs startup tasks, and registers the service with the system. Ensure to handle errors by calling Stop if the superclass Start fails.
```cpp
IMPL(HIDKeyboardDriver, Start)
{
kern_return_t ret;
// Call the superclass implementation of Start.
ret = Start(provider, SUPERDISPATCH);
if (ret != kIOReturnSuccess) {
Stop(provider, SUPERDISPATCH);
return ret;
}
// Perform startup tasks...
// Register the service with the system.
RegisterService();
return ret;
}
```
--------------------------------
### Instance Method: init
Source: https://developer.apple.com/documentation/driverkit/ioservice/init
Handles the basic initialization of the service. The system calls this method shortly after it instantiates your custom IOService subclass, and before it calls the Start method of your service. Limit the work you do in this method to simple tasks that must occur before your service starts. For example, use this method to allocate memory for your ivars structure. Always call super early in your implementation of this method.
```APIDOC
## Instance Method: init
### Description
Handles the basic initialization of the service. The system calls this method shortly after it instantiates your custom `IOService` subclass, and before it calls the `Start` method of your service. Limit the work you do in this method to simple tasks that must occur before your service starts. For example, use this method to allocate memory for your `ivars` structure. Always call `super` early in your implementation of this method.
### Method
`virtual bool init();`
### Return Value
`true` if initialization was successful, or `false` if an error occurred.
### See Also
- `Start`
- `Stop`
- `free`
```
--------------------------------
### Start method declaration
Source: https://developer.apple.com/documentation/driverkit/ioservice/start
Defines the signature for the Start method within an IOService subclass.
```cpp
virtual kern_return_t Start(IOService *provider);
```
--------------------------------
### Rigid Disk Geometry Example
Source: https://developer.apple.com/documentation/driverkit/kiopropertyheadcountkey
An example demonstrating the usage of kIOPropertyHeadCountKey within a dictionary structure.
```APIDOC
### Example
```xml
Device Characteristics
Vendor Name
Apple
Product Name
iPod
Product Revision Level
1.0
Rigid Disk Geometry
Sector Count per Track
12345
Head Count
12
Cylinder Count
12345
Bytes per Physical Sector
512
```
```
--------------------------------
### IOService Base Class Example
Source: https://developer.apple.com/documentation/driverkit
IOService is the base class for managing the setup and registration of your driver. This is a conceptual representation.
```cpp
class MyDriver : public IOService
{
OSDeclareDefaultStructors(MyDriver)
public:
virtual bool init(OSDictionary *dict = 0) override;
virtual bool start(IOService *provider) override;
virtual void stop(IOService *provider) override;
};
```
--------------------------------
### Install and Run DriverKit Extension on macOS
Source: https://developer.apple.com/documentation/driverkit/communicating-between-a-driverkit-extension-and-a-client-app
This section details the process of installing and running a DriverKit extension on macOS using the provided sample app. It covers enabling developer mode and confirming installation.
```bash
systemextensionsctl list
```
--------------------------------
### Example Device Characteristics Dictionary
Source: https://developer.apple.com/documentation/driverkit/kiopropertymediumtypesolidstatekey
This example shows how to use the 'Medium Type' key with the value 'Solid State' within a device's characteristics dictionary. This is often used in conjunction with keys like kIOPropertyMediumTypeSolidStateKey.
```xml
Device Characteristics
Vendor Name
AAPL
Product Name
FireWire Target
Product Revision Level
0000
Medium Type
Solid State
```
--------------------------------
### Invoke Inherited Method with SUPERDISPATCH
Source: https://developer.apple.com/documentation/driverkit/superdispatch
Example of calling an inherited Start method from a custom IOService subclass using the SUPERDISPATCH macro.
```c
kern_return_t IMPL(MyCustomService, Start)
{
kern_return_t ret;
ret = Start(provider, SUPERDISPATCH);
// Other Start code...
}
```
--------------------------------
### Example Rigid Disk Geometry Dictionary
Source: https://developer.apple.com/documentation/driverkit/kiopropertycylindercountkey
This example demonstrates the structure of a Rigid Disk Geometry dictionary, including the kIOPropertyCylinderCountKey to specify the number of heads.
```xml
Device Characteristics
Vendor Name
Apple
Product Name
iPod
Product Revision Level
1.0
Rigid Disk Geometry
Sector Count per Track
12345
Head Count
12
Cylinder Count
12345
Bytes per Physical Sector
512
```
--------------------------------
### Example Dictionary for Optical Device Characteristics
Source: https://developer.apple.com/documentation/driverkit/kiopropertysupportedbdfeatureskey
This example shows how to represent the characteristics of an optical device, including Vendor Name, Product Name, and specific features like CD, DVD, and BD Features using integer values.
```xml
Device Characteristics
Vendor Name
Apple
Product Name
SuperDrive
Product Revision Level
1.0
CD Features
1663
DVD Features
103
BD Features
21
```
--------------------------------
### Device Characteristics Example with Medium Type
Source: https://developer.apple.com/documentation/driverkit/kiopropertymediumtypekey
This example shows how to use the 'Medium Type' key within a device's characteristics dictionary to specify its medium. This is useful for identifying device properties.
```xml
Device Characteristics
Vendor Name
AAPL
Product Name
FireWire Target
Product Revision Level
0000
Medium Type
Rotational
```
--------------------------------
### Example Usage of Target Disk Mode
Source: https://developer.apple.com/documentation/driverkit/kiopropertytargetdiskmodekey
This example shows how to use the kIOPropertyTargetDiskModeKey within a property dictionary to signify that a device is in Target Disk Mode. This is typically used for indicating a computer is in Target Disk Mode.
```plist
Device Characteristics
Vendor Name
AAPL
Product Name
FireWire Target
Product Revision Level
0000
Target Disk Mode
```
--------------------------------
### Device Characteristics Property List Example
Source: https://developer.apple.com/documentation/driverkit/kiopropertylogicalblocksizekey
Example property list configuration for a device specifying physical and logical block sizes.
```xml
Device Characteristics
Vendor Name
Apple
Product Name
iPod
Product Revision Level
1.0
Physical Block Size
4096
Logical Block Size
512
```
--------------------------------
### Install an Aborted Handler
Source: https://developer.apple.com/documentation/driverkit/osaction/setabortedhandler
Use this function to install a handler block that the system will call when no other processes reference the action object. Specify NULL to remove an existing handler.
```c
kern_return_t SetAbortedHandler(OSActionAbortedHandler handler);
```
--------------------------------
### Example Dictionary Structure for Card Characteristics
Source: https://developer.apple.com/documentation/driverkit/kiopropertyproductserialnumberkey
This example demonstrates how to structure a dictionary to represent card characteristics, including the serial number, using the kIOPropertyProductSerialNumberKey.
```xml
Card Characteristics
Product Name
SD32G
Product Revision Level
1.0
Card Type
SDHC
Serial Number
0045ff
```
--------------------------------
### Service Lifecycle Management
Source: https://developer.apple.com/documentation/driverkit/ioservice
Methods for initializing, starting, stopping, and cleaning up IO services.
```APIDOC
## `init`
### Description
Handles the basic initialization of the service.
## `Start`
### Description
Starts the current service and associates it with the specified provider.
## `Stop`
### Description
Stops the service associated with the specified provider.
## `free`
### Description
Performs any final cleanup for the service.
```
--------------------------------
### Example Rigid Disk Geometry Dictionary
Source: https://developer.apple.com/documentation/driverkit/kiopropertysectorcountpertrackkey
This example demonstrates how to use the kIOPropertySectorCountPerTrackKey within a dictionary to specify device characteristics, including rigid disk geometry. The 'Sector Count per Track' is an integer value.
```xml
Device Characteristics
Vendor Name
Apple
Product Name
iPod
Product Revision Level
1.0
Rigid Disk Geometry
Sector Count per Track
12345
```
--------------------------------
### GET /driverkit/queue_entry/next
Source: https://developer.apple.com/documentation/driverkit/queue_entry/next
Documentation for the next property of the queue_entry structure.
```APIDOC
## Property: next
### Description
The next property is a pointer to the next queue_entry structure in the queue.
### Definition
```struct queue_entry * next;```
### Platforms
- iOS
- iPadOS
- macOS
```
--------------------------------
### RegisterService Method
Source: https://developer.apple.com/documentation/driverkit/ioservice/registerservice
Starts the registration process for the service and performs any additional matching.
```APIDOC
## RegisterService
### Description
Starts the registration process for the service and performs any additional matching. This method should be called after setting up the service in the custom Start method to notify the system that the service is running.
### Method
Method Call
### Endpoint
RegisterService()
### Return Value
- **kIOReturnSuccess** (kern_return_t) - Returned on success, or another error code if the registration fails.
```
--------------------------------
### IOTimerDispatchSource Example
Source: https://developer.apple.com/documentation/driverkit
IOTimerDispatchSource notifies your driver at a specific time. Use this for scheduled tasks.
```cpp
IOTimerDispatchSource *timerSource = IOTimerDispatchSource::create(myTimerHandler);
timerSource->schedule(kIOPriorityHigh, 1000000); // Schedule in 1ms
```
--------------------------------
### Subclassing IOUserNetworkEthernet
Source: https://developer.apple.com/documentation/driverkit/creating-a-driver-using-the-driverkit-sdk
Example of defining a custom interface service by subclassing IOUserNetworkEthernet in an .iig file.
```C++
class MyCustomDriver: public IOUserNetworkEthernet
{
public:
virtual kern_return_t
Start(IOService * provider) override;
};
```
--------------------------------
### GET /libkern/safe_allocation/begin
Source: https://developer.apple.com/documentation/driverkit/libkern/safe_allocation/begin-tww
Retrieves a constant iterator to the start of the safe_allocation container.
```APIDOC
## begin
### Description
Returns a const_iterator to the beginning of the safe_allocation container.
### Method
Instance Method
### Signature
`const_iterator begin() const noexcept;`
```
--------------------------------
### init Method
Source: https://developer.apple.com/documentation/driverkit/osmappedfile/init
Initializes an OSMappedFile instance.
```APIDOC
## init
### Description
Initializes an OSMappedFile instance.
### Method
N/A (Instance Method)
### Endpoint
OSMappedFile::init()
### Request Example
virtual bool init();
```
--------------------------------
### GET getNextIndexOfObject
Source: https://developer.apple.com/documentation/driverkit/osarray/getnextindexofobject
Searches the OSArray for a specific object starting from a provided index.
```APIDOC
## getNextIndexOfObject
### Description
Searches the array for an object starting from a specified index using pointer equality.
### Method
Instance Method
### Parameters
#### Path Parameters
- **anObject** (const OSMetaClassBase *) - Required - The object to search for.
- **index** (uint32_t) - Required - Zero based index less than the array count to begin the search.
### Return Value
- **uint32_t** - Index at which the object was found, or -1U if the member was not found in the array after the index parameter.
```
--------------------------------
### GET GetOffset
Source: https://developer.apple.com/documentation/driverkit/iomemorymap/getoffset
Retrieves the offset from the start of the original memory block for an IOMemoryMap object.
```APIDOC
## GetOffset
### Description
Returns the number of bytes from the start of the original block of memory to the first byte of this memory map object.
### Method
GET
### Endpoint
IOMemoryMap::GetOffset()
### Return Value
- **uint64_t** - The number of bytes from the start of the original block of memory to the first byte of this memory map object.
```
--------------------------------
### IOInterruptDispatchSource Example
Source: https://developer.apple.com/documentation/driverkit
IOInterruptDispatchSource reports hardware-related interrupt events to your driver. It requires proper setup to handle interrupts.
```cpp
IOInterruptDispatchSource *interruptSource = IOInterruptDispatchSource::create(myInterruptHandler);
myInterruptSource->activate();
```
--------------------------------
### init Method
Source: https://developer.apple.com/documentation/driverkit/iodmacommand/init
Initializes an IODMACommand instance.
```APIDOC
## init
### Description
Initializes an IODMACommand object.
### Method
Instance Method
### Endpoint
IODMACommand::init()
### Response
- **bool** - Returns true if the initialization is successful, false otherwise.
```
--------------------------------
### Add arm64e preview boot argument
Source: https://developer.apple.com/documentation/driverkit/debugging-and-testing-system-extensions
Use this command to enable the arm64e preview ABI for testing driver extensions on Apple silicon.
```shell
sudo nvram boot-args=-arm64e_preview_abi
```
--------------------------------
### Get Offset from Memory Block Start
Source: https://developer.apple.com/documentation/driverkit/iomemorymap/getoffset
Use this method to determine the byte offset from the original memory buffer's start to the beginning of the current memory map object. This is helpful when you've mapped a sub-section of a larger buffer.
```c
uint64_t GetOffset();
```
--------------------------------
### Get Iterator to Beginning of Container
Source: https://developer.apple.com/documentation/driverkit/libkern/bounded_array/begin-29xl0
Returns a constant iterator pointing to the beginning of the container. Use this to start iterating over elements.
```cpp
const_iterator begin() const noexcept;
```
--------------------------------
### Instance Method: begin()
Source: https://developer.apple.com/documentation/driverkit/libkern/safe_allocation/begin-3dcll
The begin() method returns an iterator to the beginning of a collection. It is available on iOS, iPadOS, and macOS.
```APIDOC
## Instance Method: begin()
### Description
Returns an iterator to the beginning of a collection.
### Method
`noexcept`
### Endpoint
N/A (Instance Method)
### Parameters
None
### Request Example
N/A
### Response
#### Success Response
- **iterator** (iterator type) - An iterator pointing to the first element.
#### Response Example
```cpp
iterator it = collection.begin();
```
```
--------------------------------
### static kern_return_t Create
Source: https://developer.apple.com/documentation/driverkit/iouserserver/create
Creates a new IOUserServer instance.
```APIDOC
## static kern_return_t Create
### Description
Creates a new IOUserServer instance.
### Method
Static Method
### Parameters
- **name** (const char[64]) - Required - The name of the server.
- **tag** (uint64_t) - Required - A tag associated with the server.
- **options** (uint64_t) - Required - Configuration options for the server.
- **bundleID** (OSString *) - Required - The bundle identifier for the server.
- **server** (IOUserServer **) - Required - A pointer to receive the created IOUserServer instance.
### Request Example
static kern_return_t Create(const char name[64], uint64_t tag, uint64_t options, OSString *bundleID, IOUserServer **server);
```
--------------------------------
### Get Pointer to OSData Buffer
Source: https://developer.apple.com/documentation/driverkit/osdata/getbytesnocopy-53puz
Use getBytesNoCopy to retrieve a pointer to the internal data buffer of an OSData object. Ensure that the requested range (start + numBytes) does not exceed the object's total length to avoid failure. The method returns NULL if the requested range is invalid.
```c++
const void * getBytesNoCopy(size_t start, size_t numBytes) const;
```
--------------------------------
### IOCommandPool::init
Source: https://developer.apple.com/documentation/driverkit/iocommandpool/init
Initializes an instance of an IOCommandPool.
```APIDOC
## init
### Description
Initializes an IOCommandPool instance.
### Method
Instance Method
### Signature
`virtual bool init();`
```
--------------------------------
### OSDictionary Example
Source: https://developer.apple.com/documentation/driverkit
OSDictionary is a container for key-value pairs. Use for mapping names to values.
```cpp
OSDictionary *myDict = OSDictionary::withCapacity(5);
myDict->setObject(OSString::withCString("key1"), OSNumber::withNumber(100));
```
--------------------------------
### Initialize IOStateReporter with static method
Source: https://developer.apple.com/documentation/driverkit/iostatereporter/with
Use this method to create an instance of IOStateReporter. Ensure the reportingService is valid before invocation.
```cpp
static IOStateReporter * with(IOService *reportingService, IOReportCategories categories, int nstates, IOReportUnit unit);
```
--------------------------------
### Boot Support
Source: https://developer.apple.com/documentation/driverkit/c-runtime-support
Utilities for parsing boot arguments.
```APIDOC
## Boot Support
### `IOParseBootArgNumber`
Parses any boot arguments in the macOS kernel boot-args.
### `IOParseBootArgString`
Parses any boot arguments in the macOS kernel boot-args.
```
--------------------------------
### Device Characteristics Dictionary Example
Source: https://developer.apple.com/documentation/driverkit/kiopropertydevicecharacteristicskey
Example of the dictionary structure required for defining device characteristics.
```XML
Device Characteristics
Vendor Name
Apple
Product Name
iPod
Product Revision Level
1.0
```
--------------------------------
### Device Characteristics Property List Example
Source: https://developer.apple.com/documentation/driverkit/kiopropertymediumtyperotationalkey
An example of a property list dictionary specifying rotational medium type.
```xml
Device Characteristics
Vendor Name
AAPL
Product Name
FireWire Target
Product Revision Level
0000
Medium Type
Rotational
```
--------------------------------
### Device Characteristics Property List Example
Source: https://developer.apple.com/documentation/driverkit/kiopropertymediumrotationratekey
An example of a property list dictionary containing device characteristics, including a rotation rate integer.
```xml
Device Characteristics
Vendor Name
AAPL
Product Name
FireWire Target
Product Revision Level
0000
Rotation Rate
7200
```
--------------------------------
### IOSimpleReporter: initWith
Source: https://developer.apple.com/documentation/driverkit/iosimplereporter/initwith
Initializes an IOSimpleReporter instance with a reporting service, categories, and unit.
```APIDOC
## initWith
### Description
Initializes a new instance of IOSimpleReporter with the specified reporting service, categories, and unit.
### Method
Instance Method
### Parameters
- **reportingService** (IOService*) - Required - The reporting service to be used.
- **categories** (IOReportCategories) - Required - The categories for the report.
- **unit** (IOReportUnit) - Required - The unit for the report.
### Request Example
bool initWith(IOService *reportingService, IOReportCategories categories, IOReportUnit unit);
```
--------------------------------
### Initialize IOSimpleReporter
Source: https://developer.apple.com/documentation/driverkit/iosimplereporter/initwith
Initializes a new reporter instance using the specified service, categories, and unit.
```cpp
bool initWith(IOService *reportingService, IOReportCategories categories, IOReportUnit unit);
```
--------------------------------
### Instance Method: get
Source: https://developer.apple.com/documentation/driverkit/ossharedptr/get-3c2qe
This instance method returns a constant pointer. It is marked as noexcept, indicating it will not throw exceptions.
```APIDOC
## Instance Method: get
### Description
Returns a constant pointer to the underlying data. This method is marked `noexcept`, guaranteeing it will not throw exceptions.
### Method
`get`
### Endpoint
N/A (Instance Method)
### Parameters
None
### Request Body
None
### Response
#### Success Response
- **pointer** (constexpr pointer) - A constant pointer to the object.
### Response Example
```cpp
constexpr pointer get() const noexcept;
```
```
--------------------------------
### DriverKit init Method
Source: https://developer.apple.com/documentation/driverkit/iodataqueuedispatchsource/init
Handles the basic initialization of the dispatch source. This method should not be called directly; use Create instead.
```APIDOC
## init
### Description
Handles the basic initialization of the dispatch source.
### Method
```swift
virtual bool init();
```
### Return Value
`true` if initialization was successful, or `false` if an error occurred.
### Discussion
Don’t call this method directly. Call `Create` when you want to create a new data-queue dispatch source.
### See Also
- `Create`
- `free`
```
--------------------------------
### Example Device Characteristics Property List
Source: https://developer.apple.com/documentation/driverkit/kiopropertysupportedcdfeatureskey
A property list snippet demonstrating how to define device characteristics including CD and DVD features.
```xml
Device Characteristics
Vendor Name
Apple
Product Name
SuperDrive
Product Revision Level
1.0
CD Features
1663
DVD Features
103
```
--------------------------------
### Configuring the Timer Source
Source: https://developer.apple.com/documentation/driverkit/iotimerdispatchsource
Details on how to create, initialize, and free an IOTimerDispatchSource, and how to set the handler block.
```APIDOC
### Configuring the Timer Source
`Create`
Creates and configures a timer dispatch object.
`init`
Handles the basic initialization of the dispatch source.
`free`
Performs any final cleanup for the timer dispatch source.
`SetHandler`
Sets the handler block to run when the timer fires.
```
--------------------------------
### init Method
Source: https://developer.apple.com/documentation/driverkit/iobuffermemorydescriptor/init
Initializes the buffer memory descriptor object. Note that this method should not be called directly; use the Create method instead.
```APIDOC
## init
### Description
Initializes the buffer memory descriptor object. Do not call this method directly; use the Create method instead.
### Method
N/A (Instance Method)
### Return Value
- **bool** - true if initialization was successful, or false if it was unsuccessful.
```
--------------------------------
### static kern_return_t Create
Source: https://developer.apple.com/documentation/driverkit/iodmacommand/create
Creates a new IODMACommand instance for a specified device and specification.
```APIDOC
## static kern_return_t Create
### Description
Creates a new IODMACommand instance for a specified device and specification.
### Method
Static Method
### Parameters
- **device** (IOService *) - Required - The device associated with the DMA command.
- **options** (uint64_t) - Required - Configuration options for the command.
- **specification** (const IODMACommandSpecification *) - Required - The specification defining the DMA command requirements.
- **command** (IODMACommand **) - Required - Output parameter that receives the created IODMACommand instance.
### Request Example
static kern_return_t Create(IOService *device, uint64_t options, const IODMACommandSpecification *specification, IODMACommand **command);
```
--------------------------------
### Method: begin()
Source: https://developer.apple.com/documentation/driverkit/libkern/bounded_array_ref/begin
Returns an iterator to the beginning of the bounded_array_ref.
```APIDOC
## begin
### Description
Returns an iterator to the beginning of the bounded_array_ref.
### Signature
`iterator begin() const noexcept;`
### Platforms
- DriverKit
- iOS
- iPadOS
- macOS
```
--------------------------------
### GET /getMetaClass
Source: https://developer.apple.com/documentation/driverkit/osmetaclassbase/getmetaclass
Documentation for the getMetaClass instance method.
```APIDOC
## getMetaClass
### Description
Internal helper for GetClassName. Not to be called directly.
### Method
Instance Method
### Signature
`virtual const OSMetaClass * getMetaClass() const;`
### See Also
- IsRemote
- GetClass
- GetClassName
```
--------------------------------
### GET /libkern/safe_allocation/size
Source: https://developer.apple.com/documentation/driverkit/libkern/safe_allocation/size
Retrieves the size of a safe_allocation object.
```APIDOC
## size()
### Description
Returns the size of the safe_allocation object.
### Method
Instance Method
### Signature
size_t size() const;
```
--------------------------------
### IOUserServer Class Overview
Source: https://developer.apple.com/documentation/driverkit/iouserserver
Overview of the IOUserServer class, its lifecycle management methods, and its inheritance from IOService.
```APIDOC
## IOUserServer
### Description
A system-managed service class used to manage individual services within DriverKit. Developers do not create or use instances of this class directly.
### Inheritance
- Inherits from: IOService
### Methods
- **Create**: Initializes the server instance.
- **init**: Initializes the object.
- **free**: Deallocates the object.
- **LoadModule**: Manages the loading of modules for the server.
- **Exit**: Manages the server lifecycle exit process.
- **RegisterService**: Registers a service with the system.
- **Panic**: Triggers a system panic.
```
--------------------------------
### IOMemoryMap Example
Source: https://developer.apple.com/documentation/driverkit
IOMemoryMap provides a reference to an existing block of memory, potentially in another process. Use for memory mapping.
```cpp
IOMemoryMap *memoryMap = IOMemoryMap::withIOMemoryDescriptor(memoryDescriptor, 0, 0, kIOMapInhibitCache);
if (memoryMap) {
// Access mapped memory
memoryMap->release();
}
```
--------------------------------
### DriverKit init Method
Source: https://developer.apple.com/documentation/driverkit/iodispatchsource/init
Handles the basic initialization of the dispatch source.
```APIDOC
## DriverKit init Method
### Description
Handles the basic initialization of the dispatch source.
### Method
`virtual bool init();`
### Return Value
`true` if initialization was successful, or `false` if an error occurred.
### See Also
- `free`
- `Cancel`
```
--------------------------------
### GET /libkern/bounded_array_ref/size
Source: https://developer.apple.com/documentation/driverkit/libkern/bounded_array_ref/size
Returns the size of the bounded_array_ref object.
```APIDOC
## size
### Description
Returns the number of elements in the bounded_array_ref.
### Method
constexpr size_t size() const noexcept;
### Response
- **size_t** - The number of elements in the array.
```
--------------------------------
### IOStateReporter initWith
Source: https://developer.apple.com/documentation/driverkit/iostatereporter/initwith
Initializes an IOStateReporter instance. This method is used to set up the reporter with the service to monitor, the categories of states to report, the number of states, and the unit of measurement for the states.
```APIDOC
## initWith
### Description
Initializes an IOStateReporter instance.
### Method Signature
```
bool initWith(IOService *reportingService, IOReportCategories categories, int nstates, IOReportUnit unit);
```
### Parameters
* **reportingService** (*IOService* *) - The service to report states for.
* **categories** (*IOReportCategories*) - The categories of states to report.
* **nstates** (*int*) - The number of states.
* **unit** (*IOReportUnit*) - The unit of measurement for the states.
### Return Value
* **bool** - Returns true if the initialization was successful, false otherwise.
```
--------------------------------
### GET /libkern/bounded_array/size
Source: https://developer.apple.com/documentation/driverkit/libkern/bounded_array/size
Retrieves the size of the bounded_array instance.
```APIDOC
## size
### Description
Returns the number of elements in the bounded_array.
### Method
constexpr size_t size() const noexcept;
### Response
- **size_t** - The number of elements currently in the bounded_array.
```
--------------------------------
### Initialize OSSharedPtr
Source: https://developer.apple.com/documentation/driverkit/ossharedptr/ossharedptr_t_-32r9g
Default constructor for creating an empty OSSharedPtr instance.
```cpp
OSSharedPtr() noexcept;
```
--------------------------------
### GET /libkern/bounded_array/length
Source: https://developer.apple.com/documentation/driverkit/libkern/bounded_array/length
Retrieves the length of a bounded_array instance.
```APIDOC
## length
### Description
Returns the number of elements in the bounded_array.
### Method
constexpr size_t length() const noexcept;
### Response
- **return** (size_t) - The length of the array.
```
--------------------------------
### Initialize a queue with queue_init
Source: https://developer.apple.com/documentation/driverkit/queue_init
Use this macro to initialize a queue object.
```c
#define queue_init(q)
```
--------------------------------
### DriverKit Create Method Signature
Source: https://developer.apple.com/documentation/driverkit/iouserserver/create
Use this method to create a new IOUserServer instance. It requires a name, tag, options, and bundle ID for configuration. The method returns a kern_return_t status code and an IOUserServer pointer.
```c
static kern_return_t Create(const char name[64], uint64_t tag, uint64_t options, OSString *bundleID, IOUserServer **server);
```
--------------------------------
### GET getLastObject
Source: https://developer.apple.com/documentation/driverkit/osorderedset/getlastobject
Retrieves the last object from an OSOrderedSet instance.
```APIDOC
## GET getLastObject
### Description
Returns the last object in the ordered set. If the set is empty, it returns NULL.
### Method
Instance Method
### Parameters
None
### Request Example
OSObject * getLastObject() const;
### Response
- **Return Value** (OSObject *) - The last object in the ordered set, or NULL if empty. Note: The returned object will be released if removed from the set; call retain if you need to store the reference.
```
--------------------------------
### GET getCapacity
Source: https://developer.apple.com/documentation/driverkit/oscollection/getcapacity
Retrieves the current capacity of an OSCollection instance.
```APIDOC
## getCapacity
### Description
Returns the capacity of the OSCollection instance.
### Method
GET
### Endpoint
OSCollection::getCapacity()
### Response
- **return** (uint32_t) - The current capacity of the collection.
```
--------------------------------
### Create OSBundle from Path
Source: https://developer.apple.com/documentation/driverkit/osbundle/createfrompath
Use this static method to create an OSBundle object from a specified file path. Ensure the path is valid.
```c
static OSBundle * createFromPath(const char *path);
```
--------------------------------
### Accessing kSCSICmd_VendorSpecific_Start
Source: https://developer.apple.com/documentation/driverkit/kscsicmd_vendorspecific_start
The constant representing the start of vendor-specific SCSI commands.
```C
kSCSICmd_VendorSpecific_Start
```
--------------------------------
### GET /DriverKit/SCSICmd_INQUIRY_StandardDataAll/flags2
Source: https://developer.apple.com/documentation/driverkit/scsicmd_inquiry_standarddataall/flags2
Documentation for the flags2 property found in the SCSICmd_INQUIRY_StandardDataAll structure.
```APIDOC
## flags2
### Description
An instance property representing a UInt8 value within the SCSICmd_INQUIRY_StandardDataAll structure.
### Type
UInt8
### Platforms
- iOS
- iPadOS
- macOS
```
--------------------------------
### static IOSimpleReporter * with
Source: https://developer.apple.com/documentation/driverkit/iosimplereporter/with
Initializes a new IOSimpleReporter instance with the specified reporting service, categories, and units.
```APIDOC
## static IOSimpleReporter * with
### Description
Creates and returns an instance of IOSimpleReporter for the provided reporting service.
### Method
Static Method
### Parameters
- **reportingService** (IOService*) - Required - The service providing the report.
- **categories** (IOReportCategories) - Required - The categories of reports to include.
- **unit** (IOReportUnit) - Required - The unit of measurement for the report.
### Request Example
static IOSimpleReporter * with(IOService *reportingService, IOReportCategories categories, IOReportUnit unit);
```
--------------------------------
### GET OSMappedFile::data
Source: https://developer.apple.com/documentation/driverkit/osmappedfile/data
Retrieves a pointer to the mapped file data.
```APIDOC
## data
### Description
Returns a pointer to the memory-mapped data associated with the OSMappedFile instance.
### Method
Instance Method
### Request Example
const void * data() const;
```
--------------------------------
### IOCommand Instance Methods
Source: https://developer.apple.com/documentation/driverkit/iocommand
Lists the instance methods available for the IOCommand class.
```APIDOC
## Instance Methods
### `CommandChain`
### `free`
### `init`
```
--------------------------------
### DriverKit init Method
Source: https://developer.apple.com/documentation/driverkit/iodispatchqueue/init
Initializes the dispatch queue object. This method should not be called directly; use `Create` instead.
```APIDOC
## init
### Description
Initializes the dispatch queue object.
### Method
virtual bool init();
### Endpoint
N/A (Instance Method)
### Parameters
None
### Request Body
None
### Response
#### Success Response (true)
`true` if initialization was successful.
#### Error Response (false)
`false` if initialization was unsuccessful.
### Discussion
Do not call this method directly. Call `Create` when you want to create a new dispatch queue.
### See Also
- Creating a Dispatch Queue
- `Create`
- `free`
```
--------------------------------
### GET OSClassLoadInformation description
Source: https://developer.apple.com/documentation/driverkit/osclassloadinformation/description
Retrieves the description property of an OSClassLoadInformation instance.
```APIDOC
## GET OSClassLoadInformation description
### Description
Retrieves the description property for an instance of OSClassLoadInformation.
### Property Definition
```const OSClassDescription * description;```
### See Also
- New
- instanceSize
- metaPointer
- resv2
- resv3
- version
```
--------------------------------
### GET OSArrayGetStringValue
Source: https://developer.apple.com/documentation/driverkit/osarraygetstringvalue
Retrieves a string value from an OSArray at the specified index.
```APIDOC
## GET OSArrayGetStringValue
### Description
Retrieves a string value from an OSArray object at a given index.
### Method
Function Call
### Parameters
- **obj** (OSArrayPtr) - Required - The OSArray object to query.
- **index** (size_t) - Required - The index of the element to retrieve.
### Request Example
const char *value = OSArrayGetStringValue(myArray, 0);
### Response
- **return** (const char *) - The string value at the specified index.
```
--------------------------------
### GET OSArray::getObject
Source: https://developer.apple.com/documentation/driverkit/osarray/getobject
Retrieves a member of the OSArray at the specified index.
```APIDOC
## getObject
### Description
Returns a member of the array at the specified index. The retain count of the returned object is not incremented.
### Method
Instance Method
### Parameters
#### Path Parameters
- **index** (uint32_t) - Required - Zero based index less than the array count.
### Return Value
- **OSObject*** - Member at the given index or NULL if the index is greater or equal to the array count.
```
--------------------------------
### GET /OSArray/getCapacity
Source: https://developer.apple.com/documentation/driverkit/osarray/getcapacity
Retrieves the total allocated capacity for members in an OSArray.
```APIDOC
## GET OSArray/getCapacity
### Description
Returns the count of currently allocated capacity for members in the array.
### Method
GET
### Endpoint
OSArray::getCapacity
### Return Value
- **uint32_t** - The capacity for members in the array.
### See Also
- **getCount**: Returns count of members in array.
- **ensureCapacity**: Allocates capacity for members in array.
- **OSArrayGetCount**: C-style function to get count.
```
--------------------------------
### static OSDictionary * CreateKernelClassMatchingDictionary(OSString *className, OSDictionary *matching)
Source: https://developer.apple.com/documentation/driverkit/ioservice/createkernelclassmatchingdictionary-9b28
Creates a dictionary used for matching kernel classes in DriverKit.
```APIDOC
## Static Method: CreateKernelClassMatchingDictionary
### Description
Creates a dictionary used to match kernel classes. This is a static method available in the DriverKit framework.
### Method
Static Function
### Parameters
- **className** (OSString*) - Required - The name of the kernel class to match.
- **matching** (OSDictionary*) - Required - An existing dictionary to be used for matching criteria.
### Response
- **OSDictionary*** - Returns a dictionary object configured for kernel class matching.
```
--------------------------------
### Create IOSimpleReporter Instance
Source: https://developer.apple.com/documentation/driverkit/iosimplereporter/with
Use this static method to create and initialize an IOSimpleReporter. Requires an IOService for reporting, IOReportCategories, and an IOReportUnit.
```objc
static IOSimpleReporter * with(IOService *reportingService, IOReportCategories categories, IOReportUnit unit);
```
--------------------------------
### GET mach_timebase_info.denom
Source: https://developer.apple.com/documentation/driverkit/mach_timebase_info-c.struct/denom
Accesses the denominator value of the timebase information structure.
```APIDOC
## GET mach_timebase_info.denom
### Description
The denom property represents the denominator of the fraction used to convert mach absolute time units into nanoseconds.
### Property Definition
`uint32_t denom;`
### See Also
- numer
```
--------------------------------
### init
Source: https://developer.apple.com/documentation/driverkit/ioextensiblepaniclog/init
Initializes an instance of IOExtensiblePaniclog. This is a virtual method provided by DriverKit.
```APIDOC
## init
### Description
Initializes an instance of the IOExtensiblePaniclog class. This method is part of the DriverKit framework and is available on iOS, iPadOS, and macOS.
### Method
`virtual bool init();`
### Parameters
This method does not take any parameters.
### Returns
Returns `true` if the initialization was successful, `false` otherwise.
```
--------------------------------
### GET /libkern/safe_allocation/data
Source: https://developer.apple.com/documentation/driverkit/libkern/safe_allocation/data-ndtq
Retrieves a pointer to the data managed by the safe_allocation object.
```APIDOC
## data()
### Description
Returns a pointer to the underlying data buffer managed by the safe_allocation instance.
### Method
Instance Method
### Signature
type-parameter-0-0 * data() noexcept;
```
--------------------------------
### init Method
Source: https://developer.apple.com/documentation/driverkit/iomemorymap/init
Initializes the memory map object. Note that this method should not be called directly; use IOMemoryDescriptor::CreateMapping instead.
```APIDOC
## init
### Description
Initializes the memory map object. Do not call this method directly; use the CreateMapping method of IOMemoryDescriptor to create a memory map object.
### Method
Virtual Method
### Return Value
- **bool** - Returns true if initialization was successful, or false if it was unsuccessful.
```
--------------------------------
### GET operator[]
Source: https://developer.apple.com/documentation/driverkit/libkern/bounded_array_ref/operator__
Accesses an element at a specific index within a bounded_array_ref.
```APIDOC
## operator[]
### Description
Provides indexed access to elements within a bounded_array_ref.
### Method
Instance Method
### Signature
type-parameter-0-0 & operator[](ptrdiff_t n) const;
### Parameters
- **n** (ptrdiff_t) - Required - The index of the element to access.
```
--------------------------------
### Instance Methods
Source: https://developer.apple.com/documentation/driverkit/ioservice
A collection of miscellaneous instance methods for IO services.
```APIDOC
## `AdjustBusy`
## `ClientCrashed`
## `ConfigureReport`
## `CopyName`
## `CopyProviderProperties`
## `CopySystemStateNotificationService`
## `CoreAnalyticsSendEvent`
## `CreateDefaultDispatchQueue`
## `GetBusyState`
## `GetProvider`
## `JoinPMTree`
## `RemoveProperty`
## `RequireMaxBusStall`
## `SetLegend`
## `SetPowerOverride`
## `StateNotificationItemCopy`
## `StateNotificationItemCreate`
## `StateNotificationItemSet`
## `Stop_async`
## `StringFromReturn`
## `Terminate`
## `UpdateReport`
## `CallPlatformFunction`
## `CreatePMAssertion`
## `ReleasePMAssertion`
```
--------------------------------
### GET /libkern/bounded_array/data
Source: https://developer.apple.com/documentation/driverkit/libkern/bounded_array/data-6lz82
Retrieves a pointer to the underlying data of a bounded_array instance.
```APIDOC
## data
### Description
Returns a pointer to the underlying data of the bounded_array.
### Method
constexpr type-parameter-0-0 * data() noexcept;
### Response
- **Return Type** (pointer) - A pointer to the first element of the array.
```
--------------------------------
### Related Methods
Source: https://developer.apple.com/documentation/driverkit/iorpc/message
Lists methods related to getting properties of messages.
```APIDOC
## See Also
### Getting the Properties
- `reply`
- `replySize`
- `sendSize`
```
--------------------------------
### Enable developer mode for system extensions
Source: https://developer.apple.com/documentation/driverkit/debugging-and-testing-system-extensions
Use this command to allow loading system extensions from any directory during development.
```shell
systemextensionsctl developer on
```
--------------------------------
### static OSSetPtr withObjects
Source: https://developer.apple.com/documentation/driverkit/osset/withobjects
Creates and initializes an OSSet populated with objects provided.
```APIDOC
## static OSSetPtr withObjects
### Description
Creates and initializes an OSSet populated with objects provided.
### Parameters
- **values** (const OSObject **) - Required - A C array of OSMetaClassBase-derived objects.
- **count** (uint32_t) - Required - The number of objects to be placed into the set.
- **capacity** (uint32_t) - Required - The initial storage capacity of the new set object. If 0, count is used; otherwise this value must be greater than or equal to count.
### Return Value
An instance of OSSet containing the objects provided, with a retain count of 1; NULL on failure.
### Discussion
Objects must be non-NULL, and count must be nonzero. If capacity is nonzero, it must be greater than or equal to count. The new OSSet will grow as needed to accommodate more objects. The objects in values are retained for storage in the new set, not copied.
```
--------------------------------
### OSNumber Example
Source: https://developer.apple.com/documentation/driverkit
OSNumber is a container for an integer value. Use for numeric data.
```cpp
OSNumber *myNumber = OSNumber::withNumber(42, 32); // Value 42, 32-bit integer
```
--------------------------------
### handleCreateLegend Instance Method
Source: https://developer.apple.com/documentation/driverkit/iohistogramreporter_ivars/handlecreatelegend
This method is part of the DriverKit framework and is used to create a legend entry.
```APIDOC
## Instance Method
### handleCreateLegend
DriverKit
iOS
iPadOS
macOS
```cpp
virtual OSSharedPtr handleCreateLegend();
```
#### Description
Creates a legend entry for reporting purposes within DriverKit.
#### Method
`virtual`
#### Return Value
An `OSSharedPtr` to an `IOReportLegendEntry` object.
```
--------------------------------
### GET /driverkit/queue_entry/prev
Source: https://developer.apple.com/documentation/driverkit/queue_entry/prev
Retrieves the definition of the prev pointer within the queue_entry structure.
```APIDOC
## Property: prev
### Description
The prev property is a pointer to the previous entry in a queue structure within DriverKit.
### Definition
```struct queue_entry * prev;```
### Platforms
- iOS
- iPadOS
- macOS
```
--------------------------------
### Getting Meta Information
Source: https://developer.apple.com/documentation/driverkit/osmetaclassbase
Methods for retrieving meta information about objects and classes.
```APIDOC
## Getting Meta Information
### `IsRemote`
### `GetClass`
Internal helper for GetClassName. Not to be called directly.
### `GetClassName`
Returns the name of the class given an OSObject pointer.
### `getMetaClass`
Internal helper for GetClassName. Not to be called directly.
```
--------------------------------
### Initialize OS_no_retain_t
Source: https://developer.apple.com/documentation/driverkit/os_no_retain_t/os_no_retain_t
Constructor for the OS_no_retain_t type.
```cpp
explicit OS_no_retain_t();
```
--------------------------------
### Get OSDictionary count
Source: https://developer.apple.com/documentation/driverkit/osdictionarygetcount
Returns the number of members in the specified dictionary object.
```c
uint32_t OSDictionaryGetCount(OSDictionaryPtr obj);
```
--------------------------------
### Instance Methods
Source: https://developer.apple.com/documentation/driverkit/osmetaclassbase
List of instance methods available on OSMetaClassBase.
```APIDOC
## Instance Methods
### `GetClassName`
### `getRetainCount`
### `operator new`
```
--------------------------------
### GET instanceSize Property
Source: https://developer.apple.com/documentation/driverkit/osclassloadinformation/instancesize
Retrieves the instance size property for an OSClassLoadInformation object.
```APIDOC
## Property: instanceSize
### Description
Returns the size of the class instance as a 32-bit unsigned integer.
### Type
`uint32_t`
### See Also
- New
- description
- metaPointer
- resv2
- resv3
- version
```
--------------------------------
### Initialize OSSharedPtr with a pointer
Source: https://developer.apple.com/documentation/driverkit/ossharedptr/ossharedptr_t_-7qy8m
Constructs an OSSharedPtr instance using a raw pointer and a retain tag.
```cpp
explicit OSSharedPtr(pointer p, retain_t ) noexcept;
```
--------------------------------
### GET superName Property
Source: https://developer.apple.com/documentation/driverkit/osclassdescription/supername
Retrieves the superName property from the OSClassDescription class in DriverKit.
```APIDOC
## Property: superName
### Description
The superName property represents the name of the superclass for a given OSClassDescription instance.
### Definition
`char superName[96];`
### Platforms
- DriverKit
- iOS
- iPadOS
- macOS
```
--------------------------------
### GET /OSAction/GetReference
Source: https://developer.apple.com/documentation/driverkit/osaction/getreference
Retrieves a pointer to additional memory allocated by the action object.
```APIDOC
## GetReference
### Description
Returns a pointer to any additional memory allocated by the action object on your behalf.
### Method
Instance Method
### Return Value
A pointer to the additional storage requested at creation time. Returns NULL if the referenceSize parameter was 0 or if the action object does not belong to the current process.
### Discussion
The action object zero-initializes the allocated memory. Access is restricted to the process that owns the action object.
```
--------------------------------
### init Method
Source: https://developer.apple.com/documentation/driverkit/ioeventlink/init
Initializes an IOEventLink object. This is a virtual method available on iOS, iPadOS, and macOS.
```APIDOC
## init
### Description
Initializes the IOEventLink object. This is a virtual method.
### Method Signature
```cpp
virtual bool init();
```
### Platform Availability
iOS, iPadOS, macOS
```
--------------------------------
### GET operator[]
Source: https://developer.apple.com/documentation/driverkit/libkern/safe_allocation/operator__-3hxos
Accesses an element at a specific index within a safe_allocation object.
```APIDOC
## operator[]
### Description
Provides indexed access to elements in a safe_allocation container.
### Method
Instance Method
### Parameters
#### Path Parameters
- **n** (ptrdiff_t) - Required - The index of the element to access.
### Response
- **Return Value** (const type-parameter-0-0 &) - A constant reference to the element at the specified index.
```