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

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

Issue 5663180676136960: Make sure IE and Engine are actually being closed by custom action (Closed)
Left Patch Set: Created June 20, 2014, 10:33 p.m.
Right Patch Set: Use handle class for HMODULE. Add back a test for immersive case. Created June 26, 2014, 1:24 p.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/handle.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 "installer-lib.h" 7 #include "installer-lib.h"
8 #include "process.h" 8 #include "process.h"
9 #include "handle.h"
10 #include "session.h"
9 11
10 //------------------------------------------------------- 12 //-------------------------------------------------------
11 //------------------------------------------------------- 13 //-------------------------------------------------------
12 typedef int (__stdcall *IsImmersiveDynamicFunc)(HANDLE); 14 typedef int (__stdcall *IsImmersiveDynamicFunc)(HANDLE);
13 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 )
14 { 16 {
15 if (processNames.find(process.szExeFile) != processNames.end()) 17 if (processNames.find(process.szExeFile) != processNames.end())
16 { 18 {
17 // Make sure the process is still alive 19 // Make sure the process is still alive
18 HANDLE procHandle = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, process.th 32ProcessID); 20 Windows_Handle procHandle = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pr ocess.th32ProcessID);
19 if ((procHandle == NULL) || (procHandle == INVALID_HANDLE_VALUE)) return fal se; 21 if ((procHandle == NULL) || (procHandle == INVALID_HANDLE_VALUE)) return fal se;
20 22
21 DWORD exitCode; 23 DWORD exitCode;
22 if (!GetExitCodeProcess(procHandle, &exitCode)) return false; 24 if (!GetExitCodeProcess(procHandle, &exitCode)) return false;
23 25
24 if (exitCode != STILL_ACTIVE) return false; 26 if (exitCode != STILL_ACTIVE) return false;
25 27
26 // Check if this is a Windows Store app process (we don't care for IE in Mod ern UI) 28 // Check if this is a Windows Store app process (we don't care for IE in Mod ern UI)
27 HINSTANCE user32Dll = LoadLibrary(L"user32.dll"); 29 Windows_Module_Handle user32Dll(LoadLibrary(L"user32.dll"));
Eric 2014/06/25 15:08:51 What's the reason for a dynamic load of this libra
Oleksandr 2014/06/26 13:25:57 Why make assumptions? From MSDN http://msdn.micros
28 if (!user32Dll) return true; 30 if (!user32Dll) return true;
29 31
30 IsImmersiveDynamicFunc IsImmersiveDynamicCall = (IsImmersiveDynamicFunc)GetP rocAddress(user32Dll, "IsImmersiveProcess"); 32 IsImmersiveDynamicFunc IsImmersiveDynamicCall = (IsImmersiveDynamicFunc)GetP rocAddress(user32Dll, "IsImmersiveProcess");
31 if (!IsImmersiveDynamicCall) return true; 33 if (!IsImmersiveDynamicCall) return true;
32 34
33 BOOL retValue = !IsImmersiveDynamicCall(procHandle); 35 BOOL retValue = !IsImmersiveDynamicCall(procHandle);
Eric 2014/06/25 15:08:51 IsImmersiveDynamicCall commingles a false result w
Oleksandr 2014/06/26 13:25:57 I agree it wouldn't hurt to log the GetLastError h
34 CloseHandle(procHandle);
Eric 2014/06/25 15:08:51 Resource Leak. CloseHandle() won't be called under
35 36
36 return retValue; 37 return retValue;
37 } 38 }
38 } 39 }
39 40
40 //------------------------------------------------------- 41 //-------------------------------------------------------
41 // creator_process 42 // creator_process
42 //------------------------------------------------------- 43 //-------------------------------------------------------
43 DWORD creator_process( HWND window ) 44 DWORD creator_process( HWND window )
44 { 45 {
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 if ( ! is_running() ) 300 if ( ! is_running() )
300 { 301 {
301 return true ; 302 return true ;
302 } 303 }
303 } 304 }
304 // Assert is_running() 305 // Assert is_running()
305 } 306 }
306 // No control path leaves the for-loop. 307 // No control path leaves the for-loop.
307 } ; 308 } ;
308 309
LEFTRIGHT

Powered by Google App Engine
This is Rietveld