Newer
Older
AMI-Aptio-BIOS-Reversed / Platform / HiiStringPacker.c
@Ajax Dong Ajax Dong 2 days ago 3 KB Init
// HiiStringPacker - decompiled from Platform.efi
unsigned __int64 __fastcall HiiStringPacker(CHAR16 *ZeroPool, UINTN n0xF4240, const CHAR16 *GUID_)
{
  CHAR16 *ZeroPool_1; // rbx
  const char *(Destination____((void__)_0)); // r8
  __int64 n241; // rdx
  UINTN n0xF4240_1; // rax
  UINTN n0xF4240_2; // rbp
  CHAR16 v11; // ax
  signed __int64 v12; // rdi

  ZeroPool_1 = ZeroPool; /*0x4ed5*/
  if ( ((unsigned __int8)ZeroPool & 1) != 0 ) /*0x4edb*/
    Assert( /*0x4eec*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\SafeString.c",
      235,
      (__int64)"((UINTN) Destination & 0x00000001) == 0");
  if ( ((unsigned __int8)GUID_ & 1) != 0 ) /*0x4ef5*/
    Assert( /*0x4f06*/
      (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\SafeString.c",
      236,
      (__int64)"((UINTN) Source & 0x00000001) == 0");
  if ( !ZeroPool_1 ) /*0x4f11*/
  {
    (Destination____((void__)_0)) = "(Destination != ((void *) 0))"; /*0x4f13*/
    n241 = 241; /*0x4f1a*/
LABEL_7:
    Assert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\SafeString.c", n241, (__int64)(Destination____((void__)_0))); /*0x4f1f*/
    return 0x8000000000000002uLL; /*0x4f31*/
  }
  if ( !GUID_ ) /*0x4f39*/
  {
    (Destination____((void__)_0)) = "(Source != ((void *) 0))"; /*0x4f3b*/
    n241 = 242; /*0x4f42*/
    goto LABEL_7; /*0x4f47*/
  }
  if ( n0xF4240 > 0xF4240 ) /*0x4f50*/
  {
    (Destination____((void__)_0)) = "(DestMax <= (_gPcd_FixedAtBuild_PcdMaximumUnicodeStringLength))"; /*0x4f52*/
    n241 = 248; /*0x4f59*/
    goto LABEL_7; /*0x4f5e*/
  }
  if ( !n0xF4240 ) /*0x4f63*/
  {
    (Destination____((void__)_0)) = "(DestMax != 0)"; /*0x4f65*/
    n241 = 254; /*0x4f6c*/
    goto LABEL_7; /*0x4f71*/
  }
  n0xF4240_1 = StrLen(GUID_); /*0x4f79*/
  n0xF4240_2 = n0xF4240_1; /*0x4f7e*/
  if ( n0xF4240 <= n0xF4240_1 ) /*0x4f84*/
  {
    Assert((__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\SafeString.c", 260, (__int64)"(DestMax > SourceLen)"); /*0x4f95*/
    return 0x8000000000000005uLL; /*0x4fa4*/
  }
  if ( GUID_ > ZeroPool_1 ) /*0x4fac*/
    goto LABEL_19; /*0x4fac*/
  if ( ZeroPool_1 >= &GUID_[n0xF4240_1 + 1] ) /*0x4fb9*/
  {
    if ( ZeroPool_1 > GUID_ ) /*0x4fbe*/
      goto LABEL_22; /*0x4fbe*/
LABEL_19:
    if ( GUID_ >= &ZeroPool_1[n0xF4240] ) /*0x4fc7*/
      goto LABEL_21; /*0x4fc7*/
  }
  Assert( /*0x4fc9*/
    (__int64)"e:\\hs\\MdePkg\\Library\\BaseLib\\SafeString.c",
    265,
    (__int64)"InternalSafeStringNoStrOverlap (Destination, DestMax, (CHAR16 *)Source, SourceLen + 1)");
LABEL_21:
  if ( GUID_ > ZeroPool_1 ) /*0x4fe0*/
  {
LABEL_24:
    if ( GUID_ < &ZeroPool_1[n0xF4240] ) /*0x4ffb*/
      return 0x800000000000000FuLL; /*0x4ffb*/
    goto LABEL_26; /*0x4ffb*/
  }
LABEL_22:
  if ( ZeroPool_1 < &GUID_[n0xF4240_2 + 1] ) /*0x4fed*/
    return 0x800000000000000FuLL; /*0x5007*/
  if ( GUID_ >= ZeroPool_1 ) /*0x4ff2*/
    goto LABEL_24; /*0x4ff2*/
LABEL_26:
  v11 = *GUID_; /*0x5009*/
  if ( *GUID_ ) /*0x5009*/
  {
    v12 = (char *)GUID_ - (char *)ZeroPool_1; /*0x5011*/
    do /*0x5022*/
    {
      *ZeroPool_1++ = v11; /*0x5014*/
      v11 = *(CHAR16 *)((char *)ZeroPool_1 + v12); /*0x501b*/
    }
    while ( v11 ); /*0x5022*/
  }
  *ZeroPool_1 = 0; /*0x5024*/
  return 0; /*0x5039*/
}