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 "util/win/ntstatus_logging.h" | |
16 | |
17 #include <string.h> | |
Mark Mentovai
2015/09/15 02:22:32
<string>, no .h
scottmg
2015/09/15 04:33:51
Done.
| |
18 | |
19 #include "base/strings/stringprintf.h" | |
20 | |
21 namespace { | |
22 | |
23 std::string FormatNtstatus(DWORD ntstatus) { | |
24 char msgbuf[256]; | |
25 DWORD flags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | | |
Mark Mentovai
2015/09/15 02:22:32
Optional: const, or write inline in the FormatMess
scottmg
2015/09/15 04:33:51
Done.
| |
26 FORMAT_MESSAGE_MAX_WIDTH_MASK | FORMAT_MESSAGE_FROM_HMODULE; | |
27 DWORD len = FormatMessageA(flags, | |
28 GetModuleHandle(L"ntdll.dll"), | |
29 ntstatus, | |
30 0, | |
31 msgbuf, | |
32 arraysize(msgbuf), | |
33 NULL); | |
Mark Mentovai
2015/09/15 02:22:32
nullptr
scottmg
2015/09/15 04:33:51
Done.
| |
34 if (len) { | |
35 return msgbuf; | |
36 } else { | |
37 return base::StringPrintf("<failed to retrieve error message (0x%x)>", | |
Mark Mentovai
2015/09/15 02:22:32
base/strings/stringprintf.h
scottmg
2015/09/15 04:33:51
Already there?
| |
38 GetLastError()); | |
39 } | |
40 } | |
41 | |
42 } // namespace | |
43 | |
44 namespace logging { | |
45 | |
46 NtstatusLogMessage::NtstatusLogMessage(const char* function, | |
47 const char* file_path, | |
48 int line, | |
49 LogSeverity severity, | |
50 DWORD ntstatus) | |
51 : LogMessage(function, file_path, line, severity), ntstatus_(ntstatus) { | |
Mark Mentovai
2015/09/15 02:22:32
:(
mini_chromium has a function argument and Chro
scottmg
2015/09/15 04:33:51
Do you find the function in the log particularly u
Mark Mentovai
2015/09/15 12:52:57
scottmg wrote:
| |
52 } | |
53 | |
54 NtstatusLogMessage::~NtstatusLogMessage() { | |
55 stream() << ": " << FormatNtstatus(ntstatus_) | |
56 << base::StringPrintf(" (0x%04x)", ntstatus_); | |
Mark Mentovai
2015/09/15 02:22:32
According to https://msdn.microsoft.com/en-us/libr
scottmg
2015/09/15 04:33:51
Done. (No idea what I was thinking there... 4 byte
| |
57 } | |
58 | |
59 } // namespace logging | |
OLD | NEW |