PnpNotifyDriverCallback

__int64 __fastcall PnpNotifyDriverCallback(__int64 a1, __int64 a2, _DWORD *a3){
  __int64(__fastcall *v3)(__int64, _QWORD); 
  unsigned __int8 CurrentIrql; 
  unsigned __int8 v8; 
  int SpareLong; 
  unsigned int CombinedApcDisable; 
  int v11; 
  NTSTATUS v12; 
  _ADAPTER_OBJECT *SessionById; 
  _ADAPTER_OBJECT *v15; 
  int v16; 
  __int16 *v17; 
  _KAPC_STATE ApcState; 

  v3 = *(__int64(__fastcall **)(__int64, _QWORD))(a1 + 32);
  memset(&ApcState, 0, sizeof(ApcState));
  if( !MmIsSessionAddress(v3) || *(_QWORD *)(a1 + 24) )
  {
    CurrentIrql = 0;
    v8 = 0;
    SpareLong = 0;
    CombinedApcDisable = 0;
    if( !MmIsSessionAddress(v3)
      || (KeGetCurrentThread()->ApcState.Process->Flags & 0x10000) != 0
      && *(_DWORD *)(a1 + 20) == PsGetCurrentProcessSessionId() )
    {
      CurrentIrql = KeGetCurrentIrql();
      SpareLong = KeGetCurrentThread()->WaitBlock[3].SpareLong;
      v11 = v3(a2, *(_QWORD *)(a1 + 40));
      v8 = KeGetCurrentIrql();
      CombinedApcDisable = KeGetCurrentThread()->CombinedApcDisable;
      if( a3 )
        *a3 = v11;
      v12 = 0;
    }
    else
    {
      SessionById = (_ADAPTER_OBJECT *)MmGetSessionById(*(unsigned int *)(a1 + 20));
      v15 = SessionById;
      if( !SessionById )
        return(unsigned int)-1073741823;
      v12 = MmAttachSession(SessionById, &ApcState);
      if( v12 >= 0 )
      {
        CurrentIrql = KeGetCurrentIrql();
        SpareLong = KeGetCurrentThread()->WaitBlock[3].SpareLong;
        v16 = (*(__int64(__fastcall **)(__int64, _QWORD))(a1 + 32))(a2, *(_QWORD *)(a1 + 40));
        v8 = KeGetCurrentIrql();
        CombinedApcDisable = KeGetCurrentThread()->CombinedApcDisable;
        if( a3 )
          *a3 = v16;
        v12 = MmDetachSession(v15, &ApcState);
      }
      HalPutDmaAdapter(v15);
    }
    if( CurrentIrql != v8 || SpareLong != CombinedApcDisable )
    {
      v17 = *(__int16 **)(a1 + 48);
      if( v17 )
      {
        IoAddTriageDumpDataBlock(*(VOID **)(a1 + 48), (_BYTE *)(unsigned int)v17[1]);
        v17 = *(__int16 **)(a1 + 48);
        if( v17[28] )
        {
          IoAddTriageDumpDataBlock(v17 + 28, (_BYTE *)2);
          IoAddTriageDumpDataBlock(
            *(VOID **)(*(_QWORD *)(a1 + 48) + 64i64),
            (_BYTE *)*(unsigned __int16 *)(*(_QWORD *)(a1 + 48) + 56i64));
          v17 = *(__int16 **)(a1 + 48);
        }
      }
      KeBugCheckEx(0xCAu, (PVOID)0xA, v17, (PVOID)v8, (PVOID)CombinedApcDisable);
    }
    return(unsigned int)v12;
  }
  return 3221225485i64;
}

Referenced by:

IoRegisterPlugPlayNotification
PipKsrNotifyDrivers
PnpNotifyDeviceClassChange
PnpNotifyHwProfileChange
PnpNotifyTargetDeviceChange
PnpNotifyTargetDeviceChangeNotifyEntry