Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Side by Side Diff: sandbox/win/tools/finder/finder.cc

Issue 1240793004: Revert of Sandbox: Make CreateRestrictedToken return a ScopedHandle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sandbox/win/tools/finder/finder.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 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "sandbox/win/src/restricted_token.h" 5 #include "sandbox/win/src/restricted_token.h"
6 #include "sandbox/win/src/restricted_token_utils.h" 6 #include "sandbox/win/src/restricted_token_utils.h"
7 #include "sandbox/win/tools/finder/finder.h" 7 #include "sandbox/win/tools/finder/finder.h"
8 8
9 Finder::Finder() { 9 Finder::Finder() {
10 file_output_ = NULL; 10 file_output_ = NULL;
11 object_type_ = 0; 11 object_type_ = 0;
12 access_type_ = 0; 12 access_type_ = 0;
13 token_handle_ = NULL;
13 memset(filesystem_stats_, 0, sizeof(filesystem_stats_)); 14 memset(filesystem_stats_, 0, sizeof(filesystem_stats_));
14 memset(registry_stats_, 0, sizeof(registry_stats_)); 15 memset(registry_stats_, 0, sizeof(registry_stats_));
15 memset(kernel_object_stats_, 0, sizeof(kernel_object_stats_)); 16 memset(kernel_object_stats_, 0, sizeof(kernel_object_stats_));
16 } 17 }
17 18
18 Finder::~Finder() { 19 Finder::~Finder() {
20 if (token_handle_)
21 ::CloseHandle(token_handle_);
19 } 22 }
20 23
21 DWORD Finder::Init(sandbox::TokenLevel token_type, 24 DWORD Finder::Init(sandbox::TokenLevel token_type,
22 DWORD object_type, 25 DWORD object_type,
23 DWORD access_type, 26 DWORD access_type,
24 FILE *file_output) { 27 FILE *file_output) {
25 DWORD err_code = ERROR_SUCCESS; 28 DWORD err_code = ERROR_SUCCESS;
26 29
27 err_code = InitNT(); 30 err_code = InitNT();
28 if (ERROR_SUCCESS != err_code) 31 if (ERROR_SUCCESS != err_code)
29 return err_code; 32 return err_code;
30 33
31 object_type_ = object_type; 34 object_type_ = object_type;
32 access_type_ = access_type; 35 access_type_ = access_type;
33 file_output_ = file_output; 36 file_output_ = file_output;
34 37
35 err_code = sandbox::CreateRestrictedToken(token_type, 38 err_code = sandbox::CreateRestrictedToken(&token_handle_, token_type,
36 sandbox::INTEGRITY_LEVEL_LAST, 39 sandbox::INTEGRITY_LEVEL_LAST,
37 sandbox::PRIMARY, &token_handle_); 40 sandbox::PRIMARY);
38 return err_code; 41 return err_code;
39 } 42 }
40 43
41 DWORD Finder::Scan() { 44 DWORD Finder::Scan() {
42 if (!token_handle_.IsValid()) { 45 if (!token_handle_) {
43 return ERROR_NO_TOKEN; 46 return ERROR_NO_TOKEN;
44 } 47 }
45 48
46 if (object_type_ & kScanRegistry) { 49 if (object_type_ & kScanRegistry) {
47 ParseRegistry(HKEY_LOCAL_MACHINE, L"HKLM\\"); 50 ParseRegistry(HKEY_LOCAL_MACHINE, L"HKLM\\");
48 ParseRegistry(HKEY_USERS, L"HKU\\"); 51 ParseRegistry(HKEY_USERS, L"HKU\\");
49 ParseRegistry(HKEY_CURRENT_CONFIG, L"HKCC\\"); 52 ParseRegistry(HKEY_CURRENT_CONFIG, L"HKCC\\");
50 } 53 }
51 54
52 if (object_type_ & kScanFileSystem) { 55 if (object_type_ & kScanFileSystem) {
53 ParseFileSystem(L"\\\\?\\C:"); 56 ParseFileSystem(L"\\\\?\\C:");
54 } 57 }
55 58
56 if (object_type_ & kScanKernelObjects) { 59 if (object_type_ & kScanKernelObjects) {
57 ParseKernelObjects(L"\\"); 60 ParseKernelObjects(L"\\");
58 } 61 }
59 62
60 return ERROR_SUCCESS; 63 return ERROR_SUCCESS;
61 } 64 }
OLDNEW
« no previous file with comments | « sandbox/win/tools/finder/finder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698