如何从MSI fi获取[Binary Data]值

2024-05-16 20:28:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用pythonmsilib库读取MSI文件。我的目标是从二进制表中提取[Binary Data]并将其转储到一个文件中。(使用ORCA工具,我们可以通过双击[binary data]单元格提取二进制数据并写入文件)

我找不到任何msilib方法来获取二进制数据。它有方法使用记录.GetString(字段)。[and not be working as this Binary]但[and not give for this Binary]不是预期的数据。在

这是代码片段

import msilib
# msi file path which is to be read
msiFilePath = "C:/msi/test.msi"
dbObj = msilib.OpenDatabase(msiFilePath, msilib.MSIDBOPEN_READONLY)
sqlQuery = "select * from Binary"
view = dbObj.OpenView(sqlQuery)
view.Execute(None)
cur_record = viewObj.Fetch()
# In Binary table; Column no 1 have string data and Column # 2 have [Binary Data]
cur_record.GetString(2)

执行时:

^{pr2}$

有办法吗?在


Tags: and文件数据方法data二进制notbe
1条回答
网友
1楼 · 发布于 2024-05-16 20:28:07

msilibnot fully featured。具体来说,它不能读取二进制数据。在

Pygame拥有一个功能更全面和可扩展的(因为它是用Python编写的,带有cypes),msidb。pygame文档中似乎没有涉及到它,但是源代码非常简单。在

您需要的msiapi是MsiRecordReadStream,它是游戏.msidb包装在get_field_stream中,它由其Cursor类使用。在

相关问题 更多 >