OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // NOTE: This code is a legacy utility API for partners to check whether | 5 // NOTE: This code is a legacy utility API for partners to check whether |
6 // Chrome can be installed and launched. Recent updates are being made | 6 // Chrome can be installed and launched. Recent updates are being made |
7 // to add new functionality. These updates use code from Chromium, the old | 7 // to add new functionality. These updates use code from Chromium, the old |
8 // coded against the win32 api directly. If you have an itch to shave a | 8 // coded against the win32 api directly. If you have an itch to shave a |
9 // yak, feel free to re-write the old code too. | 9 // yak, feel free to re-write the old code too. |
10 | 10 |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 wchar_t* exp_proc_sid; | 471 wchar_t* exp_proc_sid; |
472 if (GetUserIdForProcess(pid, &exp_proc_sid)) { | 472 if (GetUserIdForProcess(pid, &exp_proc_sid)) { |
473 if (_wcsicmp(curr_proc_sid, exp_proc_sid) == 0) { | 473 if (_wcsicmp(curr_proc_sid, exp_proc_sid) == 0) { |
474 ScopedHandle process_handle( | 474 ScopedHandle process_handle( |
475 ::OpenProcess(PROCESS_DUP_HANDLE | PROCESS_QUERY_INFORMATION, | 475 ::OpenProcess(PROCESS_DUP_HANDLE | PROCESS_QUERY_INFORMATION, |
476 TRUE, | 476 TRUE, |
477 pid)); | 477 pid)); |
478 if (process_handle.IsValid()) { | 478 if (process_handle.IsValid()) { |
479 HANDLE process_token = NULL; | 479 HANDLE process_token = NULL; |
480 HANDLE user_token = NULL; | 480 HANDLE user_token = NULL; |
481 if (::OpenProcessToken(process_handle, TOKEN_DUPLICATE | TOKEN_QUERY, | 481 if (::OpenProcessToken(process_handle.Get(), |
| 482 TOKEN_DUPLICATE | TOKEN_QUERY, |
482 &process_token) && | 483 &process_token) && |
483 ::DuplicateTokenEx(process_token, | 484 ::DuplicateTokenEx(process_token, |
484 TOKEN_IMPERSONATE | TOKEN_QUERY | | 485 TOKEN_IMPERSONATE | TOKEN_QUERY | |
485 TOKEN_ASSIGN_PRIMARY | TOKEN_DUPLICATE, | 486 TOKEN_ASSIGN_PRIMARY | TOKEN_DUPLICATE, |
486 NULL, SecurityImpersonation, | 487 NULL, SecurityImpersonation, |
487 TokenPrimary, &user_token) && | 488 TokenPrimary, &user_token) && |
488 (::ImpersonateLoggedOnUser(user_token) != 0)) { | 489 (::ImpersonateLoggedOnUser(user_token) != 0)) { |
489 impersonation_success = true; | 490 impersonation_success = true; |
490 } | 491 } |
491 if (user_token) | 492 if (user_token) |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 key.WriteValue(kRelaunchAllowedAfterValue, | 790 key.WriteValue(kRelaunchAllowedAfterValue, |
790 FormatDateOffsetByMonths(6)) != ERROR_SUCCESS || | 791 FormatDateOffsetByMonths(6)) != ERROR_SUCCESS || |
791 !SetRelaunchExperimentLabels(relaunch_brandcode, shell_mode)) { | 792 !SetRelaunchExperimentLabels(relaunch_brandcode, shell_mode)) { |
792 if (error_code) | 793 if (error_code) |
793 *error_code = RELAUNCH_ERROR_RELAUNCH_FAILED; | 794 *error_code = RELAUNCH_ERROR_RELAUNCH_FAILED; |
794 return FALSE; | 795 return FALSE; |
795 } | 796 } |
796 | 797 |
797 return TRUE; | 798 return TRUE; |
798 } | 799 } |
OLD | NEW |