如何从EventMessageFile(.dll)中读取事件消息详细信息? [重复]

问题描述 投票:0回答:1

您好我想编写一个程序,其中一部分将读取事件日志,并在发生重要事件时通知用户。

据我了解,由于记录了如此多的日志,因此Windows使用EventMessageFiles(可能是CategoryMessageFile和ParameterMessageFile)来减小日志的大小。可能的事件ID,与它们相关的描述,所需的参数以及它们在描述中的使用方式以及其他可能在这些文件中指定。我想阅读这些准备好的文件,知道哪些eventIds很重要,以及我应该如何通知用户。

例如,假设我想阅读谷歌chromes事件消息文件。我认为最接近它的是当我尝试这个时:

    import win32api,win32con

    eventmessagefile_addr = "C:\\Program 
    Files\\Google\\Chrome\\Application\\73.0.3683.103\\eventlog_provider.dll"

    eventmessagefile_handle = win32api.LoadLibraryEx(eventmessagefile_addr,None,win32con.LOAD_LIBRARY_AS_DATAFILE)

    resource_types = win32api.EnumResourceTypes(eventmessagefile_handle)  # 
    resource_types = [11,16]

    resorce11 = win32api.EnumResourceNames(lbl,"#11") # I don't know what this means but resource11 = [1]

    data= win32api.LoadResource(lbl,"#11",1) # now this gives me some bytes that I have no idea what they are and data.decode('utf-8') fails.

那我该怎么读这些dll文件呢。

PS:python是首选,但c ++和c#也可以。

winapi event-log
1个回答
0
投票

资源type 11是消息表。

MESSAGE_RESOURCE_DATA结构可以包含一个或多个MESSAGE_RESOURCE_BLOCK结构,每个结构可以包含一个或多个MESSAGE_RESOURCE_ENTRY结构。

© www.soinside.com 2019 - 2024. All rights reserved.