RtlDuplicateUnicodeString

NTSTATUS __stdcall RtlDuplicateUnicodeString(UINT64 Flags, UNICODE_STRING *StringIn, UNICODE_STRING *StringOut){
  unsigned __int16 Length; 
  wchar_t *v6; 
  int v7; 
  int v8; 
  NTSTATUS result; 
  unsigned __int16 v10; 
  UINT8 *StringRoutine; 
  Length = 0;
  v6 = 0i64;
  if( (Flags & 0xFFFFFFFC) != 0 )
    return -1073741811;
  if( !StringOut )
    return -1073741811;
  v7 = Flags & 1;
  v8 = Flags & 2;
  if( (Flags & 2) != 0 && (Flags & 1) == 0 )
    return -1073741811;
  result = RtlValidateUnicodeString(0i64, StringIn);
  if( result < 0 )
    return result;
  if( StringIn )
    Length = StringIn->Length;
  if( v7 && Length == 0xFFFE )
    return -1073741562;
  if( v7 )
    v10 = Length + 2;
  else
    v10 = Length;
  if( !v8 && !Length )
    v10 = 0;
  if( !v10 )
    goto LABEL_20;
  StringRoutine = (UINT8 *)ExpAllocateStringRoutine(v10);
  v6 = (wchar_t *)StringRoutine;
  if( StringRoutine )
  {
    if( Length )
      memmove(StringRoutine, (UINT8 *)StringIn->Buffer, Length);
    if( v7 )
      v6[(unsigned __int64)Length >> 1] = 0;
LABEL_20:
    StringOut->MaximumLength = v10;
    StringOut->Length = Length;
    StringOut->Buffer = v6;
    return 0;
  }
  return -1073741801;
}

Referenced by:

DrvDbGetObjectDatabaseNode
EtwpCovSampModuleGetName
ExpCovCreateUnloadedModuleEntry
ExpCovQueryInformation
ExpCovReadFriendlyName
ExpCovReadRequestBuffer
ExpCovResetInformation
MiFindHotPatchRecord
MiResolveImageReferences
NtManageHotPatch
PiDrvDbQuerySystemPathWin32
PipAddRequestToEdge
PnpEarlyLaunchImageNotificationPreProcess