Fixes
- Win32: If bindconfig.exe is not present, WinPcapPort::hasExclusiveControl() returns false instead of true (we assume we don't have exclusive control) - Win32: WinPcapPort now looks for bindconfig.exe in the app's dirPath() instead of the current directory
This commit is contained in:
parent
cbf114c29d
commit
602be86a42
@ -1,5 +1,6 @@
|
||||
#include "winpcapport.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QProcess>
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
@ -58,11 +59,16 @@ OstProto::LinkState WinPcapPort::linkState()
|
||||
bool WinPcapPort::hasExclusiveControl()
|
||||
{
|
||||
QString portName(adapter_->Name + strlen("\\Device\\NPF_"));
|
||||
QString bindConfigFilePath(QCoreApplication::applicationDirPath()
|
||||
+ "/bindconfig.exe");
|
||||
int exitCode;
|
||||
|
||||
qDebug("%s: %s", __FUNCTION__, portName.toAscii().constData());
|
||||
|
||||
exitCode = QProcess::execute("bindconfig.exe",
|
||||
if (!QFile::exists(bindConfigFilePath))
|
||||
return false;
|
||||
|
||||
exitCode = QProcess::execute(bindConfigFilePath,
|
||||
QStringList() << "comp" << portName);
|
||||
|
||||
qDebug("%s: exit code %d", __FUNCTION__, exitCode);
|
||||
@ -76,13 +82,18 @@ bool WinPcapPort::hasExclusiveControl()
|
||||
bool WinPcapPort::setExclusiveControl(bool exclusive)
|
||||
{
|
||||
QString portName(adapter_->Name + strlen("\\Device\\NPF_"));
|
||||
QString bindConfigFilePath(QCoreApplication::applicationDirPath()
|
||||
+ "/bindconfig.exe");
|
||||
QString status;
|
||||
|
||||
qDebug("%s: %s", __FUNCTION__, portName.toAscii().constData());
|
||||
|
||||
if (!QFile::exists(bindConfigFilePath))
|
||||
return false;
|
||||
|
||||
status = exclusive ? "disable" : "enable";
|
||||
|
||||
QProcess::execute("bindconfig.exe",
|
||||
QProcess::execute(bindConfigFilePath,
|
||||
QStringList() << "comp" << portName << status);
|
||||
|
||||
updateNotes();
|
||||
|
Loading…
Reference in New Issue
Block a user