// // CCTextInputNode::onTextFieldInsertText from 0x10009f690 to 0x10009fc1c (1420 bytes) // // 2 xrefs: // > sub_10009FCB0 @ 0x10009fcbc // > @ 0x1008b6c10 // // This function is hookable on this platform! // // Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA // Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings // bool __fastcall CCTextInputNode::onTextFieldInsertText( CCTextInputNode *a1, cocos2d::CCTextFieldTTF *a2, const char *a3, int a4, cocos2d::enumKeyCodes a5) { __m128 v5; // xmm0 cocos2d::enumKeyCodes v6; // eax int v7; // ecx cocos2d::CCTextFieldTTF *m_textField; // rax int m_uCursorPos; // esi bool v10; // cf int v11; // esi _BYTE *v12; // r15 CCTextInputNode *v13; // rbx size_t v14; // rax std::string::size_type v15; // r14 char *data; // r15 int v17; // ecx bool v18; // r13 size_t v20; // rbx std::string::size_type v21; // r12 std::string::value_type v22; // bl unsigned __int64 size; // rax std::string::size_type m_maxLabelLength; // rcx std::string::pointer v25; // r12 const char *v26; // r12 char v27; // bl int v28; // ecx std::string::size_type v29; // r13 char *v30; // r14 size_t v31; // r15 size_t v32; // rax size_t v33; // r14 CCTextInputNode *v34; // rbx char *v35; // r15 size_t v36; // r13 std::string::pointer v37; // r12 unsigned __int128 v38; // kr00_16 const void *v39; // rbx signed __int64 v40; // rax signed __int64 v41; // r14 char *v42; // rdx void *v43; // r12 int v44; // r15d size_t v45; // rdx char *v46; // rax char *v47; // r12 bool v48; // zf std::string v49; // [rsp+8h] [rbp-D8h] BYREF std::string v50; // [rsp+20h] [rbp-C0h] BYREF void *__s; // [rsp+40h] [rbp-A0h] _QWORD v52[2]; // [rsp+48h] [rbp-98h] BYREF void *__p; // [rsp+58h] [rbp-88h] int v54; // [rsp+64h] [rbp-7Ch] std::string::pointer v55; // [rsp+68h] [rbp-78h] std::string v56; // [rsp+70h] [rbp-70h] BYREF void *__src; // [rsp+90h] [rbp-50h] CCTextInputNode *v58; // [rsp+98h] [rbp-48h] std::string __dst[2]; // [rsp+A0h] [rbp-40h] BYREF v6 = KEY_Right; if ( a5 != KEY_ArrowRight ) v6 = a5; v7 = 37; if ( a5 != KEY_ArrowLeft ) v7 = v6; if ( (v7 | 2) == 0x27 ) { m_textField = a1->m_textField; m_uCursorPos = m_textField->m_uCursorPos; if ( v7 == 37 ) { if ( m_uCursorPos < 0 ) { v11 = m_textField->m_nCharCount - 1; } else { v10 = m_uCursorPos == 0; v11 = m_uCursorPos - 1; if ( v10 ) v11 = 0; } } else { v17 = m_uCursorPos + 1; if ( m_uCursorPos < 0 ) v17 = -1; if ( v17 >= m_textField->m_nCharCount ) v17 = -1; v11 = v17; } m_textField->m_uCursorPos = v11; CCTextInputNode::updateBlinkLabelToChar(a1, v11); return 1; } v58 = a1; v12 = a3; if ( a3 ) { v13 = a1; v14 = strlen(a3); if ( v14 >= 2 ) { v15 = v14; __src = v12; if ( v14 >= 0xFFFFFFFFFFFFFFF8LL ) sub_100006BF0(*(double *)v5.i64); if ( v14 >= 0x17 ) { v20 = 26; if ( (v14 | 7) != 0x17 ) v20 = (v14 | 7) + 1; data = (char *)operator new(v20); __dst[0].__r_.__value_.__r.__words[2] = (std::string::size_type)data; __dst[0].__r_.__value_.__r.__words[0] = v20 + 1; v13 = v58; __dst[0].__r_.__value_.__l.__size_ = v15; } else { __dst[0].__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v14); data = __dst[0].__r_.__value_.__s.__data_; } memcpy(data, __src, v15); data[v15] = 0; *(_WORD *)&v56.__r_.__value_.__l.0 = 0; if ( (v13->m_allowedChars.m_data.m_short.sizex2 & 1) != 0 ) { sub_100006B70( &v50, v13->m_allowedChars.m_data.m_long.longStorage, v13->m_allowedChars.m_data.m_long.size, *(double *)v5.i64); } else { v50.__r_.__value_.__r.__words[2] = (std::string::size_type)v13->m_allowedChars.m_data.m_long.longStorage; v5 = *(__m128 *)&v13->m_allowedChars.m_data.m_short.sizex2; *(__m128 *)&v50.__r_.__value_.__l.0 = v5; } if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 ) { if ( !__dst[0].__r_.__value_.__l.__size_ ) goto LABEL_40; } else if ( !(*(_BYTE *)&__dst[0].__r_.__value_.__l.0 >> 1) ) { goto LABEL_40; } v21 = 0; do { while ( 1 ) { v22 = *std::string::at(__dst, v21); if ( std::string::find(&v50, v22, 0) != -1 ) std::string::push_back(&v56, v22); if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) == 0 ) break; if ( __dst[0].__r_.__value_.__l.__size_ <= ++v21 ) goto LABEL_40; } ++v21; } while ( *(_BYTE *)&__dst[0].__r_.__value_.__l.0 >> 1 > v21 ); LABEL_40: if ( (*(_BYTE *)&v56.__r_.__value_.__s.0 & 1) != 0 ) { size = v56.__r_.__value_.__l.__size_; if ( v56.__r_.__value_.__l.__size_ ) { m_maxLabelLength = v58->m_maxLabelLength; if ( v56.__r_.__value_.__l.__size_ < m_maxLabelLength ) { v26 = v56.__r_.__value_.__l.__data_; goto LABEL_66; } v25 = v56.__r_.__value_.__l.__data_; goto LABEL_52; } } else if ( v56.__r_.__value_.__s.0 ) { size = *(_BYTE *)&v56.__r_.__value_.__l.0 >> 1; LODWORD(m_maxLabelLength) = v58->m_maxLabelLength; if ( (unsigned int)m_maxLabelLength > (unsigned int)size ) goto LABEL_65; v25 = v56.__r_.__value_.__s.__data_; LABEL_52: v28 = m_maxLabelLength - 1; v29 = v28; if ( size < v28 ) v29 = size; if ( v29 >= 0xFFFFFFFFFFFFFFF8LL ) sub_100006BF0(*(double *)v5.i64); if ( v29 >= 0x17 ) { v31 = 26; if ( (v29 | 7) != 0x17 ) v31 = (v29 | 7) + 1; v30 = (char *)operator new(v31); v49.__r_.__value_.__r.__words[2] = (std::string::size_type)v30; v49.__r_.__value_.__r.__words[0] = v31 | 1; v49.__r_.__value_.__l.__size_ = v29; } else { v49.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v29); v30 = v49.__r_.__value_.__s.__data_; if ( !v28 ) { LABEL_62: v30[v29] = 0; if ( (*(_BYTE *)&v56.__r_.__value_.__s.0 & 1) != 0 ) operator delete(v56.__r_.__value_.__l.__data_); v26 = v49.__r_.__value_.__l.__data_; v56 = v49; v5 = *(__m128 *)&v49.__r_.__value_.__l.0; if ( (*(_BYTE *)&v49.__r_.__value_.__s.0 & 1) != 0 ) { LABEL_66: v32 = strlen(v26); if ( v32 >= 0xFFFFFFFFFFFFFFF8LL ) sub_100006BF0(*(double *)v5.i64); v33 = v32; v34 = v58; if ( v32 >= 0x17 ) { v36 = 26; if ( (v32 | 7) != 0x17 ) v36 = (v32 | 7) + 1; v35 = (char *)operator new(v36); __p = v35; v52[0] = v36 | 1; v52[1] = v33; } else { LOBYTE(v52[0]) = 2 * v32; v35 = (char *)v52 + 1; if ( !v32 ) { LABEL_74: v35[v33] = 0; CCTextInputNode::setString(v34, (__int64)v52, v5); if ( (v52[0] & 1) != 0 ) operator delete(__p); v27 = 0; if ( (*(_BYTE *)&v50.__r_.__value_.__s.0 & 1) == 0 ) { LABEL_77: if ( (*(_BYTE *)&v56.__r_.__value_.__s.0 & 1) == 0 ) { LABEL_78: if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) == 0 ) goto LABEL_80; goto LABEL_79; } LABEL_49: operator delete(v56.__r_.__value_.__l.__data_); if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) == 0 ) { LABEL_80: v18 = 1; a1 = v58; v12 = __src; if ( !v27 ) return v18; goto LABEL_81; } LABEL_79: operator delete(__dst[0].__r_.__value_.__l.__data_); goto LABEL_80; } LABEL_48: operator delete(v50.__r_.__value_.__l.__data_); if ( (*(_BYTE *)&v56.__r_.__value_.__s.0 & 1) == 0 ) goto LABEL_78; goto LABEL_49; } } memmove(v35, v26, v33); goto LABEL_74; } LABEL_65: v26 = v56.__r_.__value_.__s.__data_; goto LABEL_66; } } memmove(v30, v25, v29); goto LABEL_62; } v27 = 1; if ( (*(_BYTE *)&v50.__r_.__value_.__s.0 & 1) == 0 ) goto LABEL_77; goto LABEL_48; } } LABEL_81: if ( *v12 == 10 ) return 0; if ( (a1->m_allowedChars.m_data.m_short.sizex2 & 1) != 0 ) sub_100006B70( __dst, a1->m_allowedChars.m_data.m_long.longStorage, a1->m_allowedChars.m_data.m_long.size, *(double *)v5.i64); else __dst[0] = (std::string)a1->m_allowedChars; v37 = __dst[0].__r_.__value_.__l.__data_; v54 = (int)__dst[0].__r_.__value_.__l.0; if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 ) v38 = *(_OWORD *)&__dst[0].__r_.__value_.__r.__words[1]; else v38 = __PAIR128__( (std::string *)((char *)&__dst[0].__r_.__value_.__l.0 + 1), *(_BYTE *)&__dst[0].__r_.__value_.__l.0 >> 1); v39 = v12; v40 = strlen(v12); if ( !v40 ) goto LABEL_98; v41 = v40; __s = *((void **)&v38 + 1); v18 = 1; if ( (__int64)v38 >= v40 ) { v42 = (char *)v38; v55 = __dst[0].__r_.__value_.__l.__data_; v43 = __s; __src = (char *)__s + v38; v44 = (char)*v12; while ( 1 ) { v45 = (size_t)&v42[-v41 + 1]; if ( !v45 || (v46 = (char *)memchr(v43, v44, v45)) == nullptr ) { LABEL_96: v37 = v55; goto LABEL_99; } v47 = v46; if ( !memcmp(v46, v39, v41) ) break; v43 = v47 + 1; v42 = (char *)((_BYTE *)__src - (_BYTE *)v43); if ( (_BYTE *)__src - (_BYTE *)v43 < v41 ) goto LABEL_96; } v48 = v47 != __src && v47 - (_BYTE *)__s != -1; v37 = v55; if ( v48 ) LABEL_98: v18 = a2->m_nCharCount >= v58->m_maxLabelLength && v58->m_maxLabelLength > 0; } LABEL_99: if ( (v54 & 1) != 0 ) operator delete(v37); return v18; }