Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: installer/src/installer-lib/process.h

Issue 6003395731128320: Only take into account processes that have our plugin loaded (Closed)
Patch Set: Created March 27, 2014, 3:29 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: installer/src/installer-lib/process.h
===================================================================
--- a/installer/src/installer-lib/process.h
+++ b/installer/src/installer-lib/process.h
@@ -2,8 +2,8 @@
* \file process.h
*/
-#ifndef PROCESS_H
-#define PROCESS_H
+#ifndef PROCESS_H
+#define PROCESS_H
#include <vector>
#include <set>
@@ -133,6 +133,24 @@
} ;
//-------------------------------------------------------
+//-------------------------------------------------------
+/**
+ * Filter by process name. Comparison is case-insensitive. With ABP module loaded
+ */
+class process_by_any_exe_name_CI_w_ABP
Eric 2014/03/27 16:52:44 This is not ABP-specific until after we pass it AB
+ : public std::binary_function< PROCESSENTRY32W, exe_name_set, bool >
+{
+ const exe_name_set & names ;
Eric 2014/03/27 16:52:44 This should be renamed to process_names (or the li
+ const exe_name_set & moduleNames;
+public:
+ bool operator()( const PROCESSENTRY32W & ) ;
+ process_by_any_exe_name_CI_w_ABP( const exe_name_set & names, const exe_name_set & moduleNames )
+ : names( names ), moduleNames( moduleNames )
+ {}
+} ;
+
+
+//-------------------------------------------------------
// Process utility functions.
//-------------------------------------------------------
/**
@@ -283,6 +301,74 @@
typedef PROCESSENTRY32W * Pointer ;
} ;
Eric 2014/03/27 16:52:44 We need some documentation here about CreateToolhe
+class ModulesSnapshot
+{
+ /**
+ * Handle to the process snapshot.
+ */
+ Windows_Handle handle ;
+
+ /**
+ * Buffer for reading a single module entry out of the snapshot.
+ */
+ MODULEENTRY32W module;
+
+ /**
+ * process ID of the process to retrieve modules for.
+ */
+ DWORD processId;
Eric 2014/03/27 16:52:44 Only needed for refresh(), which we don't need.
+
+ /**
+ * Copy constructor declared private and not defined.
+ *
+ * \par Implementation
+ * Add "= delete" for C++11.
+ */
+ ModulesSnapshot( const ModulesSnapshot & ) ;
+
+ /**
+ * Copy assignment declared private and not defined.
+ *
+ * \par Implementation
+ * Add "= delete" for C++11.
+ */
+ ModulesSnapshot operator=( const ModulesSnapshot & ) ;
+
+
+public:
+ /**
+ * Default constructor takes the snapshot.
+ */
+ ModulesSnapshot(DWORD processId) ;
+
+ /**
+ * Reconstruct the current instance with a new system snapshot.
+ */
+ void refresh(DWORD processId) ;
Eric 2014/03/27 16:52:44 The way this is being used, I don't believe we nee
+
+ /**
+ * Return a pointer to the first process in the snapshot.
+ */
+ MODULEENTRY32W * begin() ;
+
+ /**
+ * The end pointer is an alias for the null pointer.
+ */
+ inline MODULEENTRY32W * end() const { return 0 ; }
+
+ /**
+ * Return a pointer to the next process in the snapshot.
+ * begin() must have been called first.
+ */
+ MODULEENTRY32W * next() ;
+
+ /**
+ * Type definition for pointer to underlying structure.
+ */
+ typedef MODULEENTRY32W * Pointer ;
+} ;
+
+
//-------------------------------------------------------
// initialize_process_list
//-------------------------------------------------------
@@ -466,11 +552,14 @@
* Since it does not make a copy for itself, we define it as a class member to provide its allocation.
*/
exe_name_set exe_names ;
+ exe_name_set module_names ;
Eric 2014/03/27 16:52:44 I'd use dll_names. We configure these with .EXE an
Oleksandr 2014/03/27 23:28:46 I actually think module_names is more consistent,
/**
* Filter function object matches on any of the exe names specified in the constructor.
*/
- process_by_any_exe_name_CI filter ;
+// process_by_any_exe_name_CI filter ;
+
+ process_by_any_exe_name_CI_w_ABP filter ;
/**
* Copy function object copies just the process ID.
@@ -521,8 +610,8 @@
} ;
public:
- Process_Closer( Snapshot & snapshot, const wchar_t * exe_name_list[], size_t n_exe_names )
- : snapshot( snapshot ), exe_names( exe_name_list, n_exe_names ), filter( exe_names )
+ Process_Closer( Snapshot & snapshot, const wchar_t * exe_name_list[], size_t n_exe_names, const wchar_t * module_name_list[], size_t n_module_names )
Eric 2014/03/27 16:52:44 Likewise dll_name_list etc. here.
+ : snapshot( snapshot ), exe_names( exe_name_list, n_exe_names ), module_names(module_name_list, n_module_names), filter( exe_names, module_names )
{
update() ;
}

Powered by Google App Engine
This is Rietveld