AlpcpMapLegacyPortView

NTSTATUS __stdcall AlpcpMapLegacyPortView(
        _ALPC_PORT *PortObject,
        _PORT_VIEW *ClientView,
        _KALPC_MESSAGE_ATTRIBUTES *MessageAttributes){
  HANDLE SectionHandle; 
  NTSTATUS SectionInformation; 
  INT64 v8; 
  __int64 v9; 
  __int64 v10; 
  UINT64 v11; 
  SIZE_T v12; 
  void *v13; 
  UINT64 v14; 
  _KALPC_VIEW *v15; 
  SIZE_T v16; 
  _KALPC_VIEW *ViewPointer; 
  INT64 v18[2]; 
  INT64 v19; 
  PVOID Object; 
  _KALPC_MESSAGE_ATTRIBUTES *v21; 
  UINT64 v22; 
  v21 = MessageAttributes;
  SectionHandle = ClientView->SectionHandle;
  v22 = 0i64;
  v19 = 0i64;
  ViewPointer = 0i64;
  *(_OWORD *)v18 = 0i64;
  if( !SectionHandle )
    return -1073741816;
  Object = 0i64;
  SectionInformation = ObReferenceObjectByHandle(
                         SectionHandle,
                         6u,
                         MmSectionObjectType,
                         *((_BYTE *)KeGetCurrentThread() + 562),
                         &Object,
                         0i64);
  if( SectionInformation >= 0 )
  {
    SectionInformation = MmGetSectionInformation((INT64)Object, 0i64, (INT64)v18);
    if( SectionInformation >= 0 )
    {
      if( (v18[1] & 0x800000) != 0 )
      {
        SectionInformation = -1073741637;
      }
      else
      {
        v8 = v19;
        v9 = (unsigned int)(AlpcpViewGranularity - 1);
        v10 = ~((unsigned int)AlpcpViewGranularity - 1i64);
        v11 = v10 & (v9 + ClientView->SectionOffset);
        v12 = v10 & (v9 + ClientView->ViewSize);
        if( v12 + v11 >= v11 )
        {
          if( v12 + v11 <= v19 )
          {
            SectionInformation = AlpcpCreateSection((CHAR *)PortObject, 0, 0, SectionHandle, v19, &v22);
            if( SectionInformation >= 0 )
            {
              v13 = (void *)v22;
              v14 = v8 - v11;
              if( v12 )
                v14 = v12;
              SectionInformation = AlpcpCreateSectionView((_KALPC_SECTION *)v22, PortObject, v11, v14, &ViewPointer);
              if( SectionInformation >= 0 )
              {
                v15 = ViewPointer;
                ClientView->Length = 48;
                ClientView->ViewBase = (PVOID)*((_QWORD *)v15 + 5);
                v16 = *((_QWORD *)v15 + 6);
                ClientView->ViewRemoteBase = 0i64;
                ClientView->ViewSize = v16;
                v21->View = v15;
                AlpcpLockForCachedReferenceBlob(*((PVOID *)v15 + 2));
                ++*((_DWORD *)v15 + 19);
                AlpcpUnlockBlob(*((PVOID *)v15 + 2));
              }
              else if( AlpcpDeleteBlob(v13) )
              {
                AlpcpDereferenceView((ULONG_PTR)v13);
              }
              AlpcpDereferenceView((ULONG_PTR)v13);
            }
          }
          else
          {
            SectionInformation = -1073741670;
          }
        }
        else
        {
          SectionInformation = -1073741811;
        }
      }
    }
    HalPutDmaAdapter((PADAPTER_OBJECT)Object);
  }
  return SectionInformation;
}

Referenced by:

AlpcpAcceptConnectPort
AlpcpFormatConnectionRequest