IoFindDeviceThatFailedIrp

DEVICE_OBJECT *__stdcall IoFindDeviceThatFailedIrp(IRP *Irp){
  unsigned int v1; 
  unsigned int v2; 
  char *v3; 
  v1 = *((char *)Irp + 66);
  v2 = 0;
  if( *((int *)Irp + 12) >= 0 )
    return 0i64;
  v3 = (char *)Irp + 72 * v1 + 136;
  if( !v1 )
    return 0i64;
  while( (v3[3] & 2) == 0 )
  {
    ++v2;
    v3 -= 72;
    if( v2 >= v1 )
      return 0i64;
  }
  return(DEVICE_OBJECT *)*((_QWORD *)v3 + 5);
}

Referenced by:

PnpDeviceCompletionRoutine
PnpDiagnosticCompletionRoutine
PopDiagTraceIrpFinish
PopDiagTraceIrpFinishTelemetry
PopSystemIrpCompletion