OLD | NEW |
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 // This file contains unit tests for ServiceResolverThunk. | 5 // This file contains unit tests for ServiceResolverThunk. |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/win/windows_version.h" | 9 #include "base/win/windows_version.h" |
10 #include "sandbox/win/src/resolver.h" | 10 #include "sandbox/win/src/resolver.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 return STATUS_UNSUCCESSFUL; | 98 return STATUS_UNSUCCESSFUL; |
99 | 99 |
100 BYTE service[50]; | 100 BYTE service[50]; |
101 memcpy(service, target, sizeof(service)); | 101 memcpy(service, target, sizeof(service)); |
102 | 102 |
103 static_cast<WinXpResolverTest*>(resolver)->set_target(service); | 103 static_cast<WinXpResolverTest*>(resolver)->set_target(service); |
104 | 104 |
105 // Any pointer will do as an interception_entry_point | 105 // Any pointer will do as an interception_entry_point |
106 void* function_entry = resolver; | 106 void* function_entry = resolver; |
107 size_t thunk_size = resolver->GetThunkSize(); | 107 size_t thunk_size = resolver->GetThunkSize(); |
108 scoped_array<char> thunk(new char[thunk_size]); | 108 scoped_ptr<char[]> thunk(new char[thunk_size]); |
109 size_t used; | 109 size_t used; |
110 | 110 |
111 NTSTATUS ret = resolver->Setup(ntdll_base, NULL, function, NULL, | 111 NTSTATUS ret = resolver->Setup(ntdll_base, NULL, function, NULL, |
112 function_entry, thunk.get(), thunk_size, | 112 function_entry, thunk.get(), thunk_size, |
113 &used); | 113 &used); |
114 if (NT_SUCCESS(ret)) { | 114 if (NT_SUCCESS(ret)) { |
115 EXPECT_EQ(thunk_size, used); | 115 EXPECT_EQ(thunk_size, used); |
116 EXPECT_NE(0, memcmp(service, target, sizeof(service))); | 116 EXPECT_NE(0, memcmp(service, target, sizeof(service))); |
117 EXPECT_NE(kJump32, service[0]); | 117 EXPECT_NE(kJump32, service[0]); |
118 | 118 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 ::GetLastError(); | 218 ::GetLastError(); |
219 | 219 |
220 ret = PatchNtdllWithResolver("NtMapViewOfSection", true, resolver); | 220 ret = PatchNtdllWithResolver("NtMapViewOfSection", true, resolver); |
221 EXPECT_EQ(STATUS_SUCCESS, ret) << "NtMapViewOfSection, last error: " << | 221 EXPECT_EQ(STATUS_SUCCESS, ret) << "NtMapViewOfSection, last error: " << |
222 ::GetLastError(); | 222 ::GetLastError(); |
223 delete resolver; | 223 delete resolver; |
224 #endif | 224 #endif |
225 } | 225 } |
226 | 226 |
227 } // namespace | 227 } // namespace |
OLD | NEW |