treat string as full line

This commit is contained in:
Akash Mozumdar 2019-07-19 01:15:00 +03:00
parent e896cb033f
commit ad20ca360d
4 changed files with 22 additions and 8 deletions

View File

@ -49,6 +49,7 @@ void TextThread::Push(BYTE* data, int length)
if (hp.type & USING_UNICODE) buffer.append((wchar_t*)data, length / sizeof(wchar_t)); if (hp.type & USING_UNICODE) buffer.append((wchar_t*)data, length / sizeof(wchar_t));
else if (auto converted = Util::StringToWideString(std::string((char*)data, length), hp.codepage ? hp.codepage : Host::defaultCodepage)) buffer.append(converted.value()); else if (auto converted = Util::StringToWideString(std::string((char*)data, length), hp.codepage ? hp.codepage : Host::defaultCodepage)) buffer.append(converted.value());
else Host::AddConsoleOutput(INVALID_CODEPAGE); else Host::AddConsoleOutput(INVALID_CODEPAGE);
if (hp.type & FULL_STRING) buffer.push_back(L'\n');
lastPushTime = GetTickCount(); lastPushTime = GetTickCount();
if (filterRepetition) if (filterRepetition)
@ -62,7 +63,7 @@ void TextThread::Push(BYTE* data, int length)
} }
} }
if (flushDelay == 0 && hp.type & USING_STRING) if (flushDelay == 0 && hp.type & FULL_STRING)
{ {
AddSentence(std::move(buffer)); AddSentence(std::move(buffer));
buffer.clear(); buffer.clear();

View File

@ -102,12 +102,21 @@ namespace
} }
HCode.erase(0, 1); HCode.erase(0, 1);
if ((hp.type & USING_STRING))
{
if (HCode[0] == L'F')
{
hp.type |= FULL_STRING;
HCode.erase(0, 1);
}
// [null_length<] // [null_length<]
if ((hp.type & USING_STRING) && std::regex_search(HCode, match, std::wregex(L"^([0-9]+)<"))) if (std::regex_search(HCode, match, std::wregex(L"^([0-9]+)<")))
{ {
hp.null_length = std::stoi(match[1]); hp.null_length = std::stoi(match[1]);
HCode.erase(0, match[0].length()); HCode.erase(0, match[0].length());
} }
}
// [N] // [N]
if (HCode[0] == L'N') if (HCode[0] == L'N')
@ -226,6 +235,8 @@ namespace
else HCode << "B"; else HCode << "B";
} }
if (hp.type & FULL_STRING) HCode << "F";
if (hp.null_length != 0) HCode << hp.null_length << "<"; if (hp.null_length != 0) HCode << hp.null_length << "<";
if (hp.type & NO_CONTEXT) HCode << "N"; if (hp.type & NO_CONTEXT) HCode << "N";

View File

@ -27,6 +27,7 @@ enum HookParamType : unsigned
HOOK_EMPTY = 0x800, HOOK_EMPTY = 0x800,
FIXING_SPLIT = 0x1000, FIXING_SPLIT = 0x1000,
DIRECT_READ = 0x2000, // /R read code instead of classic /H hook code DIRECT_READ = 0x2000, // /R read code instead of classic /H hook code
HOOK_ENGINE = 0x4000, FULL_STRING = 0x4000,
HOOK_ADDITIONAL = 0x8000, HOOK_ENGINE = 0x8000,
HOOK_ADDITIONAL = 0x10000,
}; };

View File

@ -29,12 +29,13 @@ Enter read code
R{S|Q|V}[null_length<][codepage#]@addr R{S|Q|V}[null_length<][codepage#]@addr
OR OR
Enter hook code Enter hook code
H{A|B|W|S|Q|V}[null_length<][N][codepage#][padding+]data_offset[*deref_offset][:split_offset[*deref_offset]]@addr[:module[:func]] H{A|B|W|S|Q|V}[F][null_length<][N][codepage#][padding+]data_offset[*deref_offset][:split_offset[*deref_offset]]@addr[:module[:func]]
All numbers except codepage/null_length in hexadecimal All numbers except codepage/null_length in hexadecimal
Default codepage is 932 (Shift-JIS) but this can be changed in settings Default codepage is 932 (Shift-JIS) but this can be changed in settings
A/B: codepage char little/big endian A/B: codepage char little/big endian
W: UTF-16 char W: UTF-16 char
S/Q/V: codepage/UTF-16/UTF-8 string S/Q/V: codepage/UTF-16/UTF-8 string
F: treat strings as full lines of text
N: don't use context N: don't use context
null_length: length of null terminator used for string null_length: length of null terminator used for string
padding: length of padding data before string (C struct { int64_t size; char string[500]; } needs padding = 8) padding: length of padding data before string (C struct { int64_t size; char string[500]; } needs padding = 8)