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

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

Issue 10942004: Cleanup: avoid foo ? true : false, part 2. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 | « sandbox/win/src/policy_engine_processor.cc ('k') | sandbox/win/src/sandbox_utils.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/sandbox_nt_util.h" 5 #include "sandbox/win/src/sandbox_nt_util.h"
6 6
7 #include "base/win/pe_image.h" 7 #include "base/win/pe_image.h"
8 #include "sandbox/win/src/sandbox_factory.h" 8 #include "sandbox/win/src/sandbox_factory.h"
9 #include "sandbox/win/src/target_services.h" 9 #include "sandbox/win/src/target_services.h"
10 10
11 namespace sandbox { 11 namespace sandbox {
12 12
13 // This is the list of all imported symbols from ntdll.dll. 13 // This is the list of all imported symbols from ntdll.dll.
14 SANDBOX_INTERCEPT NtExports g_nt = { NULL }; 14 SANDBOX_INTERCEPT NtExports g_nt = { NULL };
15 15
16 } 16 } // namespace
17 17
18 namespace { 18 namespace {
19 19
20 #if defined(_WIN64) 20 #if defined(_WIN64)
21 void* AllocateNearTo(void* source, size_t size) { 21 void* AllocateNearTo(void* source, size_t size) {
22 using sandbox::g_nt; 22 using sandbox::g_nt;
23 23
24 // Start with 1 GB above the source. 24 // Start with 1 GB above the source.
25 const unsigned int kOneGB = 0x40000000; 25 const unsigned int kOneGB = 0x40000000;
26 void* base = reinterpret_cast<char*>(source) + kOneGB; 26 void* base = reinterpret_cast<char*>(source) + kOneGB;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // Create a new heap using default values for everything. 159 // Create a new heap using default values for everything.
160 void* heap = g_nt.RtlCreateHeap(HEAP_GROWABLE, NULL, 0, 0, NULL, NULL); 160 void* heap = g_nt.RtlCreateHeap(HEAP_GROWABLE, NULL, 0, 0, NULL, NULL);
161 if (!heap) 161 if (!heap)
162 return false; 162 return false;
163 163
164 if (NULL != _InterlockedCompareExchangePointer(&g_heap, heap, NULL)) { 164 if (NULL != _InterlockedCompareExchangePointer(&g_heap, heap, NULL)) {
165 // Somebody beat us to the memory setup. 165 // Somebody beat us to the memory setup.
166 g_nt.RtlDestroyHeap(heap); 166 g_nt.RtlDestroyHeap(heap);
167 } 167 }
168 } 168 }
169 return (g_heap) ? true : false; 169 return (g_heap != NULL);
170 } 170 }
171 171
172 // Physically reads or writes from memory to verify that (at this time), it is 172 // Physically reads or writes from memory to verify that (at this time), it is
173 // valid. Returns a dummy value. 173 // valid. Returns a dummy value.
174 int TouchMemory(void* buffer, size_t size_bytes, RequiredAccess intent) { 174 int TouchMemory(void* buffer, size_t size_bytes, RequiredAccess intent) {
175 const int kPageSize = 4096; 175 const int kPageSize = 4096;
176 int dummy = 0; 176 int dummy = 0;
177 char* start = reinterpret_cast<char*>(buffer); 177 char* start = reinterpret_cast<char*>(buffer);
178 char* end = start + size_bytes - 1; 178 char* end = start + size_bytes - 1;
179 179
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 UNREFERENCED_PARAMETER(type); 590 UNREFERENCED_PARAMETER(type);
591 return buffer; 591 return buffer;
592 } 592 }
593 593
594 void __cdecl operator delete(void* memory, void* buffer, 594 void __cdecl operator delete(void* memory, void* buffer,
595 sandbox::AllocationType type) { 595 sandbox::AllocationType type) {
596 UNREFERENCED_PARAMETER(memory); 596 UNREFERENCED_PARAMETER(memory);
597 UNREFERENCED_PARAMETER(buffer); 597 UNREFERENCED_PARAMETER(buffer);
598 UNREFERENCED_PARAMETER(type); 598 UNREFERENCED_PARAMETER(type);
599 } 599 }
OLDNEW
« no previous file with comments | « sandbox/win/src/policy_engine_processor.cc ('k') | sandbox/win/src/sandbox_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698