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

Side by Side Diff: sandbox/win/sandbox_poc/sandbox.cc

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/sandbox_poc/pocdll/spyware.cc ('k') | sandbox/win/src/Wow64.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 #include <windows.h> 5 #include <windows.h>
6 #include <tchar.h> 6 #include <tchar.h>
7 #include <shellapi.h> 7 #include <shellapi.h>
8 #include "sandbox/win/sandbox_poc/sandbox.h" 8 #include "sandbox/win/sandbox_poc/sandbox.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "sandbox/win/sandbox_poc/main_ui_window.h" 10 #include "sandbox/win/sandbox_poc/main_ui_window.h"
11 #include "sandbox/win/src/sandbox.h" 11 #include "sandbox/win/src/sandbox.h"
12 #include "sandbox/win/src/sandbox_factory.h" 12 #include "sandbox/win/src/sandbox_factory.h"
13 13
14 // Prototype allowed for functions to be called in the POC 14 // Prototype allowed for functions to be called in the POC
15 typedef void(__cdecl *lpfnInit)(HANDLE); 15 typedef void(__cdecl *lpfnInit)(HANDLE);
16 16
17 bool ParseCommandLine(wchar_t * command_line, 17 bool ParseCommandLine(wchar_t * command_line,
18 std::string * dll_name, 18 std::string * dll_name,
19 std::string * entry_point, 19 std::string * entry_point,
20 std::wstring * log_file) { 20 base::string16 * log_file) {
21 DCHECK(dll_name); 21 DCHECK(dll_name);
22 DCHECK(entry_point); 22 DCHECK(entry_point);
23 DCHECK(log_file); 23 DCHECK(log_file);
24 if (!dll_name || !entry_point || !log_file) 24 if (!dll_name || !entry_point || !log_file)
25 return false; 25 return false;
26 26
27 LPWSTR *arg_list; 27 LPWSTR *arg_list;
28 int arg_count; 28 int arg_count;
29 29
30 // We expect the command line to contain: EntryPointName "DLLPath" "LogPath" 30 // We expect the command line to contain: EntryPointName "DLLPath" "LogPath"
31 // NOTE: Double quotes are required, even if long path name not used 31 // NOTE: Double quotes are required, even if long path name not used
32 // NOTE: LogPath can be blank, but still requires the double quotes 32 // NOTE: LogPath can be blank, but still requires the double quotes
33 arg_list = CommandLineToArgvW(command_line, &arg_count); 33 arg_list = CommandLineToArgvW(command_line, &arg_count);
34 if (NULL == arg_list || arg_count < 4) { 34 if (NULL == arg_list || arg_count < 4) {
35 return false; 35 return false;
36 } 36 }
37 37
38 std::wstring entry_point_wide = arg_list[1]; 38 base::string16 entry_point_wide = arg_list[1];
39 std::wstring dll_name_wide = arg_list[2]; 39 base::string16 dll_name_wide = arg_list[2];
40 *entry_point = std::string(entry_point_wide.begin(), entry_point_wide.end()); 40 *entry_point = std::string(entry_point_wide.begin(), entry_point_wide.end());
41 *dll_name = std::string(dll_name_wide.begin(), dll_name_wide.end()); 41 *dll_name = std::string(dll_name_wide.begin(), dll_name_wide.end());
42 *log_file = arg_list[3]; 42 *log_file = arg_list[3];
43 43
44 // Free memory allocated for CommandLineToArgvW arguments. 44 // Free memory allocated for CommandLineToArgvW arguments.
45 LocalFree(arg_list); 45 LocalFree(arg_list);
46 46
47 return true; 47 return true;
48 } 48 }
49 49
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 119
120 // Sleep(10000); 120 // Sleep(10000);
121 121
122 if (sandbox::SBOX_ALL_OK != (result = target_service->Init())) { 122 if (sandbox::SBOX_ALL_OK != (result = target_service->Init())) {
123 // TODO(finnur): write the initialization error to the log file 123 // TODO(finnur): write the initialization error to the log file
124 return -2; 124 return -2;
125 } 125 }
126 126
127 // Parse the command line to find out what we need to call 127 // Parse the command line to find out what we need to call
128 std::string dll_name, entry_point; 128 std::string dll_name, entry_point;
129 std::wstring log_file; 129 base::string16 log_file;
130 if (!ParseCommandLine(GetCommandLineW(), 130 if (!ParseCommandLine(GetCommandLineW(),
131 &dll_name, 131 &dll_name,
132 &entry_point, 132 &entry_point,
133 &log_file)) { 133 &log_file)) {
134 // TODO(finnur): write the failure to the log file 134 // TODO(finnur): write the failure to the log file
135 return -3; 135 return -3;
136 } 136 }
137 137
138 // Open the pipe to transfert the log output 138 // Open the pipe to transfert the log output
139 HANDLE pipe = ::CreateFile(log_file.c_str(), 139 HANDLE pipe = ::CreateFile(log_file.c_str(),
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 173
174 CloseHandle(pipe); 174 CloseHandle(pipe);
175 Sleep(1000); // Give a change to the debug output to arrive before the 175 Sleep(1000); // Give a change to the debug output to arrive before the
176 // end of the process 176 // end of the process
177 177
178 ::FreeLibrary(dll_module); 178 ::FreeLibrary(dll_module);
179 } 179 }
180 180
181 return 0; 181 return 0;
182 } 182 }
OLDNEW
« no previous file with comments | « sandbox/win/sandbox_poc/pocdll/spyware.cc ('k') | sandbox/win/src/Wow64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698