Rename dosPath to kernelPath.

This commit is contained in:
Nodir Temirkhodjaev 2017-09-13 13:26:51 +05:00
parent ca30844963
commit d3fc7fc350
17 changed files with 52 additions and 52 deletions

View File

@ -68,7 +68,7 @@ void Test::confWriteRead()
QVERIFY(!FortCommon::confIpInRange(data, NetUtil::textToIp4("193.0.0.0"))); QVERIFY(!FortCommon::confIpInRange(data, NetUtil::textToIp4("193.0.0.0")));
QVERIFY(FortCommon::confAppBlocked(data, "System")); QVERIFY(FortCommon::confAppBlocked(data, "System"));
QVERIFY(!FortCommon::confAppBlocked(data, FileUtil::pathToDosPath("C:\\Programs\\Skype\\Phone\\Skype.exe").toLower())); QVERIFY(!FortCommon::confAppBlocked(data, FileUtil::pathToKernelPath("C:\\Programs\\Skype\\Phone\\Skype.exe").toLower()));
QVERIFY(!FortCommon::confAppBlocked(data, FileUtil::pathToDosPath("C:\\Utils\\Dev\\Git\\").toLower())); QVERIFY(!FortCommon::confAppBlocked(data, FileUtil::pathToKernelPath("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:\\Utils\\Firefox\\Bin\\firefox.exe").toLower()));
} }

View File

@ -13,15 +13,15 @@ void Test::paths()
const QString subPath = QString(subPathBack) const QString subPath = QString(subPathBack)
.replace(QLatin1Char('\\'), QLatin1Char('/')); .replace(QLatin1Char('\\'), QLatin1Char('/'));
const QString dosPath = dosNameC + subPathBack; const QString kernelPath = dosNameC + subPathBack;
const QString pathBack = driveC + subPathBack; const QString pathBack = driveC + subPathBack;
const QString path = driveC + subPath; const QString path = driveC + subPath;
QCOMPARE(FileUtil::dosNameToDrive(dosNameC), driveC); QCOMPARE(FileUtil::dosNameToDrive(dosNameC), driveC);
QCOMPARE(FileUtil::driveToDosName(driveC), dosNameC); QCOMPARE(FileUtil::driveToDosName(driveC), dosNameC);
QCOMPARE(FileUtil::dosPathToPath(dosPath), pathBack); QCOMPARE(FileUtil::kernelPathToPath(kernelPath), pathBack);
QCOMPARE(FileUtil::pathToDosPath(path), dosPath); QCOMPARE(FileUtil::pathToKernelPath(path), kernelPath);
} }
void Test::process() void Test::process()
@ -29,5 +29,5 @@ void Test::process()
const ProcessInfo pi(ProcessInfo::currentPid()); const ProcessInfo pi(ProcessInfo::currentPid());
QVERIFY(pi.isValid()); QVERIFY(pi.isValid());
QVERIFY(!pi.dosPath().isEmpty()); QVERIFY(!pi.kernelPath().isEmpty());
} }

View File

@ -32,6 +32,6 @@ void Test::logWriteRead()
while (buf.read(&entry)) { while (buf.read(&entry)) {
QCOMPARE(entry.ip(), ip); QCOMPARE(entry.ip(), ip);
QCOMPARE(entry.pid(), pid); QCOMPARE(entry.pid(), pid);
QCOMPARE(entry.dosPath(), path); QCOMPARE(entry.kernelPath(), path);
} }
} }

View File

@ -70,13 +70,13 @@ void Test::printLogs(LogBuffer &buf)
while (buf.read(&entry)) { while (buf.read(&entry)) {
const quint32 pid = entry.pid(); const quint32 pid = entry.pid();
QString dosPath = entry.dosPath(); QString kernelPath = entry.kernelPath();
if (dosPath.isEmpty()) { if (kernelPath.isEmpty()) {
ProcessInfo pi(pid); ProcessInfo pi(pid);
dosPath = pi.dosPath(); kernelPath = pi.kernelPath();
} }
qDebug() << pid << dosPath << NetUtil::ip4ToText(entry.ip()); qDebug() << pid << kernelPath << NetUtil::ip4ToText(entry.ip());
} }
} }

View File

