summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2012-01-22 22:23:49 +0100
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2012-01-22 22:26:01 +0100
commit250a73317f6933ab72e1557d479ee3f09412d135 (patch)
tree51e7095bd8b564454e5fa97c716141303212436d
parent8a3af263641dfa6e6bd8f9dfe06654c4e27b094e (diff)
downloadrockbox-250a73317f6933ab72e1557d479ee3f09412d135.tar.gz
rockbox-250a73317f6933ab72e1557d479ee3f09412d135.zip
Check running processes at startup.
Retrieve the processes running at startup and compare with a list of potentially problematic ones. Right now this is Itunes which is known to be able to cause problems when trying to install the bootloader on an Ipod. No user notification yet. This adds the implementation for Windows. Change-Id: I5ce8a85da52e0ed8f523b5ae6fb5d8f14f6a14c9
-rw-r--r--rbutil/rbutilqt/base/utils.cpp56
-rw-r--r--rbutil/rbutilqt/base/utils.h1
-rw-r--r--rbutil/rbutilqt/rbutilqt.cpp1
3 files changed, 58 insertions, 0 deletions
diff --git a/rbutil/rbutilqt/base/utils.cpp b/rbutil/rbutilqt/base/utils.cpp
index f91f3c25c2..7df5d28da9 100644
--- a/rbutil/rbutilqt/base/utils.cpp
+++ b/rbutil/rbutilqt/base/utils.cpp
@@ -51,6 +51,7 @@
51#include <windows.h> 51#include <windows.h>
52#include <setupapi.h> 52#include <setupapi.h>
53#include <winioctl.h> 53#include <winioctl.h>
54#include <tlhelp32.h>
54#endif 55#endif
55#if defined(Q_OS_MACX) 56#if defined(Q_OS_MACX)
56#include <CoreFoundation/CoreFoundation.h> 57#include <CoreFoundation/CoreFoundation.h>
@@ -606,3 +607,58 @@ QStringList Utils::mountpoints()
606} 607}
607 608
608 609
610/** Check if a process with a given name is running
611 * @param names list of names to check
612 * @return list of detected processes.
613 */
614QStringList Utils::findRunningProcess(QStringList names)
615{
616 QStringList processlist;
617 QStringList found;
618#if defined(Q_OS_WIN32)
619 HANDLE hdl;
620 PROCESSENTRY32 entry;
621 bool result;
622
623 hdl = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
624 if(hdl == INVALID_HANDLE_VALUE) {
625 qDebug() << "[Utils] CreateToolhelp32Snapshot failed.";
626 return found;
627 }
628 entry.dwSize = sizeof(PROCESSENTRY32);
629 entry.szExeFile[0] = '\0';
630 if(!Process32First(hdl, &entry)) {
631 qDebug() << "[Utils] Process32First failed.";
632 return found;
633 }
634
635 processlist.append(QString::fromWCharArray(entry.szExeFile));
636 do {
637 entry.dwSize = sizeof(PROCESSENTRY32);
638 entry.szExeFile[0] = '\0';
639 result = Process32Next(hdl, &entry);
640 if(result) {
641 processlist.append(QString::fromWCharArray(entry.szExeFile));
642 }
643 } while(result);
644 CloseHandle(hdl);
645 qDebug() << processlist;
646#endif
647#if defined(Q_OS_MACX)
648
649#endif
650 // check for given names in list of processes
651 for(int i = 0; i < names.size(); ++i) {
652#if defined(Q_OS_WIN32)
653 // the process name might be truncated. Allow the extension to be partial.
654 int index = processlist.indexOf(QRegExp(names.at(i) + "(\\.(e(x(e?)?)?)?)?"));
655#else
656 int index = processlist.indexOf(names.at(i));
657#endif
658 if(index != -1) {
659 found.append(processlist.at(index));
660 }
661 }
662 qDebug() << "[Utils] Found listed processes running:" << found;
663 return found;
664}
diff --git a/rbutil/rbutilqt/base/utils.h b/rbutil/rbutilqt/base/utils.h
index aeff1e36c3..185c0323a6 100644
--- a/rbutil/rbutilqt/base/utils.h
+++ b/rbutil/rbutilqt/base/utils.h
@@ -49,6 +49,7 @@ public:
49 static QStringList mountpoints(void); 49 static QStringList mountpoints(void);
50 static QString resolveDevicename(QString path); 50 static QString resolveDevicename(QString path);
51 static QString resolveMountPoint(QString device); 51 static QString resolveMountPoint(QString device);
52 static QStringList findRunningProcess(QStringList names);
52}; 53};
53 54
54#endif 55#endif
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp
index 958550e880..cb991a21b7 100644
--- a/rbutil/rbutilqt/rbutilqt.cpp
+++ b/rbutil/rbutilqt/rbutilqt.cpp
@@ -170,6 +170,7 @@ RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
170#else 170#else
171 connect(ui.actionInstall_Rockbox_Utility_on_player, SIGNAL(triggered()), this, SLOT(installPortable())); 171 connect(ui.actionInstall_Rockbox_Utility_on_player, SIGNAL(triggered()), this, SLOT(installPortable()));
172#endif 172#endif
173 Utils::findRunningProcess(QStringList("iTunes"));
173 174
174} 175}
175 176