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

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

Issue 5195376613130240: Issue #1762 - Remove smart handle for HMODULE (Closed)
Patch Set: Created Jan. 7, 2015, 7:38 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 | « installer/src/installer-lib/handle.h ('k') | 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 the name is not found in our list, it's filtered out
18 { 18 if (processNames.find(process.szExeFile) == processNames.end()) return false;
19 // Make sure the process is still alive
20 HANDLE tmpHandle = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, process.th3 2ProcessID);
21 if (tmpHandle == NULL)
22 return false;
23 Windows_Handle procHandle(tmpHandle);
24 19
25 DWORD exitCode; 20 // Make sure the process is still alive
26 if (!GetExitCodeProcess(procHandle, &exitCode)) return false; 21 HANDLE tmpHandle = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, process.th32P rocessID);
22 if (tmpHandle == NULL) return false;
23 Windows_Handle procHandle(tmpHandle);
24 DWORD exitCode;
25 if (!GetExitCodeProcess(procHandle, &exitCode)) return false;
26 if (exitCode != STILL_ACTIVE) return false;
27 27
28 if (exitCode != STILL_ACTIVE) return false; 28 // Check if this is a Windows Store app process (we don't care for IE in Moder n UI)
29 29 HMODULE user32Dll = LoadLibrary(L"user32.dll");
30 // Check if this is a Windows Store app process (we don't care for IE in Mod ern UI) 30 if (!user32Dll) return true;
31 HMODULE tmpModule = LoadLibrary(L"user32.dll"); 31 IsImmersiveDynamicFunc IsImmersiveDynamicCall = (IsImmersiveDynamicFunc)GetPro cAddress(user32Dll, "IsImmersiveProcess");
32 if (tmpModule == NULL) 32 if (!IsImmersiveDynamicCall) return true;
33 return true; 33 return !IsImmersiveDynamicCall(procHandle);
34 Windows_Module_Handle user32Dll(tmpModule);
35 if (!user32Dll) return true;
36
37 IsImmersiveDynamicFunc IsImmersiveDynamicCall = (IsImmersiveDynamicFunc)GetP rocAddress(user32Dll, "IsImmersiveProcess");
38 if (!IsImmersiveDynamicCall) return true;
39
40 BOOL retValue = !IsImmersiveDynamicCall(procHandle);
41
42 return retValue;
43 }
44 return false;
45 } 34 }
46 35
47 //------------------------------------------------------- 36 //-------------------------------------------------------
48 // creator_process 37 // creator_process
49 //------------------------------------------------------- 38 //-------------------------------------------------------
50 DWORD creator_process( HWND window ) 39 DWORD creator_process( HWND window )
51 { 40 {
52 DWORD pid ; 41 DWORD pid ;
53 DWORD r = GetWindowThreadProcessId( window, & pid ) ; 42 DWORD r = GetWindowThreadProcessId( window, & pid ) ;
54 if ( r == 0 ) 43 if ( r == 0 )
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 if ( ! is_running() ) 295 if ( ! is_running() )
307 { 296 {
308 return true ; 297 return true ;
309 } 298 }
310 } 299 }
311 // Assert is_running() 300 // Assert is_running()
312 } 301 }
313 // No control path leaves the for-loop. 302 // No control path leaves the for-loop.
314 } ; 303 } ;
315 304
OLDNEW
« no previous file with comments | « installer/src/installer-lib/handle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld