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

Side by Side Diff: sandbox/win/src/win_utils.h

Issue 109843003: Replace wstring with string16 in sandbox (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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/sync_policy.cc ('k') | sandbox/win/src/win_utils.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) 2006-2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-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_WIN_UTILS_H_ 5 #ifndef SANDBOX_SRC_WIN_UTILS_H_
6 #define SANDBOX_SRC_WIN_UTILS_H_ 6 #define SANDBOX_SRC_WIN_UTILS_H_
7 7
8 #include <windows.h> 8 #include <windows.h>
9 #include <string> 9 #include <string>
10
10 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/strings/string16.h"
11 13
12 namespace sandbox { 14 namespace sandbox {
13 15
14 // Prefix for path used by NT calls. 16 // Prefix for path used by NT calls.
15 const wchar_t kNTPrefix[] = L"\\??\\"; 17 const wchar_t kNTPrefix[] = L"\\??\\";
16 const size_t kNTPrefixLen = arraysize(kNTPrefix) - 1; 18 const size_t kNTPrefixLen = arraysize(kNTPrefix) - 1;
17 19
18 const wchar_t kNTObjManPrefix[] = L"\\Device\\"; 20 const wchar_t kNTObjManPrefix[] = L"\\Device\\";
19 const size_t kNTObjManPrefixLen = arraysize(kNTObjManPrefix) - 1; 21 const size_t kNTObjManPrefixLen = arraysize(kNTObjManPrefix) - 1;
20 22
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 // process is shutting down. 60 // process is shutting down.
59 static int __cdecl OnExit() { 61 static int __cdecl OnExit() {
60 delete GetInstance(); 62 delete GetInstance();
61 return 0; 63 return 0;
62 } 64 }
63 }; 65 };
64 66
65 // Convert a short path (C:\path~1 or \\??\\c:\path~1) to the long version of 67 // Convert a short path (C:\path~1 or \\??\\c:\path~1) to the long version of
66 // the path. If the path is not a valid filesystem path, the function returns 68 // the path. If the path is not a valid filesystem path, the function returns
67 // false and the output parameter is not modified. 69 // false and the output parameter is not modified.
68 bool ConvertToLongPath(const std::wstring& short_path, std::wstring* long_path); 70 bool ConvertToLongPath(const base::string16& short_path,
71 base::string16* long_path);
69 72
70 // Sets result to true if the path contains a reparse point. The return value 73 // Sets result to true if the path contains a reparse point. The return value
71 // is ERROR_SUCCESS when the function succeeds or the appropriate error code 74 // is ERROR_SUCCESS when the function succeeds or the appropriate error code
72 // when the function fails. 75 // when the function fails.
73 // This function is not smart. It looks for each element in the path and 76 // This function is not smart. It looks for each element in the path and
74 // returns true if any of them is a reparse point. 77 // returns true if any of them is a reparse point.
75 DWORD IsReparsePoint(const std::wstring& full_path, bool* result); 78 DWORD IsReparsePoint(const base::string16& full_path, bool* result);
76 79
77 // Returns true if the handle corresponds to the object pointed by this path. 80 // Returns true if the handle corresponds to the object pointed by this path.
78 bool SameObject(HANDLE handle, const wchar_t* full_path); 81 bool SameObject(HANDLE handle, const wchar_t* full_path);
79 82
80 // Resolves a handle to an nt path. Returns true if the handle can be resolved. 83 // Resolves a handle to an nt path. Returns true if the handle can be resolved.
81 bool GetPathFromHandle(HANDLE handle, std::wstring* path); 84 bool GetPathFromHandle(HANDLE handle, base::string16* path);
82 85
83 // Resolves a win32 path to an nt path using GetPathFromHandle. The path must 86 // Resolves a win32 path to an nt path using GetPathFromHandle. The path must
84 // exist. Returs true if the translation was succesful. 87 // exist. Returs true if the translation was succesful.
85 bool GetNtPathFromWin32Path(const std::wstring& path, std::wstring* nt_path); 88 bool GetNtPathFromWin32Path(const base::string16& path,
89 base::string16* nt_path);
86 90
87 // Translates a reserved key name to its handle. 91 // Translates a reserved key name to its handle.
88 // For example "HKEY_LOCAL_MACHINE" returns HKEY_LOCAL_MACHINE. 92 // For example "HKEY_LOCAL_MACHINE" returns HKEY_LOCAL_MACHINE.
89 // Returns NULL if the name does not represent any reserved key name. 93 // Returns NULL if the name does not represent any reserved key name.
90 HKEY GetReservedKeyFromName(const std::wstring& name); 94 HKEY GetReservedKeyFromName(const base::string16& name);
91 95
92 // Resolves a user-readable registry path to a system-readable registry path. 96 // Resolves a user-readable registry path to a system-readable registry path.
93 // For example, HKEY_LOCAL_MACHINE\\Software\\microsoft is translated to 97 // For example, HKEY_LOCAL_MACHINE\\Software\\microsoft is translated to
94 // \\registry\\machine\\software\\microsoft. Returns false if the path 98 // \\registry\\machine\\software\\microsoft. Returns false if the path
95 // cannot be resolved. 99 // cannot be resolved.
96 bool ResolveRegistryName(std::wstring name, std::wstring* resolved_name); 100 bool ResolveRegistryName(base::string16 name, base::string16* resolved_name);
97 101
98 // Writes |length| bytes from the provided |buffer| into the address space of 102 // Writes |length| bytes from the provided |buffer| into the address space of
99 // |child_process|, at the specified |address|, preserving the original write 103 // |child_process|, at the specified |address|, preserving the original write
100 // protection attributes. Returns true on success. 104 // protection attributes. Returns true on success.
101 bool WriteProtectedChildMemory(HANDLE child_process, void* address, 105 bool WriteProtectedChildMemory(HANDLE child_process, void* address,
102 const void* buffer, size_t length); 106 const void* buffer, size_t length);
103 107
104 } // namespace sandbox 108 } // namespace sandbox
105 109
106 // Resolves a function name in NTDLL to a function pointer. The second parameter 110 // Resolves a function name in NTDLL to a function pointer. The second parameter
107 // is a pointer to the function pointer. 111 // is a pointer to the function pointer.
108 void ResolveNTFunctionPtr(const char* name, void* ptr); 112 void ResolveNTFunctionPtr(const char* name, void* ptr);
109 113
110 #endif // SANDBOX_SRC_WIN_UTILS_H_ 114 #endif // SANDBOX_SRC_WIN_UTILS_H_
OLDNEW
« no previous file with comments | « sandbox/win/src/sync_policy.cc ('k') | sandbox/win/src/win_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698