OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
| 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at |
| 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. |
| 14 |
| 15 #include <stdlib.h> |
| 16 #include <windows.h> |
| 17 |
| 18 #include "base/files/file_path.h" |
| 19 #include "base/logging.h" |
| 20 #include "build/build_config.h" |
| 21 #include "client/crashpad_client.h" |
| 22 #include "test/paths.h" |
| 23 #include "tools/tool_support.h" |
| 24 |
| 25 #if !defined(ARCH_CPU_X86) |
| 26 #error This test is only supported on x86. |
| 27 #endif // !ARCH_CPU_X86 |
| 28 |
| 29 namespace crashpad { |
| 30 namespace { |
| 31 |
| 32 int CrashyLoadZ7Main(int argc, char* argv[]) { |
| 33 if (argc != 2) { |
| 34 fprintf(stderr, "Usage: %s <server_pipe_name>\n", argv[0]); |
| 35 return EXIT_FAILURE; |
| 36 } |
| 37 |
| 38 CrashpadClient client; |
| 39 if (!client.SetHandler(argv[1])) { |
| 40 LOG(ERROR) << "SetHandler"; |
| 41 return EXIT_FAILURE; |
| 42 } |
| 43 if (!client.UseHandler()) { |
| 44 LOG(ERROR) << "UseHandler"; |
| 45 return EXIT_FAILURE; |
| 46 } |
| 47 |
| 48 // The DLL has /Z7 symbols embedded in the binary (rather than in a .pdb). |
| 49 // There's only an x86 version of this dll as newer x64 toolchains can't |
| 50 // generate this format any more. |
| 51 base::FilePath z7_path = test::Paths::TestDataRoot().Append( |
| 52 FILE_PATH_LITERAL("handler/win/z7_test.dll")); |
| 53 HMODULE z7_test = LoadLibrary(z7_path.value().c_str()); |
| 54 if (!z7_test) { |
| 55 PLOG(ERROR) << "LoadLibrary"; |
| 56 return EXIT_FAILURE; |
| 57 } |
| 58 FARPROC crash_me = GetProcAddress(z7_test, "CrashMe"); |
| 59 if (!crash_me) { |
| 60 PLOG(ERROR) << "GetProcAddress"; |
| 61 return EXIT_FAILURE; |
| 62 } |
| 63 reinterpret_cast<void(*)()>(crash_me)(); |
| 64 |
| 65 return EXIT_SUCCESS; |
| 66 } |
| 67 |
| 68 } // namespace |
| 69 } // namespace crashpad |
| 70 |
| 71 int wmain(int argc, wchar_t* argv[]) { |
| 72 return crashpad::ToolSupport::Wmain(argc, argv, crashpad::CrashyLoadZ7Main); |
| 73 } |
OLD | NEW |