OLD | NEW |
---|---|
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 // Read a REG_SZ value from the registry into the memory indicated by |value| | 67 // Read a REG_SZ value from the registry into the memory indicated by |value| |
68 // (of |value_size| wchar_t units). Returns ERROR_SUCCESS, | 68 // (of |value_size| wchar_t units). Returns ERROR_SUCCESS, |
69 // ERROR_FILE_NOT_FOUND, ERROR_MORE_DATA, or some other error. |value| is | 69 // ERROR_FILE_NOT_FOUND, ERROR_MORE_DATA, or some other error. |value| is |
70 // guaranteed to be null-terminated on success. | 70 // guaranteed to be null-terminated on success. |
71 LONG ReadValue(const wchar_t* value_name, | 71 LONG ReadValue(const wchar_t* value_name, |
72 wchar_t* value, | 72 wchar_t* value, |
73 size_t value_size) const; | 73 size_t value_size) const; |
74 | 74 |
75 // Write a REG_SZ value to the registry. |value| must be null-terminated. | 75 // Write a REG_SZ value to the registry. |value| must be null-terminated. |
76 // Returns ERROR_SUCCESS or an error code. | 76 // Returns ERROR_SUCCESS or an error code. |
77 LONG WriteValue(const wchar_t* value_name, const wchar_t* value); | 77 LONG WriteValue(const wchar_t* value_name, const wchar_t* value); |
grt (UTC plus 2)
2015/07/24 14:49:10
some suggestions:
- change this to WriteSZValue
-
bcwhite
2015/07/24 17:08:01
Done.
| |
78 LONG WriteDword(const wchar_t* value_name, DWORD value); | |
78 | 79 |
79 // Closes the key if it was open. | 80 // Closes the key if it was open. |
80 void Close(); | 81 void Close(); |
81 | 82 |
82 private: | 83 private: |
83 RegKey(const RegKey&); | 84 RegKey(const RegKey&); |
84 RegKey& operator=(const RegKey&); | 85 RegKey& operator=(const RegKey&); |
85 | 86 |
86 HKEY key_; | 87 HKEY key_; |
87 }; // class RegKey | 88 }; // class RegKey |
(...skipping 25 matching lines...) Expand all Loading... | |
113 } | 114 } |
114 return result; | 115 return result; |
115 } | 116 } |
116 | 117 |
117 LONG RegKey::WriteValue(const wchar_t* value_name, const wchar_t* value) { | 118 LONG RegKey::WriteValue(const wchar_t* value_name, const wchar_t* value) { |
118 return ::RegSetValueEx(key_, value_name, 0, REG_SZ, | 119 return ::RegSetValueEx(key_, value_name, 0, REG_SZ, |
119 reinterpret_cast<const BYTE*>(value), | 120 reinterpret_cast<const BYTE*>(value), |
120 (lstrlen(value) + 1) * sizeof(wchar_t)); | 121 (lstrlen(value) + 1) * sizeof(wchar_t)); |
121 } | 122 } |
122 | 123 |
124 LONG RegKey::WriteDword(const wchar_t* value_name, DWORD value) { | |
125 return ::RegSetValueEx(key_, value_name, 0, REG_DWORD, | |
126 reinterpret_cast<const BYTE*>(&value), | |
127 sizeof(value)); | |
128 } | |
129 | |
123 void RegKey::Close() { | 130 void RegKey::Close() { |
124 if (key_ != NULL) { | 131 if (key_ != NULL) { |
125 ::RegCloseKey(key_); | 132 ::RegCloseKey(key_); |
126 key_ = NULL; | 133 key_ = NULL; |
127 } | 134 } |
128 } | 135 } |
129 | 136 |
130 // Helper function to read a value from registry. Returns true if value | 137 // Helper function to read a value from registry. Returns true if value |
131 // is read successfully and stored in parameter value. Returns false otherwise. | 138 // is read successfully and stored in parameter value. Returns false otherwise. |
132 // |size| is measured in wchar_t units. | 139 // |size| is measured in wchar_t units. |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
879 // we don't need anymore. Let's give it back to the pool before running | 886 // we don't need anymore. Let's give it back to the pool before running |
880 // setup. | 887 // setup. |
881 ::SetProcessWorkingSetSize(::GetCurrentProcess(), -1, -1); | 888 ::SetProcessWorkingSetSize(::GetCurrentProcess(), -1, -1); |
882 | 889 |
883 if (exit_code == SUCCESS_EXIT_CODE) | 890 if (exit_code == SUCCESS_EXIT_CODE) |
884 exit_code = RunSetup(configuration, archive_path.get(), setup_path.get()); | 891 exit_code = RunSetup(configuration, archive_path.get(), setup_path.get()); |
885 | 892 |
886 if (ShouldDeleteExtractedFiles()) | 893 if (ShouldDeleteExtractedFiles()) |
887 DeleteExtractedFiles(base_path.get(), archive_path.get(), setup_path.get()); | 894 DeleteExtractedFiles(base_path.get(), archive_path.get(), setup_path.get()); |
888 | 895 |
896 const HKEY root_key = | |
grt (UTC plus 2)
2015/07/24 14:49:11
please move this into a helper function (WriteInst
bcwhite
2015/07/24 17:08:01
Done.
| |
897 configuration.is_system_level() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | |
898 const wchar_t* app_guid = configuration.chrome_app_guid(); | |
grt (UTC plus 2)
2015/07/24 14:49:11
this and SetInstallerFlags need to use the same Cl
bcwhite
2015/07/24 17:08:01
Done. Complicated logic, though. Please check th
| |
899 const REGSAM key_access = KEY_QUERY_VALUE | KEY_SET_VALUE; | |
grt (UTC plus 2)
2015/07/24 14:49:11
looks like KEY_QUERY_VALUE isn't needed here.
| |
900 RegKey key; | |
901 if (OpenClientStateKey(root_key, app_guid, key_access, &key)) { | |
902 key.WriteDword(kInstallerResultRegistryValue, | |
903 exit_code ? 1 /* FAILED_CUSTOM_ERROR */ : 0 /* SUCCESS */); | |
904 key.WriteDword(kInstallerErrorRegistryValue, exit_code); | |
905 key.WriteDword(kInstallerExtraCode1RegistryValue, ::GetLastError()); | |
grt (UTC plus 2)
2015/07/24 14:49:11
GetLastError must be called immediately after a fa
bcwhite
2015/07/24 17:08:01
Weird. I wrote that for initial testing and chang
| |
906 key.Close(); | |
907 } | |
908 | |
889 return exit_code; | 909 return exit_code; |
890 } | 910 } |
891 | 911 |
892 } // namespace mini_installer | 912 } // namespace mini_installer |
893 | 913 |
894 int MainEntryPoint() { | 914 int MainEntryPoint() { |
895 mini_installer::ProcessExitCode result = | 915 mini_installer::ProcessExitCode result = |
896 mini_installer::WMain(::GetModuleHandle(NULL)); | 916 mini_installer::WMain(::GetModuleHandle(NULL)); |
917 | |
897 ::ExitProcess(result); | 918 ::ExitProcess(result); |
898 } | 919 } |
899 | 920 |
900 // VC Express editions don't come with the memset CRT obj file and linking to | 921 // VC Express editions don't come with the memset CRT obj file and linking to |
901 // the obj files between versions becomes a bit problematic. Therefore, | 922 // the obj files between versions becomes a bit problematic. Therefore, |
902 // simply implement memset. | 923 // simply implement memset. |
903 // | 924 // |
904 // This also avoids having to explicitly set the __sse2_available hack when | 925 // This also avoids having to explicitly set the __sse2_available hack when |
905 // linking with both the x64 and x86 obj files which is required when not | 926 // linking with both the x64 and x86 obj files which is required when not |
906 // linking with the std C lib in certain instances (including Chromium) with | 927 // linking with the std C lib in certain instances (including Chromium) with |
907 // MSVC. __sse2_available determines whether to use SSE2 intructions with | 928 // MSVC. __sse2_available determines whether to use SSE2 intructions with |
908 // std C lib routines, and is set by MSVC's std C lib implementation normally. | 929 // std C lib routines, and is set by MSVC's std C lib implementation normally. |
909 extern "C" { | 930 extern "C" { |
910 #pragma function(memset) | 931 #pragma function(memset) |
911 void* memset(void* dest, int c, size_t count) { | 932 void* memset(void* dest, int c, size_t count) { |
912 void* start = dest; | 933 void* start = dest; |
913 while (count--) { | 934 while (count--) { |
914 *reinterpret_cast<char*>(dest) = static_cast<char>(c); | 935 *reinterpret_cast<char*>(dest) = static_cast<char>(c); |
915 dest = reinterpret_cast<char*>(dest) + 1; | 936 dest = reinterpret_cast<char*>(dest) + 1; |
916 } | 937 } |
917 return start; | 938 return start; |
918 } | 939 } |
919 } // extern "C" | 940 } // extern "C" |
OLD | NEW |