@ -23,7 +23,7 @@ void LogBuffer::prepareFor(int len)
int LogBuffer::write(const LogEntry *logEntry) 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 pathLen = path.size() * sizeof(wchar_t);
const int entrySize = FortCommon::logSize(pathLen); const int entrySize = FortCommon::logSize(pathLen);
@ -63,7 +63,7 @@ int LogBuffer::read(LogEntry *logEntry)
logEntry->setIp(ip); logEntry->setIp(ip);
logEntry->setPid(pid); logEntry->setPid(pid);
logEntry->setDosPath(path); logEntry->setKernelPath(path);
const int entrySize = FortCommon::logSize(pathLen); const int entrySize = FortCommon::logSize(pathLen);
m_offset += entrySize; m_offset += entrySize;

View File

@ -1,12 +1,12 @@
#include "logentry.h" #include "logentry.h"
LogEntry::LogEntry(quint32 ip, quint32 pid, LogEntry::LogEntry(quint32 ip, quint32 pid,
const QString &dosPath, const QString &kernelPath,
QObject *parent) : QObject *parent) :
QObject(parent), QObject(parent),
m_ip(ip), m_ip(ip),
m_pid(pid), 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) { if (m_kernelPath != kernelPath) {
m_dosPath = dosPath; m_kernelPath = kernelPath;
emit dosPathChanged(); emit kernelPathChanged();
} }
} }

View File

@ -8,11 +8,11 @@ class LogEntry : public QObject
Q_OBJECT Q_OBJECT
Q_PROPERTY(quint32 ip READ ip WRITE setIp NOTIFY ipChanged) Q_PROPERTY(quint32 ip READ ip WRITE setIp NOTIFY ipChanged)
Q_PROPERTY(quint32 pid READ pid WRITE setPid NOTIFY pidChanged) 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: public:
explicit LogEntry(quint32 ip = 0, quint32 pid = 0, explicit LogEntry(quint32 ip = 0, quint32 pid = 0,
const QString &dosPath = QString(), const QString &kernelPath = QString(),
QObject *parent = nullptr); QObject *parent = nullptr);
quint32 ip() const { return m_ip; } quint32 ip() const { return m_ip; }
@ -21,20 +21,20 @@ public:
quint32 pid() const { return m_pid; } quint32 pid() const { return m_pid; }
void setPid(quint32 pid); void setPid(quint32 pid);
QString dosPath() const { return m_dosPath; } QString kernelPath() const { return m_kernelPath; }
void setDosPath(const QString &dosPath); void setKernelPath(const QString &kernelPath);
signals: signals:
void ipChanged(); void ipChanged();
void pidChanged(); void pidChanged();
void dosPathChanged(); void kernelPathChanged();
public slots: public slots:
private: private:
quint32 m_ip; quint32 m_ip;
quint32 m_pid; quint32 m_pid;
QString m_dosPath; QString m_kernelPath;
}; };
#endif // LOGENTRY_H #endif // LOGENTRY_H

View File

