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 "client/crashpad_client.h" | |
21 #include "test/paths.h" | |
22 #include "tools/tool_support.h" | |
23 | |
24 #if !defined(ARCH_CPU_X86) | |
Mark Mentovai
2015/10/31 01:29:33
#include "build/build_config.h"
scottmg
2015/10/31 18:39:47
Done.
| |
25 #error This test is only supported on x86. | |
26 #endif // !ARCH_CPU_X86 | |
27 | |
28 namespace crashpad { | |
29 namespace { | |
30 | |
31 int CrashyLoadZ7Main(int argc, char* argv[]) { | |
32 if (argc != 2) { | |
33 fprintf(stderr, "Usage: %s <server_pipe_name>\n", argv[0]); | |
34 return EXIT_FAILURE; | |
35 } | |
36 | |
37 CrashpadClient client; | |
38 if (!client.SetHandler(argv[1])) { | |
39 LOG(ERROR) << "SetHandler"; | |
40 return EXIT_FAILURE; | |
41 } | |
42 if (!client.UseHandler()) { | |
43 LOG(ERROR) << "UseHandler"; | |
44 return EXIT_FAILURE; | |
45 } | |
46 | |
47 // The DLL has /Z7 symbols embedded in the binary (rather than in a .pdb). | |
48 // There's only an x86 version of this dll as newer x64 toolchains can't | |
49 // generate this format any more. | |
50 base::FilePath z7_path = test::Paths::TestDataRoot().Append( | |
51 FILE_PATH_LITERAL("handler/win/z7_test.dll")); | |
52 HMODULE z7_test = LoadLibrary(z7_path.value().c_str()); | |
53 if (!z7_test) { | |
54 PLOG(ERROR) << "LoadLibrary"; | |
55 return EXIT_FAILURE; | |
56 } | |
57 FARPROC crash_me = GetProcAddress(z7_test, "?CrashMe@@YAXXZ"); | |
58 if (!crash_me) { | |
59 PLOG(ERROR) << "GetProcAddress"; | |
60 return EXIT_FAILURE; | |
61 } | |
62 reinterpret_cast<void(*)()>(crash_me)(); | |
63 | |
64 return EXIT_SUCCESS; | |
65 } | |
66 | |
67 } // namespace | |
68 } // namespace crashpad | |
69 | |
70 int wmain(int argc, wchar_t* argv[]) { | |
71 return crashpad::ToolSupport::Wmain(argc, argv, crashpad::CrashyLoadZ7Main); | |
72 } | |
OLD | NEW |