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 |
//------------------------------------------------------- |
/** |