iOS 13 Text To Speech (TTS - AVSpeechSynthesisVoice) crashes for some users after update - text-to-speech

We are seeing a weird crashes for a small percentage of users related to a problem of TTS after updating to iOS 13. Anybody any idea why this happens? Anybody seeing the same crashes?
let voices = AVSpeechSynthesisVoice.speechVoices()
for voice in voices {
if voice.name == storedName {
synthVoice = voice
break
}
}
...
let utterance = AVSpeechUtterance(string: text)
utterance.voice = self.synthVoice
self.synthesizer.speak(utterance)
Crashlog:
Error: Fatal Exception: std::logic_error: Unable to find resource `lang'[kLanguage].
8 libc++abi.dylib 0x19c929304 std::__terminate(void (*)()) + 16
9 libc++abi.dylib 0x19c928c58 __cxa_get_exception_ptr + 30
10 libc++abi.dylib 0x19c928c18 __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*) + 122
11 SiriTTS 0x19f877894 VoiceConfig::report_error(unsigned int, VoiceConfig::IfMissing, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 960
12 SiriTTS 0x19f877d88 VoiceConfigImpl::get_json(unsigned int, VoiceConfig::IfMissing) const + 144
13 SiriTTS 0x19f8e1210 std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > VoiceConfig::get_param<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(unsigned int, VoiceConfig::IfMissing) const + 36
14 SiriTTS 0x19f848490 NashvilleAdapterStream::NashvilleAdapterStream(nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>) + 308
15 SiriTTS 0x19f8c0158 std::__1::__compressed_pair_elem<NashvilleAdapterStream, 1, false>::__compressed_pair_elem<nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>&, 0ul, 1ul>(std::__1::piecewise_construct_t, std::__1::tuple<nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>&>, std::__1::__tuple_indices<0ul, 1ul>) + 72
16 SiriTTS 0x19f8c00d0 std::__1::__shared_ptr_emplace<NashvilleAdapterStream, std::__1::allocator<NashvilleAdapterStream> >::__shared_ptr_emplace<nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>&>(std::__1::allocator<NashvilleAdapterStream>, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&&&, std::__1::shared_ptr<SharedObjectPool>&&&) + 40
17 SiriTTS 0x19f8c0078 std::__1::shared_ptr<NashvilleAdapterStream> std::__1::shared_ptr<NashvilleAdapterStream>::make_shared<nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>&>(nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&&&, std::__1::shared_ptr<SharedObjectPool>&&&) + 52
18 SiriTTS 0x19f8bffd8 std::__1::shared_ptr<Module> std::__1::__invoke_void_return_wrapper<std::__1::shared_ptr<Module> >::__call<void ModuleFactory::ModuleFactoryImpl::register_module<NashvilleAdapterStream>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::'lambda'(nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>)&, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool> >(void ModuleFactory::ModuleFactoryImpl::register_module<NashvilleAdapterStream>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::'lambda'(nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>)&&&, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&&&, std::__1::shared_ptr<SharedObjectPool>&&) + 48
19 SiriTTS 0x19f8bdeb4 ModuleFactory::ModuleFactoryImpl::create(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>) + 164
20 SiriTTS 0x19f8bdda4 ModuleFactory::create(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>) + 60
21 SiriTTS 0x19f8652e4 GryphonPipelineFactory::pipeline_from_config(std::__1::shared_ptr<SharedObjectPool>, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&) + 472
22 SiriTTS 0x19f866a84
GryphonPipelineFactory::nashvilleFE_backend_pipeline(std::__1::shared_ptr<SharedObjectPool>) + 1140 23 SiriTTS 0x19f85ffb0 FeatureExtractorTarget::init_with_object_pool(std::__1::shared_ptr, bool) + 924
24 SiriTTS 0x19f86027c
FeatureExtractorTarget::init_with_install_path(char const*) + 272
25 TTSSpeechBundle 0x110480b50 (Missing)
26 TTSSpeechBundle 0x1104919c4 (Missing)
27 TTSSpeechBundle 0x110491a6c (Missing)
28 TTSSpeechBundle 0x11048ef44 (Missing)
29 TTSSpeechBundle 0x110490514 (Missing)
30 TTSSpeechBundle 0x11048eefc (Missing)
31 libsystem_pthread.dylib 0x19c8781f0 _pthread_start + 124
32 libsystem_pthread.dylib 0x19c87baf0 thread_start + 8

UPDATE: Issue appears to be fixed in iOS 13.2! Yay!
Looks like a bug on some devices running IOS 13 (In my case 13.1.2 on an iPhone SE),
AVSpeechSynthesisVoice.speechVoices()
is returning nil.
Also, FYI, setting a voice using the AVSpeechSynthesisVoice initializer such as
AVSpeechSynthesisVoice(language: "fr-FR")
results in the voice being set as nil and English being used as a fallback/default.
I have filed a feedback on both issues... and also previously this one which was fixed during 13 beta, but now I'm not so sure... since this new issue either supersedes it or is a result of engineers in different departments working at cross-purposes.

Related

How can I fix the damage in PDF files requested using MS2XML.XMLHTTP?

Friends, this is my first question here... I've been facing some problems when downloading a PDF buffer using MS2XML.XMLHTTP. I've been using Genexus to do so but I also tried right in pure Visual Fox Pro. The problem is that when I send the ResponseText to a string variable, some characters are replaced by question marks, the sam happens when I send the ResponseText to a pdf or txt file. The object created in MS2XML.XMLHTTP.6.0 does not allow using the ResponseBody property. Any thoughts on how could I solve it using MS2XML.XMLHTTP? Thanks.
oHTTP = CreateObject("MSXML2.XMLHTTP.6.0")
oHTTP.Open("GET", 'https://homologacao.plugboleto.com.br/api/v1/boletos/impressa /lote/NIKLfYBWz',.F.)
oHTTP.setRequestHeader("content-type", "application/pdf")
oHTTP.Send()
? oHTTP.responseText
I've received someething like the following (full of question marks):
%PDF-1.4 %??2 0 obj <</ColorSpace/DeviceRGB/Subtype/Image/Height 38/Filter/DCTDecode/Type/XObject/Width 149/BitsPerComponent 8/Length 2619>>stream ???JFIF H H ??C  !"$"$??C?? & ?" ?? ??? } !1AQa"q2???#B??R?$3br? %&'()456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz???????????????????????????????????????????????????? ??? w !1AQaq"2?B????#3R??$4?&'()56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz??????????????????????????????????????????????????? ? ?h???8OO????a&??G?3? ?p1???|b?o?? ??x?_???%??E?en9??T???T>.????JG??rx??????????h?w????????:?!?????????jlm?Tn???????u??? ??Ey?PA?? (?? (?? (?? (??>B???;.??3?e??J??~?F??? y,s??i???#?m=kw???? ?[?K#????vR#G??^$?????k?[??BSu??#???M??????? _??Z?Fo??????/??*x?¾ mn??{)???80??s]W?x? ??+??k??=????????8 ?|D?c?j???h???$?8???:c??(???M/?Ze??;O?[?J????? '?~/j~!???n?urm???1^ITl;?3?%[?b??~?&<=u?Y\x??W6?¬$2?q?1?;??qc??_??qk>?&?v?????,??F?{??x???s??????{?k????r8.??<P?|,????q?]I?]?e???p;??/?W?x??)???A?????&)??dc,?d7?J?s??m?>???????!??9Va?? c???Zv??x+?b?wd??f?8a????????,6????????x?? ?-????<9F???????[~$?{??o???X??????y?ZgQ?#8??ox;? ???|??mZ?? I~a?k ~P ?? j??? '?c??4?F??l??$?8???(?'?"?.?????,????9V?????d???????UU)??? ???o?&???4?7?Z?? g???y?
W[?????d?Q$?#??^mZ???B Z(??QE ?Q#Q#Q#Q#Q#??endstream endobj 6 0 obj <</Filter/FlateDecode/Length 846>>stream x??V???+?q??z???'U./h???{???d?U??xf??PQ?O???unA???x1?0 50]#?\?T?y?B?s?9B? ? 2|????C???2t????k?U??]??]{? ?????s?AH??????h?"w????? f?????i??? ??>?9?8?#??"??G?$???<??0???S?2??sn?n??^?5?\FN?o1?4?~4~??Qe=&?T[???????Z??x??????k?????0z'#?;?'a??a?f~?q?~8ZH~?m???????Mm?p?#hh{????W7??????
?8?Olk'?A|?[???P?5?????uGxRr#?pw<$y?n??kD ???0??ih??9?5v??0?_}iG?Dq?8??_U??5a?????k????d???M??2???C(??;t2uA]z ??6A??o?t?}d????[?<;??R?iO8n??f???40???S?aVX????Y?p2N?eq]N?VeE?>??/V0?]MV?&???.aZ-???z2???????????8o??3?S????????gf??B?'6??]?J endstream endobj 8 0 obj<</Contents 6 0 R/Type/Page/Resources<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]/Font<</F1 3 0 R/F2 4 0 R>>/XObject<</Xf1 1 0 R/Xf2 5 0 R/img0 2 0 R>>>>/Parent 7 0 R/MediaBox[0 0 595 842]>>endobj 3 0 obj<</Subtype/Type1/Type/Font/BaseFont/Helvetica-Bold/Encoding/WinAnsiEncoding>>endobj 4 0 obj<</Subtype/Type1/Type/Font/BaseFont/Helvetica/Encoding/WinAnsiEncoding>>endobj 5 0 obj <</Subtype/Form/Filter/FlateDecode/Type/XObject/Matrix [1 0 0 1 0 0]/FormType 1/Resources<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]>>/BBox[0 0 292.41 39]/Length 474>>stream x?m??e1C?#???1Ly}??Ua??>????r?R?????r?7gr??a???\??PTj??p???s????~m"???:K??T???1????Gw({c???? !???p?rB g M?QG*?PC ?o??v?????'n[!n2??}*?g}r?G??J?R"aI?S??q ???d;??-??m?????y?lCp??[B(=?L??G[]2??)???
?8???9L????]y)?B??t<??E??????I????????#1?]$? ??h??6?Q[A)?8????<???????z??8c??????s??R????%6? endstream endobj 1 0 obj <</Subtype/Form/Filter/FlateDecode/Type/XObject/Matrix [1 0 0 1 0 0]/FormType 1/Resources<</ProcSet[/PDF/Text]/ExtGState 9 0 R/Font 10 0 R>>/Length 1818/BBox[0 0 595.28 419.53]>>stream x???Ko???t??V|???4-$n??{Pm%]6????P????:?$E?6i ?4??????d??m.U?7L????E??"???e?^r??c????????S#'?????????X?bz?k.J?3!?)??{?V ??'VS1?????8??L???? fU"&Fx?v?Q?9G??EL]?iLIN}?C?i~??4???J<??P?4Ec??F??P%c=!
?=?!U??P?T?b]???k>+¹&?5?9A5ai?"???G????H???J??J?#N??#?3dP??#O=A6%??&dO?eU&5;?Q?#M?'??.??8????P???z!
'??j??O?8??7?
?f????????u???^???:N#?q?Y?xN6Kjv B??Z?????<?? Dx^?J??;A1?3s /?S?k?8??'?9?n??.w?s????g????? M<0????????<?,p???xG!pv?v??O??,?!pv?v?P??l?O??3?M)[????????x??D?h????Z??&i)??,????k???k????j*???-?#?'?x9D)]?J:?=?G??1r? ???!???X?I???|n?q}?=?6?:ðl??????_T??[??_?AC???YI??????+??]??}f}S?P<{??EY??#??q?pah???,Pj?????v~??a?c???{R?7????? ?E~?mv??v?6??t ?? ??Y?????&???F?7P'?e?????R&??(?#????????)?2???P??j?.I??s4?|???s???$z????????E?P??x?{??tU?????????|??b?'?jH????f6 .?g? ?"?????iVR";;?P?'????F?????*??^?b?Nu6rO6? ?Xn[~>t???x2????n?[?D^????6C4O??vx??p?#???$?ru??Yj??55,?Z???u?&?yy????%????+????aMk?3 ???v?1M\A&?q???? '?Sf?,??ce)? ??x?????P?#?Ea&y????/n??~8j???????Co????????????%?? ????????5C???(?<??}???OA???a$?)J?`?!vd????T????D{,?}^?e?]]#?'#T?v??J??;??4?G?e???&b?Bl???K????.?t=s?i?;6.> ?????:?H??Z}:.V? ??) endstream endobj 9 0 obj<</R7 11 0 R/R9 12 0 R>>endobj 10 0 obj<</R8 13 0 R>>endobj 11 0 obj<</TK true/Type/ExtGState/BM/Normal/OPM 1>>endobj 12 0 obj<</Type/ExtGState/SA true>>endobj 13 0 obj<</Subtype/Type1/Type/Font/BaseFont/Helvetica/Encoding 14 0 R>>endobj 14 0 obj<</Type/Encoding/Differences[225/aacute/acircumflex/atilde 231/ccedilla 233/eacute/ecircumflex 243/oacute 245/otilde 250/uacute]>>endobj 7 0 obj<</Kids[8 0 R]/Type/Pages/Count 1>>endobj 15 0 obj<</Type/Catalog/Pages 7 0 R>>endobj 16 0 obj<<>>endobj xref 0 17 0000000000 65535 f 0000004765 00000 n 0000000015 00000 n 0000003908 00000 n 0000004000 00000 n 0000004087 00000 n 0000002787 00000 n 0000007190 00000 n 0000003700 00000 n 0000006794 00000 n 0000006833 00000 n 0000006863 00000 n 0000006922 00000 n 0000006965 00000 n 0000007044 00000 n 0000007240 00000 n 0000007285 00000 n trailer<</Info 16 0 R/ID []/Root 15 0 R/Size 17>>startxref 7305 %%EOF
Since a PDF is a binary file and not a text file, it is quite normal you would see ? and all sorts of other non-printable characters. Instead save it to a file on disk and open with something like ShellExecute. ie:
oHTTP = CreateObject("MSXML2.XMLHTTP.6.0")
oHTTP.Open("GET", 'https://homologacao.plugboleto.com.br/api/v1/boletos/impressa /lote/NIKLfYBWz',.F.)
oHTTP.setRequestHeader("content-type", "application/pdf")
oHTTP.Send()
Local lcFileName
lcFileName = Forcepath(Sys(2015)+'.pdf', Sys(2023))
Strtofile(oHttp.responseText, m.lcFileName)
Declare Long ShellExecute In "shell32.dll" ;
long HWnd, String lpszOp, ;
string lpszFile, String lpszParams, ;
string lpszDir, Long nShowCmd
ShellExecute(_vfp.HWnd,'',m.lcFileName,'','',1)
EDIT: It was not a job MSXML2.XmlHttp. You simply download the file as a PDF and open it:
Local lcFileName, lcRemote
lcRemote = 'https://homologacao.plugboleto.com.br/api/v1/boletos/impressao/lote/NIKLfYBWz'
lcFileName = Forcepath(Sys(2015)+'.pdf', Sys(2023))
If (getFileFromURL(m.lcRemote, m.lcFileName) = 0)
Declare Long ShellExecute In "shell32.dll" ;
long HWnd, String lpszOp, ;
string lpszFile, String lpszParams, ;
string lpszDir, Long nShowCmd
ShellExecute(_vfp.HWnd,'',m.lcFileName,'','',1)
Endif
Procedure getFileFromURL
Lparameters tcRemoteFile,tcLocalFile
Declare Integer URLDownloadToFile In urlmon.Dll;
INTEGER pCaller, String szURL, String szFileName,;
INTEGER dwReserved, Integer lpfnCB
Return URLDownloadToFile(0, m.tcRemoteFile, m.tcLocalFile, 0, 0)
endproc

