1
0
mirror of synced 2024-11-13 18:50:53 +01:00

patterns: Add std::mem::read_string

This commit is contained in:
WerWolv 2021-09-21 23:29:30 +02:00
parent 471ba80b4d
commit 85b8698e35

View File

@ -164,6 +164,17 @@ namespace hex::plugin::builtin {
return hex::signExtend(size * 8, value);
});
/* read_string(address, size) */
ContentRegistry::PatternLanguageFunctions::add(nsStdMem, "read_string", 2, [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
auto address = Token::literalToUnsigned(params[0]);
auto size = Token::literalToUnsigned(params[1]);
std::string result(size, '\x00');
ctx->getProvider()->read(address, result.data(), size);
return result;
});
}
ContentRegistry::PatternLanguageFunctions::Namespace nsStdStr = { "std", "str" };