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 #include "base/process/process_info.h" | 5 #include "base/process/process_info.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include <memory> |
| 10 |
10 #include "base/time/time.h" | 11 #include "base/time/time.h" |
11 #include "base/win/scoped_handle.h" | 12 #include "base/win/scoped_handle.h" |
12 #include "base/win/windows_version.h" | 13 #include "base/win/windows_version.h" |
13 | 14 |
14 namespace base { | 15 namespace base { |
15 | 16 |
16 // static | 17 // static |
17 const Time CurrentProcessInfo::CreationTime() { | 18 const Time CurrentProcessInfo::CreationTime() { |
18 FILETIME creation_time = {}; | 19 FILETIME creation_time = {}; |
19 FILETIME ignore1 = {}; | 20 FILETIME ignore1 = {}; |
(...skipping 17 matching lines...) Expand all Loading... |
37 } | 38 } |
38 win::ScopedHandle scoped_process_token(process_token); | 39 win::ScopedHandle scoped_process_token(process_token); |
39 | 40 |
40 DWORD token_info_length = 0; | 41 DWORD token_info_length = 0; |
41 if (::GetTokenInformation(process_token, TokenIntegrityLevel, nullptr, 0, | 42 if (::GetTokenInformation(process_token, TokenIntegrityLevel, nullptr, 0, |
42 &token_info_length) || | 43 &token_info_length) || |
43 ::GetLastError() != ERROR_INSUFFICIENT_BUFFER) { | 44 ::GetLastError() != ERROR_INSUFFICIENT_BUFFER) { |
44 return INTEGRITY_UNKNOWN; | 45 return INTEGRITY_UNKNOWN; |
45 } | 46 } |
46 | 47 |
47 scoped_ptr<char[]> token_label_bytes(new char[token_info_length]); | 48 std::unique_ptr<char[]> token_label_bytes(new char[token_info_length]); |
48 if (!token_label_bytes.get()) | 49 if (!token_label_bytes.get()) |
49 return INTEGRITY_UNKNOWN; | 50 return INTEGRITY_UNKNOWN; |
50 | 51 |
51 TOKEN_MANDATORY_LABEL* token_label = | 52 TOKEN_MANDATORY_LABEL* token_label = |
52 reinterpret_cast<TOKEN_MANDATORY_LABEL*>(token_label_bytes.get()); | 53 reinterpret_cast<TOKEN_MANDATORY_LABEL*>(token_label_bytes.get()); |
53 if (!token_label) | 54 if (!token_label) |
54 return INTEGRITY_UNKNOWN; | 55 return INTEGRITY_UNKNOWN; |
55 | 56 |
56 if (!::GetTokenInformation(process_token, TokenIntegrityLevel, token_label, | 57 if (!::GetTokenInformation(process_token, TokenIntegrityLevel, token_label, |
57 token_info_length, &token_info_length)) { | 58 token_info_length, &token_info_length)) { |
(...skipping 14 matching lines...) Expand all Loading... |
72 } | 73 } |
73 | 74 |
74 if (integrity_level >= SECURITY_MANDATORY_HIGH_RID) | 75 if (integrity_level >= SECURITY_MANDATORY_HIGH_RID) |
75 return HIGH_INTEGRITY; | 76 return HIGH_INTEGRITY; |
76 | 77 |
77 NOTREACHED(); | 78 NOTREACHED(); |
78 return INTEGRITY_UNKNOWN; | 79 return INTEGRITY_UNKNOWN; |
79 } | 80 } |
80 | 81 |
81 } // namespace base | 82 } // namespace base |
OLD | NEW |