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

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

Issue 13888007: Rewrite scoped_array<T> to scoped_ptr<T[]> in sandbox. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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/interception.cc ('k') | sandbox/win/src/service_resolver_32.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // This file contains unit tests for InterceptionManager. 5 // This file contains unit tests for InterceptionManager.
6 // The tests require private information so the whole interception.cc file is 6 // The tests require private information so the whole interception.cc file is
7 // included from this file. 7 // included from this file.
8 8
9 #include <windows.h> 9 #include <windows.h>
10 10
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 INTERCEPTION_EAT, function, OPEN_KEY_ID); 128 INTERCEPTION_EAT, function, OPEN_KEY_ID);
129 interceptions.AddToPatchedFunctions(L"a.dll", "BIsLame", 129 interceptions.AddToPatchedFunctions(L"a.dll", "BIsLame",
130 INTERCEPTION_EAT, function, OPEN_KEY_ID); 130 INTERCEPTION_EAT, function, OPEN_KEY_ID);
131 interceptions.AddToPatchedFunctions(L"a.dll", "ARules", 131 interceptions.AddToPatchedFunctions(L"a.dll", "ARules",
132 INTERCEPTION_EAT, function, OPEN_KEY_ID); 132 INTERCEPTION_EAT, function, OPEN_KEY_ID);
133 133
134 // Verify that all interceptions were added 134 // Verify that all interceptions were added
135 ASSERT_EQ(18, interceptions.interceptions_.size()); 135 ASSERT_EQ(18, interceptions.interceptions_.size());
136 136
137 size_t buffer_size = interceptions.GetBufferSize(); 137 size_t buffer_size = interceptions.GetBufferSize();
138 scoped_array<BYTE> local_buffer(new BYTE[buffer_size]); 138 scoped_ptr<BYTE[]> local_buffer(new BYTE[buffer_size]);
139 139
140 ASSERT_TRUE(interceptions.SetupConfigBuffer(local_buffer.get(), 140 ASSERT_TRUE(interceptions.SetupConfigBuffer(local_buffer.get(),
141 buffer_size)); 141 buffer_size));
142 142
143 // At this point, the interceptions should have been separated into two 143 // At this point, the interceptions should have been separated into two
144 // groups: one group with the local ("cold") interceptions, consisting of 144 // groups: one group with the local ("cold") interceptions, consisting of
145 // everything from ntdll and stuff set as INTRECEPTION_SERVICE_CALL, and 145 // everything from ntdll and stuff set as INTRECEPTION_SERVICE_CALL, and
146 // another group with the interceptions belonging to dlls that will be "hot" 146 // another group with the interceptions belonging to dlls that will be "hot"
147 // patched on the client. The second group lives on local_buffer, and the 147 // patched on the client. The second group lives on local_buffer, and the
148 // first group remains on the list of interceptions (inside the object 148 // first group remains on the list of interceptions (inside the object
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 interceptions.AddToPatchedFunctions(L"kernel32.dll", "CreateFileEx", 181 interceptions.AddToPatchedFunctions(L"kernel32.dll", "CreateFileEx",
182 INTERCEPTION_EAT, function, OPEN_FILE_ID); 182 INTERCEPTION_EAT, function, OPEN_FILE_ID);
183 interceptions.AddToUnloadModules(L"some02.dll"); 183 interceptions.AddToUnloadModules(L"some02.dll");
184 interceptions.AddToPatchedFunctions(L"kernel32.dll", "SomeFileEx", 184 interceptions.AddToPatchedFunctions(L"kernel32.dll", "SomeFileEx",
185 INTERCEPTION_SMART_SIDESTEP, function, 185 INTERCEPTION_SMART_SIDESTEP, function,
186 OPEN_FILE_ID); 186 OPEN_FILE_ID);
187 // Verify that all interceptions were added 187 // Verify that all interceptions were added
188 ASSERT_EQ(5, interceptions.interceptions_.size()); 188 ASSERT_EQ(5, interceptions.interceptions_.size());
189 189
190 size_t buffer_size = interceptions.GetBufferSize(); 190 size_t buffer_size = interceptions.GetBufferSize();
191 scoped_array<BYTE> local_buffer(new BYTE[buffer_size]); 191 scoped_ptr<BYTE[]> local_buffer(new BYTE[buffer_size]);
192 192
193 ASSERT_TRUE(interceptions.SetupConfigBuffer(local_buffer.get(), 193 ASSERT_TRUE(interceptions.SetupConfigBuffer(local_buffer.get(),
194 buffer_size)); 194 buffer_size));
195 195
196 // At this point, the interceptions should have been separated into two 196 // At this point, the interceptions should have been separated into two
197 // groups: one group with the local ("cold") interceptions, and another 197 // groups: one group with the local ("cold") interceptions, and another
198 // group with the interceptions belonging to dlls that will be "hot" 198 // group with the interceptions belonging to dlls that will be "hot"
199 // patched on the client. The second group lives on local_buffer, and the 199 // patched on the client. The second group lives on local_buffer, and the
200 // first group remains on the list of interceptions, in this case just one. 200 // first group remains on the list of interceptions, in this case just one.
201 EXPECT_EQ(1, interceptions.interceptions_.size()); 201 EXPECT_EQ(1, interceptions.interceptions_.size());
202 202
203 int num_dlls, num_functions, num_names; 203 int num_dlls, num_functions, num_names;
204 WalkBuffer(local_buffer.get(), buffer_size, &num_dlls, &num_functions, 204 WalkBuffer(local_buffer.get(), buffer_size, &num_dlls, &num_functions,
205 &num_names); 205 &num_names);
206 206
207 EXPECT_EQ(3, num_dlls); 207 EXPECT_EQ(3, num_dlls);
208 EXPECT_EQ(4, num_functions); 208 EXPECT_EQ(4, num_functions);
209 EXPECT_EQ(0, num_names); 209 EXPECT_EQ(0, num_names);
210 } 210 }
211 211
212 } // namespace sandbox 212 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/win/src/interception.cc ('k') | sandbox/win/src/service_resolver_32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698