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

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

Issue 5643369099296768: Issue 1147 - Fix installation when IE is opened (Closed)
Patch Set: Created Aug. 8, 2014, 9:01 a.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 tmpHandle = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, process.th3 2ProcessID);
21 if (tmpHandle == NULL)
22 return false;
23
24 Windows_Handle procHandle(tmpHandle);
21 if ((procHandle == NULL) || (procHandle == INVALID_HANDLE_VALUE)) return fal se; 25 if ((procHandle == NULL) || (procHandle == INVALID_HANDLE_VALUE)) return fal se;
Eric 2014/08/08 14:14:58 This line is redundant. The previous check on tmpH
sergei 2014/08/08 15:17:36 - There is no reason to have tmpHandle. - As Eric
Eric 2014/08/08 15:34:19 No. See below.
22 26
23 DWORD exitCode; 27 DWORD exitCode;
24 if (!GetExitCodeProcess(procHandle, &exitCode)) return false; 28 if (!GetExitCodeProcess(procHandle, &exitCode)) return false;
25 29
26 if (exitCode != STILL_ACTIVE) return false; 30 if (exitCode != STILL_ACTIVE) return false;
27 31
28 // Check if this is a Windows Store app process (we don't care for IE in Mod ern UI) 32 // 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")); 33 HMODULE tmpModule = LoadLibrary(L"user32.dll");
34 if (tmpModule == NULL)
35 return true;
36 Windows_Module_Handle user32Dll(tmpModule);
sergei 2014/08/08 15:17:36 Similar here. The problem was in the missed valida
Eric 2014/08/08 15:34:19 It would help to understand the class in question
sergei 2014/08/08 15:45:25 But why? No one standard smart pointer or wrapper
30 if (!user32Dll) return true; 37 if (!user32Dll) return true;
31 38
32 IsImmersiveDynamicFunc IsImmersiveDynamicCall = (IsImmersiveDynamicFunc)GetP rocAddress(user32Dll, "IsImmersiveProcess"); 39 IsImmersiveDynamicFunc IsImmersiveDynamicCall = (IsImmersiveDynamicFunc)GetP rocAddress(user32Dll, "IsImmersiveProcess");
33 if (!IsImmersiveDynamicCall) return true; 40 if (!IsImmersiveDynamicCall) return true;
34 41
35 BOOL retValue = !IsImmersiveDynamicCall(procHandle); 42 BOOL retValue = !IsImmersiveDynamicCall(procHandle);
36 43
37 return retValue; 44 return retValue;
38 } 45 }
39 return false; 46 return false;
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 if ( ! is_running() ) 308 if ( ! is_running() )
302 { 309 {
303 return true ; 310 return true ;
304 } 311 }
305 } 312 }
306 // Assert is_running() 313 // Assert is_running()
307 } 314 }
308 // No control path leaves the for-loop. 315 // No control path leaves the for-loop.
309 } ; 316 } ;
310 317
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