PiCMCaptureRegisterInterfaceInputData

INT64 __fastcall PiCMCaptureRegisterInterfaceInputData(UINT64 a1, UINT64 a2, INT64 a3, INT64 a4){
  INT8 CallerMode; 
  int UserModeCallersCopy; 
  UINT64 v7; 
  UINT64 v8; 
  _QWORD *v9; 
  VOID *v10; 
  UINT64 v11; 
  _QWORD *v12; 
  VOID *v13; 
  UINT64 v14; 
  UINT64 AllocateDestination; 
  int v17; 
  int v18; 
  v17 = 0;
  v18 = 0;
  CallerMode = *((_BYTE *)KeGetCurrentThread() + 562);
  UserModeCallersCopy = 0;
  if( !a1 || !(_DWORD)a2 )
  {
    UserModeCallersCopy = -1073741811;
    goto LABEL_44;
  }
  if( (_DWORD)a3 )
  {
    if( (a1 & 3) != 0 )
      ExRaiseDatatypeMisalignment();
    v7 = a1 + (unsigned int)a2;
    if( v7 > 0x7FFFFFFF0000i64 || v7 < a1 )
      MEMORY[0x7FFFFFFF0000] = 0;
    if( (unsigned int)a2 >= 0x2C && *(_DWORD *)a1 == 44 )
    {
      *(_DWORD *)a4 = 56;
      *(_DWORD *)(a4 + 4) = *(_DWORD *)(a1 + 4);
      *(_OWORD *)(a4 + 8) = *(_OWORD *)(a1 + 8);
      *(_QWORD *)(a4 + 24) = *(unsigned int *)(a1 + 24);
      *(_DWORD *)(a4 + 32) = *(_DWORD *)(a1 + 28);
      *(_QWORD *)(a4 + 40) = *(unsigned int *)(a1 + 32);
      *(_DWORD *)(a4 + 48) = *(_DWORD *)(a1 + 36);
      *(_DWORD *)(a4 + 52) = *(_DWORD *)(a1 + 40);
    }
    else
    {
      UserModeCallersCopy = -1073741811;
    }
  }
  else
  {
    if( (a1 & 7) != 0 )
      ExRaiseDatatypeMisalignment();
    v8 = a1 + (unsigned int)a2;
    if( v8 > 0x7FFFFFFF0000i64 || v8 < a1 )
      MEMORY[0x7FFFFFFF0000] = 0;
    if( (unsigned int)a2 >= 0x38 )
    {
      *(_OWORD *)a4 = *(_OWORD *)a1;
      *(_OWORD *)(a4 + 16) = *(_OWORD *)(a1 + 16);
      *(_OWORD *)(a4 + 32) = *(_OWORD *)(a1 + 32);
      *(_QWORD *)(a4 + 48) = *(_QWORD *)(a1 + 48);
      if( *(_DWORD *)a4 != 56 )
        UserModeCallersCopy = -1073741811;
    }
    else
    {
      UserModeCallersCopy = -1073741811;
    }
  }
  if( UserModeCallersCopy >= 0 )
  {
    v9 = (_QWORD *)(a4 + 24);
    v10 = *(VOID **)(a4 + 24);
    *(_QWORD *)(a4 + 24) = 0i64;
    if( v10 )
    {
      v11 = *(unsigned int *)(a4 + 32);
      if( (unsigned int)v11 >= 2 )
      {
        LODWORD(AllocateDestination) = 1;
        UserModeCallersCopy = PiControlMakeUserModeCallersCopy(
                                (VOID **)(a4 + 24),
                                v10,
                                v11,
                                2ui64,
                                CallerMode,
                                AllocateDestination);
        if( UserModeCallersCopy < 0 )
        {
          *v9 = 0i64;
          *(_DWORD *)(a4 + 32) = 0;
        }
        else
        {
          v17 = 1;
          *(_WORD *)(*v9 + 2 * ((unsigned __int64)*(unsigned int *)(a4 + 32) >> 1) - 2) = 0;
        }
LABEL_27:
        v12 = (_QWORD *)(a4 + 40);
        v13 = *(VOID **)(a4 + 40);
        *(_QWORD *)(a4 + 40) = 0i64;
        if( v13 )
        {
          v14 = *(unsigned int *)(a4 + 48);
          if( (unsigned int)v14 >= 2 )
          {
            LODWORD(AllocateDestination) = 1;
            UserModeCallersCopy = PiControlMakeUserModeCallersCopy(
                                    (VOID **)(a4 + 40),
                                    v13,
                                    v14,
                                    2ui64,
                                    CallerMode,
                                    AllocateDestination);
            if( UserModeCallersCopy < 0 )
            {
              *v12 = 0i64;
              *(_DWORD *)(a4 + 48) = 0;
            }
            else
            {
              v18 = 1;
              *(_WORD *)(*v12 + 2 * ((unsigned __int64)*(unsigned int *)(a4 + 48) >> 1) - 2) = 0;
            }
LABEL_44:
            if( UserModeCallersCopy >= 0 )
              return(unsigned int)UserModeCallersCopy;
            goto LABEL_45;
          }
          if( *(_DWORD *)(a4 + 48) >= 2u )
            goto LABEL_44;
        }
        else if( !*(_DWORD *)(a4 + 48) )
        {
          goto LABEL_44;
        }
        goto LABEL_36;
      }
      if( *(_DWORD *)(a4 + 32) >= 2u )
        goto LABEL_27;
    }
    else if( !*(_DWORD *)(a4 + 32) )
    {
      goto LABEL_27;
    }
LABEL_36:
    UserModeCallersCopy = -1073741811;
  }
LABEL_45:
  if( v17 )
    PiControlFreeUserModeCallersBuffer(CallerMode, *(PVOID *)(a4 + 24));
  if( v18 )
    PiControlFreeUserModeCallersBuffer(CallerMode, *(PVOID *)(a4 + 40));
  *(_OWORD *)a4 = 0i64;
  *(_OWORD *)(a4 + 16) = 0i64;
  *(_OWORD *)(a4 + 32) = 0i64;
  *(_QWORD *)(a4 + 48) = 0i64;
  return(unsigned int)UserModeCallersCopy;
}

Referenced by:

PiCMRegisterDeviceInterface