OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef SANDBOX_SRC_SANDBOX_NT_UTIL_H_ | 5 #ifndef SANDBOX_SRC_SANDBOX_NT_UTIL_H_ |
6 #define SANDBOX_SRC_SANDBOX_NT_UTIL_H_ | 6 #define SANDBOX_SRC_SANDBOX_NT_UTIL_H_ |
7 | 7 |
8 #include <intrin.h> | 8 #include <intrin.h> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 #ifndef NDEBUG | 38 #ifndef NDEBUG |
39 #define DCHECK_NT(condition) { (condition) ? (void)0 : __debugbreak(); } | 39 #define DCHECK_NT(condition) { (condition) ? (void)0 : __debugbreak(); } |
40 #define VERIFY(action) DCHECK_NT(action) | 40 #define VERIFY(action) DCHECK_NT(action) |
41 #define VERIFY_SUCCESS(action) DCHECK_NT(NT_SUCCESS(action)) | 41 #define VERIFY_SUCCESS(action) DCHECK_NT(NT_SUCCESS(action)) |
42 #else | 42 #else |
43 #define DCHECK_NT(condition) | 43 #define DCHECK_NT(condition) |
44 #define VERIFY(action) (action) | 44 #define VERIFY(action) (action) |
45 #define VERIFY_SUCCESS(action) (action) | 45 #define VERIFY_SUCCESS(action) (action) |
46 #endif | 46 #endif |
47 | 47 |
| 48 #define CHECK_NT(condition) { (condition) ? (void)0 : __debugbreak(); } |
| 49 |
48 #define NOTREACHED_NT() DCHECK_NT(false) | 50 #define NOTREACHED_NT() DCHECK_NT(false) |
49 | 51 |
50 namespace sandbox { | 52 namespace sandbox { |
51 | 53 |
52 #if defined(_M_X64) | 54 #if defined(_M_X64) |
53 #pragma intrinsic(_InterlockedCompareExchange) | 55 #pragma intrinsic(_InterlockedCompareExchange) |
54 #pragma intrinsic(_InterlockedCompareExchangePointer) | 56 #pragma intrinsic(_InterlockedCompareExchangePointer) |
55 | 57 |
56 #elif defined(_M_IX86) | 58 #elif defined(_M_IX86) |
57 extern "C" long _InterlockedCompareExchange(long volatile* destination, | 59 extern "C" long _InterlockedCompareExchange(long volatile* destination, |
(...skipping 29 matching lines...) Expand all Loading... |
87 WRITE | 89 WRITE |
88 }; | 90 }; |
89 | 91 |
90 // Performs basic user mode buffer validation. In any case, buffers access must | 92 // Performs basic user mode buffer validation. In any case, buffers access must |
91 // be protected by SEH. intent specifies if the buffer should be tested for read | 93 // be protected by SEH. intent specifies if the buffer should be tested for read |
92 // or write. | 94 // or write. |
93 // Note that write intent implies destruction of the buffer content (we actually | 95 // Note that write intent implies destruction of the buffer content (we actually |
94 // write) | 96 // write) |
95 bool ValidParameter(void* buffer, size_t size, RequiredAccess intent); | 97 bool ValidParameter(void* buffer, size_t size, RequiredAccess intent); |
96 | 98 |
97 | |
98 // Copies data from a user buffer to our buffer. Returns the operation status. | 99 // Copies data from a user buffer to our buffer. Returns the operation status. |
99 NTSTATUS CopyData(void* destination, const void* source, size_t bytes); | 100 NTSTATUS CopyData(void* destination, const void* source, size_t bytes); |
100 | 101 |
101 // Copies the name from an object attributes. | 102 // Copies the name from an object attributes. |
102 NTSTATUS AllocAndCopyName(const OBJECT_ATTRIBUTES* in_object, | 103 NTSTATUS AllocAndCopyName(const OBJECT_ATTRIBUTES* in_object, |
103 wchar_t** out_name, uint32* attributes, HANDLE* root); | 104 wchar_t** out_name, uint32* attributes, HANDLE* root); |
104 | 105 |
105 // Initializes our ntdll level heap | 106 // Initializes our ntdll level heap |
106 bool InitHeap(); | 107 bool InitHeap(); |
107 | 108 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 177 |
177 // Returns true if the file_rename_information structure is supported by our | 178 // Returns true if the file_rename_information structure is supported by our |
178 // rename handler. | 179 // rename handler. |
179 bool IsSupportedRenameCall(FILE_RENAME_INFORMATION* file_info, DWORD length, | 180 bool IsSupportedRenameCall(FILE_RENAME_INFORMATION* file_info, DWORD length, |
180 uint32 file_info_class); | 181 uint32 file_info_class); |
181 | 182 |
182 } // namespace sandbox | 183 } // namespace sandbox |
183 | 184 |
184 | 185 |
185 #endif // SANDBOX_SRC_SANDBOX_NT_UTIL_H__ | 186 #endif // SANDBOX_SRC_SANDBOX_NT_UTIL_H__ |
OLD | NEW |