PiDmCacheDataEncode

__int64 __fastcall PiDmCacheDataEncode(int a1, int *a2, unsigned int a3, int a4, int a5, __int64 a6){
  UINT64 v6; 
  UINT8 *v7; 
  unsigned int v9; 
  int Object; 
  int v12; 
  UINT8 *PoolWithTag; 
  __int128 v14; 
  __int16 v15[40]; 
  v6 = a3;
  v7 = (UINT8 *)a2;
  v9 = 0;
  if( !a1 )
  {
    *(_DWORD *)a6 = 2;
    return v9;
  }
  if( !a5 || a1 != a4 )
    goto LABEL_3;
  if( a1 == 13 )
  {
    PnpStringFromGuid(a2, (wchar_t *)v15);
    v9 = v12;
    if( v12 < 0 )
      return v9;
    a2 = (int *)v15;
  }
  else
  {
    if( a1 != 18 )
    {
LABEL_3:
      if( a1 == 13 )
      {
        v14 = *(_OWORD *)v7;
        *(_DWORD *)a6 = 4;
        *(_OWORD *)(a6 + 8) = v14;
        return v9;
      }
      if( (unsigned int)v6 > 8 )
      {
        PoolWithTag = (UINT8 *)ExAllocatePoolWithTag(PagedPool, v6, 0x5A706E50ui64);
        *(_QWORD *)(a6 + 16) = PoolWithTag;
        if( !PoolWithTag )
          return(unsigned int)-1073741670;
        memmove(PoolWithTag, v7, v6);
        *(_DWORD *)a6 = 5;
      }
      else
      {
        memmove((UINT8 *)(a6 + 16), v7, v6);
        *(_DWORD *)a6 = 3;
      }
      *(_DWORD *)(a6 + 12) = v6;
      goto LABEL_7;
    }
    if( a2 )
      *((_WORD *)a2 + ((unsigned __int64)a3 >> 1) - 1) = 0;
  }
  if( !a2 )
    goto LABEL_3;
  Object = PiDmGetObject((unsigned int)a5, (WCHAR *)a2, (INT64 *)(a6 + 16));
  v9 = Object;
  if( Object == -1073741772 )
  {
    v9 = 0;
    goto LABEL_3;
  }
  if( Object < 0 )
    return v9;
  *(_DWORD *)a6 = 6;
LABEL_7:
  *(_DWORD *)(a6 + 8) = a1;
  return v9;
}

Referenced by:

PiDmObjectCreate
PiDmObjectProcessPropertyChange
PiDmObjectUpdateCachedObjectProperty