remove useless

Update hookcode.cpp
This commit is contained in:
恍兮惚兮 2024-03-27 19:33:28 +08:00
parent a74f773826
commit d0e2bb27c2
3 changed files with 34 additions and 41 deletions

View File

@ -57,8 +57,7 @@ void TextThread::Push(BYTE* data, int length)
} }
} }
if (hp.type & HEX_DUMP) for (int i = 0; i < length; i += sizeof(short)) buffer.append(FormatString(L"%04hX ", *(short*)(data + i))); if (auto converted = commonparsestring(data,length,&hp,Host::defaultCodepage)) buffer.append(converted.value());
else if (auto converted = commonparsestring(data,length,&hp,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'); if (hp.type & FULL_STRING) buffer.push_back(L'\n');
lastPushTime = GetTickCount64(); lastPushTime = GetTickCount64();

View File

@ -49,7 +49,6 @@ enum HookParamType : uint64_t
FIXING_SPLIT = 0x800, FIXING_SPLIT = 0x800,
DIRECT_READ = 0x1000, // /R read code instead of classic /H hook code DIRECT_READ = 0x1000, // /R read code instead of classic /H hook code
FULL_STRING = 0x2000, FULL_STRING = 0x2000,
HEX_DUMP = 0x4000,
KNOWN_UNSTABLE = 0x20000, KNOWN_UNSTABLE = 0x20000,
EMBED_ABLE=0x40000, EMBED_ABLE=0x40000,
EMBED_DYNA_SJIS=0x80000, EMBED_DYNA_SJIS=0x80000,

View File

@ -22,9 +22,6 @@ namespace
case L'V': case L'V':
hp.type |= CODEC_UTF8; hp.type |= CODEC_UTF8;
break; break;
case L'M':
hp.type |= CODEC_UTF16 | HEX_DUMP;
break;
default: default:
return {}; return {};
} }
@ -63,9 +60,6 @@ namespace
case L'I': case L'I':
hp.type |= CODEC_UTF32; hp.type |= CODEC_UTF32;
break; break;
case L'H':
hp.type |= CODEC_UTF16 | HEX_DUMP;
break;
case L'S': case L'S':
hp.type |= USING_STRING; hp.type |= USING_STRING;
break; break;
@ -78,9 +72,6 @@ namespace
case L'V': case L'V':
hp.type |= USING_STRING | CODEC_UTF8; hp.type |= USING_STRING | CODEC_UTF8;
break; break;
case L'M':
hp.type |= USING_STRING | CODEC_UTF16 | HEX_DUMP;
break;
default: default:
return {}; return {};
} }
@ -221,13 +212,13 @@ namespace
std::wstring GenerateRCode(HookParam hp) std::wstring GenerateRCode(HookParam hp)
{ {
std::wstring RCode = L"R"; std::wstring RCode = L"R";
if (hp.type & CODEC_UTF16||hp.type & CODEC_UTF32) if(hp.type&CODEC_UTF16)
{ RCode += L'Q';
if (hp.type & HEX_DUMP) RCode += L'M'; else if (hp.type&CODEC_UTF32)
else if (hp.type&CODEC_UTF16)RCode += L'Q'; RCode += L'U';
else if (hp.type&CODEC_UTF32)RCode += L'U'; else if (hp.type&CODEC_UTF8)
} RCode += L'V';
else else
{ {
RCode += L'S'; RCode += L'S';
@ -254,6 +245,7 @@ namespace
HCode+=L"D"; HCode+=L"D";
if(hp.type&EMBED_BEFORE_SIMPLE) if(hp.type&EMBED_BEFORE_SIMPLE)
HCode+=L"S"; HCode+=L"S";
if(hp.type&EMBED_AFTER_NEW) if(hp.type&EMBED_AFTER_NEW)
HCode+=L"N"; HCode+=L"N";
else if(hp.type&EMBED_AFTER_OVERWRITE) else if(hp.type&EMBED_AFTER_OVERWRITE)
@ -266,39 +258,40 @@ namespace
else else
HCode += L"H"; HCode += L"H";
if (hp.type & CODEC_UTF16||hp.type & CODEC_UTF32) if (hp.text_fun || hp.filter_fun)
HCode += L'X';
else
{ {
if (hp.type & HEX_DUMP) if(hp.type & USING_STRING)
{ {
if (hp.type & USING_STRING) HCode += L'M'; if(hp.type&CODEC_UTF16)
else HCode += L'H'; HCode += L'Q';
else if(hp.type&CODEC_UTF8)
HCode += L'V';
else if(hp.type&CODEC_UTF32)
HCode += L'U';
else
HCode += L'S';
} }
else else
{ {
if(hp.type&CODEC_UTF16){ if(hp.type&CODEC_UTF16)
HCode += L'W';
if (hp.type & USING_STRING) HCode += L'Q'; else if(hp.type&CODEC_UTF32)
else HCode += L'W'; HCode += L'I';
} else if (hp.type & CODEC_ANSI_BE)
else if(hp.type&CODEC_UTF32){ HCode += L'A';
if (hp.type & USING_STRING) HCode += L'U'; else
else HCode += L'I'; HCode += L'B';
}
} }
}
else
{
if (hp.type & USING_STRING) HCode += L'S';
else if (hp.type & CODEC_ANSI_BE) HCode += L'A';
else HCode += L'B';
}
}
if (hp.type & FULL_STRING) HCode += L'F'; if (hp.type & FULL_STRING) HCode += L'F';
if (hp.type & NO_CONTEXT) HCode += L'N'; if (hp.type & NO_CONTEXT) HCode += L'N';
if (hp.text_fun || hp.filter_fun) HCode += L'X'; // no AGTH equivalent
if (hp.codepage != 0 && !(hp.type & CODEC_UTF16||hp.type & CODEC_UTF32)) HCode += std::to_wstring(hp.codepage) + L'#'; if (hp.codepage != 0 && !(hp.type & CODEC_UTF8) ) HCode += std::to_wstring(hp.codepage) + L'#';
if (hp.padding) HCode += HexString(hp.padding) + L'+'; if (hp.padding) HCode += HexString(hp.padding) + L'+';
@ -309,6 +302,8 @@ namespace
if (hp.type & DATA_INDIRECT) HCode += L'*' + HexString(hp.index); if (hp.type & DATA_INDIRECT) HCode += L'*' + HexString(hp.index);
if (hp.type & USING_SPLIT) HCode += L':' + HexString(hp.split); if (hp.type & USING_SPLIT) HCode += L':' + HexString(hp.split);
if (hp.type & SPLIT_INDIRECT) HCode += L'*' + HexString(hp.split_index); if (hp.type & SPLIT_INDIRECT) HCode += L'*' + HexString(hp.split_index);
// Attempt to make the address relative // Attempt to make the address relative
if (processId && !(hp.type & MODULE_OFFSET)) if (processId && !(hp.type & MODULE_OFFSET))