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

Delta Between Two Patch Sets: installer/src/installer-lib/process.cpp

Issue 6003395731128320: Only take into account processes that have our plugin loaded (Closed)
Left Patch Set: Addressing comments Created March 28, 2014, 12:45 p.m.
Right Patch Set: Simplify Process_Closer constructor Created March 31, 2014, 8:31 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « installer/src/installer-lib/process.h ('k') | installer/src/installer-lib/test/process_test.cpp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 #include <stdexcept> 1 #include <stdexcept>
2 #include <functional> 2 #include <functional>
3 #include <wctype.h> 3 #include <wctype.h>
4 // <thread> is C++11, but implemented in VS2012 4 // <thread> is C++11, but implemented in VS2012
5 #include <thread> 5 #include <thread>
6 6
7 #include "process.h" 7 #include "process.h"
8 8
9 //------------------------------------------------------- 9 //-------------------------------------------------------
10 // Windows_Handle 10 // Windows_Handle
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 54
55 bool process_by_any_exe_with_any_module::operator()( const PROCESSENTRY32W & pro cess ) 55 bool process_by_any_exe_with_any_module::operator()( const PROCESSENTRY32W & pro cess )
56 { 56 {
57 if (processNames.find(process.szExeFile) != processNames.end()) 57 if (processNames.find(process.szExeFile) != processNames.end())
58 { 58 {
59 if (moduleNames.empty()) 59 if (moduleNames.empty())
60 return true; 60 return true;
61 61
62 ModulesSnapshot ms(process.th32ProcessID); 62 ModulesSnapshot ms(process.th32ProcessID);
63 ModulesSnapshot::Pointer me = ms.begin(); 63 MODULEENTRY32W* me = ms.first();
64 while (me != ms.end()) 64 while (me != NULL)
65 { 65 {
66 if (moduleNames.find(me->szModule) != moduleNames.end()) 66 if (moduleNames.find(me->szModule) != moduleNames.end())
67 { 67 {
68 return true; 68 return true;
69 } 69 }
70 me = ms.next(); 70 me = ms.next();
71 } 71 }
72 } 72 }
73 return false; 73 return false;
74 } 74 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 156
157 //------------------------------------------------------- 157 //-------------------------------------------------------
158 // Snapshot 158 // Snapshot
159 //------------------------------------------------------- 159 //-------------------------------------------------------
160 Snapshot::Snapshot() 160 Snapshot::Snapshot()
161 : handle( ::CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ) ) 161 : handle( ::CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ) )
162 { 162 {
163 process.dwSize = sizeof( PROCESSENTRY32W ) ; 163 process.dwSize = sizeof( PROCESSENTRY32W ) ;
164 } 164 }
165 165
166 PROCESSENTRY32W * Snapshot::begin() 166 PROCESSENTRY32W * Snapshot::first()
167 { 167 {
168 return ::Process32FirstW( handle, & process ) ? ( & process ) : 0 ; 168 return ::Process32FirstW(handle, &process) ? (&process) : 0;
169 } 169 }
170 170
171 PROCESSENTRY32W * Snapshot::next() 171 PROCESSENTRY32W * Snapshot::next()
172 { 172 {
173 return ::Process32NextW( handle, & process ) ? ( & process ) : 0 ; 173 return ::Process32NextW(handle, &process) ? (&process) : 0;
174 } 174 }
175 175
176 void Snapshot::refresh() 176 void Snapshot::refresh()
177 { 177 {
178 handle = ::CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ) ; 178 handle = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
179 } 179 }
180 180
181 181
182 //------------------------------------------------------- 182 //-------------------------------------------------------
183 // ModulesSnapshot 183 // ModulesSnapshot
184 //------------------------------------------------------- 184 //-------------------------------------------------------
185 ModulesSnapshot::ModulesSnapshot(DWORD processId) 185 ModulesSnapshot::ModulesSnapshot(DWORD processId)
186 : handle(::CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, p rocessId)) 186 : handle(::CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, p rocessId))
187 { 187 {
188 module.dwSize = sizeof(MODULEENTRY32); 188 module.dwSize = sizeof(MODULEENTRY32);
189 } 189 }
190 190
191 MODULEENTRY32W * ModulesSnapshot::begin() 191 MODULEENTRY32W * ModulesSnapshot::first()
192 { 192 {
193 return ::Module32FirstW(handle, &module) ? (&module) : 0; 193 return ::Module32FirstW(handle, &module) ? (&module) : 0;
194 } 194 }
195 195
196 MODULEENTRY32W * ModulesSnapshot::next() 196 MODULEENTRY32W * ModulesSnapshot::next()
197 { 197 {
198 return ::Module32NextW(handle, &module) ? (&module) : 0; 198 return ::Module32NextW(handle, &module) ? (&module) : 0;
199 } 199 }
200 200
201 201
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 if ( ! is_running() ) 445 if ( ! is_running() )
446 { 446 {
447 return true ; 447 return true ;
448 } 448 }
449 } 449 }
450 // Assert is_running() 450 // Assert is_running()
451 } 451 }
452 // No control path leaves the for-loop. 452 // No control path leaves the for-loop.
453 } ; 453 } ;
454 454
LEFTRIGHT

Powered by Google App Engine
This is Rietveld