PiCMCaptureRegistryPropertyInputData

__int64 __fastcall PiCMCaptureRegistryPropertyInputData(unsigned __int64 a1, unsigned int a2, int a3, __int64 a4){
  INT8 CallerMode; 
  int UserModeCallersCopy; 
  unsigned __int64 v7; 
  _QWORD *v8; 
  VOID *v9; 
  UINT64 v10; 
  VOID *v11; 
  unsigned __int64 v13; 
  UINT64 v14; 
  UINT64 AllocateDestination; 
  int v16; 
  int v17; 
  v16 = 0;
  v17 = 0;
  CallerMode = *((_BYTE *)KeGetCurrentThread() + 562);
  UserModeCallersCopy = 0;
  if( !a1 || !a2 )
  {
    UserModeCallersCopy = -1073741811;
    goto LABEL_21;
  }
  if( a3 )
  {
    if( (a1 & 3) != 0 )
      ExRaiseDatatypeMisalignment();
    v13 = a1 + a2;
    if( v13 > 0x7FFFFFFF0000i64 || v13 < a1 )
      MEMORY[0x7FFFFFFF0000] = 0;
    if( a2 >= 0x28 && *(_DWORD *)a1 == 40 )
    {
      *(_DWORD *)a4 = 56;
      *(_DWORD *)(a4 + 4) = *(_DWORD *)(a1 + 4);
      *(_DWORD *)(a4 + 8) = *(_DWORD *)(a1 + 8);
      *(_QWORD *)(a4 + 16) = *(unsigned int *)(a1 + 12);
      *(_DWORD *)(a4 + 24) = *(_DWORD *)(a1 + 16);
      *(_DWORD *)(a4 + 28) = *(_DWORD *)(a1 + 20);
      *(_DWORD *)(a4 + 32) = *(_DWORD *)(a1 + 24);
      *(_QWORD *)(a4 + 40) = *(unsigned int *)(a1 + 28);
      *(_DWORD *)(a4 + 48) = *(_DWORD *)(a1 + 32);
      *(_DWORD *)(a4 + 52) = *(_DWORD *)(a1 + 36);
    }
    else
    {
      UserModeCallersCopy = -1073741811;
    }
  }
  else
  {
    if( (a1 & 7) != 0 )
      ExRaiseDatatypeMisalignment();
    v7 = a1 + a2;
    if( v7 > 0x7FFFFFFF0000i64 || v7 < a1 )
      MEMORY[0x7FFFFFFF0000] = 0;
    if( a2 < 0x38 )
    {
      UserModeCallersCopy = -1073741811;
    }
    else
    {
      *(_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;
    }
  }
  if( UserModeCallersCopy < 0 )
    goto LABEL_45;
  v8 = (_QWORD *)(a4 + 16);
  v9 = *(VOID **)(a4 + 16);
  *(_QWORD *)(a4 + 16) = 0i64;
  if( v9 )
  {
    v10 = *(unsigned int *)(a4 + 24);
    if( (unsigned int)v10 < 2 )
    {
      if( *(_DWORD *)(a4 + 24) < 2u )
        goto LABEL_24;
    }
    else
    {
      LODWORD(AllocateDestination) = 1;
      UserModeCallersCopy = PiControlMakeUserModeCallersCopy(
                              (VOID **)(a4 + 16),
                              v9,
                              v10,
                              2ui64,
                              CallerMode,
                              AllocateDestination);
      if( UserModeCallersCopy < 0 )
      {
        *v8 = 0i64;
        *(_DWORD *)(a4 + 24) = 0;
      }
      else
      {
        v16 = 1;
        *(_WORD *)(*v8 + 2 * ((unsigned __int64)*(unsigned int *)(a4 + 24) >> 1) - 2) = 0;
      }
    }
  }
  else if( *(_DWORD *)(a4 + 24) )
  {
    goto LABEL_24;
  }
  v11 = *(VOID **)(a4 + 40);
  *(_QWORD *)(a4 + 40) = 0i64;
  if( !v11 )
  {
    if( !*(_DWORD *)(a4 + 48) )
      goto LABEL_21;
    goto LABEL_24;
  }
  v14 = *(unsigned int *)(a4 + 48);
  if( (_DWORD)v14 )
  {
    LODWORD(AllocateDestination) = 1;
    UserModeCallersCopy = PiControlMakeUserModeCallersCopy(
                            (VOID **)(a4 + 40),
                            v11,
                            v14,
                            1ui64,
                            CallerMode,
                            AllocateDestination);
    if( UserModeCallersCopy < 0 )
    {
      *(_QWORD *)(a4 + 40) = 0i64;
      *(_DWORD *)(a4 + 48) = 0;
    }
    else
    {
      v17 = 1;
    }
LABEL_21:
    if( UserModeCallersCopy >= 0 )
      return(unsigned int)UserModeCallersCopy;
    goto LABEL_45;
  }
LABEL_24:
  UserModeCallersCopy = -1073741811;
LABEL_45:
  if( v16 )
    PiControlFreeUserModeCallersBuffer(CallerMode, *(PVOID *)(a4 + 16));
  if( v17 )
    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:

PiCMGetRegistryProperty
PiCMSetRegistryProperty