我目前正在玩用JavaScript编写的WinDBG脚本described by Microsoft

如何从JavaScript代码中访问文件系统?我对读写磁盘上的文件感兴趣。对于出于安全原因在浏览器上执行的JavaScript,这些功能被禁用,但是例如NodeJS具有自己的库来支持文件系统操作。

最佳答案

我按照整个Internet上的建议尝试了FileBlobActiveXObject,但是在WinDbg中它们都不起作用。

您可以尝试.dvalloc + .writemem + .dvfree的组合。以下是一个起点,但还远未完成:

function saveTextAsFile()
{
    var dbgOut = host.diagnostics.debugLog;
    var exec = host.namespace.Debugger.Utility.Control.ExecuteCommand;
    var output = exec(".dvalloc 0x10000");
    for (var line of output)
    {
        dbgOut("Output: "+line+"\n");
        var index = line.indexOf("starting at ");
        var address = line.substring(index+("starting at ".length));
        dbgOut("Allocated memory at "+address+"\n");
        exec(".writemem f:\\debug\\logs\\fromscript.txt "+address+" L10000")
        var output = exec(".dvfree " + address + " 0x10000");
        break;
    }
}

09-05 23:22
查看更多