fix: Yara matching not being interruptable
This commit is contained in:
parent
582858c0d4
commit
5cf6baca88
@ -33,6 +33,7 @@ namespace hex {
|
||||
[[nodiscard]] bool isFinished() const;
|
||||
[[nodiscard]] bool hadException() const;
|
||||
[[nodiscard]] bool wasInterrupted() const;
|
||||
[[nodiscard]] bool shouldInterrupt() const;
|
||||
void clearException();
|
||||
[[nodiscard]] std::string getExceptionMessage() const;
|
||||
|
||||
@ -79,6 +80,7 @@ namespace hex {
|
||||
[[nodiscard]] bool isRunning() const;
|
||||
[[nodiscard]] bool hadException() const;
|
||||
[[nodiscard]] bool wasInterrupted() const;
|
||||
[[nodiscard]] bool shouldInterrupt() const;
|
||||
|
||||
void interrupt();
|
||||
private:
|
||||
|
@ -78,6 +78,10 @@ namespace hex {
|
||||
return this->m_hadException;
|
||||
}
|
||||
|
||||
bool Task::shouldInterrupt() const {
|
||||
return this->m_shouldInterrupt;
|
||||
}
|
||||
|
||||
bool Task::wasInterrupted() const {
|
||||
return this->m_interrupted;
|
||||
}
|
||||
@ -136,6 +140,14 @@ namespace hex {
|
||||
return !task->hadException();
|
||||
}
|
||||
|
||||
bool TaskHolder::shouldInterrupt() const {
|
||||
if (this->m_task.expired())
|
||||
return false;
|
||||
|
||||
auto task = this->m_task.lock();
|
||||
return !task->shouldInterrupt();
|
||||
}
|
||||
|
||||
bool TaskHolder::wasInterrupted() const {
|
||||
if (this->m_task.expired())
|
||||
return false;
|
||||
|
@ -287,11 +287,13 @@ namespace hex::plugin::builtin {
|
||||
|
||||
|
||||
struct ResultContext {
|
||||
Task *task = nullptr;
|
||||
std::vector<YaraMatch> newMatches;
|
||||
std::vector<std::string> consoleMessages;
|
||||
};
|
||||
|
||||
ResultContext resultContext;
|
||||
resultContext.task = &task;
|
||||
|
||||
yr_rules_scan_mem_blocks(
|
||||
rules, &iterator, 0, [](YR_SCAN_CONTEXT *context, int message, void *data, void *userData) -> int {
|
||||
@ -325,7 +327,7 @@ namespace hex::plugin::builtin {
|
||||
break;
|
||||
}
|
||||
|
||||
return CALLBACK_CONTINUE;
|
||||
return results.task->shouldInterrupt() ? CALLBACK_ABORT : CALLBACK_CONTINUE;
|
||||
},
|
||||
&resultContext,
|
||||
0);
|
||||
|
Loading…
Reference in New Issue
Block a user