diff --git a/src/include/wxss.h b/src/include/wxss.h index f5b48cd..071c1cc 100644 --- a/src/include/wxss.h +++ b/src/include/wxss.h @@ -94,7 +94,7 @@ namespace WXSS public: Offset0Type *offset_0 = nullptr; std::string offset_4_str; - std::string offset_4_int; + int offset_4_int; int offset_28 = 0; int offset_32 = 0; std::string offset_36 = ""; @@ -118,19 +118,19 @@ namespace WXSS ~TransitTable(); static TransitTable* GetInstance(); void Init(void); - std::string GetTopType(); + int GetTopType(); }; class CSSSyntaxTree { private: /* data - size: 0xB0 + size: 0xB0 176 */ public: std::string offset_0; WXSS::Token offset_24; - bool offset_116; // 类型未确定 + int offset_116; // 类型未确定 std::vector> offset_120; bool offset_132; // 类型未确定,不是布尔值 std::shared_ptr offset_140; @@ -184,10 +184,10 @@ namespace WXSS { private: /* data */ - std::shared_ptr offset_0; std::deque> offset_8; std::deque> offset_48; public: + std::shared_ptr offset_0; Parser(/* args */); ~Parser(); /** @@ -213,6 +213,7 @@ namespace WXSS std::string offset_8; // 长度24 std::map> offset_32; std::map> offset_56; + std::map offset_104; std::map offset_128; std::map offset_152; XCompiler(/* args */); diff --git a/src/wxss/css_tree_lib/css_tree_lib.cpp b/src/wxss/css_tree_lib/css_tree_lib.cpp index f537c50..a9aae89 100644 --- a/src/wxss/css_tree_lib/css_tree_lib.cpp +++ b/src/wxss/css_tree_lib/css_tree_lib.cpp @@ -7,19 +7,19 @@ namespace WXSS int off_519B58() { - throw "not implement"; + return 1; } int off_519B2C() { - throw "not implement"; + return 3; } int off_519A44() { - throw "not implement"; + return 2; } int off_519B18() { - throw "not implement"; + return 4; } } } \ No newline at end of file diff --git a/src/wxss/css_tree_lib/parser.cpp b/src/wxss/css_tree_lib/parser.cpp index bccafed..6ce0ac4 100644 --- a/src/wxss/css_tree_lib/parser.cpp +++ b/src/wxss/css_tree_lib/parser.cpp @@ -32,7 +32,8 @@ namespace WXSS // Parse - 5 std::shared_ptr le(new WXSS::CSSTreeLib::CSSSyntaxTree()); - + this->offset_0 = le; + le->offset_0 = "RULES"; if (v118.begin() == v118.end()) { return 0; @@ -48,12 +49,13 @@ namespace WXSS std::shared_ptr v102(new WXSS::CSSTreeLib::Base()); v102->offset_4_str = "$"; + v102->offset_28 = 1; this->offset_8.push_back(v102); // off_519A44 std::shared_ptr v104(new WXSS::CSSTreeLib::Base()); - // v104->offset_0 = off_519A44; - v104->offset_4_str = instance->GetTopType(); + v104->offset_0 = off_519A44; + v104->offset_4_int = instance->GetTopType(); this->offset_8.push_back(v104); // Parse - 15 @@ -63,10 +65,11 @@ namespace WXSS int v75 = 0; while (true) { - if (/* ??? || */v75 >= v118.size()) + if (this->offset_8.begin() == this->offset_8.end() || v75 >= v118.size()) { break; } + auto v116 = this->offset_8.back(); auto cur = v118[v75]; std::string str; switch (cur.offset_0) @@ -116,9 +119,10 @@ namespace WXSS break; } // Parse - 20-0 - if (true) + if (v116->offset_0() == 1) { - if (true) + auto v27 = v116->offset_4_str; + if (str[0] != v27[0] || str != v27) { std::stringstream v135; if (str[0] != '$' || str[1]) @@ -135,10 +139,10 @@ namespace WXSS if (cur.offset_0 != 8) { v41 = "UNKNOWN"; - // if (cur.offset_4) - // { - // v41 = cur.offset_4; - // } + if (cur.offset_4.get() != nullptr) + { + v41 = cur.offset_4.get()->data(); + } } } v135 << v41; @@ -166,10 +170,10 @@ namespace WXSS } } // Parse - 20-5 - else if (true) + else if (v116->offset_0() == 3) { this->offset_8.pop_back(); - if (2) + if (v116->offset_28 == 2) { if (this->offset_48.begin() == this->offset_48.end()) { @@ -233,8 +237,45 @@ namespace WXSS } // Parse - 20-10 - else if (true) + else if (v116->offset_0() == 2) { + // off_519A44 + + int v52 = v116->offset_4_int; + + std::string v135 = str; + auto v86 = instance->offset_0[v52]; + auto strc = v86.find(v135); + if ( strc == v86.end() || strc->second.size() == 0) + { + std::stringstream v135; + v135 << a3 << "(" << cur.offset_20; + v135 << cur.offset_24 << "): unexpected token `"; + std::string v63 = cur.offset_28; + if (cur.offset_0 != 1) + { + v63 = "$"; + if (cur.offset_0 != 8) + { + v63 = "UNKNOWN"; + if (cur.offset_4.get() != nullptr) + { + v63 = *cur.offset_4.get(); + } + } + } + v135 << v63 << "`"; + a4 = v135.str(); + return -1; + } + this->offset_8.pop_back(); + for (int i = strc->second.size() - 1; i >= 0; i--) + { + auto cur = strc->second[i]; + if (cur[0]->offset_0() == 4) + break; + this->offset_8.push_back(cur[0]); + } } // Parse - 20-15 diff --git a/src/wxss/css_tree_lib/transit_table.cpp b/src/wxss/css_tree_lib/transit_table.cpp index d857423..c479b52 100644 --- a/src/wxss/css_tree_lib/transit_table.cpp +++ b/src/wxss/css_tree_lib/transit_table.cpp @@ -4201,9 +4201,9 @@ namespace WXSS } } } - std::string TransitTable::GetTopType() + int TransitTable::GetTopType() { - throw "not implement"; + return 25; } } } \ No newline at end of file diff --git a/src/wxss/x_compiler.cpp b/src/wxss/x_compiler.cpp index bff6960..0d6ca7d 100644 --- a/src/wxss/x_compiler.cpp +++ b/src/wxss/x_compiler.cpp @@ -20,7 +20,6 @@ namespace WXSS { WXSS::CSSTreeLib::Parser v29; std::string v61; - std::string v77; int v47 = v29.Parse(i->second, i->first, v61, a4); if (v47) { @@ -30,12 +29,11 @@ namespace WXSS } else { - std::shared_ptr v57(new WXSS::CSSTreeLib::CSSSyntaxTree()); - v4->Traval(v57); + v4->Traval(v29.offset_0); std::string v42; - for (int j = 0; j < v57->offset_120.size(); j++) + for (int j = 0; j < v29.offset_0->offset_120.size(); j++) { - auto cur = v57->offset_120[j]; + auto cur = v29.offset_0->offset_120[j]; if (cur->offset_0 == "DIRECTIVE") { auto v8 = cur->offset_120; @@ -209,6 +207,11 @@ namespace WXSS } int XCompiler::GetCompiled(std::string const&, std::string&) { + if (this->offset_0) + { + return 6; + } + throw "not implement"; } int XCompiler::GetJSCompiled(std::string const& a2, std::string& a3) diff --git a/test/wcsc.disassembly.cpp b/test/wcsc.disassembly.cpp index 339ce28..7e9936c 100644 --- a/test/wcsc.disassembly.cpp +++ b/test/wcsc.disassembly.cpp @@ -7843,18 +7843,20 @@ int __thiscall WXSS::XCompiler::GetCompiled(int *this, int a2, unsigned int **a3 v5 = *(_DWORD *)(v16 + 8); v16 = v5; } + if ( v13 == v15 || (unsigned __int8)std::operator<(a2, (int)(v15 + 4)) ) { + // end == find if ( this + 9 == std::_Rb_tree>,std::_Select1st>>,std::less,std::allocator>>>::find( this + 8, a2) ) { v14 = 1; - std::string::operator=(a3, (char *)&byte_50DF9A); + std::string::operator=(a3, (char *)&byte_50DF9A); // '\0' } else { - std::string::operator=(a3, (char *)&byte_50DF9A); + std::string::operator=(a3, (char *)&byte_50DF9A); // '\0' v7 = std::map>::operator[](this + 8, a2); std::__shared_ptr::__shared_ptr(&v19, v7); for ( i = 0; ; ++i ) @@ -7886,6 +7888,7 @@ int __thiscall WXSS::XCompiler::GetCompiled(int *this, int a2, unsigned int **a3 1u); } } + // 26 * 4 = 104 v11 = std::map::operator[](this + 26, a2); std::string::_M_assign((int)v11, (int)a3); std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count(&v20); @@ -8973,14 +8976,16 @@ void __thiscall WXSS::XCompiler::XCompiler(char *this, _DWORD *a2, char a3, int v55 = this + 8; // this->offset_8 this[16] = 0; - // this->offset_8 + // this->offset_8 std::string *((_DWORD *)this + 2) = this + 16; + // this->offset_12 *((_DWORD *)this + 3) = 0; // this->offset_36 *((_DWORD *)this + 9) = 0; // this->offset_40 *((_DWORD *)this + 10) = 0; + // offset_44 *((_DWORD *)this + 11) = this + 36; *((_DWORD *)this + 12) = this + 36; *((_DWORD *)this + 13) = 0; @@ -9021,6 +9026,7 @@ void __thiscall WXSS::XCompiler::XCompiler(char *this, _DWORD *a2, char a3, int *(_DWORD *)this = 0; *((_DWORD *)this + 1) = 0; + // a2->offset_12 for ( i = (_DWORD *)a2[3]; ; i = (_DWORD *)std::_Rb_tree_increment(v38) ) { v38 = (int)i; @@ -11131,14 +11137,14 @@ int __thiscall WXSS::CSSTreeLib::Parser::Parse(int this, char **a2, int *a3, uns volatile signed __int32 *v124[5]; // [esp+100h] [ebp-178h] BYREF void *v125[6]; // [esp+114h] [ebp-164h] BYREF void *v126; // [esp+12Ch] [ebp-14Ch] BYREF - int v127; // [esp+144h] [ebp-134h] BYREF - volatile signed __int32 *v128; // [esp+148h] [ebp-130h] BYREF - volatile signed __int32 *v129; // [esp+14Ch] [ebp-12Ch] BYREF - int v130; // [esp+150h] [ebp-128h] - int v131; // [esp+154h] [ebp-124h] - int v132; // [esp+158h] [ebp-120h] - int v133; // [esp+15Ch] [ebp-11Ch] - char v134[64]; // [esp+160h] [ebp-118h] BYREF + int v127; // [esp+144h] [ebp-134h] BYREF v127->offset_0 + volatile signed __int32 *v128; // [esp+148h] [ebp-130h] BYREF v127->offset_4 + volatile signed __int32 *v129; // [esp+14Ch] [ebp-12Ch] BYREF v127->offset_8 + int v130; // [esp+150h] [ebp-128h] v127->offset_12 + int v131; // [esp+154h] [ebp-124h] v127->offset_16 + int v132; // [esp+158h] [ebp-120h] v127->offset_20 + int v133; // [esp+15Ch] [ebp-11Ch] v127->offset_24 + char v134[64]; // [esp+160h] [ebp-118h] BYREF v127->offset_28 _DWORD *v135; // [esp+1A0h] [ebp-D8h] BYREF volatile signed __int32 *v136; // [esp+1A4h] [ebp-D4h] BYREF char v137[4]; // [esp+1A8h] [ebp-D0h] BYREF @@ -11174,12 +11180,13 @@ int __thiscall WXSS::CSSTreeLib::Parser::Parse(int this, char **a2, int *a3, uns WXSS::CSSTreeLib::TransitTable::Init((int)&WXSS::CSSTreeLib::TransitTable::GetInstance(void)::ret); // Parse - 5 - lpuexcpte = (struct _Unwind_Exception *)operator new(0xB0u); + lpuexcpte = (struct _Unwind_Exception *)operator new(0xB0u); // 176 WXSS::CSSTreeLib::CSSSyntaxTree::CSSSyntaxTree((int)lpuexcpte); zcc::shared_ptr::shared_ptr(lpuexcpte); *(_DWORD *)this = v127; std::__shared_count<(__gnu_cxx::_Lock_policy)2>::operator=((volatile signed __int32 **)(this + 4), v128); std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count(&v128); + std::string::operator=(*(unsigned int ***)this, "RULES"); lpuexcpt = (struct _Unwind_Exception *)v119; if ( v118 == v119 ) @@ -11210,18 +11217,26 @@ int __thiscall WXSS::CSSTreeLib::Parser::Parse(int this, char **a2, int *a3, uns *((_DWORD *)lpuexcpt + 4) = v131; *((_DWORD *)lpuexcpt + 5) = v132; *((_DWORD *)lpuexcpt + 6) = v133; - qmemcpy((char *)lpuexcpt + 28, v134, 0x40u); + qmemcpy((char *)lpuexcpt + 28, v134, 0x40u); // 64字节 } // Parse - 10 - v7 = operator new(0x78u); + v7 = operator new(0x78u); // 120 *v7 = &off_519B58; - v7[1] = v7 + 3; + // v7->offset_4 = v7->offset_12 + v7[1] = v7 + 3; // std::string + // v7->offset_8 = 0 v7[2] = 0; + // v7->offset_12 = 0 *((_BYTE *)v7 + 12) = 0; + + // v7->offset_32 = 0 v7[8] = 0; + // v7->offset_36 = 0 v7[9] = 0; + // v7->offset_56 = 0 *((_BYTE *)v7 + 56) = 0; + // v7->offset_28 = 1 v7[7] = 1; v7[10] = 0; v7[11] = 0; @@ -11234,6 +11249,7 @@ int __thiscall WXSS::CSSTreeLib::Parser::Parse(int this, char **a2, int *a3, uns std::string::_M_assign((int)lpuexcptf + 4, (int)&v135); std::string::_M_dispose((void **)&v135); + // int this v78 = (_DWORD *)(this + 8); std::deque>::push_back(this + 8, (int *)&v102); @@ -11252,11 +11268,11 @@ int __thiscall WXSS::CSSTreeLib::Parser::Parse(int this, char **a2, int *a3, uns v107 = 0; v112 = v9; v113 = 0; - // v9->offset_0 = &v9->offset_8 + // v9->offset_0 = &v9->offset_8 std::string *v9 = v9 + 2; - // v9->offset_24 = v9->offset_32 + // v9->offset_24 = v9->offset_32 std::string v9[6] = v9 + 8; - // v9->offset_48 = v9->offset_56 + // v9->offset_48 = v9->offset_56 std::string v9[12] = v9 + 14; /* v9: @@ -11361,16 +11377,19 @@ int __thiscall WXSS::CSSTreeLib::Parser::Parse(int this, char **a2, int *a3, uns while ( 1 ) { v24 = this; + v25 = *(_DWORD *)(this + 32); // it_finish // this->offset_16 -> it_start, v75 索引 if ( *(_DWORD *)(this + 16) == v25 || v75 >= -373475417 * ((v119 - v118) >> 2) ) break; if ( v25 == *(_DWORD *)(this + 36) ) v25 = *(_DWORD *)(*(_DWORD *)(this + 44) - 4) + 512; + v72 = *(volatile signed __int32 **)(v25 - 4); v116 = *(char **)(v25 - 8); std::__shared_count<(__gnu_cxx::_Lock_policy)2>::operator=(&v117, v72); - lpuexcpta = (struct _Unwind_Exception *)&v118[92 * v75]; + + lpuexcpta = (struct _Unwind_Exception *)&v118[92 * v75]; // cur switch ( *(_DWORD *)lpuexcpta ) { case 1: @@ -11386,7 +11405,7 @@ int __thiscall WXSS::CSSTreeLib::Parser::Parse(int this, char **a2, int *a3, uns Str = "$NAME"; break; case 5: - Str = (char *)&off_50F38C; + Str = (char *)&off_50F38C; // "$ID" break; case 6: Str = "$MULTI_EXPR"; @@ -11454,7 +11473,7 @@ int __thiscall WXSS::CSSTreeLib::Parser::Parse(int this, char **a2, int *a3, uns } ++v75; std::deque>::pop_back(v78); - if ( *Str != 36 || Str[1] ) + if ( *Str != '$'/*36*/ || Str[1] ) { v82 = operator new(0xB0u); WXSS::CSSTreeLib::CSSSyntaxTree::CSSSyntaxTree((int)v82); @@ -11599,10 +11618,11 @@ int __thiscall WXSS::CSSTreeLib::Parser::Parse(int this, char **a2, int *a3, uns v32 = v124; // 只是为了销毁 LABEL_59: std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count(v32); - } + } // end == 3 // Parse - 20-10 else if ( (*(int (__fastcall **)(char *))(*(_DWORD *)v116 + 8))(v116) == 2 ) { + // int *v86 v86 = &dword_50CBE0; v52 = *((_DWORD *)v116 + 1); v53 = (_DWORD *)dword_50CBE4; @@ -11620,8 +11640,13 @@ int __thiscall WXSS::CSSTreeLib::Parser::Parse(int this, char **a2, int *a3, uns if ( v86 != &dword_50CBE0 && v52 < v86[4] ) v86 = &dword_50CBE0; v73 = std::string::basic_string((void **)&v135, Str); + v77 = (char *)(v86 + 6); + // v77 = v86->offset_24 + v87 = (char *)v86[7]; + // v87 = v86->offset_28 + Strc = v77; while ( v87 ) { @@ -11648,13 +11673,13 @@ int __thiscall WXSS::CSSTreeLib::Parser::Parse(int this, char **a2, int *a3, uns Strc = v58; } std::string::_M_dispose((void **)&v135); - v20 = (int *)v77; + v20 = (int *)v77; // end if ( Strc == v77 || *((_DWORD *)Strc + 11) == *((_DWORD *)Strc + 10) ) { std::basic_stringstream,std::allocator>::basic_stringstream((int)&v135); v59 = std::operator<<((std::ostream::sentry *)v137, a3); std::operator<<>(v59, "("); - v60 = (std::ostream::sentry *)std::ostream::operator<<(*((_DWORD *)lpuexcpta + 5)); + v60 = (std::ostream::sentry *)std::ostream::operator<<(*((_DWORD *)lpuexcpta + 5)); // cur std::operator<<>(v60, ":"); v61 = (std::ostream::sentry *)std::ostream::operator<<(*((_DWORD *)lpuexcpta + 6)); v62 = std::operator<<>(v61, "): unexpected token `"); @@ -11677,6 +11702,7 @@ int __thiscall WXSS::CSSTreeLib::Parser::Parse(int this, char **a2, int *a3, uns v36 = (char *)&v123; goto LABEL_48;// 销毁数据,返回-1 } + // this->offset_8 std::deque>::pop_back(v78); for ( lpuexcptd = ((*(_DWORD *)(*((_DWORD *)Strc + 10) + 4) - **((_DWORD **)Strc + 10)) >> 3) - 1; lpuexcptd >= 0; @@ -11686,12 +11712,15 @@ int __thiscall WXSS::CSSTreeLib::Parser::Parse(int this, char **a2, int *a3, uns v67 = *(_DWORD *)(**((_DWORD **)Strc + 10) + 8 * lpuexcptd); if ( (*(int (__thiscall **)(int, int))(*(_DWORD *)v67 + 8))(v67, v73) == 4 ) break; + + // zcc::shared_ptr v20 = (int *)(**((_DWORD **)Strc + 10) + 8 * lpuexcptd); std::deque>::push_back((int)v78, v20); v73 = v66; } - } + } // end == 2 } + // Parse - 25 if ( *(_DWORD *)(this + 72) == *(_DWORD *)(this + 56) ) {