fix: 一些错误

This commit is contained in:
msojocs 2023-08-20 19:46:40 +08:00
parent 00f4999f19
commit 5006afee06
4 changed files with 101 additions and 82 deletions

View File

@ -13,8 +13,11 @@ namespace WXSS
{
}
int parse_i = 0;
int temp_count = 0;
int Parser::Parse(std::string const& a2, std::string const& a3, std::string& a4, std::string const& a5)
{
int inner_parse_i = ++parse_i;
// Parse - 0
WXSS::Tokenizer v125(a2.data(), a3);
std::vector<WXSS::Token> v118;
@ -51,12 +54,14 @@ namespace WXSS
v102->offset_0 = off_519B58;
v102->offset_4_str = "$";
v102->offset_28 = 1;
temp_count++;
this->offset_8.push_back(v102);
// off_519A44
std::shared_ptr<WXSS::CSSTreeLib::Base> v104(new WXSS::CSSTreeLib::Base());
v104->offset_0 = off_519A44;
v104->offset_4_int = instance->GetTopType();
temp_count++;
this->offset_8.push_back(v104);
// Parse - 15
@ -74,6 +79,7 @@ namespace WXSS
{
break;
}
// this->offset_8.back()
auto v116 = this->offset_8.back();
auto cur = v118[v75];
std::string str;
@ -170,6 +176,7 @@ namespace WXSS
if (str[0] != '$' || str[1])
{
std::shared_ptr<WXSS::CSSTreeLib::CSSSyntaxTree> v82(new WXSS::CSSTreeLib::CSSSyntaxTree());
v82->offset_0 = str;
v82->offset_24 = cur;
v82->offset_148 = v9;
v82->offset_156 = v14;
@ -201,6 +208,7 @@ namespace WXSS
{
v45->offset_164 = v44->offset_164;
}
v45->offset_168 = v44->offset_168;
v45->offset_120.push_back(v44);
}
@ -226,7 +234,7 @@ namespace WXSS
auto v48 = v123->offset_120;
auto v49 = v48[stra - 1];
v123->offset_164 = v49->offset_164;
v123->offset_168 = v49->offset_168;
v123->offset_168 = v48[0]->offset_168;
v123->offset_148 = v9;
v123->offset_156 = v14;
}
@ -253,7 +261,11 @@ namespace WXSS
else if (v116->offset_0() == 2)
{
// off_519A44
if (inner_parse_i == 2)
{
int a = temp_count;
}
int v52 = v116->offset_4_int;
std::string v135 = str;
@ -282,12 +294,19 @@ namespace WXSS
return -1;
}
this->offset_8.pop_back();
for (int i = strc->second.size() - 1; i >= 0; i--)
for (int i = strc->second[0].size() - 1; i >= 0; i--)
{
auto cur = strc->second[i];
if (cur[0]->offset_0() == 4)
auto cur = strc->second[0][i];
if (cur->offset_0() == 4)
break;
this->offset_8.push_back(cur[0]);
temp_count++;
this->offset_8.push_back(cur);
if (inner_parse_i == 2 && temp_count > 2983)
{
int a = temp_count;
}
}
}
@ -306,7 +325,7 @@ namespace WXSS
this->offset_0 = v68;
}
// Parse - 30
throw "not implement";
return 0;
}
}

View File

