PopCloneUnicodeString

INT64 __stdcall PopCloneUnicodeString(PCUNICODE_STRING SourceString, PUNICODE_STRING DestinationString){
  wchar_t *Buffer; 
  wchar_t *v5; 
  unsigned int Length; 
  unsigned int v7; 
  unsigned int v8; 
  NTSTATUS v9; 
  wchar_t *PoolWithTag; 
  Buffer = SourceString->Buffer;
  v5 = 0i64;
  if( Buffer && (Length = SourceString->Length, Length >= 2) )
  {
    v7 = Length >> 1;
    v8 = 2 * v7 + 2;
    if( !Buffer[v7 - 1] )
      v8 = 2 * v7;
    if( v8 >= 0xFFFF )
    {
      v9 = -2147483643;
LABEL_15:
      *DestinationString = 0i64;
      return(unsigned int)v9;
    }
    PoolWithTag = (wchar_t *)ExAllocatePoolWithTag(PagedPool, v8, 0x67696450ui64);
    v5 = PoolWithTag;
    if( !PoolWithTag )
    {
      v9 = -1073741670;
      goto LABEL_15;
    }
    memset((INT64)PoolWithTag, 0i64);
    DestinationString->Buffer = v5;
    DestinationString->Length = 0;
    DestinationString->MaximumLength = v8;
    v9 = RtlUnicodeStringCopy(DestinationString, (UNICODE_STRING *)SourceString);
    if( v9 >= 0 )
      return 0;
  }
  else
  {
    v9 = 0;
    *SourceString = 0i64;
  }
  if( v5 )
    ExFreePoolWithTag(v5, 0x67696450u);
  if( v9 < 0 )
    goto LABEL_15;
  return(unsigned int)v9;
}

Referenced by:

PopDirectedDripsDiagCreateDeviceDescription