support hex dump codes
This commit is contained in:
parent
a8202893e3
commit
0f7a648403
@ -46,7 +46,8 @@ void TextThread::Push(BYTE* data, int length)
|
|||||||
if (leadByte) std::tie(doubleByteChar[0], doubleByteChar[1], data, length, leadByte) = std::tuple(leadByte, data[0], doubleByteChar, 2, 0);
|
if (leadByte) std::tie(doubleByteChar[0], doubleByteChar[1], data, length, leadByte) = std::tuple(leadByte, data[0], doubleByteChar, 2, 0);
|
||||||
else if (IsDBCSLeadByteEx(hp.codepage ? hp.codepage : Host::defaultCodepage, data[0])) std::tie(leadByte, length) = std::tuple(data[0], 0);
|
else if (IsDBCSLeadByteEx(hp.codepage ? hp.codepage : Host::defaultCodepage, data[0])) std::tie(leadByte, length) = std::tuple(data[0], 0);
|
||||||
|
|
||||||
if (hp.type & USING_UNICODE) buffer.append((wchar_t*)data, length / sizeof(wchar_t));
|
if (hp.type & HEX_DUMP) for (int i = 0; i < length; i += sizeof(short)) buffer.append(FormatString(L"%04hX ", *(short*)(data + i)));
|
||||||
|
else 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');
|
if (hp.type & FULL_STRING) buffer.push_back(L'\n');
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include <sstream>
|
|
||||||
#include <Psapi.h>
|
#include <Psapi.h>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
@ -10,7 +9,7 @@ namespace
|
|||||||
HookParam hp = {};
|
HookParam hp = {};
|
||||||
hp.type |= DIRECT_READ;
|
hp.type |= DIRECT_READ;
|
||||||
|
|
||||||
// {S|Q|V}
|
// {S|Q|V|M}
|
||||||
switch (RCode[0])
|
switch (RCode[0])
|
||||||
{
|
{
|
||||||
case L'S':
|
case L'S':
|
||||||
@ -21,6 +20,9 @@ namespace
|
|||||||
case L'V':
|
case L'V':
|
||||||
hp.type |= USING_UTF8;
|
hp.type |= USING_UTF8;
|
||||||
break;
|
break;
|
||||||
|
case L'M':
|
||||||
|
hp.type |= USING_UNICODE | HEX_DUMP;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@ -51,12 +53,9 @@ namespace
|
|||||||
std::wsmatch match;
|
std::wsmatch match;
|
||||||
HookParam hp = {};
|
HookParam hp = {};
|
||||||
|
|
||||||
// {A|B|W|S|Q|V}
|
// {A|B|W|H|S|Q|V|M}
|
||||||
switch (HCode[0])
|
switch (HCode[0])
|
||||||
{
|
{
|
||||||
case L'S':
|
|
||||||
hp.type |= USING_STRING;
|
|
||||||
break;
|
|
||||||
case L'A':
|
case L'A':
|
||||||
hp.type |= BIG_ENDIAN;
|
hp.type |= BIG_ENDIAN;
|
||||||
hp.length_offset = 1;
|
hp.length_offset = 1;
|
||||||
@ -64,16 +63,26 @@ namespace
|
|||||||
case L'B':
|
case L'B':
|
||||||
hp.length_offset = 1;
|
hp.length_offset = 1;
|
||||||
break;
|
break;
|
||||||
case L'Q':
|
|
||||||
hp.type |= USING_STRING | USING_UNICODE;
|
|
||||||
break;
|
|
||||||
case L'W':
|
case L'W':
|
||||||
hp.type |= USING_UNICODE;
|
hp.type |= USING_UNICODE;
|
||||||
hp.length_offset = 1;
|
hp.length_offset = 1;
|
||||||
break;
|
break;
|
||||||
|
case L'H':
|
||||||
|
hp.type |= USING_UNICODE | HEX_DUMP;
|
||||||
|
hp.length_offset = 1;
|
||||||
|
break;
|
||||||
|
case L'S':
|
||||||
|
hp.type |= USING_STRING;
|
||||||
|
break;
|
||||||
|
case L'Q':
|
||||||
|
hp.type |= USING_STRING | USING_UNICODE;
|
||||||
|
break;
|
||||||
case L'V':
|
case L'V':
|
||||||
hp.type |= USING_STRING | USING_UTF8;
|
hp.type |= USING_STRING | USING_UTF8;
|
||||||
break;
|
break;
|
||||||
|
case L'M':
|
||||||
|
hp.type |= USING_STRING | USING_UNICODE | HEX_DUMP;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@ -178,7 +187,8 @@ namespace
|
|||||||
|
|
||||||
if (hp.type & USING_UNICODE)
|
if (hp.type & USING_UNICODE)
|
||||||
{
|
{
|
||||||
RCode += L'Q';
|
if (hp.type & HEX_DUMP) RCode += L'M';
|
||||||
|
else RCode += L'Q';
|
||||||
if (hp.null_length != 0) RCode += std::to_wstring(hp.null_length) + L'<';
|
if (hp.null_length != 0) RCode += std::to_wstring(hp.null_length) + L'<';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -199,8 +209,16 @@ namespace
|
|||||||
|
|
||||||
if (hp.type & USING_UNICODE)
|
if (hp.type & USING_UNICODE)
|
||||||
{
|
{
|
||||||
if (hp.type & USING_STRING) HCode += L'Q';
|
if (hp.type & HEX_DUMP)
|
||||||
else HCode += L'W';
|
{
|
||||||
|
if (hp.type & USING_STRING) HCode += L'M';
|
||||||
|
else HCode += L'H';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (hp.type & USING_STRING) HCode += L'Q';
|
||||||
|
else HCode += L'W';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -28,6 +28,7 @@ enum HookParamType : unsigned
|
|||||||
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,
|
||||||
BLOCK_FLOOD = 0x4000, // remove this hook if flooding text causing perf issues
|
BLOCK_FLOOD = 0x4000, // remove this hook if flooding text causing perf issues
|
||||||
HOOK_ENGINE = 0x8000,
|
HEX_DUMP = 0x8000,
|
||||||
HOOK_ADDITIONAL = 0x10000,
|
HOOK_ENGINE = 0x10000,
|
||||||
|
HOOK_ADDITIONAL = 0x20000,
|
||||||
};
|
};
|
||||||
|
7
text.cpp
7
text.cpp
@ -21,15 +21,16 @@ const char* SELECT_PROCESS_INFO = u8"If you manually type in the process file na
|
|||||||
const char* FROM_COMPUTER = u8"Select from computer";
|
const char* FROM_COMPUTER = u8"Select from computer";
|
||||||
const char* PROCESSES = u8"Processes (*.exe)";
|
const char* PROCESSES = u8"Processes (*.exe)";
|
||||||
const char* CODE_INFODUMP = u8R"(Enter read code
|
const char* CODE_INFODUMP = u8R"(Enter read code
|
||||||
R{S|Q|V}[null_length<][codepage#]@addr
|
R{S|Q|V|M}[null_length<][codepage#]@addr
|
||||||
OR
|
OR
|
||||||
Enter hook code
|
Enter hook code
|
||||||
H{A|B|W|S|Q|V}[F][null_length<][N][codepage#][padding+]data_offset[*deref_offset][:split_offset[*deref_offset]]@addr[:module[:func]]
|
H{A|B|W|H|S|Q|V|M}[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
|
H: Two hex bytes
|
||||||
|
S/Q/V/M: codepage/UTF-16/UTF-8/hex string
|
||||||
F: treat strings as full lines of text
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user