@ -5,54 +5,55 @@
namespace WXSS
{
Tokenizer::Tokenizer(/* args */)
{
}
Tokenizer::Tokenizer(char const* str, std::string const& a3)
Tokenizer::Tokenizer(char const *str, std::string const &a3)
{
this->offset_0.replace(0, 0, str, strlen(str));
this->offset_24.assign(a3);
}
Tokenizer::~Tokenizer()
{
}
const char *DIRECTIVES[] = {"@import", "@charset", "@media", "@keyframes", "@-webkit-keyframes", "@supports", "nth-child", "nth-last-child", "nth-of-type", "nth-last-of-type"};
int Tokenizer::TT[26113] = {0};
bool Tokenizer::bInited = false;
void Tokenizer::InitTransitTable(/* args */)
{
// start 0x005222A0
if(!this->bInited)
if (!this->bInited)
{
// InitTransitTable - 0
this->bInited = true;
const char* ntr = " \n\t\r";
for (int i = 0; i < 5; i++)
const char *ntr = " \n\t\r";
for (int i = 0; i < 4; i++)
{
char v1 = ntr[i];
this->TT[(0x5232A0 - 0x005222A0) / 4 + 2 * v1] = 134217729;
this->TT[(0x5232A4 - 0x005222A0) / 4 + 2 * v1] = 0;
}
const char* dotabc = ".abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";
for (int i = 0; i < 56; i++)
const char *dotabc = ".abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";
for (int i = 0; i < 55; i++)
{
char v1 = dotabc[i];
this->TT[(0x5232A0 - 0x005222A0) / 4 + 2 * v1] = 2;
this->TT[(0x5232A4 - 0x005222A0) / 4 + 2 * v1] = 0;
}
const char* _0123 = "0123456789";
for (int i = 0; i < 11; i++)
const char *_0123 = "0123456789";
for (int i = 0; i < 10; i++)
{
char v1 = _0123[i];
this->TT[(0x5232A0 - 0x005222A0) / 4 + 2 * v1] = 5;
this->TT[(0x5232A4 - 0x005222A0) / 4 + 2 * v1] = 0;
}
// InitTransitTable - 5
const char* sharp = "#*,{}[]:()~=|>\"+^@;";
for (int i = 0; i < 20; i++)
const char *sharp = "#*,{}[]:()~=|>\"+^@;";
for (int i = 0; i < 19; i++)
{
char v1 = sharp[i];
this->TT[(0x5232A0 - 0x005222A0) / 4 + 2 * v1] = 1114113;
@ -85,7 +86,7 @@ namespace WXSS
this->TT[(0x53BAA0 - 0x005222A0) / 4] = -1;
this->TT[(0x53BAA4 - 0x005222A0) / 4] = -1;
// InitTransitTable - 10
for (int i = 0; i < 56; i++)
for (int i = 0; i < 55; i++)
{
char v1 = dotabc[i];
this->TT[(0x5392A0 - 0x005222A0) / 4 + 2 * v1] = 2;
@ -93,14 +94,14 @@ namespace WXSS
}
this->TT[(0x539AA0 - 0x005222A0) / 4] = 68288513;
this->TT[(0x539AA4 - 0x005222A0) / 4] = 0;
for (int i = 0; i < 56; i++)
for (int i = 0; i < 55; i++)
{
char v1 = dotabc[i];
this->TT[(0x5272A0 - 0x005222A0) / 4 + 2 * v1] = 5;
this->TT[(0x5272A4 - 0x005222A0) / 4 + 2 * v1] = 0;
}
// InitTransitTable - 15
for (int i = 0; i < 11; i++)
for (int i = 0; i < 10; i++)
{
char v1 = _0123[i];
this->TT[(0x5272A0 - 0x005222A0) / 4 + 2 * v1] = 5;
@ -151,19 +152,19 @@ namespace WXSS
this->TT[(0x536AA0 - 0x005222A0) / 4] = 19;
this->TT[(0x536AA4 - 0x005222A0) / 4] = 0;
// InitTransitTable - 20
for (int i = 0; i < 56; i++)
for (int i = 0; i < 55; i++)
{
char v1 = dotabc[i];
this->TT[(0x5242A0 - 0x005222A0) / 4 + 2 * v1] = 2;
this->TT[(0x5242A4 - 0x005222A0) / 4 + 2 * v1] = 0;
}
for (int i = 0; i < 11; i++)
for (int i = 0; i < 10; i++)
{
char v1 = _0123[i];
this->TT[(0x5242A0 - 0x005222A0) / 4 + 2 * v1] = 2;
this->TT[(0x5242A4 - 0x005222A0) / 4 + 2 * v1] = 0;
}
for (int i = 0; i < 5; i++)
for (int i = 0; i < 4; i++)
{
char v1 = ntr[i];
this->TT[(0x5242A0 - 0x005222A0) / 4 + 2 * v1] = 67764225;
@ -174,13 +175,13 @@ namespace WXSS
this->TT[(0x5243B4 - 0x005222A0) / 4] = 0;
this->TT[(0x524AA0 - 0x005222A0) / 4] = 67764225;
this->TT[(0x524AA4 - 0x005222A0) / 4] = 0;
for (int i = 0; i < 56; i++)
for (int i = 0; i < 55; i++)
{
char v1 = dotabc[i];
this->TT[(0x5252A0 - 0x005222A0) / 4 + 2 * v1] = 3;
this->TT[(0x5252A4 - 0x005222A0) / 4 + 2 * v1] = 0;
}
for (int i = 0; i < 11; i++)
for (int i = 0; i < 10; i++)
{
char v1 = _0123[i];
this->TT[(0x5252A0 - 0x005222A0) / 4 + 2 * v1] = 3;
@ -189,32 +190,32 @@ namespace WXSS
// InitTransitTable - 30
this->TT[(0x525AA0 - 0x005222A0) / 4] = 69337089;
this->TT[(0x525AA4 - 0x005222A0) / 4] = 0;
for (int i = 0; i < 5; i++)
for (int i = 0; i < 4; i++)
{
char v1 = ntr[i];
this->TT[(0x5262A0 - 0x005222A0) / 4 + 2 * v1] = 134217732;
this->TT[(0x5262A4 - 0x005222A0) / 4 + 2 * v1] = 0;
}
for (int i = 0; i < 56; i++)
for (int i = 0; i < 55; i++)
{
char v1 = dotabc[i];
this->TT[(0x5262A0 - 0x005222A0) / 4 + 2 * v1] = 8;
this->TT[(0x5262A4 - 0x005222A0) / 4 + 2 * v1] = 0;
}
for (int i = 0; i < 56; i++)
for (int i = 0; i < 55; i++)
{
char v1 = dotabc[i];
this->TT[(0x52A2A0 - 0x005222A0) / 4 + 2 * v1] = 8;
this->TT[(0x52A2A4 - 0x005222A0) / 4 + 2 * v1] = 0;
}
// InitTransitTable - 35
for (int i = 0; i < 11; i++)
for (int i = 0; i < 10; i++)
{
char v1 = _0123[i];
this->TT[(0x52A2A0 - 0x005222A0) / 4 + 2 * v1] = 8;
this->TT[(0x52A2A4 - 0x005222A0) / 4 + 2 * v1] = 0;
}
for (int i = 0; i < 5; i++)
for (int i = 0; i < 4; i++)
{
char v1 = ntr[i];
this->TT[(0x52A2A0 - 0x005222A0) / 4 + 2 * v1] = 67764228;
@ -275,7 +276,7 @@ namespace WXSS
// InitTransitTable - 40
}
}
bool WXSS::Tokenizer::SubStrCheckingClause::inited = false;
WXSS::Tokenizer::SubStrCheckingClause WXSS::Tokenizer::SCC[5];
void Tokenizer::InitSubStrCheckingCaluseTable()
@ -296,8 +297,11 @@ namespace WXSS
}
}
int Tokenizer::GetTokens(std::vector<WXSS::Token> & a2, std::string & a3, int a4)
int GetTokens_i = 0;
int Tokenizer::GetTokens(std::vector<WXSS::Token> &a2, std::string &a3, int a4)
{
GetTokens_i++;
int inner_GetTokens_i = GetTokens_i;
// GetTokens - 0
this->InitTransitTable();
this->InitSubStrCheckingCaluseTable();
@ -311,14 +315,17 @@ namespace WXSS
a2.reserve(a2.size());
// GetTokens - 5
int v33 = 4194305;
// int AnotherTypeByAnySubStr = 0;
int v37 = 1;
int v41 = 1;
int v35 = 1;
int v31 = 0;
WXSS::TokenType AnotherTypeByAnySubStr = 0;
for (int sa = 0; ; sa = v31)
for (int sa = 0;; sa = v31)
{
if (inner_GetTokens_i == 2 && a2.size() == 75)
{
int a = 1;
}
if (v47 > this->offset_0.length())
{
return 0;
@ -347,7 +354,6 @@ namespace WXSS
a3 = v66.str();
return -1;
}
}
if (lt == -1)
break;
@ -355,7 +361,7 @@ namespace WXSS
if ((lt & 0x30000) != 0)
{
int v43 = ((lt & 0x20000) == 0) + v47 - 1;
if ( !AnotherTypeByAnySubStr )
if (!AnotherTypeByAnySubStr)
{
AnotherTypeByAnySubStr = 2;
if (!bittest(&lt, 0x12))
@ -380,7 +386,7 @@ namespace WXSS
WXSS::Token v58;
v58.offset_0 = AnotherTypeByAnySubStr;
// const char * v59 = nullptr;
v58.offset_12 = sa; // v61
v58.offset_12 = sa; // v61
v58.offset_20 = v35;
v58.offset_24 = v37;
v58.offset_16 = ((lt & 0x20000) == 0) + v47 - sa;
@ -394,7 +400,7 @@ namespace WXSS
int v38 = ((lt & 0x20000) == 0) + v47 - 1;
if (bittest(&lt, 0x18u))
{
for (char i = this->offset_0[sa]; v43 != sa && i-10 <= 0x16u && ((0x400009u >> (i - 10)) & 1) != 0 ; i = this->offset_0[sa])
for (char i = this->offset_0[sa]; v43 != sa && i - 10 <= 0x16u && ((0x400009u >> (i - 10)) & 1) != 0; i = this->offset_0[sa])
{
if (i == 10)
{
@ -412,7 +418,6 @@ namespace WXSS
}
--v38;
}
}
v58.offset_12 = sa;
int v39 = v38 - sa + 1;
@ -431,18 +436,13 @@ namespace WXSS
if (v58.offset_0 == 4)
{
if (
!strcasecmp(v58.offset_4->data(), "@media")
|| !strcasecmp(v58.offset_4->data(), "@keyframes")
|| !strcasecmp(v58.offset_4->data(), "@-webkit-keyframes")
|| !strcasecmp(v58.offset_4->data(), "@supports")
)
!strcasecmp(v58.offset_4->data(), "@media") || !strcasecmp(v58.offset_4->data(), "@keyframes") || !strcasecmp(v58.offset_4->data(), "@-webkit-keyframes") || !strcasecmp(v58.offset_4->data(), "@supports"))
{
v4 = 24;
}
const char *DIRECTIVES = "@import";
for (int k = 0; DIRECTIVES[k]; k++)
for (int k = 0; k < 10; k++)
{
if (!strcasecmp(v58.offset_4->data(), DIRECTIVES + k))
if (!strcasecmp(v58.offset_4->data(), DIRECTIVES[k]))
{
WXSS::Token v66;
v66.offset_0 = 1;
@ -451,20 +451,17 @@ namespace WXSS
v66.offset_20 = v58.offset_20;
v66.offset_24 = v37;
// v66.offset_28 = DIRECTIVES + k;
strcpy(v66.offset_28, DIRECTIVES + k);
strcpy(v66.offset_28, DIRECTIVES[k]);
a2.push_back(v66);
goto LABEL_77;
break;
}
}
}
}
{
a2.push_back(v58);
}
LABEL_77:
a2.push_back(v58);
LABEL_77:
sa = v43 + 1;
v37 = v41 + 1;
}
@ -508,14 +505,14 @@ namespace WXSS
Tokenizer::SubStrCheckingClause::SubStrCheckingClause()
{
}
Tokenizer::SubStrCheckingClause::SubStrCheckingClause(WXSS::Tokenizer::STATE a2, char const* a3, WXSS::TokenType a4)
Tokenizer::SubStrCheckingClause::SubStrCheckingClause(WXSS::Tokenizer::STATE a2, char const *a3, WXSS::TokenType a4)
{
this->offset_0 = a2;
this->offset_4 = strlen(a3);
strcpy(this->offset_8, a3);
this->offset_24 = a4;
}
Tokenizer::SubStrCheckingClause& Tokenizer::SubStrCheckingClause::operator=(SubStrCheckingClause const & t)
Tokenizer::SubStrCheckingClause &Tokenizer::SubStrCheckingClause::operator=(SubStrCheckingClause const &t)
{
this->offset_0 = t.offset_0;
this->offset_4 = t.offset_4;
@ -523,8 +520,8 @@ namespace WXSS
this->offset_24 = t.offset_24;
return *this;
}
WXSS::TokenType Tokenizer::TryGetAnotherTypeByAnySubStr(char const* a1, uint a2, WXSS::Tokenizer::STATE a3, WXSS::TokenType a4)
WXSS::TokenType Tokenizer::TryGetAnotherTypeByAnySubStr(char const *a1, uint a2, WXSS::Tokenizer::STATE a3, WXSS::TokenType a4)
{
if (!a4)
{
@ -546,9 +543,7 @@ namespace WXSS
return WXSS::Tokenizer::SCC[i].offset_24;
}
}
}
}
return a4;
}

View File

@ -72,12 +72,12 @@ namespace WXSS
}
else
{
auto v34 = this->offset_56;
std::vector<std::string> v10 = v34[i->first];
auto v10 = this->offset_56[i->first];
v10.push_back(v70);
std::shared_ptr<std::string> v33(new std::string());
v33->assign(v70);
cur->offset_140 = v33;
this->offset_56[i->first] = v10;
}
}
@ -104,9 +104,9 @@ namespace WXSS
auto v43 = this->offset_56.find(v32);
if (v43 != this->offset_56.end())
{
for (int k = 0; k < this->offset_56[v32].size(); k++)
for (int m = 0; m < this->offset_56[v32].size(); m++)
{
_v64[this->offset_56[v32][k]]++;
_v64[this->offset_56[v32][m]]++;
}
}
@ -114,20 +114,19 @@ namespace WXSS
}
// XCompiler - 5 - 0
std::map<std::string,unsigned int> v37;
std::map<std::string, std::vector<std::string>> v34;
std::set<std::string> v72;
std::set<std::string> v70;
while (true)
{
std::vector<std::string> v61;
for (auto v20 = _v64.begin(); v20 != _v64.end(); v20++)
{
if (v20->second)
if (!v20->second)
{
auto v36 = v72.find(v20->first);
if (v36 == v72.end())
auto v36 = v70.find(v20->first);
if (v36 == v70.end())
{
v61.push_back(v20->first);
v72.insert(v20->first);
v70.insert(v20->first);
}
}
}
@ -145,9 +144,9 @@ namespace WXSS
v45 = a2.find(v74)->second.size();
}
v37[v74] = v37[v74] + v45;
for (int j = 0; j < v34[v74].size(); j++)
for (int j = 0; j < this->offset_56[v74].size(); j++)
{
std::string v77 = v34[v74][j];
std::string v77 = this->offset_56[v74][j];
_v64[v77]--;
v37[v77] = v37[v77] + v37[v74];
}
@ -157,7 +156,7 @@ namespace WXSS
}
// XCompiler - 5 - 5
if (a2.size() != 0) // todo...
if (a2.size() != v70.size()) // todo...
{
v55 += "I don't know what will happen if a snake eats its tail, but a file can not import itself.";
this->offset_0 = 4;

View File

@ -8963,10 +8963,10 @@ void __thiscall WXSS::XCompiler::XCompiler(char *this, _DWORD *a2, char a3, int
int *v67; // [esp+B4h] [ebp-A4h]
int *v68; // [esp+B8h] [ebp-A0h]
int v69; // [esp+BCh] [ebp-9Ch]
int v70; // [esp+C0h] [ebp-98h] BYREF
int v71; // [esp+C4h] [ebp-94h] BYREF
int v72[3]; // [esp+C8h] [ebp-90h] BYREF
int v73; // [esp+D4h] [ebp-84h]
int v70; // [esp+C0h] [ebp-98h] BYREF v70->offset_0
int v71; // [esp+C4h] [ebp-94h] BYREF v70->offset_4
int v72[3]; // [esp+C8h] [ebp-90h] BYREF v70->offset_8, v70->offset_12, v70->offset_16
int v73; // [esp+D4h] [ebp-84h] v70->offset_20
int v74[6]; // [esp+D8h] [ebp-80h] BYREF
int v75; // [esp+F0h] [ebp-68h] BYREF
volatile signed __int32 *v76; // [esp+F4h] [ebp-64h] BYREF
@ -9220,11 +9220,12 @@ void __thiscall WXSS::XCompiler::XCompiler(char *this, _DWORD *a2, char a3, int
}
}
// XCompiler - 5 - 0
// std::set<std::string> v70;
v71 = 0;
v72[0] = 0;
v72[1] = (int)&v71;
v72[2] = (int)&v71;
v73 = 0;
v73 = 0; // v70.size()
while ( 1 )
{
// int *v20
@ -11499,7 +11500,10 @@ int __thiscall WXSS::CSSTreeLib::Parser::Parse(int this, char **a2, int *a3, uns
// v83->offset_48
for ( i = 0; i != 64; ++i ) // Token里面的
*((_BYTE *)v83 + i + 52) = *((_BYTE *)lpuexcpta + i + 28);
std::string::operator=((unsigned int **)v83, Str);
// v83->offset_0
v31 = *((_DWORD *)lpuexcpta + 3);
v83[41] = v31;
// v83->offset_164
@ -11558,6 +11562,7 @@ int __thiscall WXSS::CSSTreeLib::Parser::Parse(int this, char **a2, int *a3, uns
// offset_164
v135[41] = *((_DWORD *)v123 + 41);
std::vector<zcc::shared_ptr<WXSS::CSSTreeLib::CSSSyntaxTree>>::push_back(v46 + 30, &v123);
// v135->offset_168
v135[42] = *((_DWORD *)v123 + 42);
std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count(&v136);
}
@ -11749,6 +11754,7 @@ int __thiscall WXSS::CSSTreeLib::Parser::Parse(int this, char **a2, int *a3, uns
}
else
{
// int this
v68 = (int *)std::deque<zcc::shared_ptr<WXSS::CSSTreeLib::CSSSyntaxTree>>::back((_DWORD *)(this + 48));
v69 = *v68;
v70 = (volatile signed __int32 *)v68[1];