PopPlInitWString

INT64 __stdcall PopPlInitWString(PUNICODE_STRING DestinationString){
  unsigned int v1; 
  __int64 v2; 
  __int64 v3; 
  const wchar_t *v5; 
  NTSTATUS v6; 
  size_t v7; 
  UINT64 v8; 
  wchar_t *PoolWithTag; 
  size_t cchToCopy; 
  v5 = (const wchar_t *)(v2 + v1);
  *DestinationString = 0i64;
  cchToCopy = 0i64;
  v6 = RtlStringCchLengthW(v5, v3 - (_QWORD)v5, &cchToCopy);
  if( v6 >= 0 )
  {
    v7 = cchToCopy;
    if( cchToCopy <= 0x7FFF )
    {
      if( cchToCopy )
      {
        v8 = 2 * cchToCopy;
        DestinationString->MaximumLength = 2 * cchToCopy;
        PoolWithTag = (wchar_t *)ExAllocatePoolWithTag(NonPagedPoolNx, v8, 0x6C506F50ui64);
        DestinationString->Buffer = PoolWithTag;
        if( PoolWithTag )
        {
          v6 = RtlUnicodeStringCchCopyStringN(DestinationString, v5, v7);
          if( v6 < 0 )
          {
            ExFreePoolWithTag(DestinationString->Buffer, 0x6C506F50u);
            *DestinationString = 0i64;
          }
        }
        else
        {
          DestinationString->MaximumLength = 0;
          return(unsigned int)-1073741670;
        }
      }
      else
      {
        return 0;
      }
    }
    else
    {
      return(unsigned int)-1073741820;
    }
  }
  return(unsigned int)v6;
}

Referenced by:

PopPlInitDevice
PopPlInitPowerPlane