AlpcpReceiveLegacyConnectionReply

INT64 __fastcall AlpcpReceiveLegacyConnectionReply(
        _ALPC_DISPATCH_CONTEXT *DispatchContext,
        VOID *ConnectionInformation,
        UINT *CapturedLength,
        _KALPC_VIEW *AlpcView,
        _PORT_VIEW *CapturedClientView,
        _REMOTE_PORT_VIEW *CapturedServerView){
  void *v8; 
  _ALPC_PORT *PortObject; 
  int v10; 
  int RemoteView; 
  __int64 v12; 
  __int64 v13; 
  __int16 v14; 
  UINT v15; 
  ULONG_PTR v16; 
  ULONG_PTR BugCheckParameter2; 
  INT64 v19[2]; 
  void *v20; 
  v8 = ConnectionInformation;
  LOBYTE(ConnectionInformation) = *((_BYTE *)KeGetCurrentThread() + 562);
  BugCheckParameter2 = 0i64;
  PortObject = DispatchContext->PortObject;
  v10 = AlpcpReceiveSynchronousReply(
          DispatchContext,
          (UINT64)ConnectionInformation,
          (_KALPC_MESSAGE **)&BugCheckParameter2,
          0i64,
          0i64);
  RemoteView = v10;
  if( !v10 )
  {
    if( AlpcView )
    {
      v20 = 0i64;
      RemoteView = AlpcpQueryRemoteView((INT64)PortObject, (INT64)AlpcView, (INT64)v19);
      if( RemoteView < 0 )
      {
        v16 = BugCheckParameter2;
LABEL_17:
        AlpcpUnlockMessage(v16);
        return(unsigned int)RemoteView;
      }
      CapturedClientView->ViewRemoteBase = v20;
    }
    v12 = BugCheckParameter2;
    if( CapturedServerView )
    {
      v13 = *(_QWORD *)(BugCheckParameter2 + 144);
      if( v13 )
      {
        CapturedServerView->Length = 24;
        CapturedServerView->ViewBase = *(void **)(v13 + 40);
        CapturedServerView->ViewSize = *(_QWORD *)(*(_QWORD *)(v13 + 16) + 40i64);
      }
    }
    if( v8 )
    {
      v14 = 0;
      v15 = *(unsigned __int16 *)(v12 + 240);
      if( *CapturedLength < v15 )
      {
        v14 = *(_WORD *)(v12 + 240);
        *(_WORD *)(v12 + 240) = *(_WORD *)CapturedLength;
      }
      else
      {
        *CapturedLength = v15;
      }
      if( *(_QWORD *)(v12 + 176) )
        AlpcpGetDataFromUserVaSafe(v12, v8);
      else
        AlpcpReadMessageData(v12, (char *)v8);
      if( v14 )
        *(_WORD *)(v12 + 240) = v14;
    }
    v16 = v12;
    goto LABEL_17;
  }
  if( (*((_DWORD *)PortObject + 104) & 0x10) != 0 || v10 == -1073740031 )
    return(unsigned int)-1073741759;
  return(unsigned int)RemoteView;
}

Referenced by:

NtSecureConnectPort