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

Side by Side Diff: sandbox/win/src/handle_closer_agent.cc

Issue 419533003: Make HandleCloserAgent walk in 4x multiples on x64 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | sandbox/win/src/handle_closer_test.cc » ('j') | 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) 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 "sandbox/win/src/handle_closer_agent.h" 5 #include "sandbox/win/src/handle_closer_agent.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "sandbox/win/src/nt_internals.h" 8 #include "sandbox/win/src/nt_internals.h"
9 #include "sandbox/win/src/win_utils.h" 9 #include "sandbox/win/src/win_utils.h"
10 10
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 72
73 // Clean up the memory we copied over. 73 // Clean up the memory we copied over.
74 ::VirtualFree(g_handles_to_close, 0, MEM_RELEASE); 74 ::VirtualFree(g_handles_to_close, 0, MEM_RELEASE);
75 g_handles_to_close = NULL; 75 g_handles_to_close = NULL;
76 } 76 }
77 77
78 bool HandleCloserAgent::CloseHandles() { 78 bool HandleCloserAgent::CloseHandles() {
79 DWORD handle_count = UINT_MAX; 79 DWORD handle_count = UINT_MAX;
80 const int kInvalidHandleThreshold = 100; 80 const int kInvalidHandleThreshold = 100;
81 const size_t kHandleOffset = sizeof(HANDLE); 81 const size_t kHandleOffset = 4; // Handles are always a multiple of 4.
82 82
83 if (!::GetProcessHandleCount(::GetCurrentProcess(), &handle_count)) 83 if (!::GetProcessHandleCount(::GetCurrentProcess(), &handle_count))
84 return false; 84 return false;
85 85
86 // Set up buffers for the type info and the name. 86 // Set up buffers for the type info and the name.
87 std::vector<BYTE> type_info_buffer(sizeof(OBJECT_TYPE_INFORMATION) + 87 std::vector<BYTE> type_info_buffer(sizeof(OBJECT_TYPE_INFORMATION) +
88 32 * sizeof(wchar_t)); 88 32 * sizeof(wchar_t));
89 OBJECT_TYPE_INFORMATION* type_info = 89 OBJECT_TYPE_INFORMATION* type_info =
90 reinterpret_cast<OBJECT_TYPE_INFORMATION*>(&(type_info_buffer[0])); 90 reinterpret_cast<OBJECT_TYPE_INFORMATION*>(&(type_info_buffer[0]));
91 base::string16 handle_name; 91 base::string16 handle_name;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 return false; 136 return false;
137 if (!::CloseHandle(handle)) 137 if (!::CloseHandle(handle))
138 return false; 138 return false;
139 } 139 }
140 } 140 }
141 141
142 return true; 142 return true;
143 } 143 }
144 144
145 } // namespace sandbox 145 } // namespace sandbox
OLDNEW
« no previous file with comments | « no previous file | sandbox/win/src/handle_closer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698