// Hidden C++ exception states: #wind=1 std::optional<std::string > *__fastcall…
- User
// Hidden C++ exception states: #wind=1 std::optional<std::string > *__fastcall RBX::Security::SessionCrypto::encryptData( RBX::Security::SessionCrypto *this, std::optional<std::string > *result, RBX::ArrayView *message) { unsigned __int64 v6; // rsi std::optional<std::string > *p_box; // r10 char *Ptr; // rcx unsigned __int64 Myres; // rdx __int64 v10; // r9 const unsigned __int8 *k; // r9 char *v12; // r8 bool Has_value; // al unsigned __int64 v14; // rdx char *v16; // rax unsigned __int8 *m[2]; // [rsp+60h] [rbp-19h] __int128 v18; // [rsp+70h] [rbp-9h] __int128 v19; // [rsp+80h] [rbp+7h] std::optional<std::string > box; // [rsp+90h] [rbp+17h] BYREF unsigned __int64 maclen_p; // [rsp+F8h] [rbp+7Fh] BYREF
*&v18 = 0LL; *&v19 = 0LL; v6 = 15LL; *(&v19 + 1) = 15LL; *&box._Dummy = v18; *&box._Value._Mypair._Myval2._Mysize = v19; box._Has_value = 1; std::string::resize(&box, message->length + 28, 0); p_box = &box; Ptr = box._Value._Mypair._Myval2._Bx._Ptr; Myres = box._Value._Mypair._Myval2._Myres; if ( box._Value._Mypair._Myval2._Myres >= 0x10 ) p_box = box._Value._Mypair._Myval2._Bx._Ptr; *m = *message; if ( !this->isError && this->isSessionReady ) { v10 = 96LL; if ( !this->isServer ) v10 = 64LL; k = this + v10; if ( box._Value._Mypair._Myval2._Mysize == m[1] + 28 ) { v12 = &p_box->_Value._Mypair._Myval2._Bx._Buf[m[1]]; *v12 = std::_Ref_count_obj2<std::function<void (std::shared_ptr<RBX::Reflection::Tuple const>,std::function<void (std::shared_ptr<RBX::Reflection::Tuple const>)>,std::function<void (std::string)>)>>::`vftable'[4] + _InterlockedExchangeAdd64(&this->appNonce, 1uLL); *(v12 + 2) = 1919246957; if ( !crypto_aead_chacha20poly1305_ietf_encrypt_detached( p_box, &p_box->_Value._Mypair._Myval2._Bx._Buf[m[1] + 12], &maclen_p, m[0], m[1], 0LL, 0LL, 0LL, &p_box->_Value._Mypair._Myval2._Bx._Buf[m[1]], k) ) { result->_Has_value = 0; Has_value = box._Has_value; if ( box._Has_value ) { *&result->_Dummy = *&box._Dummy; *&result->_Value._Mypair._Myval2._Mysize = *&box._Value._Mypair._Myval2._Mysize; box._Value._Mypair._Myval2._Mysize = 0LL; box._Value._Mypair._Myval2._Myres = 15LL; box._Value._Mypair._Myval2._Bx._Buf[0] = 0; result->_Has_value = 1; } else { v6 = box._Value._Mypair._Myval2._Myres; } if ( Has_value && v6 >= 0x10 ) { v14 = v6 + 1; Ptr = box._Value._Mypair._Myval2._Bx._Ptr; if ( v6 + 1 < 0x1000 || (v14 = v6 + 40, Ptr = *(box._Value._Mypair._Myval2._Bx._Ptr - 1), (box._Value._Mypair._Myval2._Bx._Ptr - Ptr - 8) <= 0x1F) ) { LABEL_16: operator delete(Ptr, v14); return result; } LABEL_23: _invalid_parameter_noinfo_noreturn(); } return result; } Myres = box._Value._Mypair._Myval2._Myres; Ptr = box._Value._Mypair._Myval2._Bx._Ptr; } } result->_Has_value = 0; if ( box._Has_value && Myres >= 0x10 ) { v14 = Myres + 1; v16 = Ptr; if ( v14 < 0x1000 ) goto LABEL_16; v14 += 39LL; Ptr = *(Ptr - 1); if ( (v16 - Ptr - 8) <= 0x1F ) goto LABEL_16; goto LABEL_23; } return result; }
Convert this C++ psuedocode into human-readable C++. Do not add helper functions or rename
typesarrayviews have a buffer and a length. - Assistant