事件 ID 与事件查看器中显示的不匹配

发布于 2024-09-14 07:10:10 字数 637 浏览 2 评论 0原文

系统事件日志中的事件具有以下详细信息:

Source: Kernel-General
Event ID: 1
Details: The system time has changed to ‎2010‎-‎07‎-‎17T02:58:20.285000000Z from ‎2010‎-‎07‎-‎17T02:58:20.285868600Z.

EVENTLOGRECORD 的 EventID 字段也为 1,因此它与我们在事件日志查看器中看到的内容相匹配。

到目前为止,一切都很好。

问题是,当您查看 advapi32.dll(该源从中获取消息的位置)时,您会看到以下内容:

ID:01000001
String: The system time has changed to %1 from %2.

事件日志查看器如何神奇地知道将这些额外位添加到 ID 中以找到正确的字符串?并非所有事件字符串都具有该高位,有些事件字符串还设置了其他高位。

使用 1 调用 FormatMessage 失败。用 x01000001 调用成功。但这不是事件日志记录包含的内容...:(

我找不到任何文档讨论这个问题(除了描述显示错误/严重性/设施/代码位的 ID 格式)。

In the System event log is an event with the following details:

Source: Kernel-General
Event ID: 1
Details: The system time has changed to ‎2010‎-‎07‎-‎17T02:58:20.285000000Z from ‎2010‎-‎07‎-‎17T02:58:20.285868600Z.

The EVENTLOGRECORD also has a 1 for the EventID field, so it matches what we see in the Event Log viewer.

So far so good.

The problem is, when you look in advapi32.dll which is where this source gets it's messages from, you see this:

ID:01000001
String: The system time has changed to %1 from %2.

How does the Event Log Viewer magically know to add those extra bits to the ID to find the right string? Not all event strings have that upper bit, and some have other upper bits set.

Calling FormatMessage with 1 fails. Calling it with x01000001 succeeds. But that's not what the event log record contains... :(

No docs that I can find discuss this at all (other that describing the ID format which shows error/severity/facility/code bits).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你另情深 2024-09-21 07:10:10

据推测,在 Windows XP 及更早版本中,事件 ID 直接映射到消息表中的消息 ID。在 Vista 及更高版本中,可以通过两种方式将事件 ID 映射到消息 ID。

  1. 事件限定符(这可能就是像 Brian 最初提到的那样,严重性被掩盖的情况)
  2. Windows 事件模板资源

本文更详细地描述了这两种方法:
https://github.com/libyal/libevtx/blob/master/documentation/Windows%20XML%20Event%20Log%20(EVTX).asciidoc#message-string-identifier

对于这个“系统时间有尤其是更改...”事件,Windows 10 正在使用 Windows 事件模板资源。如果您在注册表中查找此事件的 EventMessageFile 项(基于事件源 = Microsoft-Windows-Kernel-General),您将找到提供程序 DLL。

Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\System\Microsoft-Windows-Kernel-General

然后,您可以使用 Windows 事件实用程序查看提供程序 dll 的内容(添加 /gm :true 标志将显示消息文本):

wevtutil gp Microsoft-Windows-Kernel-General /ge:true

输出显示事件任务 5 的事件 ID 1 的消息 ID = 16777217 (0x01000001 )。

Supposedly, in Windows XP and earlier the Event ID was directly mapped to the Message ID within the message table. With Vista and later there are two ways that the Event ID can be mapped to the Message ID.

  1. Event Qualifiers (this is probably what looks like the severity being masked like Brian originally mentioned)
  2. Windows Event Template Resource

This article describes the two ways in more detail:
https://github.com/libyal/libevtx/blob/master/documentation/Windows%20XML%20Event%20Log%20(EVTX).asciidoc#message-string-identifier

For this "The system time has changed..." event in particular, Windows 10 is using the Windows Event Template Resource. If you lookup the EventMessageFile key, in the registry, for this event (based on the Event Source = Microsoft-Windows-Kernel-General) you find the Provider DLL.

Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\System\Microsoft-Windows-Kernel-General

You can then use the windows event utility to look at the contents of the provider dll (adding the /gm:true flag will display the message text):

wevtutil gp Microsoft-Windows-Kernel-General /ge:true

The output shows that Event ID 1 with an Event Task 5 has a Message ID = 16777217 (0x01000001).

怀念你的温柔 2024-09-21 07:10:10

和你一样,我在任何地方都找不到它的记录,但看起来事件查看器将 EVENTLOGRECORD 结构的 EventType 成员映射到 Severity 位消息表标识符。

例如,服务控制管理器事件 7035 的类型为“信息”,它映射到严重性值 1,生成消息 ID 0x40001B7B,这确实是事件查看器从 netevent.dll 显示的文本:%1 服务已成功发送 %2 控制。

同样,事件 7000 的类型为“错误”,映射到严重性 3 和消息 ID 0xC0001B58:< em>由于以下错误,%1 服务无法启动:%n%2

当然,这与您的示例不太相符;你确定你的 0 和 1 放在正确的位置吗?

Like you I can't find it documented anywhere, but it looks like Event Viewer maps the EventType member of the EVENTLOGRECORD structure to the Severity bits of the message table identifier.

So for example, Service Control Manager event 7035 is of type "Information", which maps to Severity value 1, yielding a message ID of 0x40001B7B, which is indeed the text that Event Viewer displays from netevent.dll: The %1 service was successfully sent a %2 control.

Similarly, event 7000 is of type "Error", mapping to Severity 3 and a message ID of 0xC0001B58: The %1 service failed to start due to the following error: %n%2

Of course that doesn't quite fit with your example; are you sure you've got your 0s and 1s in the right place?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文