@ -88,12 +88,12 @@ bool FortCommon::confIpInRange(const void *drvConf, quint32 ip,
} }
bool FortCommon::confAppBlocked(const void *drvConf, 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 PFORT_CONF conf = (const PFORT_CONF) drvConf;
const QString dosPathLower = dosPath.toLower(); const QString kernelPathLower = kernelPath.toLower();
const int len = dosPathLower.size() * sizeof(wchar_t); const int len = kernelPathLower.size() * sizeof(wchar_t);
const wchar_t *p = (const wchar_t *) dosPathLower.utf16(); const wchar_t *p = (const wchar_t *) kernelPathLower.utf16();
BOOL blocked, notifyUser; BOOL blocked, notifyUser;
blocked = fort_conf_app_blocked(conf, len, (const char *) p, &notifyUser); blocked = fort_conf_app_blocked(conf, len, (const char *) p, &notifyUser);

View File

@ -31,7 +31,7 @@ public:
static bool confIpInRange(const void *drvConf, quint32 ip, static bool confIpInRange(const void *drvConf, quint32 ip,
bool included = false); bool included = false);
static bool confAppBlocked(const void *drvConf, static bool confAppBlocked(const void *drvConf,
const QString &dosPath, bool *notify = 0); const QString &kernelPath, bool *notify = 0);
static uint provRegister(bool boot); static uint provRegister(bool boot);
static void provUnregister(); static void provUnregister();

View File

@ -90,12 +90,12 @@ BasePage {
} }
function getEntryPath(logEntry) { function getEntryPath(logEntry) {
var dosPath = logEntry.dosPath; var kernelPath = logEntry.kernelPath;
if (!dosPath) { if (!kernelPath) {
dosPath = osUtil.pidToDosPath(logEntry.pid); kernelPath = osUtil.pidToKernelPath(logEntry.pid);
} }
return fileUtil.dosPathToPath(dosPath); return fileUtil.kernelPathToPath(kernelPath);
} }
function refreshListViews() { function refreshListViews() {

View File

@ -190,8 +190,8 @@ QString ConfUtil::parseAppPath(const QStringRef &line)
if (!QStringRef::compare(path, systemPath, Qt::CaseInsensitive)) if (!QStringRef::compare(path, systemPath, Qt::CaseInsensitive))
return systemPath; return systemPath;
const QString dosPath = FileUtil::pathToDosPath(path.toString()); const QString kernelPath = FileUtil::pathToKernelPath(path.toString());
return dosPath.toLower(); return kernelPath.toLower();
} }
void ConfUtil::writeData(char *output, const FirewallConf &conf, void ConfUtil::writeData(char *output, const FirewallConf &conf,

View File

@ -43,25 +43,25 @@ QString FileUtil::driveToDosName(const QString &drive)
} }
// Convert "\\Device\\HarddiskVolume1\\path" to "C:\\path" // Convert "\\Device\\HarddiskVolume1\\path" to "C:\\path"
QString FileUtil::dosPathToPath(const QString &dosPath) QString FileUtil::kernelPathToPath(const QString &kernelPath)
{ {
const QLatin1Char sep('\\'); const QLatin1Char sep('\\');
if (dosPath.startsWith(sep)) { if (kernelPath.startsWith(sep)) {
const int sepPos1 = dosPath.indexOf(sep, 1); const int sepPos1 = kernelPath.indexOf(sep, 1);
if (sepPos1 > 0) { if (sepPos1 > 0) {
const int sepPos2 = dosPath.indexOf(sep, sepPos1 + 1); const int sepPos2 = kernelPath.indexOf(sep, sepPos1 + 1);
if (sepPos2 > 0) { if (sepPos2 > 0) {
const QString dosName = dosPath.left(sepPos2); const QString dosName = kernelPath.left(sepPos2);
return dosNameToDrive(dosName) + dosPath.mid(sepPos2); return dosNameToDrive(dosName) + kernelPath.mid(sepPos2);
} }
} }
} }
return dosPath; return kernelPath;
} }
// Convert "C:\\path" to "\\Device\\HarddiskVolume1\\path" // 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); const QString drive = path.left(2);

View File

@ -17,10 +17,10 @@ public:
static QString driveToDosName(const QString &drive); static QString driveToDosName(const QString &drive);
// Convert Native path to Win32 path // 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 // 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); static QString absolutePath(const QString &path);

View File

@ -31,10 +31,10 @@ void OsUtil::setClipboardData(const QVariant &data)
} }
} }
QString OsUtil::pidToDosPath(quint32 pid) QString OsUtil::pidToKernelPath(quint32 pid)
{ {
const ProcessInfo pi(pid); const ProcessInfo pi(pid);
return pi.dosPath(); return pi.kernelPath();
} }
bool OsUtil::createGlobalMutex(const char *name) bool OsUtil::createGlobalMutex(const char *name)

View File

@ -13,7 +13,7 @@ public:
Q_INVOKABLE static void setClipboardData(const QVariant &data); 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); static bool createGlobalMutex(const char *name);
}; };

View File

@ -46,7 +46,7 @@ void ProcessInfo::closeProcess()
} }
} }
QString ProcessInfo::dosPath() const QString ProcessInfo::kernelPath() const
{ {
if (isValid()) { if (isValid()) {
QByteArray buf(PROC_PATH_MAX * sizeof(wchar_t), Qt::Uninitialized); QByteArray buf(PROC_PATH_MAX * sizeof(wchar_t), Qt::Uninitialized);

View File

@ -30,7 +30,7 @@ public:
signals: signals:
public slots: public slots:
QString dosPath() const; QString kernelPath() const;
private: private:
void openProcess(); void openProcess();