mirror of
https://github.com/Artikash/Textractor.git
synced 2024-12-23 08:54:12 +08:00
parse shortened hook codes
This commit is contained in:
parent
dc1f819952
commit
f6742de3d5
@ -125,36 +125,44 @@ namespace
|
|||||||
HCode.erase(0, match[0].length());
|
HCode.erase(0, match[0].length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto ConsumeHexInt = [&HCode]
|
||||||
|
{
|
||||||
|
size_t size = 0;
|
||||||
|
int value = 0;
|
||||||
|
try { value = std::stoi(HCode, &size, 16); }
|
||||||
|
catch (std::invalid_argument) {}
|
||||||
|
HCode.erase(0, size);
|
||||||
|
return value;
|
||||||
|
};
|
||||||
|
|
||||||
// data_offset
|
// data_offset
|
||||||
if (!std::regex_search(HCode, match, std::wregex(L"^-?[[:xdigit:]]+"))) return {};
|
hp.offset = ConsumeHexInt();
|
||||||
hp.offset = std::stoi(match[0], nullptr, 16);
|
|
||||||
HCode.erase(0, match[0].length());
|
|
||||||
|
|
||||||
// [*deref_offset1]
|
// [*deref_offset1]
|
||||||
if (std::regex_search(HCode, match, std::wregex(L"^\\*(-?[[:xdigit:]]+)")))
|
if (HCode[0] == L'*')
|
||||||
{
|
{
|
||||||
hp.type |= DATA_INDIRECT;
|
hp.type |= DATA_INDIRECT;
|
||||||
hp.index = std::stoi(match[1], nullptr, 16);
|
HCode.erase(0, 1);
|
||||||
HCode.erase(0, match[0].length());
|
hp.index = ConsumeHexInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
// [:split_offset[*deref_offset2]]
|
// [:split_offset[*deref_offset2]]
|
||||||
if (std::regex_search(HCode, match, std::wregex(L"^:(-?[[:xdigit:]]+)")))
|
if (HCode[0] == L':')
|
||||||
{
|
{
|
||||||
hp.type |= USING_SPLIT;
|
hp.type |= USING_SPLIT;
|
||||||
hp.split = std::stoi(match[1], nullptr, 16);
|
HCode.erase(0, 1);
|
||||||
HCode.erase(0, match[0].length());
|
hp.split = ConsumeHexInt();
|
||||||
|
|
||||||
if (std::regex_search(HCode, match, std::wregex(L"^\\*(-?[[:xdigit:]]+)")))
|
if (HCode[0] == L'*')
|
||||||
{
|
{
|
||||||
hp.type |= SPLIT_INDIRECT;
|
hp.type |= SPLIT_INDIRECT;
|
||||||
hp.split_index = std::stoi(match[1], nullptr, 16);
|
HCode.erase(0, 1);
|
||||||
HCode.erase(0, match[0].length());
|
hp.split_index = ConsumeHexInt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @addr[:module[:func]]
|
// @addr[:module[:func]]
|
||||||
if (!std::regex_match(HCode, match, std::wregex(L"@([[:xdigit:]]+)(:.+?)?(:.+)?"))) return {};
|
if (!std::regex_match(HCode, match, std::wregex(L"^@([[:xdigit:]]+)(:.+?)?(:.+)?"))) return {};
|
||||||
hp.address = std::stoull(match[1], nullptr, 16);
|
hp.address = std::stoull(match[1], nullptr, 16);
|
||||||
if (match[2].matched)
|
if (match[2].matched)
|
||||||
{
|
{
|
||||||
@ -287,7 +295,7 @@ namespace HookCode
|
|||||||
assert(Parse(L"/HQN936#-c*C:C*1C@4AA:gdi.dll:GetTextOutA")),
|
assert(Parse(L"/HQN936#-c*C:C*1C@4AA:gdi.dll:GetTextOutA")),
|
||||||
assert(Parse(L"HB4@0")),
|
assert(Parse(L"HB4@0")),
|
||||||
assert(Parse(L"/RS65001#@44")),
|
assert(Parse(L"/RS65001#@44")),
|
||||||
assert(!Parse(L"HQ@4")),
|
assert(Parse(L"HQ@4")),
|
||||||
assert(!Parse(L"/RW@44")),
|
assert(!Parse(L"/RW@44")),
|
||||||
assert(!Parse(L"/HWG@33"))
|
assert(!Parse(L"/HWG@33"))
|
||||||
);
|
);
|
||||||
|
@ -61,7 +61,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
static bool Ignore(wchar_t ch)
|
static bool Ignore(wchar_t ch)
|
||||||
{
|
{
|
||||||
return ch <= 0x20 || std::iswspace(ch);
|
return ch <= 0x20 || iswspace(ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Node>
|
template <typename Node>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user