summaryrefslogtreecommitdiff
path: root/src/envmodule.h
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2019-10-29 10:03:59 -0400
committerisanae <14251494+isanae@users.noreply.github.com>2019-11-06 07:44:54 -0500
commit8c72077febaea485200adcf1e9f615902e930def (patch)
tree13fe30db88d40d1554343b40cb33e9dcf846db7d /src/envmodule.h
parent18b438cf27a552e69e984bfee63187b6471682ab (diff)
replaced uilock by a progress callback in spawn
waiting for process now gets the whole process tree to find an interesting process
Diffstat (limited to 'src/envmodule.h')
-rw-r--r--src/envmodule.h35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/envmodule.h b/src/envmodule.h
index 6c0a028d..d152b840 100644
--- a/src/envmodule.h
+++ b/src/envmodule.h
@@ -7,6 +7,23 @@
namespace env
{
+// used by HandlePtr, calls CloseHandle() as the deleter
+//
+struct HandleCloser
+{
+ using pointer = HANDLE;
+
+ void operator()(HANDLE h)
+ {
+ if (h != INVALID_HANDLE_VALUE) {
+ ::CloseHandle(h);
+ }
+ }
+};
+
+using HandlePtr = std::unique_ptr<HANDLE, HandleCloser>;
+
+
// represents one module
//
class Module
@@ -101,25 +118,39 @@ private:
class Process
{
public:
- Process(DWORD pid, QString name);
+ Process();
+ explicit Process(HANDLE h);
+ Process(DWORD pid, DWORD ppid, QString name);
+ bool isValid() const;
DWORD pid() const;
+ DWORD ppid() const;
const QString& name() const;
+ HandlePtr openHandleForWait() const;
+
// whether this process can be accessed; fails if the current process doesn't
// have the proper permissions
//
bool canAccess() const;
+ void addChild(Process p);
+ std::vector<Process>& children();
+
private:
DWORD m_pid;
- QString m_name;
+ mutable std::optional<DWORD> m_ppid;
+ mutable std::optional<QString> m_name;
+ std::vector<Process> m_children;
};
std::vector<Process> getRunningProcesses();
std::vector<Module> getLoadedModules();
+Process getProcessTree(HANDLE parent);
+
+QString getProcessName(DWORD pid);
QString getProcessName(HANDLE process);
DWORD getProcessParentID(DWORD pid);