Files
mountcloud 3dbac60203 1:重构规则引擎,支持多种逻辑运算,支持多种统计运算,支持多种比较运算。
2:重构特征库格式,从json改用yaml(json确实看起来不好看)。
3:更改特征匹配逻辑,将字节匹配与校验匹配结果拆分。
4:编辑器适配新的规则引擎和特征库格式。
2022-06-30 01:48:43 +08:00

115 lines
2.0 KiB
C++

#ifndef FIREDOG_MATCHTHEAD_H
#define FIREDOG_MATCHTHEAD_H
#include <QThread>
#include <QQueue>
#include <QString>
#include <QMutex>
#include <QHash>
#include "partutil.h"
#define WORK_TYPE_TEXT 1
#define WORK_TYPE_HEX 2
#define WORK_TYPE_FILE 3
#define WORK_TYPE_PART 4
#define STATE_NO_ERROR 0
#define STATE_ERROR -1
#define WORK_READ_FILE_LENGTH 1024
namespace firedog {
class Matcher;
class FeatureLibrary;
class FireDog;
}
class HitFeature {
public:
int sourceId;
int featureId;
int workType;
QString content;
QString name;
QString author;
QString describe;
};
/// <summary>
/// 데몸묏鱗
/// </summary>
class MatchWork {
public:
int sourceId;
int workType;
QString content;
Part part;
firedog::Matcher* matcher = NULL;
~MatchWork();
};
/// <summary>
/// 튈토훨蛟窟넋
/// </summary>
class MatchWorkThread : public QThread {
Q_OBJECT;
public:
MatchWorkThread(int id);
~MatchWorkThread();
void run();
int getState();
void setWork(MatchWork* work);
private:
int id;
int state;
MatchWork* nowWork = NULL;
void match(QByteArray byteArray);
signals:
void nextWork(MatchWorkThread* misson, int* state);
void workSuccess(int id);
void hit(HitFeature hit);
};
/// <summary>
/// 밗소窟넋
/// </summary>
class MatchButlerThread : public QThread {
Q_OBJECT;
public:
MatchButlerThread(int threadNum, firedog::FeatureLibrary* featureLibrary);
~MatchButlerThread();
int init();
void run();
QVector<HitFeature> getHits();
public slots:
void addWork(MatchWork work);
void nextWork(MatchWorkThread* misson, int* state);
void workSuccess(int id);
void hit(HitFeature hit);
signals:
void matchEnd(int worksize,int success, int error, int state);
private:
firedog::FeatureLibrary* featureLibrary = NULL;
firedog::FireDog* fireDog = NULL;
int threadNum;
QHash<int, MatchWorkThread*> workThreads;
QHash<int,bool> worksStates;
QQueue<MatchWork> works;
QMutex workMutex;
QMutex hitMutex;
QVector<HitFeature> hits;
QHash<int, QVector<int>> sourceHitFeatures;
};
#endif