PopAnsiStringToUnicodeString

NTSTATUS __stdcall PopAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PCANSI_STRING SourceString){
  unsigned int v4; 
  PVOID *p_Buffer; 
  VOID **PoolWithTag; 
  NTSTATUS result; 

  v4 = RtlxAnsiStringToUnicodeSize(&SourceString->Length);
  p_Buffer = (PVOID *)&DestinationString->Buffer;
  if( v4 > 0xFFFF )
  {
    if( *p_Buffer )
      goto LABEL_7;
    v4 = 0xFFFF;
  }
  if( !*p_Buffer || DestinationString->MaximumLength < v4 )
  {
    PoolWithTag = ExAllocatePoolWithTag(1ui64, v4, 1414616912i64);
    if( PoolWithTag )
    {
      if( *p_Buffer )
        ExFreePoolWithTag(*p_Buffer, 0);
      *p_Buffer = PoolWithTag;
      DestinationString->Length = 0;
      DestinationString->MaximumLength = v4;
    }
  }
LABEL_7:
  result = RtlAnsiStringToUnicodeString(DestinationString, SourceString, 0);
  if( result >= 0 )
    *((_WORD *)*p_Buffer + ((unsigned __int64)DestinationString->Length >> 1)) = 0;
  return result;
}

Referenced by:

PopAvlGetPowerRequestKey