OLD | NEW |
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 #include "sandbox/win/src/win_utils.h" | 5 #include "sandbox/win/src/win_utils.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 std::wstring* long_path) { | 184 std::wstring* long_path) { |
185 // Check if the path is a NT path. | 185 // Check if the path is a NT path. |
186 bool is_nt_path = false; | 186 bool is_nt_path = false; |
187 std::wstring path = short_path; | 187 std::wstring path = short_path; |
188 if (0 == path.compare(0, kNTPrefixLen, kNTPrefix)) { | 188 if (0 == path.compare(0, kNTPrefixLen, kNTPrefix)) { |
189 path = path.substr(kNTPrefixLen); | 189 path = path.substr(kNTPrefixLen); |
190 is_nt_path = true; | 190 is_nt_path = true; |
191 } | 191 } |
192 | 192 |
193 DWORD size = MAX_PATH; | 193 DWORD size = MAX_PATH; |
194 scoped_array<wchar_t> long_path_buf(new wchar_t[size]); | 194 scoped_ptr<wchar_t[]> long_path_buf(new wchar_t[size]); |
195 | 195 |
196 DWORD return_value = ::GetLongPathName(path.c_str(), long_path_buf.get(), | 196 DWORD return_value = ::GetLongPathName(path.c_str(), long_path_buf.get(), |
197 size); | 197 size); |
198 while (return_value >= size) { | 198 while (return_value >= size) { |
199 size *= 2; | 199 size *= 2; |
200 long_path_buf.reset(new wchar_t[size]); | 200 long_path_buf.reset(new wchar_t[size]); |
201 return_value = ::GetLongPathName(path.c_str(), long_path_buf.get(), size); | 201 return_value = ::GetLongPathName(path.c_str(), long_path_buf.get(), size); |
202 } | 202 } |
203 | 203 |
204 DWORD last_error = ::GetLastError(); | 204 DWORD last_error = ::GetLastError(); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 | 314 |
315 for (int tries = 1; !(*function_ptr) && tries < max_tries; ++tries) { | 315 for (int tries = 1; !(*function_ptr) && tries < max_tries; ++tries) { |
316 if (tries >= sleep_threshold) | 316 if (tries >= sleep_threshold) |
317 ::Sleep(1); | 317 ::Sleep(1); |
318 ntdll = ::GetModuleHandle(sandbox::kNtdllName); | 318 ntdll = ::GetModuleHandle(sandbox::kNtdllName); |
319 *function_ptr = ::GetProcAddress(ntdll, name); | 319 *function_ptr = ::GetProcAddress(ntdll, name); |
320 } | 320 } |
321 | 321 |
322 CHECK(*function_ptr); | 322 CHECK(*function_ptr); |
323 } | 323 } |
OLD | NEW |