iOS 13 TTS Crashes - Unable to find resource `lang'[kLanguage] - (AVSpeechSynthesisVoice, AVSpeechUtterance)

We are seeing a weird crash probably related to TTS (Fatal Exception: std::logic_error: Unable to find resource `lang'[kLanguage]). It happens for me with different languages, so it seems there is some change in iOS 13. Maybe the TextToSpeech ressources are not loaded in time. Anybody any idea? Does anybody else see this crash or better know how to fix this?
let voices = AVSpeechSynthesisVoice.speechVoices()
for voice in voices {
if voice.name == storedName {
synthVoice = voice
break
}
}
...
let utterance = AVSpeechUtterance(string: text)
utterance.voice = self.synthVoice
self.synthesizer.speak(utterance)
Error: Fatal Exception: std::logic_error: Unable to find resource `lang'[kLanguage].
Trace:
8 libc++abi.dylib 0x19c929304 std::__terminate(void (*)()) + 16
9 libc++abi.dylib 0x19c928c58 __cxa_get_exception_ptr + 30
10 libc++abi.dylib 0x19c928c18 __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*) + 122
11 SiriTTS 0x19f877894 VoiceConfig::report_error(unsigned int, VoiceConfig::IfMissing, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 960
12 SiriTTS 0x19f877d88 VoiceConfigImpl::get_json(unsigned int, VoiceConfig::IfMissing) const + 144
13 SiriTTS 0x19f8e1210 std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > VoiceConfig::get_param<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(unsigned int, VoiceConfig::IfMissing) const + 36
14 SiriTTS 0x19f848490 NashvilleAdapterStream::NashvilleAdapterStream(nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>) + 308
15 SiriTTS 0x19f8c0158 std::__1::__compressed_pair_elem<NashvilleAdapterStream, 1, false>::__compressed_pair_elem<nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>&, 0ul, 1ul>(std::__1::piecewise_construct_t, std::__1::tuple<nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>&>, std::__1::__tuple_indices<0ul, 1ul>) + 72
16 SiriTTS 0x19f8c00d0 std::__1::__shared_ptr_emplace<NashvilleAdapterStream, std::__1::allocator<NashvilleAdapterStream> >::__shared_ptr_emplace<nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>&>(std::__1::allocator<NashvilleAdapterStream>, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&&&, std::__1::shared_ptr<SharedObjectPool>&&&) + 40
17 SiriTTS 0x19f8c0078 std::__1::shared_ptr<NashvilleAdapterStream> std::__1::shared_ptr<NashvilleAdapterStream>::make_shared<nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>&>(nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&&&, std::__1::shared_ptr<SharedObjectPool>&&&) + 52
18 SiriTTS 0x19f8bffd8 std::__1::shared_ptr<Module> std::__1::__invoke_void_return_wrapper<std::__1::shared_ptr<Module> >::__call<void ModuleFactory::ModuleFactoryImpl::register_module<NashvilleAdapterStream>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::'lambda'(nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>)&, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool> >(void ModuleFactory::ModuleFactoryImpl::register_module<NashvilleAdapterStream>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::'lambda'(nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>)&&&, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&&&, std::__1::shared_ptr<SharedObjectPool>&&) + 48
19 SiriTTS 0x19f8bdeb4 ModuleFactory::ModuleFactoryImpl::create(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>) + 164
20 SiriTTS 0x19f8bdda4 ModuleFactory::create(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>) + 60
21 SiriTTS 0x19f8652e4 GryphonPipelineFactory::pipeline_from_config(std::__1::shared_ptr<SharedObjectPool>, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&) + 472
22 SiriTTS 0x19f866a84
GryphonPipelineFactory::nashvilleFE_backend_pipeline(std::__1::shared_ptr<SharedObjectPool>) + 1140 23 SiriTTS 0x19f85ffb0 FeatureExtractorTarget::init_with_object_pool(std::__1::shared_ptr, bool) + 924
24 SiriTTS 0x19f86027c
FeatureExtractorTarget::init_with_install_path(char const*) + 272
25 TTSSpeechBundle 0x110480b50 (Missing)
26 TTSSpeechBundle 0x1104919c4 (Missing)
27 TTSSpeechBundle 0x110491a6c (Missing)
28 TTSSpeechBundle 0x11048ef44 (Missing)
29 TTSSpeechBundle 0x110490514 (Missing)
30 TTSSpeechBundle 0x11048eefc (Missing)
31 libsystem_pthread.dylib 0x19c8781f0 _pthread_start + 124
32 libsystem_pthread.dylib 0x19c87baf0 thread_start + 8

Assign a string to CommandText in IL using Reflexil

I need to edit a query for an application developed some time ago. But I don't have the source code, only the compiled dll's. Following is the source decompiled by Telerik JustDecompile.
conCl.Conn();
conCl.Con.Open();
SqlCommand com = conCl.Com;
string[] strArrays = new string[] { "SELECT * FROM TBL_USER WHERE u_name = '", user.Replace("'", "''"), "' AND u_pass = '", password.Replace("'", "''"), "' and u_IsActive = 1 " };
com.CommandText = string.Concat(strArrays);
SqlDataReader sqlDataReader = conCl.Com.ExecuteReader();
The resulting IL in Reflexil is:
off op operand
set code
18 ldfld System.Data.SqlClient.SqlConnection ANZFrameWorkDAL.ConCls::Con
23 callvirt System.Void System.Data.SqlClient.SqlConnection::Open()
28 nop
29 ldloc.0
30 ldfld System.Data.SqlClient.SqlCommand ANZFrameWorkDAL.ConCls::Com
35 ldc.i4.5
36 newarr System.String
41 stloc.s -> (4) (System.String[])
43 ldloc.s -> (4) (System.String[])
45 ldc.i4.0
46 ldstr SELECT * FROM TBL_USER WHERE u_name = '
51 stelem.ref
52 nop
53 ldloc.s -> (4) (System.String[])
55 ldc.i4.1
56 ldarg.1
57 ldstr '
62 ldstr ''
67 callvirt System.String System.String::Replace(System.String,System.String)
72 stelem.ref
73 nop
74 ldloc.s -> (4) (System.String[])
76 ldc.i4.2
77 ldstr ' AND u_pass = '
82 stelem.ref
83 nop
84 ldloc.s -> (4) (System.String[])
86 ldc.i4.3
87 ldarg.2
88 ldstr '
93 ldstr ''
98 callvirt System.String System.String::Replace(System.String,System.String)
103 stelem.ref
104 nop
105 ldloc.s -> (4) (System.String[])
107 ldc.i4.4
108 ldstr ' and u_IsActive = 1
113 stelem.ref
114 nop
115 ldloc.s -> (4) (System.String[])
117 call System.String System.String::Concat(System.String[])
122 callvirt System.Void System.Data.SqlClient.SqlCommand::set_CommandText(System.String)
127 nop
128 ldloc.0
129 ldfld System.Data.SqlClient.SqlCommand ANZFrameWorkDAL.ConCls::Com
134 callvirt System.Data.SqlClient.SqlDataReader System.Data.SqlClient.SqlCommand::ExecuteReader()
Now what I want is:
com.CommandText = "Select * form tbl_user where u_name = 'admin'"
I tried to load a string after offset 115 as
opcode = ldstr operand = select * form tbl_user where u_name = 'admin'
but the output became
strArrays.CommandText = string.Concat((string[])"select * form tbl_user where u_name = 'admin'");
so i deleted my change and add the same string after offset 117 as:
opcode = ldstr operand = select * form tbl_user where u_name = 'admin'
the output changed and feels somewhat near to what I want but still not correct. the output became:
string.Concat(strArrays).CommandText = "select * form tbl_user where u_name = 'admin'";
What I want is:
com.CommandText = "select * from tbl_user where u_name = 'admin'"
I also tried to add callvirt opcode after offset 122 but i was unable to find set_CommandText method in System.Data.SqlClient.SqlCommand when the loaded .NET framework was 4.6.1
How can I do this? Please, any help would be appreciated. THANKS
Most of the method is just the string concatenation so you can remove it. You can replace all the instructions from offset 35 to 117 inclusive, with a single ldstr that contains your string.

How to set multiple bit values within an integer

I am coding a program in vb.net using Visual Studio 2015. I am trying to figure out how to modify individual bits in a 16 bit integer. The numeric data-type byte-order is little-Indian and is as follows:
origin (2 bits)
tagged (1 bit)
addressable (1 bit)
protocol (12 bits)
Field: [ origin ] [tagged] [addressable] [protocol]
Bits: 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
In the example code below, I am trying to figure out how to set origin, tagged, addressable and protocol in the variable "i" which is a 16 bit integer.
Dim i As UInt16 = 0
Dim origin As Byte = 0 ' Message origin indicator
Dim tagged As Byte = 0 ' Determines usage of the Frame Address target field (0 or 1)
Dim addressable As Byte = 0 ' Message includes a target address (0 or 1)
Dim protocol As UInt16 = 1024 ' Protocol number: must be 1024 (decimal)
Can anyone provide a vb.net example of how I can update the variable "i" so that it contains the bit values for origin, tagged, addressable and protocol?
You can use a combination of or to set individual bits and >> and << to shift bits.
For example, to set two bytes from tagged, addressable and protocol, you can do:
Dim tagged As Byte = 1 ' Determines usage of the Frame Address target field (0 or 1)
Dim addressable As Byte = 1 ' Message includes a target address (0 or 1)
Dim protocol As UInt16 = 1026 ' Protocol number: must be 1024 (decimal)
sendbuf(0) = sendbuf(0) or tagged ' bit 0
sendbuf(0) = sendbuf(0) or (addressable << 1) ' bit 1
sendbuf(0) = sendbuf(0) or ((protocol << 2) and 255) ' first 6 bits of protocol
sendbuf(1) = sendbuf(1) or (protocol >> 6) ' next 6 bits of protocol
You may need to adjust it - I didn't follow the link, so I'm not completely sure which bits should go where (there's 14 bits to fit into 2 bytes).
Map the bit values using binary values in an enumeration. 1 = 1, 2 = 10, 4 = 100, etc. Then you can assign your variable using the enumeration. You can also combine the values into a new enumeration (see ProtocolX).
To give initial values, just add the enumeration you want to use.
' switch bits on 1, 5, 13, 14, 16
i = FrameSectionEnum.ProtocolBit1 + FrameSectionEnum.ProtocolBit5 +
FrameSectionEnum.AddressableBit13 +
FrameSectionEnum.TaggedBit14 + FrameSectionEnum.OriginBit16
PrintBits(i)
To switch on some bits and preserve the other bits, use OR.
' switch bits on 2 and 3 using a combined value. preserve other bits
i = SetOn(i, FrameSectionEnum.ProtocolX)
PrintBits(i)
To switch off some bits and preserve the other bits, use AND and NOT.
' switch bits off 1 and 5
i = SetOff(i, FrameSectionEnum.ProtocolBit1 + FrameSectionEnum.ProtocolBit5)
PrintBits(i)
List of utilities functions:
Check if certain bits is on:
Function CheckBit(i As Integer, bit As FrameSectionEnum) As Integer
Return If((i And bit) = bit, 1, 0)
End Function
Set bits on, preserve other bits:
Function SetOn(i As Integer, bit As FrameSectionEnum) As Integer
Return i Or bit
End Function
Set bits off, preserve other bits:
Function SetOff(i As Integer, bit As FrameSectionEnum) As Integer
Return i And (Not bit)
End Function
Full code:
Module Module1
Enum FrameSectionEnum
ProtocolBit1 = 1
ProtocolBit2 = 2
ProtocolBit3 = 4
ProtocolBit4 = 8
ProtocolBit5 = 16
ProtocolBit6 = 32
ProtocolBit7 = 64
ProtocolBit8 = 128
ProtocolBit9 = 256
ProtocolBit10 = 512
ProtocolBit11 = 1024
ProtocolBit12 = 2048
AddressableBit13 = 4096
TaggedBit14 = 8192
OriginBit15 = 16384
OriginBit16 = 32768
ProtocolX = ProtocolBit2 + ProtocolBit3
End Enum
Sub Main()
Dim i As UInt16 = 0
' switch bits on 1, 5, 13, 14, 16
i = FrameSectionEnum.ProtocolBit1 + FrameSectionEnum.ProtocolBit5 +
FrameSectionEnum.AddressableBit13 +
FrameSectionEnum.TaggedBit14 + FrameSectionEnum.OriginBit16
PrintBits(i)
' switch bits on 2 and 3 using a combined value. preserve other bits
i = SetOn(i, FrameSectionEnum.ProtocolX)
PrintBits(i)
' switch bits off 1 and 5
i = SetOff(i, FrameSectionEnum.ProtocolBit1 + FrameSectionEnum.ProtocolBit5)
PrintBits(i)
Console.ReadKey(True)
End Sub
Function SetOn(i As Integer, bit As FrameSectionEnum) As Integer
Return i Or bit
End Function
Function SetOff(i As Integer, bit As FrameSectionEnum) As Integer
Return i And (Not bit)
End Function
Function CheckBit(i As Integer, bit As FrameSectionEnum) As Integer
Return If((i And bit) = bit, 1, 0)
End Function
Sub PrintBits(i As Integer)
Console.Write(CheckBit(i, FrameSectionEnum.OriginBit16))
Console.Write(CheckBit(i, FrameSectionEnum.OriginBit15))
Console.Write(CheckBit(i, FrameSectionEnum.TaggedBit14))
Console.Write(CheckBit(i, FrameSectionEnum.AddressableBit13))
Console.Write(CheckBit(i, FrameSectionEnum.ProtocolBit12))
Console.Write(CheckBit(i, FrameSectionEnum.ProtocolBit11))
Console.Write(CheckBit(i, FrameSectionEnum.ProtocolBit10))
Console.Write(CheckBit(i, FrameSectionEnum.ProtocolBit9))
Console.Write(CheckBit(i, FrameSectionEnum.ProtocolBit8))
Console.Write(CheckBit(i, FrameSectionEnum.ProtocolBit7))
Console.Write(CheckBit(i, FrameSectionEnum.ProtocolBit6))
Console.Write(CheckBit(i, FrameSectionEnum.ProtocolBit5))
Console.Write(CheckBit(i, FrameSectionEnum.ProtocolBit4))
Console.Write(CheckBit(i, FrameSectionEnum.ProtocolBit3))
Console.Write(CheckBit(i, FrameSectionEnum.ProtocolBit2))
Console.Write(CheckBit(i, FrameSectionEnum.ProtocolBit1))
Console.WriteLine()
End Sub
End Module
The header format in the question contains the key to getting all the bits in the right place. For me personally, it's easier to visualize if you renumber the bits using a zero-based index:
Field: [ origin ] [tagged] [addressable] [protocol]
Bits: 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Starting with the origin field, it needs to be shifted 14 bits to the left, which can be done like this:
origin << 14
The tagged and addressable fields need to be shifted to the left by 13 and 12 bits, respectively, which can be done the same way. The protocol field is already in the right place, so it doesn't need to be shifted. They can all be combined together with the Or operator as follows:
i = (origin << 14) Or (tagged << 13) Or (addressable << 12) Or protocol
One last detail that needs to be addressed is that in VB.NET, bit shift operations are dependent upon the datatype that is being shifted. In your code above, the origin, tagged, and addressable variables are all of type Byte. Shifts on this type will all be done modulo 8 (the number of bits in a byte), meaning a shift of 9 bits is the same of a shift of 1 bit.
Because all of our shifts are more than 8 bits, we need to convert to a wider datatype or else things won't end up in the right place. The easy way to do this is to just change the declarations of all the variables to UInt16:
Dim i As UInt16
Dim origin As UInt16 = 0
Dim tagged As UInt16 = 0
Dim addressable As UInt16 = 0
Dim protocol As UInt16 = 1024
i = (origin << 14) Or (tagged << 13) Or (addressable << 12) Or protocol
The alternative to this is to keep your variables declared as they are and use CType to convert the fields right before doing the shifts:
Dim i As UInt16 = 0
Dim origin As Byte = 0
Dim tagged As Byte = 0
Dim addressable As Byte = 0
Dim protocol As UInt16 = 1024
i = (CType(origin, UInt16) << 14) Or (CType(tagged, UInt16) << 13) Or (CType(addressable, UInt16) << 12) Or protocol
Personally, I prefer the first way due to brevity, but the choice is yours!

Base64 Encoding for file upload VB.Net

I have a project in VBA that does the base64 encoding and uploads the file (.xlsm).
VBA Code:
Option Explicit
Private Const clOneMask = 16515072 '000000 111111 111111 111111
Private Const clTwoMask = 258048 '111111 000000 111111 111111
Private Const clThreeMask = 4032 '111111 111111 000000 111111
Private Const clFourMask = 63 '111111 111111 111111 000000
Private Const clHighMask = 16711680 '11111111 00000000 00000000
Private Const clMidMask = 65280 '00000000 11111111 00000000
Private Const clLowMask = 255 '00000000 00000000 11111111
Private Const cl2Exp18 = 262144 '2 to the 18th power
Private Const cl2Exp12 = 4096 '2 to the 12th
Private Const cl2Exp6 = 64 '2 to the 6th
Private Const cl2Exp8 = 256 '2 to the 8th
Private Const cl2Exp16 = 65536 '2 to the 16th
Private cbTransTo(63) As Byte
Private cbTransFrom(255) As Byte
Private clPowers8(255) As Long
Private clPowers16(255) As Long
Private clPowers6(63) As Long
Private clPowers12(63) As Long
Private clPowers18(63) As Long
Private Sub Class_Initialize()
Dim lTemp As Long
For lTemp = 0 To 63 'Fill the translation table.
Select Case lTemp
Case 0 To 25
cbTransTo(lTemp) = 65 + lTemp 'A - Z
Case 26 To 51
cbTransTo(lTemp) = 71 + lTemp 'a - z
Case 52 To 61
cbTransTo(lTemp) = lTemp - 4 '1 - 0
Case 62
cbTransTo(lTemp) = 43 'Chr(43) = "+"
Case 63
cbTransTo(lTemp) = 47 'Chr(47) = "/"
End Select
Next lTemp
For lTemp = 0 To 255 'Fill the lookup tables.
clPowers8(lTemp) = lTemp * cl2Exp8
clPowers16(lTemp) = lTemp * cl2Exp16
Next lTemp
For lTemp = 0 To 63
clPowers6(lTemp) = lTemp * cl2Exp6
clPowers12(lTemp) = lTemp * cl2Exp12
clPowers18(lTemp) = lTemp * cl2Exp18
Next lTemp
For lTemp = 0 To 255 'Fill the translation table.
Select Case lTemp
Case 65 To 90
cbTransFrom(lTemp) = lTemp - 65 'A - Z
Case 97 To 122
cbTransFrom(lTemp) = lTemp - 71 'a - z
Case 48 To 57
cbTransFrom(lTemp) = lTemp + 4 '1 - 0
Case 43
cbTransFrom(lTemp) = 62 'Chr(43) = "+"
Case 47
cbTransFrom(lTemp) = 63 'Chr(47) = "/"
End Select
Next lTemp
End Sub
Public Function Encode(sString As String) As String
Dim bTrans(63) As Byte, bOut() As Byte, bIn() As Byte, lOutSize As Long
Dim lChar As Long, lTrip As Long, iPad As Integer, lLen As Long, lTemp As Long, lPos As Long
iPad = Len(sString) Mod 3 'See if the length is divisible by 3
If iPad Then 'If not, figure out the end pad and resize the input.
iPad = 3 - iPad
sString = sString & String(iPad, Chr(0))
End If
bIn = StrConv(sString, vbFromUnicode) 'Load the input string.
lLen = ((UBound(bIn) + 1) \ 3) * 4 'Length of resulting string.
lTemp = lLen \ 72 'Added space for vbCrLfs.
lOutSize = ((lTemp * 2) + lLen) - 1 'Calculate the size of the output buffer.
ReDim bOut(lOutSize) 'Make the output buffer.
lLen = 0 'Reusing this one, so reset it.
For lChar = LBound(bIn) To UBound(bIn) Step 3
lTrip = clPowers16(bIn(lChar)) + clPowers8(bIn(lChar + 1)) + bIn(lChar + 2) 'Combine the 3 bytes
lTemp = lTrip And clOneMask 'Mask for the first 6 bits
bOut(lPos) = cbTransTo(lTemp \ cl2Exp18) 'Shift it down to the low 6 bits and get the value
lTemp = lTrip And clTwoMask 'Mask for the second set.
bOut(lPos + 1) = cbTransTo(lTemp \ cl2Exp12) 'Shift it down and translate.
lTemp = lTrip And clThreeMask 'Mask for the third set.
bOut(lPos + 2) = cbTransTo(lTemp \ cl2Exp6) 'Shift it down and translate.
bOut(lPos + 3) = cbTransTo(lTrip And clFourMask) 'Mask for the low set.
If lLen = 68 Then 'Ready for a newline
bOut(lPos + 4) = 13 'Chr(13) = vbCr
bOut(lPos + 5) = 10 'Chr(10) = vbLf
lLen = 0 'Reset the counter
lPos = lPos + 6
Else
lLen = lLen + 4
lPos = lPos + 4
End If
Next lChar
If bOut(lOutSize) = 10 Then lOutSize = lOutSize - 2 'Shift the padding chars down if it ends with CrLf.
If iPad = 1 Then 'Add the padding chars if any.
bOut(lOutSize) = 61 'Chr(61) = "="
ElseIf iPad = 2 Then
bOut(lOutSize) = 61
bOut(lOutSize - 1) = 61
End If
Encode = StrConv(bOut, vbUnicode) 'Convert back to a string and return it.
End Function
The generated output is exactly like this:
Required Output
I am trying to achieve the same output in VB.Net but I am unable to do so. I tried using the following:
Dim testStr As String = "test.xlsm"
Dim byt As Byte() = Encoding.Default.GetBytes(testStr)
testStr = Convert.ToBase64String(byt)
Input String: http://txt.do/obff
But I am not getting exactly the same string back. The first line is different in both cases (VBA and VB.Net) and I'm not sure why.
Required Output (VBA and the weblink):
UEsDBBQABgAIAAAAIQCsmTVRbwEAAD8EAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAAAAAAAAAAAAAAAAAAAAAA
Generated Output (VB.Net):
UEsDBBQABgAIAAAAIQA/PzVRbwEAAD8EAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCA/BAIoPwACAAAAAAAAAAAAAAAAAAAAAAAAA
Could you please let me know where I am going wrong and how can I achieve the same in VB.Net?
I managed to solve the problem by getting the file directly, reading all its bytes and converting it to base64 string.
Dim dat As Byte() = IO.File.ReadAllBytes(FileName)
testStr = Convert.ToBase64String(dat, Base64FormattingOptions.InsertLineBreaks)