Guest User

Untitled

a guest
Oct 22nd, 2020
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4.  
  5. #include <stdint.h>
  6.  
  7. #include "base/clang_profiling_buildflags.h"
  8. #include "build/build_config.h"
  9. #include "chrome/installer/mini_installer/mini_installer.h"
  10.  
  11. // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx
  12. extern "C" IMAGE_DOS_HEADER __ImageBase;
  13.  
  14. extern "C" int __stdcall MainEntryPoint() {
  15. mini_installer::ProcessExitResult result =
  16. mini_installer::WMain(reinterpret_cast<HMODULE>(&__ImageBase));
  17. ::ExitProcess(result.exit_code);
  18. }
  19.  
  20.  
  21. // Executables instrumented with ASAN need CRT functions. We do not use
  22. // the /ENTRY switch for ASAN instrumented executable and a "main" function
  23. // is required.
  24. extern "C" int WINAPI wWinMain(HINSTANCE /* instance */,
  25. HINSTANCE /* previous_instance */,
  26. LPWSTR /* command_line */,
  27. int /* command_show */) {
  28. return MainEntryPoint();
  29. }
  30.  
  31.  
  32. // We don't link with the CRT (this is enforced through use of the /ENTRY linker
  33. // flag) so we have to implement CRT functions that the compiler generates calls
  34. // to.
  35. extern "C" {
  36.  
  37. __attribute__((used))
  38. void* memset(void* dest, int c, size_t count) {
  39. uint8_t* scan = reinterpret_cast<uint8_t*>(dest);
  40. while (count--)
  41. *scan++ = static_cast<uint8_t>(c);
  42. return dest;
  43. }
  44.  
  45. __attribute__((used))
  46. void* memcpy(void* destination, const void* source, size_t count) {
  47. auto* dst = reinterpret_cast<uint8_t*>(destination);
  48. auto* src = reinterpret_cast<const uint8_t*>(source);
  49. while (count--)
  50. *dst++ = *src++;
  51. return destination;
  52. }
  53.  
  54. } // extern "C"
  55.  
Add Comment
Please, Sign In to add comment