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

Unified Diff: chrome/installer/mini_installer/mini_installer_exe_main.cc

Issue 2661463003: Extract the mini_installer's entrypoint into its own source file. (Closed)
Patch Set: shrink memset 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/installer/mini_installer/mini_installer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/mini_installer/mini_installer_exe_main.cc
diff --git a/chrome/installer/mini_installer/mini_installer_exe_main.cc b/chrome/installer/mini_installer/mini_installer_exe_main.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b592cd23e25425445c3d3a1eeeaaf2cb6226af8d
--- /dev/null
+++ b/chrome/installer/mini_installer/mini_installer_exe_main.cc
@@ -0,0 +1,47 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <stdint.h>
+
+#include "chrome/installer/mini_installer/mini_installer.h"
+
+// http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx
+extern "C" IMAGE_DOS_HEADER __ImageBase;
+
+extern "C" int __stdcall MainEntryPoint() {
+ mini_installer::ProcessExitResult result =
+ mini_installer::WMain(reinterpret_cast<HMODULE>(&__ImageBase));
+ ::ExitProcess(result.exit_code);
+}
+
+#if defined(ADDRESS_SANITIZER)
+// Executables instrumented with ASAN need CRT functions. We do not use
+// the /ENTRY switch for ASAN instrumented executable and a "main" function
+// is required.
+extern "C" int WINAPI wWinMain(HINSTANCE /* instance */,
+ HINSTANCE /* previous_instance */,
+ LPWSTR /* command_line */,
+ int /* command_show */) {
+ return MainEntryPoint();
+}
+#endif
+
+// VC Express editions don't come with the memset CRT obj file and linking to
+// the obj files between versions becomes a bit problematic. Therefore,
+// simply implement memset.
+//
+// This also avoids having to explicitly set the __sse2_available hack when
+// linking with both the x64 and x86 obj files which is required when not
+// linking with the std C lib in certain instances (including Chromium) with
+// MSVC. __sse2_available determines whether to use SSE2 intructions with
+// std C lib routines, and is set by MSVC's std C lib implementation normally.
+extern "C" {
+#pragma function(memset)
+void* memset(void* dest, int c, size_t count) {
+ uint8_t* scan = reinterpret_cast<uint8_t*>(dest);
+ while (count--)
+ *scan++ = static_cast<uint8_t>(c);
+ return dest;
+}
+} // extern "C"
« no previous file with comments | « chrome/installer/mini_installer/mini_installer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698