NtAlpcCreateSectionView

NTSTATUS __stdcall NtAlpcCreateSectionView(
        VOID *PortHandle,
        PGENERIC_MAPPING Flags,
        _KPROCESSOR_MODE ViewAttributes,
        PACCESS_MASK GrantedAccess){
  __int64 v4; 
  _ETHREAD *CurrentThread; 
  char PreviousMode; 
  __int64 v8; 
  char v9; 
  int v10; 
  _BLOB_TYPE *v11; 
  _ALPC_PORT *v12; 
  _KALPC_SECTION *v13; 
  _KALPC_VIEW *v14; 
  PVOID Object[2]; 
  VOID *Handle[2]; 
  UINT64 Size[2]; 
  _KALPC_VIEW *ViewPointer; 

  v4 = *(_QWORD *)&ViewAttributes;
  *(_OWORD *)Handle = 0i64;
  *(_OWORD *)Size = 0i64;
  ViewPointer = 0i64;
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  --CurrentThread->Tcb.KernelApcDisable;
  if( (_DWORD)Flags )
    goto LABEL_22;
  PreviousMode = KeGetCurrentThread()->PreviousMode;
  if( PreviousMode )
  {
    if( (ViewAttributes & 3) != 0 )
      ExRaiseDatatypeMisalignment();
    v8 = 0x7FFFFFFF0000i64;
    if( *(_QWORD *)&ViewAttributes < 0x7FFFFFFF0000ui64 )
      v8 = *(_QWORD *)&ViewAttributes;
    *(_BYTE *)v8 = *(_BYTE *)v8;
    *(_BYTE *)(v8 + 31) = *(_BYTE *)(v8 + 31);
    *(_OWORD *)Handle = **(_OWORD **)&ViewAttributes;
    *(_OWORD *)Size = *(_OWORD *)(*(_QWORD *)&ViewAttributes + 16i64);
  }
  else
  {
    *(_OWORD *)Handle = **(_OWORD **)&ViewAttributes;
    *(_OWORD *)Size = *(_OWORD *)(*(_QWORD *)&ViewAttributes + 16i64);
  }
  if( LODWORD(Handle[0]) || !Size[1] || Size[0] )
  {
LABEL_22:
    v10 = -1073741811;
  }
  else
  {
    v9 = KeGetCurrentThread()->PreviousMode;
    Object[0] = 0i64;
    v10 = ObReferenceObjectByHandle(PortHandle, 1ui64, AlpcPortObjectType, v9, Object, 0i64);
    if( v10 >= 0 )
    {
      v12 = (_ALPC_PORT *)Object[0];
      v13 = (_KALPC_SECTION *)AlpcReferenceBlobByHandle(
                                (_ALPC_HANDLE_TABLE *)(*((_QWORD *)Object[0] + 2) + 40i64),
                                Handle[1],
                                (_BLOB_TYPE *)&AlpcSectionType,
                                v11);
      Object[1] = v13;
      if( v13 )
      {
        v10 = AlpcpCreateSectionView(v13, v12, 0i64, Size[1], &ViewPointer);
        if( v10 >= 0 )
        {
          if( PreviousMode )
          {
            v14 = ViewPointer;
            *(_QWORD *)(v4 + 16) = ViewPointer->Address;
            *(_QWORD *)(v4 + 24) = v14->Size;
            if( v10 < 0 )
              AlpcpDeleteView(v14);
          }
          else
          {
            v14 = ViewPointer;
            *(_QWORD *)(v4 + 16) = ViewPointer->Address;
            *(_QWORD *)(v4 + 24) = v14->Size;
          }
          AlpcpDereferenceBlobEx(v14, 1i64);
        }
        AlpcpDereferenceBlobEx(v13, 1i64);
      }
      else
      {
        v10 = -1073741816;
      }
      HalPutDmaAdapter((PADAPTER_OBJECT)v12);
    }
  }
  KeLeaveCriticalRegionThread(KeGetCurrentThread());
  return v10;
}

Referenced by:

No references.