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

Side by Side Diff: chrome/installer/mini_installer/mini_installer.cc

Issue 2655473002: Handle spaces in the name of the mini_installer. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | no next file » | 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) 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 // mini_installer.exe is the first exe that is run when chrome is being 5 // mini_installer.exe is the first exe that is run when chrome is being
6 // installed or upgraded. It is designed to be extremely small (~5KB with no 6 // installed or upgraded. It is designed to be extremely small (~5KB with no
7 // extra resources linked) and it has two main jobs: 7 // extra resources linked) and it has two main jobs:
8 // 1) unpack the resources (possibly decompressing some) 8 // 1) unpack the resources (possibly decompressing some)
9 // 2) run the real installer (setup.exe) with appropriate flags. 9 // 2) run the real installer (setup.exe) with appropriate flags.
10 // 10 //
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 NULL, full_exe_path.get(), static_cast<DWORD>(full_exe_path.capacity())); 242 NULL, full_exe_path.get(), static_cast<DWORD>(full_exe_path.capacity()));
243 if (!len || len >= full_exe_path.capacity()) 243 if (!len || len >= full_exe_path.capacity())
244 return; 244 return;
245 245
246 const wchar_t* exe_name = 246 const wchar_t* exe_name =
247 GetNameFromPathExt(full_exe_path.get(), static_cast<DWORD>(len)); 247 GetNameFromPathExt(full_exe_path.get(), static_cast<DWORD>(len));
248 248
249 // - configuration.program() returns the first command line argument 249 // - configuration.program() returns the first command line argument
250 // passed into the program (that the user probably typed in this case). 250 // passed into the program (that the user probably typed in this case).
251 // "mini_installer.exe" 251 // "mini_installer.exe"
252 // "mini_installer (1).exe"
252 // "mini_installer" 253 // "mini_installer"
253 // "out\Release\mini_installer" 254 // "out\Release\mini_installer"
254 // - |exe_name| is the executable file of the current process. 255 // - |exe_name| is the executable file of the current process.
255 // "mini_installer.exe" 256 // "mini_installer.exe"
256 // 257 //
257 // Note that there are three possibilities to handle here. 258 // Note that there are three possibilities to handle here.
258 // Receive a cmdline containing: 259 // Receive a cmdline containing:
259 // 1) executable name WITH extension 260 // 1) executable name WITH extension (possibly containing a space)
260 // 2) executable name with NO extension 261 // 2) executable name with NO extension
261 // 3) NO executable name as part of cmdline 262 // 3) NO executable name as part of cmdline
262 const wchar_t* cmd_to_append = L""; 263 const wchar_t* cmd_to_append = L"";
263 const wchar_t* arg0 = configuration.program(); 264 const wchar_t* arg0 = configuration.program();
264 if (!arg0) 265 if (!arg0)
265 return; 266 return;
266 const wchar_t* arg0_base_name = GetNameFromPathExt(arg0, ::lstrlen(arg0)); 267 const wchar_t* arg0_base_name = GetNameFromPathExt(arg0, ::lstrlen(arg0));
267 if (!StrStartsWith(exe_name, arg0_base_name)) { 268 if (!StrStartsWith(exe_name, arg0_base_name)) {
268 // State 3: NO executable name as part of cmdline. 269 // State 3: NO executable name as part of cmdline.
269 buffer->append(L" "); 270 buffer->append(L" ");
270 cmd_to_append = configuration.command_line(); 271 cmd_to_append = configuration.command_line();
271 } else if (configuration.argument_count() > 1) { 272 } else if (configuration.argument_count() > 1) {
272 // State 1 or 2: Executable name is in cmdline. 273 // State 1 or 2: Executable name is in cmdline.
273 // - Append everything AFTER the executable name. 274 // - Append everything AFTER the executable name.
274 // (Using arg0_base_name here to make sure to match with or without 275 // (Using arg0_base_name here to make sure to match with or without
275 // extension. Then move to the space following the token.) 276 // extension. Then move to the space following the token.)
276 const wchar_t* tmp = SearchStringI(configuration.command_line(), 277 const wchar_t* tmp = SearchStringI(configuration.command_line(),
277 arg0_base_name); 278 arg0_base_name);
278 tmp = SearchStringI(tmp, L" "); 279 tmp = SearchStringI(tmp + ::lstrlen(arg0_base_name), L" ");
bcwhite 2017/01/26 15:36:22 If you know the length of the program name, why do
grt (UTC plus 2) 2017/01/26 16:07:47 I think it's possible that there could be a traili
279 cmd_to_append = tmp; 280 cmd_to_append = tmp;
280 } 281 }
281 282
282 buffer->append(cmd_to_append); 283 buffer->append(cmd_to_append);
283 } 284 }
284 285
285 286
286 // Windows defined callback used in the EnumResourceNames call. For each 287 // Windows defined callback used in the EnumResourceNames call. For each
287 // matching resource found, the callback is invoked and at this point we write 288 // matching resource found, the callback is invoked and at this point we write
288 // it to disk. We expect resource names to start with 'chrome' or 'setup'. Any 289 // it to disk. We expect resource names to start with 'chrome' or 'setup'. Any
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 #pragma function(memset) 922 #pragma function(memset)
922 void* memset(void* dest, int c, size_t count) { 923 void* memset(void* dest, int c, size_t count) {
923 void* start = dest; 924 void* start = dest;
924 while (count--) { 925 while (count--) {
925 *reinterpret_cast<char*>(dest) = static_cast<char>(c); 926 *reinterpret_cast<char*>(dest) = static_cast<char>(c);
926 dest = reinterpret_cast<char*>(dest) + 1; 927 dest = reinterpret_cast<char*>(dest) + 1;
927 } 928 }
928 return start; 929 return start;
929 } 930 }
930 } // extern "C" 931 } // extern "C"
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698