IopAllocateBackpocketIrp

_IRP *__stdcall IopAllocateBackpocketIrp(_DEVICE_OBJECT *DeviceObject, CHAR StackSize, UINT8 ReadRequest){
  __int16 v3; 
  _ETHREAD *CurrentThread; 
  _IRP *result; 
  PIRP v7; 
  union _LARGE_INTEGER v8; 
  VOID *retaddr; 
  union _LARGE_INTEGER Timeout; 
  v3 = StackSize;
  if( StackSize > byte_140C45AA0 )
    return 0i64;
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  if( !ReadRequest )
  {
    if( (_ETHREAD *)qword_140C45A78 != CurrentThread )
    {
      v8.QuadPart = -300000000i64;
      while( _InterlockedExchange(&dword_140C45A70, 1) == 1 )
      {
        if( KeWaitForSingleObject(&stru_140C45A80, Executive, 0, 0, &v8) == 258 )
        {
          result = IopAllocateIrpExReturn(DeviceObject, v3, 0, retaddr);
          if( result )
            return result;
        }
      }
      v7 = qword_140C45A68;
      IoInitializeIrp(qword_140C45A68, 72 * v3 + 280, v3 + 1);
      *((_BYTE *)v7 + 71) = 33;
      qword_140C45A78 = (__int64)KeGetCurrentThread();
      goto LABEL_9;
    }
    v7 = qword_140C45A98;
    if( qword_140C45A98 )
    {
LABEL_19:
      qword_140C45A98 = *(PIRP *)qword_140C45A98;
      IoInitializeIrp(v7, 72 * StackSize + 280, StackSize + 1);
      *((_QWORD *)v7 + 23) -= 72i64;
      *((_QWORD *)v7 + 25) = *((_QWORD *)v7 + 23);
      *((_BYTE *)v7 + 71) = 33;
      goto LABEL_20;
    }
    return 0i64;
  }
  if( (_ETHREAD *)qword_140C45A48 == CurrentThread )
  {
    v7 = qword_140C45A98;
    if( !qword_140C45A98 )
      KeBugCheckEx(0x11Eu, 0i64, 0i64, 0i64, 0i64);
    goto LABEL_19;
  }
  Timeout.QuadPart = -300000000i64;
  while( _InterlockedExchange(&dword_140C45A40, 1) == 1 )
  {
    if( KeWaitForSingleObject(&word_140C45A50, Executive, 0, 0, &Timeout) == 258 )
    {
      result = IopAllocateIrpExReturn(DeviceObject, v3, 0, retaddr);
      if( result )
        return result;
    }
  }
  v7 = *(PIRP *)Irp;
  IoInitializeIrp((_IRP *)Irp, 72 * v3 + 280, v3 + 1);
  *((_BYTE *)v7 + 71) = 33;
  qword_140C45A48 = (__int64)KeGetCurrentThread();
LABEL_9:
  *((_QWORD *)v7 + 23) -= 72i64;
  *((_QWORD *)v7 + 25) = *((_QWORD *)v7 + 23);
LABEL_20:
  --*((_BYTE *)v7 + 66);
  --*((_BYTE *)v7 + 67);
  if( IopIsActivityTracingEnabled() )
    IopInitActivityIdIrp(v7);
  return v7;
}

Referenced by:

IoAsynchronousPageWrite
IoPageReadEx
IoSynchronousPageWriteEx