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

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

Issue 6693015: Switch out the setup api for using the cabinet API directly.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 appropiate flags. 9 // 2) run the real installer (setup.exe) with appropiate flags.
10 // 10 //
(...skipping 15 matching lines...) Expand all
26 // memcpy and memset intrinsics. 26 // memcpy and memset intrinsics.
27 27
28 // having the linker merge the sections is saving us ~500 bytes. 28 // having the linker merge the sections is saving us ~500 bytes.
29 #pragma comment(linker, "/MERGE:.rdata=.text") 29 #pragma comment(linker, "/MERGE:.rdata=.text")
30 30
31 #include <windows.h> 31 #include <windows.h>
32 #include <setupapi.h> 32 #include <setupapi.h>
33 #include <shellapi.h> 33 #include <shellapi.h>
34 34
35 #include "chrome/installer/mini_installer/appid.h" 35 #include "chrome/installer/mini_installer/appid.h"
36 #include "chrome/installer/mini_installer/decompress.h"
36 #include "chrome/installer/mini_installer/mini_installer.h" 37 #include "chrome/installer/mini_installer/mini_installer.h"
37 #include "chrome/installer/mini_installer/mini_string.h" 38 #include "chrome/installer/mini_installer/mini_string.h"
38 #include "chrome/installer/mini_installer/pe_resource.h" 39 #include "chrome/installer/mini_installer/pe_resource.h"
39 40
40 // arraysize borrowed from basictypes.h 41 // arraysize borrowed from basictypes.h
41 template <typename T, size_t N> 42 template <typename T, size_t N>
42 char (&ArraySizeHelper(T (&array)[N]))[N]; 43 char (&ArraySizeHelper(T (&array)[N]))[N];
43 #define arraysize(array) (sizeof(ArraySizeHelper(array))) 44 #define arraysize(array) (sizeof(ArraySizeHelper(array)))
44 45
45 // Required linker symbol. See remarks above. 46 // Required linker symbol. See remarks above.
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 421
421 // setup.exe wasn't sent as 'B7', lets see if it was sent as 'BL' 422 // setup.exe wasn't sent as 'B7', lets see if it was sent as 'BL'
422 // (compressed setup). 423 // (compressed setup).
423 if (!::EnumResourceNames(module, kLZCResourceType, OnResourceFound, 424 if (!::EnumResourceNames(module, kLZCResourceType, OnResourceFound,
424 reinterpret_cast<LONG_PTR>(&context)) && 425 reinterpret_cast<LONG_PTR>(&context)) &&
425 ::GetLastError() != ERROR_RESOURCE_TYPE_NOT_FOUND) 426 ::GetLastError() != ERROR_RESOURCE_TYPE_NOT_FOUND)
426 return false; 427 return false;
427 428
428 if (setup_path->length() > 0) { 429 if (setup_path->length() > 0) {
429 // Uncompress LZ compressed resource. Setup is packed with 'MSCF' 430 // Uncompress LZ compressed resource. Setup is packed with 'MSCF'
430 // as opposed to old DOS way of 'SZDD'. Hence use SetupInstallFile 431 // as opposed to old DOS way of 'SZDD'. Hence we don't use LZCopy.
431 // instead of LZCopy. 432 bool success = mini_installer::Expand(setup_path->get(),
432 // Note that the API will automatically delete the original file 433 setup_dest_path.get());
433 // if the extraction was successful. 434 ::DeleteFile(setup_path->get());
434 // TODO(tommi): Use the cabinet API directly. 435 if (success) {
435 if (!SetupInstallFile(NULL, NULL, setup_path->get(), NULL, 436 if (!setup_path->assign(setup_dest_path.get())) {
436 setup_dest_path.get(), 437 ::DeleteFile(setup_dest_path.get());
437 SP_COPY_DELETESOURCE | SP_COPY_SOURCE_ABSOLUTE, 438 success = false;
438 NULL, NULL)) { 439 }
439 DeleteFile(setup_path->get());
440 return false;
441 } 440 }
442 441
443 return setup_path->assign(setup_dest_path.get()); 442 return success;
444 } 443 }
445 444
446 // setup.exe still not found. So finally check if it was sent as 'BN' 445 // setup.exe still not found. So finally check if it was sent as 'BN'
447 // (uncompressed setup). 446 // (uncompressed setup).
448 // TODO(tommi): We don't need BN anymore so let's remove it (and remove 447 // TODO(tommi): We don't need BN anymore so let's remove it (and remove
449 // it from create_installer_archive.py). 448 // it from create_installer_archive.py).
450 if (!::EnumResourceNames(module, kBinResourceType, OnResourceFound, 449 if (!::EnumResourceNames(module, kBinResourceType, OnResourceFound,
451 reinterpret_cast<LONG_PTR>(&context)) && 450 reinterpret_cast<LONG_PTR>(&context)) &&
452 ::GetLastError() != ERROR_RESOURCE_TYPE_NOT_FOUND) 451 ::GetLastError() != ERROR_RESOURCE_TYPE_NOT_FOUND)
453 return false; 452 return false;
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 815
817 return exit_code; 816 return exit_code;
818 } 817 }
819 818
820 } // namespace mini_installer 819 } // namespace mini_installer
821 820
822 int MainEntryPoint() { 821 int MainEntryPoint() {
823 int result = mini_installer::WMain(::GetModuleHandle(NULL)); 822 int result = mini_installer::WMain(::GetModuleHandle(NULL));
824 ::ExitProcess(result); 823 ::ExitProcess(result);
825 } 824 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698