forked from Public-Mirror/Textractor
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);
|
||||
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 Host::AddConsoleOutput(INVALID_CODEPAGE);
|
||||
if (hp.type & FULL_STRING) buffer.push_back(L'\n');
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "util.h"
|
||||
#include <sstream>
|
||||
#include <Psapi.h>
|
||||
|
||||
namespace
|
||||
@ -10,7 +9,7 @@ namespace
|
||||
HookParam hp = {};
|
||||
hp.type |= DIRECT_READ;
|
||||
|
||||
// {S|Q|V}
|
||||
// {S|Q|V|M}
|
||||
switch (RCode[0])
|
||||
{
|
||||
case L'S':
|
||||
@ -21,6 +20,9 @@ namespace
|
||||
case L'V':
|
||||
hp.type |= USING_UTF8;
|
||||
break;
|
||||
case L'M':
|
||||
hp.type |= USING_UNICODE | HEX_DUMP;
|
||||
break;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
@ -51,12 +53,9 @@ namespace
|
||||
std::wsmatch match;
|
||||
HookParam hp = {};
|
||||
|
||||
// {A|B|W|S|Q|V}
|
||||
// {A|B|W|H|S|Q|V|M}
|
||||
switch (HCode[0])
|
||||
{
|
||||
case L'S':
|
||||
hp.type |= USING_STRING;
|
||||
break;
|
||||
case L'A':
|
||||
hp.type |= BIG_ENDIAN;
|
||||
hp.length_offset = 1;
|
||||
@ -64,16 +63,26 @@ namespace
|
||||
case L'B':
|
||||
hp.length_offset = 1;
|
||||
break;
|
||||
case L'Q':
|
||||
hp.type |= USING_STRING | USING_UNICODE;
|
||||
break;
|
||||
case L'W':
|
||||
hp.type |= USING_UNICODE;
|
||||
hp.length_offset = 1;
|
||||
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':
|
||||
hp.type |= USING_STRING | USING_UTF8;
|
||||
break;
|
||||
case L'M':
|
||||
hp.type |= USING_STRING | USING_UNICODE | HEX_DUMP;
|
||||
break;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
@ -178,7 +187,8 @@ namespace
|
||||
|
||||
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'<';
|
||||
}
|
||||
else
|
||||
@ -199,8 +209,16 @@ namespace
|
||||
|
||||
if (hp.type & USING_UNICODE)
|
||||
{
|
||||
if (hp.type & USING_STRING) HCode += L'Q';
|
||||
else HCode += L'W';
|
||||
if (hp.type & HEX_DUMP)
|
||||
{
|
||||
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
|
||||
{
|
||||
|
@ -28,6 +28,7 @@ enum HookParamType : unsigned
|
||||
DIRECT_READ = 0x1000, // /R read code instead of classic /H hook code
|
||||
FULL_STRING = 0x2000,
|
||||
BLOCK_FLOOD = 0x4000, // remove this hook if flooding text causing perf issues
|
||||
HOOK_ENGINE = 0x8000,
|
||||
HOOK_ADDITIONAL = 0x10000,
|
||||
HEX_DUMP = 0x8000,
|
||||
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* PROCESSES = u8"Processes (*.exe)";
|
||||
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
|
||||
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
|
||||
Default codepage is 932 (Shift-JIS) but this can be changed in settings
|
||||
A/B: codepage char little/big endian
|
||||
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
|
||||
N: don't use context
|
||||
null_length: length of null terminator used for string
|
||||
|
Loading…
x
Reference in New Issue
Block a user