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

Side by Side Diff: installer/src/installer-lib/process.cpp

Issue 4642970720534528: Issue #1147 (Closed)
Patch Set: Created July 31, 2014, 3:32 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "installer-lib.h" 7 #include "installer-lib.h"
8 #include "process.h" 8 #include "process.h"
9 #include "handle.h" 9 #include "handle.h"
10 #include "session.h" 10 #include "session.h"
11 11
12 //------------------------------------------------------- 12 //-------------------------------------------------------
13 //------------------------------------------------------- 13 //-------------------------------------------------------
14 typedef int (__stdcall *IsImmersiveDynamicFunc)(HANDLE); 14 typedef int (__stdcall *IsImmersiveDynamicFunc)(HANDLE);
15 bool process_by_any_exe_not_immersive::operator()( const PROCESSENTRY32W & proce ss ) 15 bool process_by_any_exe_not_immersive::operator()( const PROCESSENTRY32W & proce ss )
16 { 16 {
17 if (processNames.find(process.szExeFile) != processNames.end()) 17 if (processNames.find(process.szExeFile) != processNames.end())
18 { 18 {
19 // Make sure the process is still alive 19 // Make sure the process is still alive
20 Windows_Handle procHandle = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pr ocess.th32ProcessID); 20 HANDLE h = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, process.th32Process ID);
21 if ((procHandle == NULL) || (procHandle == INVALID_HANDLE_VALUE)) return fal se; 21 // OpenProcess does not return INVALID_HANDLE VALUE, so a simple check is f ine.
Eric 2014/07/31 15:37:08 You can kill this comment in your own patch set.
22 if (!h) return false;
Eric 2014/07/31 15:44:24 OOPS! This should be 'return true'. If the process
23 Windows_Handle procHandle(h);
22 24
23 DWORD exitCode; 25 DWORD exitCode;
24 if (!GetExitCodeProcess(procHandle, &exitCode)) return false; 26 if (!GetExitCodeProcess(procHandle, &exitCode)) return false;
25 27
26 if (exitCode != STILL_ACTIVE) return false; 28 if (exitCode != STILL_ACTIVE) return false;
27 29
28 // Check if this is a Windows Store app process (we don't care for IE in Mod ern UI) 30 // Check if this is a Windows Store app process (we don't care for IE in Mod ern UI)
29 Windows_Module_Handle user32Dll(LoadLibrary(L"user32.dll")); 31 HMODULE m = LoadLibrary(L"user32.dll");
30 if (!user32Dll) return true; 32 if (!m) return true;
33 Windows_Module_Handle user32Dll(m);
31 34
32 IsImmersiveDynamicFunc IsImmersiveDynamicCall = (IsImmersiveDynamicFunc)GetP rocAddress(user32Dll, "IsImmersiveProcess"); 35 IsImmersiveDynamicFunc IsImmersiveDynamicCall = (IsImmersiveDynamicFunc)GetP rocAddress(user32Dll, "IsImmersiveProcess");
33 if (!IsImmersiveDynamicCall) return true; 36 if (!IsImmersiveDynamicCall) return true;
34 37
35 BOOL retValue = !IsImmersiveDynamicCall(procHandle); 38 BOOL retValue = !IsImmersiveDynamicCall(procHandle);
36 39
37 return retValue; 40 return retValue;
38 } 41 }
39 return false; 42 return false;
40 } 43 }
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 if ( ! is_running() ) 304 if ( ! is_running() )
302 { 305 {
303 return true ; 306 return true ;
304 } 307 }
305 } 308 }
306 // Assert is_running() 309 // Assert is_running()
307 } 310 }
308 // No control path leaves the for-loop. 311 // No control path leaves the for-loop.
309 } ; 312 } ;
310 313
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld