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

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

Issue 6676030: WinDDK ATL and MSVC express compatability (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Take out atlcheck; VC2005e compat 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
« no previous file with comments | « chrome/installer/mini_installer.gyp ('k') | chrome/installer/setup/setup.rc » ('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-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 appropriate flags.
10 // 10 //
11 // In order to be really small we don't link against the CRT and we define the 11 // In order to be really small the app doesn't link against the CRT and
12 // following compiler/linker flags: 12 // defines the following compiler/linker flags:
13 // EnableIntrinsicFunctions="true" compiler: /Oi 13 // EnableIntrinsicFunctions="true" compiler: /Oi
14 // BasicRuntimeChecks="0" 14 // BasicRuntimeChecks="0"
15 // BufferSecurityCheck="false" compiler: /GS- 15 // BufferSecurityCheck="false" compiler: /GS-
16 // EntryPointSymbol="MainEntryPoint" linker: /ENTRY 16 // EntryPointSymbol="MainEntryPoint" linker: /ENTRY
17 // IgnoreAllDefaultLibraries="true" linker: /NODEFAULTLIB 17 // IgnoreAllDefaultLibraries="true" linker: /NODEFAULTLIB
18 // OptimizeForWindows98="1" liker: /OPT:NOWIN98 18 // OptimizeForWindows98="1" liker: /OPT:NOWIN98
19 // linker: /SAFESEH:NO 19 // linker: /SAFESEH:NO
20 // Also some built-in code that the compiler relies on is not defined so we
21 // are forced to manually link against it. It comes in the form of two
22 // object files that exist in $(VCInstallDir)\crt\src which are memset.obj and
23 // P4_memset.obj. These two object files rely on the existence of a static
24 // variable named __sse2_available which indicates the presence of intel sse2
25 // extensions. We define it to false which causes a slower but safe code for
26 // memcpy and memset intrinsics.
27 20
28 // having the linker merge the sections is saving us ~500 bytes. 21 // have the linker merge the sections, saving us ~500 bytes.
29 #pragma comment(linker, "/MERGE:.rdata=.text") 22 #pragma comment(linker, "/MERGE:.rdata=.text")
30 23
31 #include <windows.h> 24 #include <windows.h>
32 #include <setupapi.h> 25 #include <setupapi.h>
33 #include <shellapi.h> 26 #include <shellapi.h>
34 27
35 #include "chrome/installer/mini_installer/appid.h" 28 #include "chrome/installer/mini_installer/appid.h"
36 #include "chrome/installer/mini_installer/decompress.h" 29 #include "chrome/installer/mini_installer/decompress.h"
37 #include "chrome/installer/mini_installer/mini_installer.h" 30 #include "chrome/installer/mini_installer/mini_installer.h"
38 #include "chrome/installer/mini_installer/mini_string.h" 31 #include "chrome/installer/mini_installer/mini_string.h"
39 #include "chrome/installer/mini_installer/pe_resource.h" 32 #include "chrome/installer/mini_installer/pe_resource.h"
40 33
41 // arraysize borrowed from basictypes.h 34 // arraysize borrowed from basictypes.h
42 template <typename T, size_t N> 35 template <typename T, size_t N>
43 char (&ArraySizeHelper(T (&array)[N]))[N]; 36 char (&ArraySizeHelper(T (&array)[N]))[N];
44 #define arraysize(array) (sizeof(ArraySizeHelper(array))) 37 #define arraysize(array) (sizeof(ArraySizeHelper(array)))
45 38
46 // Required linker symbol. See remarks above.
47 extern "C" unsigned int __sse2_available = 0;
48
49 namespace mini_installer { 39 namespace mini_installer {
50 40
51 typedef StackString<MAX_PATH> PathString; 41 typedef StackString<MAX_PATH> PathString;
52 typedef StackString<MAX_PATH * 4> CommandString; 42 typedef StackString<MAX_PATH * 4> CommandString;
53 43
54 // This structure passes data back and forth for the processing 44 // This structure passes data back and forth for the processing
55 // of resource callbacks. 45 // of resource callbacks.
56 struct Context { 46 struct Context {
57 // Input to the call back method. Specifies the dir to save resources. 47 // Input to the call back method. Specifies the dir to save resources.
58 const wchar_t* base_path; 48 const wchar_t* base_path;
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 805
816 return exit_code; 806 return exit_code;
817 } 807 }
818 808
819 } // namespace mini_installer 809 } // namespace mini_installer
820 810
821 int MainEntryPoint() { 811 int MainEntryPoint() {
822 int result = mini_installer::WMain(::GetModuleHandle(NULL)); 812 int result = mini_installer::WMain(::GetModuleHandle(NULL));
823 ::ExitProcess(result); 813 ::ExitProcess(result);
824 } 814 }
815
816 // VC Express editions don't come with the memset CRT obj file and linking to
817 // the obj files between versions becomes a bit problematic. Therefore,
818 // simply implement memset.
819 //
820 // This also avoids having to explicitly set the __sse2_available hack when
821 // linking with both the x64 and x86 obj files which is required when not
822 // linking with the std C lib in certain instances (including Chromium) with
823 // MSVC. __sse2_available determines whether to use SSE2 intructions with
824 // std C lib routines, and is set by MSVC's std C lib implementation normally.
825 extern "C" {
826 #pragma function(memset)
827 void* memset(void* dest, int c, size_t count) {
828 // Simplistic 32-bit memset C implementation which assumes properly aligned
829 // memory; performance hit on memory that isn't properly aligned, but still
830 // better overall then a 8-bit implementation.
831 size_t adjcount = count >> 2;
832 UINT32 fill = (c << 24 | c << 16 | c << 8 | c);
833 UINT32* dest32 = reinterpret_cast<UINT32*>(dest);
834 UINT8* dest8 = reinterpret_cast<UINT8*>(dest);
835
836 // Take care of the ending 0-3 bytes (binary 11 = 3). The lack of breaks is
837 // deliberate; it falls through for each byte. Think of it a simplified for
838 // loop.
839 switch (count - (adjcount << 2)) {
840 case 3:
841 dest8[count - 3] = c;
842 case 2:
843 dest8[count - 2] = c;
844 case 1:
845 dest8[count - 1] = c;
846 }
847
848 while (adjcount-- > 0) // Copy the rest, 4 bytes/32 bits at a time
849 *(dest32++) = fill;
850
851 return dest;
852 }
853 } // extern "C"
OLDNEW
« no previous file with comments | « chrome/installer/mini_installer.gyp ('k') | chrome/installer/setup/setup.rc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698