2018-12-18 09:48:14 +08:00
|
|
|
#include "extension.h"
|
2018-08-19 12:13:19 +08:00
|
|
|
|
2018-11-07 23:43:54 +08:00
|
|
|
void RemoveRepeatedChars(std::wstring& sentence)
|
2018-08-19 12:13:19 +08:00
|
|
|
{
|
2018-09-23 03:45:54 +08:00
|
|
|
int repeatNumber = 0;
|
2018-09-01 16:24:22 +08:00
|
|
|
wchar_t prevChar = sentence[0];
|
2018-10-31 09:21:21 +08:00
|
|
|
for (auto c : sentence)
|
|
|
|
if (c == prevChar) repeatNumber++;
|
2018-09-01 16:24:22 +08:00
|
|
|
else break;
|
2018-11-07 23:43:54 +08:00
|
|
|
if (repeatNumber == 1) return;
|
2018-09-01 16:24:22 +08:00
|
|
|
|
|
|
|
for (int i = 0; i < sentence.size(); i += repeatNumber)
|
|
|
|
for (int j = i; j < sentence.size(); ++j)
|
|
|
|
if (sentence[j] != sentence[i])
|
2018-11-07 23:43:54 +08:00
|
|
|
if ((j - i) % repeatNumber != 0) return;
|
2018-09-01 16:24:22 +08:00
|
|
|
else break;
|
|
|
|
|
2018-09-13 14:50:03 +08:00
|
|
|
std::wstring newSentence = L"";
|
2018-11-07 23:43:54 +08:00
|
|
|
for (int i = 0; i < sentence.size(); i += repeatNumber) newSentence.push_back(sentence[i]);
|
2018-09-13 14:50:03 +08:00
|
|
|
sentence = newSentence;
|
2018-09-01 16:24:22 +08:00
|
|
|
}
|
2018-08-19 12:13:19 +08:00
|
|
|
|
2018-11-07 23:43:54 +08:00
|
|
|
void RemoveCyclicRepeats(std::wstring& sentence)
|
2018-09-01 16:24:22 +08:00
|
|
|
{
|
2018-11-15 13:06:49 +08:00
|
|
|
remove:
|
2018-11-28 05:54:19 +08:00
|
|
|
for (std::wstring junk = sentence; junk.size() > 4; junk.pop_back())
|
2018-11-15 13:06:49 +08:00
|
|
|
if (sentence.rfind(junk) > 0)
|
|
|
|
{
|
|
|
|
sentence.erase(0, junk.size());
|
|
|
|
goto remove;
|
|
|
|
}
|
2018-09-01 16:24:22 +08:00
|
|
|
}
|
2018-08-19 12:13:19 +08:00
|
|
|
|
2018-09-23 03:08:31 +08:00
|
|
|
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
2018-09-01 16:24:22 +08:00
|
|
|
{
|
2018-09-23 03:08:31 +08:00
|
|
|
if (sentenceInfo["hook address"] == -1) return false;
|
2018-11-07 23:43:54 +08:00
|
|
|
RemoveRepeatedChars(sentence);
|
|
|
|
RemoveCyclicRepeats(sentence);
|
|
|
|
return true;
|
|
|
|
}
|