IOCTL_SERVICE_NOTIFY_ADDR_CHANGE (Compact 2013)

3/26/2014

This I/O control message is passed as an input parameter when Servicesd.exe notifies every running service of address changes in the system. Send this message with DeviceIoControl.

Syntax

BOOL DeviceIoControl(
    HANDLE hDevice,          // handle to the device
    DWORD dwIoControlCode,   // use IOCTL_SERVICE_NOTIFY_ADDR_CHANGE
    LPVOID lpInBuffer,       // pointer to input buffer
    DWORD nInBufferSize,     // input buffer size
    LPVOID lpOutBuffer,      // pointer to output buffer
    DWORD nOutBufferSize,    // output buffer size
    LPDWORD lpBytesReturned, // number of bytes returned
    OVERLAPPED lpOverlapped  // pointer to OVERLAPPED structure
);

Parameters

  • hDevice
    [in] Handle to the device.
  • dwIoControlCode
    [in] The control code for the operation. Use IOCTL_SERVICE_NOTIFY_ADDR_CHANGE for this operation.
  • lpInBuffer
    [in] Pointer to a PIP_ADAPTER_ADDRESSES structure containing information on the local addresses for a specific network adapter.

Return Values

Returns TRUE if successful; otherwise, returns FALSE. To obtain extended error information, call the SetLastError function.

Remarks

When Servicesd.exe initializes, it creates a thread that receives notification about address changes in the system. When an IP address on the system is added or removed, this thread wakes and calls the GetAdaptersAddresses function to retrieve the information about the local addresses. It then calls every running service with IOCTL_SERVICE_NOTIFY_ADDR_CHANGE and with the results of GetAdaptersAddresses in the input parameters.

If a service needs to use this information later, it must call GetAdaptersAddresses to retrieve its own copy of this data. The pointer passed to the service during the call to the xxx_IOControl (Servicesd.exe) function is valid only during the duration of the function call. You must not copy the data to a private buffer using memcpy_s because the structure contains internal pointers to memory locations inside the buffer that will not be valid when the call to xxx_IOControl returns.

If a service needs to keep track of network interfaces, it must call GetAdaptersAddresses when it initializes to obtain the current state of the network adapters. Servicesd.exe only generates the IOCTL_SERVICE_NOTIFY_ADDR_CHANGE IOCTL when network adapter information changes, therefore the service must read this information on its own initially. A logical place for the call to GetAdaptersAddresses would be in the service's xxx_Init (Servicesd.exe) function.

Requirements

Header

service.h

See Also

Reference

Servicesd.exe IOCTLS
xxx_IOControl (Servicesd.exe)

Other Resources

GetAdaptersAddresses