mirror of
https://github.com/tnodir/fort
synced 2024-11-15 03:56:18 +00:00
Rename dosPath to kernelPath.
This commit is contained in:
parent
ca30844963
commit
d3fc7fc350
@ -68,7 +68,7 @@ void Test::confWriteRead()
|
||||
QVERIFY(!FortCommon::confIpInRange(data, NetUtil::textToIp4("193.0.0.0")));
|
||||
|
||||
QVERIFY(FortCommon::confAppBlocked(data, "System"));
|
||||
QVERIFY(!FortCommon::confAppBlocked(data, FileUtil::pathToDosPath("C:\\Programs\\Skype\\Phone\\Skype.exe").toLower()));
|
||||
QVERIFY(!FortCommon::confAppBlocked(data, FileUtil::pathToDosPath("C:\\Utils\\Dev\\Git\\").toLower()));
|
||||
QVERIFY(FortCommon::confAppBlocked(data, FileUtil::pathToDosPath("C:\\Utils\\Firefox\\Bin\\firefox.exe").toLower()));
|
||||
QVERIFY(!FortCommon::confAppBlocked(data, FileUtil::pathToKernelPath("C:\\Programs\\Skype\\Phone\\Skype.exe").toLower()));
|
||||
QVERIFY(!FortCommon::confAppBlocked(data, FileUtil::pathToKernelPath("C:\\Utils\\Dev\\Git\\").toLower()));
|
||||
QVERIFY(FortCommon::confAppBlocked(data, FileUtil::pathToKernelPath("C:\\Utils\\Firefox\\Bin\\firefox.exe").toLower()));
|
||||
}
|
||||
|
@ -13,15 +13,15 @@ void Test::paths()
|
||||
const QString subPath = QString(subPathBack)
|
||||
.replace(QLatin1Char('\\'), QLatin1Char('/'));
|
||||
|
||||
const QString dosPath = dosNameC + subPathBack;
|
||||
const QString kernelPath = dosNameC + subPathBack;
|
||||
const QString pathBack = driveC + subPathBack;
|
||||
const QString path = driveC + subPath;
|
||||
|
||||
QCOMPARE(FileUtil::dosNameToDrive(dosNameC), driveC);
|
||||
QCOMPARE(FileUtil::driveToDosName(driveC), dosNameC);
|
||||
|
||||
QCOMPARE(FileUtil::dosPathToPath(dosPath), pathBack);
|
||||
QCOMPARE(FileUtil::pathToDosPath(path), dosPath);
|
||||
QCOMPARE(FileUtil::kernelPathToPath(kernelPath), pathBack);
|
||||
QCOMPARE(FileUtil::pathToKernelPath(path), kernelPath);
|
||||
}
|
||||
|
||||
void Test::process()
|
||||
@ -29,5 +29,5 @@ void Test::process()
|
||||
const ProcessInfo pi(ProcessInfo::currentPid());
|
||||
|
||||
QVERIFY(pi.isValid());
|
||||
QVERIFY(!pi.dosPath().isEmpty());
|
||||
QVERIFY(!pi.kernelPath().isEmpty());
|
||||
}
|
||||
|
@ -32,6 +32,6 @@ void Test::logWriteRead()
|
||||
while (buf.read(&entry)) {
|
||||
QCOMPARE(entry.ip(), ip);
|
||||
QCOMPARE(entry.pid(), pid);
|
||||
QCOMPARE(entry.dosPath(), path);
|
||||
QCOMPARE(entry.kernelPath(), path);
|
||||
}
|
||||
}
|
||||
|
@ -70,13 +70,13 @@ void Test::printLogs(LogBuffer &buf)
|
||||
|
||||
while (buf.read(&entry)) {
|
||||
const quint32 pid = entry.pid();
|
||||
QString dosPath = entry.dosPath();
|
||||
QString kernelPath = entry.kernelPath();
|
||||
|
||||
if (dosPath.isEmpty()) {
|
||||
if (kernelPath.isEmpty()) {
|
||||
ProcessInfo pi(pid);
|
||||
dosPath = pi.dosPath();
|
||||
kernelPath = pi.kernelPath();
|
||||
}
|
||||
|
||||
qDebug() << pid << dosPath << NetUtil::ip4ToText(entry.ip());
|
||||
qDebug() << pid << kernelPath << NetUtil::ip4ToText(entry.ip());
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ void LogBuffer::prepareFor(int len)
|
||||
|
||||
int LogBuffer::write(const LogEntry *logEntry)
|
||||
{
|
||||
const QString path = logEntry->dosPath();
|
||||
const QString path = logEntry->kernelPath();
|
||||
const int pathLen = path.size() * sizeof(wchar_t);
|
||||
|
||||
const int entrySize = FortCommon::logSize(pathLen);
|
||||
@ -63,7 +63,7 @@ int LogBuffer::read(LogEntry *logEntry)
|
||||
|
||||
logEntry->setIp(ip);
|
||||
logEntry->setPid(pid);
|
||||
logEntry->setDosPath(path);
|
||||
logEntry->setKernelPath(path);
|
||||
|
||||
const int entrySize = FortCommon::logSize(pathLen);
|
||||
m_offset += entrySize;
|
||||
|
@ -1,12 +1,12 @@
|
||||
#include "logentry.h"
|
||||
|
||||
LogEntry::LogEntry(quint32 ip, quint32 pid,
|
||||
const QString &dosPath,
|
||||
const QString &kernelPath,
|
||||
QObject *parent) :
|
||||
QObject(parent),
|
||||
m_ip(ip),
|
||||
m_pid(pid),
|
||||
m_dosPath(dosPath)
|
||||
m_kernelPath(kernelPath)
|
||||
{
|
||||
}
|
||||
|
||||
@ -26,10 +26,10 @@ void LogEntry::setPid(quint32 pid)
|
||||
}
|
||||
}
|
||||
|
||||
void LogEntry::setDosPath(const QString &dosPath)
|
||||
void LogEntry::setKernelPath(const QString &kernelPath)
|
||||
{
|
||||
if (m_dosPath != dosPath) {
|
||||
m_dosPath = dosPath;
|
||||
emit dosPathChanged();
|
||||
if (m_kernelPath != kernelPath) {
|
||||
m_kernelPath = kernelPath;
|
||||
emit kernelPathChanged();
|
||||
}
|
||||
}
|
||||
|
@ -8,11 +8,11 @@ class LogEntry : public QObject
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(quint32 ip READ ip WRITE setIp NOTIFY ipChanged)
|
||||
Q_PROPERTY(quint32 pid READ pid WRITE setPid NOTIFY pidChanged)
|
||||
Q_PROPERTY(QString dosPath READ dosPath WRITE setDosPath NOTIFY dosPathChanged)
|
||||
Q_PROPERTY(QString kernelPath READ kernelPath WRITE setKernelPath NOTIFY kernelPathChanged)
|
||||
|
||||
public:
|
||||
explicit LogEntry(quint32 ip = 0, quint32 pid = 0,
|
||||
const QString &dosPath = QString(),
|
||||
const QString &kernelPath = QString(),
|
||||
QObject *parent = nullptr);
|
||||
|
||||
quint32 ip() const { return m_ip; }
|
||||
@ -21,20 +21,20 @@ public:
|
||||
quint32 pid() const { return m_pid; }
|
||||
void setPid(quint32 pid);
|
||||
|
||||
QString dosPath() const { return m_dosPath; }
|
||||
void setDosPath(const QString &dosPath);
|
||||
QString kernelPath() const { return m_kernelPath; }
|
||||
void setKernelPath(const QString &kernelPath);
|
||||
|
||||
signals:
|
||||
void ipChanged();
|
||||
void pidChanged();
|
||||
void dosPathChanged();
|
||||
void kernelPathChanged();
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
quint32 m_ip;
|
||||
quint32 m_pid;
|
||||
QString m_dosPath;
|
||||
QString m_kernelPath;
|
||||
};
|
||||
|
||||
#endif // LOGENTRY_H
|
||||
|
@ -88,12 +88,12 @@ bool FortCommon::confIpInRange(const void *drvConf, quint32 ip,
|
||||
}
|
||||
|
||||
bool FortCommon::confAppBlocked(const void *drvConf,
|
||||
const QString &dosPath, bool *notify)
|
||||
const QString &kernelPath, bool *notify)
|
||||
{
|
||||
const PFORT_CONF conf = (const PFORT_CONF) drvConf;
|
||||
const QString dosPathLower = dosPath.toLower();
|
||||
const int len = dosPathLower.size() * sizeof(wchar_t);
|
||||
const wchar_t *p = (const wchar_t *) dosPathLower.utf16();
|
||||
const QString kernelPathLower = kernelPath.toLower();
|
||||
const int len = kernelPathLower.size() * sizeof(wchar_t);
|
||||
const wchar_t *p = (const wchar_t *) kernelPathLower.utf16();
|
||||
BOOL blocked, notifyUser;
|
||||
|
||||
blocked = fort_conf_app_blocked(conf, len, (const char *) p, ¬ifyUser);
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
static bool confIpInRange(const void *drvConf, quint32 ip,
|
||||
bool included = false);
|
||||
static bool confAppBlocked(const void *drvConf,
|
||||
const QString &dosPath, bool *notify = 0);
|
||||
const QString &kernelPath, bool *notify = 0);
|
||||
|
||||
static uint provRegister(bool boot);
|
||||
static void provUnregister();
|
||||
|
@ -90,12 +90,12 @@ BasePage {
|
||||
}
|
||||
|
||||
function getEntryPath(logEntry) {
|
||||
var dosPath = logEntry.dosPath;
|
||||
if (!dosPath) {
|
||||
dosPath = osUtil.pidToDosPath(logEntry.pid);
|
||||
var kernelPath = logEntry.kernelPath;
|
||||
if (!kernelPath) {
|
||||
kernelPath = osUtil.pidToKernelPath(logEntry.pid);
|
||||
}
|
||||
|
||||
return fileUtil.dosPathToPath(dosPath);
|
||||
return fileUtil.kernelPathToPath(kernelPath);
|
||||
}
|
||||
|
||||
function refreshListViews() {
|
||||
|
@ -190,8 +190,8 @@ QString ConfUtil::parseAppPath(const QStringRef &line)
|
||||
if (!QStringRef::compare(path, systemPath, Qt::CaseInsensitive))
|
||||
return systemPath;
|
||||
|
||||
const QString dosPath = FileUtil::pathToDosPath(path.toString());
|
||||
return dosPath.toLower();
|
||||
const QString kernelPath = FileUtil::pathToKernelPath(path.toString());
|
||||
return kernelPath.toLower();
|
||||
}
|
||||
|
||||
void ConfUtil::writeData(char *output, const FirewallConf &conf,
|
||||
|
@ -43,25 +43,25 @@ QString FileUtil::driveToDosName(const QString &drive)
|
||||
}
|
||||
|
||||
// Convert "\\Device\\HarddiskVolume1\\path" to "C:\\path"
|
||||
QString FileUtil::dosPathToPath(const QString &dosPath)
|
||||
QString FileUtil::kernelPathToPath(const QString &kernelPath)
|
||||
{
|
||||
const QLatin1Char sep('\\');
|
||||
|
||||
if (dosPath.startsWith(sep)) {
|
||||
const int sepPos1 = dosPath.indexOf(sep, 1);
|
||||
if (kernelPath.startsWith(sep)) {
|
||||
const int sepPos1 = kernelPath.indexOf(sep, 1);
|
||||
if (sepPos1 > 0) {
|
||||
const int sepPos2 = dosPath.indexOf(sep, sepPos1 + 1);
|
||||
const int sepPos2 = kernelPath.indexOf(sep, sepPos1 + 1);
|
||||
if (sepPos2 > 0) {
|
||||
const QString dosName = dosPath.left(sepPos2);
|
||||
return dosNameToDrive(dosName) + dosPath.mid(sepPos2);
|
||||
const QString dosName = kernelPath.left(sepPos2);
|
||||
return dosNameToDrive(dosName) + kernelPath.mid(sepPos2);
|
||||
}
|
||||
}
|
||||
}
|
||||
return dosPath;
|
||||
return kernelPath;
|
||||
}
|
||||
|
||||
// Convert "C:\\path" to "\\Device\\HarddiskVolume1\\path"
|
||||
QString FileUtil::pathToDosPath(const QString &path)
|
||||
QString FileUtil::pathToKernelPath(const QString &path)
|
||||
{
|
||||
const QString drive = path.left(2);
|
||||
|
||||
|
@ -17,10 +17,10 @@ public:
|
||||
static QString driveToDosName(const QString &drive);
|
||||
|
||||
// Convert Native path to Win32 path
|
||||
Q_INVOKABLE static QString dosPathToPath(const QString &dosPath);
|
||||
Q_INVOKABLE static QString kernelPathToPath(const QString &kernelPath);
|
||||
|
||||
// Convert Win32 path to Native path
|
||||
Q_INVOKABLE static QString pathToDosPath(const QString &path);
|
||||
Q_INVOKABLE static QString pathToKernelPath(const QString &path);
|
||||
|
||||
static QString absolutePath(const QString &path);
|
||||
|
||||
|
@ -31,10 +31,10 @@ void OsUtil::setClipboardData(const QVariant &data)
|
||||
}
|
||||
}
|
||||
|
||||
QString OsUtil::pidToDosPath(quint32 pid)
|
||||
QString OsUtil::pidToKernelPath(quint32 pid)
|
||||
{
|
||||
const ProcessInfo pi(pid);
|
||||
return pi.dosPath();
|
||||
return pi.kernelPath();
|
||||
}
|
||||
|
||||
bool OsUtil::createGlobalMutex(const char *name)
|
||||
|
@ -13,7 +13,7 @@ public:
|
||||
|
||||
Q_INVOKABLE static void setClipboardData(const QVariant &data);
|
||||
|
||||
Q_INVOKABLE static QString pidToDosPath(quint32 pid);
|
||||
Q_INVOKABLE static QString pidToKernelPath(quint32 pid);
|
||||
|
||||
static bool createGlobalMutex(const char *name);
|
||||
};
|
||||
|
@ -46,7 +46,7 @@ void ProcessInfo::closeProcess()
|
||||
}
|
||||
}
|
||||
|
||||
QString ProcessInfo::dosPath() const
|
||||
QString ProcessInfo::kernelPath() const
|
||||
{
|
||||
if (isValid()) {
|
||||
QByteArray buf(PROC_PATH_MAX * sizeof(wchar_t), Qt::Uninitialized);
|
||||
|
@ -30,7 +30,7 @@ public:
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
QString dosPath() const;
|
||||
QString kernelPath() const;
|
||||
|
||||
private:
|
||||
void openProcess();
|
||||
|
Loading…
Reference in New Issue
Block a user