Nota
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare ad accedere o modificare le directory.
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare a modificare le directory.
Quando il sistema operativo chiama una funzione di callback registrata, passa un puntatore a una struttura DEVICE_INTERFACE_CHANGE_NOTIFICATION nel parametro NotificationStructure .
L'esempio di codice seguente illustra un'implementazione di una funzione di callback che elabora le notifiche asincrone dei driver per i processori:
// Asynchronous processor notification callback function
NTSTATUS
AsyncProcessorCallback(
IN PVOID NotificationStructure,
IN PVOID Context
)
{
PDEVICE_INTERFACE_CHANGE_NOTIFICATION Notification;
ULONG ProcessorCount;
KAFFINITY ActiveProcessors;
Notification =
(PDEVICE_INTERFACE_CHANGE_NOTIFICATION)
NotificationStructure;
// Verify that this notification is about a processor
// that is being added to the hardware partition.
if (IsEqualGUID(
&Notification->Event,
&GUID_DEVICE_INTERFACE_ARRIVAL
))
{
// Get the current processor count and affinity
ProcessorCount =
KeQueryActiveProcessorCount(
&ActiveProcessors
);
// Adjust any resource allocations that are based
// on the number of processors.
...
// Adjust the assignment of resources that are
// assigned to specific processors.
...
// Begin scheduling any per processor threads
// on the new processor.
...
// Adjust the scheduling of DPCs and other threads
...
// Adjust any load balancing algorithms
...
}
// Always return success status
return STATUS_SUCCESS;
}
L'esempio di codice seguente illustra un'implementazione di una funzione di callback che elabora le notifiche asincrone del driver per la memoria:
// Asynchronous memory notification callback function
NTSTATUS
AsyncMemoryCallback(
IN PVOID NotificationStructure,
IN PVOID Context
)
{
PDEVICE_INTERFACE_CHANGE_NOTIFICATION Notification;
Notification =
(PDEVICE_INTERFACE_CHANGE_NOTIFICATION)
NotificationStructure;
// Verify that this notification is about memory
// that is being added to the hardware partition.
if (IsEqualGUID(
&Notification->Event,
&GUID_DEVICE_INTERFACE_ARRIVAL
))
{
// Increase the size of any memory buffers
// for optimal performance of the driver.
...
}
// Always return success status
return STATUS_SUCCESS;
}