BiAddBootEntryToEfiBootManagerDisplayOrder

INT64 __fastcall BiAddBootEntryToEfiBootManagerDisplayOrder(VOID *a1, INT64 a2){
  int v3; 
  int Element; 
  unsigned int v5; 
  _QWORD *v6; 
  int v7; 
  __int64 v8; 
  UINT8 *PoolWithTag; 
  UINT8 *v10; 
  UINT8 *v11; 
  UINT64 v12; 
  UINT64 DataSize; 
  VOID *ObjectHandle; 
  UINT64 ElementSize; 
  void *Src; 
  LODWORD(ElementSize) = 0;
  Src = 0i64;
  ObjectHandle = 0i64;
  v3 = BcdOpenObject(a1, &GUID_FIRMWARE_BOOTMGR, &ObjectHandle);
  if( v3 < 0 )
    goto LABEL_17;
  Element = BiGetElement(ObjectHandle, 0x24000001ui64, &Src, &ElementSize);
  v3 = Element;
  if( Element == -1073741275 )
  {
    v5 = 0;
    goto LABEL_6;
  }
  if( Element >= 0 )
  {
    v5 = ElementSize;
LABEL_6:
    v6 = Src;
    v7 = 0;
    if( v5 >> 4 )
    {
      while( 1 )
      {
        v8 = *(_QWORD *)(a2 + 16) - *v6;
        if( !v8 )
          v8 = *(_QWORD *)(a2 + 24) - v6[1];
        if( !v8 )
          break;
        v6 += 2;
        if( ++v7 >= v5 >> 4 )
          goto LABEL_11;
      }
      v3 = 0;
    }
    else
    {
LABEL_11:
      PoolWithTag = (UINT8 *)ExAllocatePoolWithTag(PagedPool, v5 + 16i64, 0x4B444342ui64);
      v10 = PoolWithTag;
      if( PoolWithTag )
      {
        v11 = (UINT8 *)Src;
        *(_OWORD *)PoolWithTag = *(_OWORD *)(a2 + 16);
        memmove(PoolWithTag + 16, v11, v5);
        LODWORD(DataSize) = v5 + 16;
        v3 = BcdSetElementDataWithFlags(ObjectHandle, 0x24000001ui64, v12, v10, DataSize);
        ExFreePoolWithTag(v10, 0x4B444342u);
      }
      else
      {
        v3 = -1073741801;
      }
    }
  }
  if( Src )
    ExFreePoolWithTag(Src, 0x4B444342u);
LABEL_17:
  if( ObjectHandle )
    BcdCloseObject(ObjectHandle);
  return(unsigned int)v3;
}

Referenced by:

BiExportBcdObjects