I have a piece of code that gets random binary string from CAPICOM.Utilities.
m_pUtilities.CreateInstance(__uuidof(Utilities));
_bstr_t bstrResult;
m_pUtilities->raw_GetRandom(64, CAPICOM_ENCODE_BINARY, bstrResult.GetAddress());
I made a method that returns
return std::wstring(bstrResult);
My method crashes plugin appr. 1 of 6 calls. The exception description is Unhandled exception at 0x7572969b in chrome.exe: Microsoft C++ exception: utf8::invalid_utf16 at memory location. I tried to change return type of my method from FB::variant to std::wstring, but this didn't help.
What I did wrong? How should I return the binary string? Converting the binary string to base64 or other changes in return string is not suitable for me.