PiDevCfgPushCopyKeyEntry

VOID __fastcall PiDevCfgPushCopyKeyEntry(
        _LIST_ENTRY *CopyKeyStack,
        VOID *SourceKeyHandle,
        VOID *TargetKeyHandle,
        UINT64 Flags){
  int v7; 
  VOID **PoolWithTag; 
  INT64 v9; 
  VOID **v10; 
  VOID **v11; 
  _LIST_ENTRY *Blink; 
  INT64 v13; 
  _OBJECT_ATTRIBUTES ObjectAttributes; 

  v7 = Flags;
  memset(&ObjectAttributes, 0, sizeof(ObjectAttributes));
  PoolWithTag = ExAllocatePoolWithTag(1ui64, 0x28ui64, 1667526736i64);
  v10 = PoolWithTag;
  if( PoolWithTag )
  {
    *((_DWORD *)PoolWithTag + 8) = v7;
    v11 = PoolWithTag + 2;
    if( v7 >= 0 )
    {
      *v11 = SourceKeyHandle;
      PoolWithTag[3] = TargetKeyHandle;
LABEL_4:
      Blink = CopyKeyStack->Blink;
      if( Blink->Flink != CopyKeyStack )
        __fastfail(3u);
      *v10 = CopyKeyStack;
      v10[1] = Blink;
      Blink->Flink = (_LIST_ENTRY *)v10;
      CopyKeyStack->Blink = (_LIST_ENTRY *)v10;
      v10 = 0i64;
      goto LABEL_6;
    }
    ObjectAttributes.Attributes = 512;
    ObjectAttributes.Length = 48;
    *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
    if( ZwOpenKey(
           v11,
           0x20019ui64,
           &ObjectAttributes,
           v9,
           *(INT64 *)&ObjectAttributes.Length,
           (INT64)SourceKeyHandle,
           (INT64)&PiDevCfgEmptyString,
           *(INT64 *)&ObjectAttributes.Attributes) >= 0 )
    {
      ObjectAttributes.Length = 48;
      ObjectAttributes.Attributes = 512;
      *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
      if( ZwOpenKey(
             v10 + 3,
             0xF003Fui64,
             &ObjectAttributes,
             v13,
             *(INT64 *)&ObjectAttributes.Length,
             (INT64)TargetKeyHandle,
             (INT64)&PiDevCfgEmptyString,
             *(INT64 *)&ObjectAttributes.Attributes) >= 0 )
      {
        *((_DWORD *)v10 + 8) |= 0x40000000u;
        goto LABEL_4;
      }
      ZwClose((_HANDLE)*v11);
    }
LABEL_6:
    if( v10 )
      ExFreePoolWithTag(v10, 0);
  }
}

Referenced by:

PiDevCfgCopyDeviceKey
PiDevCfgCopyDeviceKeys