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

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

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.cpp
===================================================================
--- a/installer/src/installer-lib/process.cpp
+++ b/installer/src/installer-lib/process.cpp
@@ -31,7 +31,9 @@
{
if ( handle == INVALID_HANDLE_VALUE )
{
- throw std::runtime_error( "Invalid handle" ) ;
+ char tmp[256];
+ sprintf(tmp, "Invalid handle. Last error: %d", GetLastError());
Eric 2014/03/27 16:52:44 Using sprintf() seems safe here, but it's such a b
+ throw std::runtime_error( tmp ) ;
}
}
@@ -56,6 +58,33 @@
}
//-------------------------------------------------------
+// process_by_any_exe_name_CI_w_ABP
+//-------------------------------------------------------
+bool process_by_any_exe_name_CI_w_ABP::operator()( const PROCESSENTRY32W & process )
+{
+ bool moduleFound = false;
Eric 2014/03/27 16:52:44 We can eliminate 'moduleFound'
+ if ( names.find( process.szExeFile ) != names.end() )
+ {
+ if (moduleNames.empty())
+ return true;
Eric 2014/03/27 16:52:44 We should document that if no module names are pre
+
+ ModulesSnapshot ms( process.th32ProcessID );
+return true;
Eric 2014/03/27 16:52:44 Stub return for testing something, I assume?
+ MODULEENTRY32* me = ms.begin();
+ while ( me != ms.end() )
+ {
+ if (moduleNames.find( me->szModule ) != moduleNames.end())
+ {
+ moduleFound = true;
Eric 2014/03/27 16:52:44 return true
+ break;
+ }
+ me = ms.next();
+ }
+ }
+ return moduleFound;
Eric 2014/03/27 16:52:44 return false
+}
+
+//-------------------------------------------------------
// wcscmpi
//-------------------------------------------------------
int wcscmpi( const wchar_t * s1, const wchar_t * s2 )
@@ -162,6 +191,31 @@
//-------------------------------------------------------
+// ModulesSnapshot
+//-------------------------------------------------------
+ModulesSnapshot::ModulesSnapshot(DWORD processId)
+ : handle( ::CreateToolhelp32Snapshot( TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, processId ) )
+{
+ module.dwSize = sizeof( MODULEENTRY32 ) ;
+}
+
+MODULEENTRY32W * ModulesSnapshot::begin()
+{
+ return ::Module32FirstW( handle, & module ) ? ( & module ) : 0 ;
+}
+
+MODULEENTRY32W * ModulesSnapshot::next()
+{
+ return ::Module32NextW( handle, & module ) ? ( & module ) : 0 ;
+}
+
+void ModulesSnapshot::refresh(DWORD processId)
Eric 2014/03/27 16:52:44 refresh() not needed.
+{
+ handle = ::CreateToolhelp32Snapshot( TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, processId ) ;
Eric 2014/03/27 16:52:44 Not that it matters, but processID isn't initializ
+}
+
+
+//-------------------------------------------------------
// send_message, send_endsession_messages
//-------------------------------------------------------
/**

Powered by Google App Engine
This is Rietveld