RtlStringCbCopyUnicodeString

__int64 __fastcall RtlStringCbCopyUnicodeString(
        unsigned __int16 *a1,
        unsigned __int64 a2,
        const struct _UNICODE_STRING *a3){
  unsigned __int64 v3; 
  NTSTATUS v5; 
  __int64 v6; 
  signed __int64 v7; 
  unsigned __int16 *v8; 
  ULONG v10; 
  __int64 v11; 
  WCHAR *v12; 

  v3 = a2 >> 1;
  v5 = 0;
  if( v3 - 1 > 0x7FFE )
    v5 = -1073741811;
  if( v5 >= 0 )
  {
    v12 = 0i64;
    v11 = 0i64;
    v5 = RtlUnicodeStringValidateSrcWorker(a3, &v12, (size_t *)&v11, (size_t)a3, v10);
    if( v5 < 0 )
    {
      *a1 = 0;
    }
    else
    {
      if( v3 )
      {
        v6 = v11 - v3;
        v7 = (char *)v12 - (char *)a1;
        do
        {
          if( !(v6 + v3) )
            break;
          *a1 = *(unsigned __int16 *)((char *)a1 + v7);
          ++a1;
          --v3;
        }
        while( v3 );
      }
      v8 = a1 - 1;
      if( v3 )
        v8 = a1;
      v5 = v3 == 0 ? 0x80000005 : 0;
      *v8 = 0;
    }
  }
  return(unsigned int)v5;
}

Referenced by:

PoStoreRequester
PopSafeCopyUnicodeString
SmKmKeyGenStart