我正在尝试创建一个 powershell 脚本来读取存储在 AppData\Local\Microsoft\Windows\WebCache\WebCache.dat 中的 IE 10/11 互联网历史记录。
我正在使用Managed Esent +- 与 .NET 中的 Win32 Jet api 交互。
我的问题是我永远无法真正打开数据库,因为当我调用 JetAttachDatabase 时会抛出 EsentPageSizeMismatchException。在对这个错误做了一些研究后,我发现 IE WebCache 的页面大小为 32K。当我尝试通过将 DatabasePageSize 系统参数设置为 0x8000 来纠正此问题时,JetInit 开始抛出相同的异常。
这是我的代码
#stop the things locking the database
stop-process -name taskhost
stop-process -name dllhost
#give powershell access to the interop dlls
add-type -path "$PSScriptRoot\ManagedEsent 1.6\Esent.Interop.dll"
$instance = [Microsoft.Isam.Esent.Interop.JET_INSTANCE]::Nil
#set page size
[Microsoft.Isam.Esent.Interop.api]::JetSetSystemParameter(
$instance,
[Microsoft.Isam.Esent.Interop.JET_SESID]::Nil,
[Microsoft.Isam.Esent.Interop.JET_param]::DatabasePageSize,
0x8000,
$null
)
[Microsoft.Isam.Esent.Interop.Api]::JetCreateInstance([ref]$instance,"testing")
# init the instance, throws EsentPageSizeMismatchException if the page size is not default
[Microsoft.Isam.Esent.Interop.Api]::JetInit([ref]$instance)
$sesid = [Microsoft.Isam.Esent.Interop.JET_SESID]::Nil
[Microsoft.Isam.Esent.Interop.Api]::JetBeginSession($instance,[ref]$sesid,$null,$null)
# throws EsentPageSizeMismatchException if page size is default
[Microsoft.Isam.Esent.Interop.api]::JetAttachDatabase(
$sesid,
"C:\Users\Administrator\AppData\Local\Microsoft\Windows\WebCache\WebCacheV01.dat",
[Microsoft.Isam.Esent.Interop.AttachDatabaseGrbit]::ReadOnly
)
...
似乎 ESENT 引擎不喜欢具有非默认页面大小,但我已经搜索了互联网,似乎没有办法更改引擎页面大小。是什么导致了这个错误?