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

Side by Side Diff: sandbox/src/service_resolver_unittest.cc

Issue 6713107: Make the windows_version.h functions threadsafe by using a singleton. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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
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 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/src/resolver.h" 10 #include "sandbox/src/resolver.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 ret = resolver->Setup(ntdll_base, NULL, function, NULL, function_entry, 113 ret = resolver->Setup(ntdll_base, NULL, function, NULL, function_entry,
114 thunk.get(), thunk_size, &used); 114 thunk.get(), thunk_size, &used);
115 CheckJump(service, thunk.get()); 115 CheckJump(service, thunk.get());
116 } 116 }
117 } 117 }
118 118
119 return ret; 119 return ret;
120 } 120 }
121 121
122 sandbox::ServiceResolverThunk* GetTestResolver(bool relaxed) { 122 sandbox::ServiceResolverThunk* GetTestResolver(bool relaxed) {
123 if (base::win::GetWOW64Status() == base::win::WOW64_ENABLED) 123 if (base::win::OSInfo::GetInstance()->wow64_status() ==
124 base::win::OSInfo::WOW64_ENABLED)
124 return new Wow64ResolverTest(relaxed); 125 return new Wow64ResolverTest(relaxed);
125 if (!sandbox::IsXPSP2OrLater()) 126 if (!sandbox::IsXPSP2OrLater())
126 return new Win2kResolverTest(relaxed); 127 return new Win2kResolverTest(relaxed);
127 return new WinXpResolverTest(relaxed); 128 return new WinXpResolverTest(relaxed);
128 } 129 }
129 130
130 NTSTATUS PatchNtdll(const char* function, bool relaxed) { 131 NTSTATUS PatchNtdll(const char* function, bool relaxed) {
131 sandbox::ServiceResolverThunk* resolver = GetTestResolver(relaxed); 132 sandbox::ServiceResolverThunk* resolver = GetTestResolver(relaxed);
132 133
133 NTSTATUS ret = PatchNtdllWithResolver(function, relaxed, resolver); 134 NTSTATUS ret = PatchNtdllWithResolver(function, relaxed, resolver);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 ::GetLastError(); 197 ::GetLastError();
197 198
198 ret = PatchNtdllWithResolver("NtMapViewOfSection", true, resolver); 199 ret = PatchNtdllWithResolver("NtMapViewOfSection", true, resolver);
199 EXPECT_EQ(STATUS_SUCCESS, ret) << "NtMapViewOfSection, last error: " << 200 EXPECT_EQ(STATUS_SUCCESS, ret) << "NtMapViewOfSection, last error: " <<
200 ::GetLastError(); 201 ::GetLastError();
201 delete resolver; 202 delete resolver;
202 #endif 203 #endif
203 } 204 }
204 205
205 } // namespace 206 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698