以下是用 VBScript 编写的程序,可实现您所需的功能:

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("output.txt")

' 写入 0x5a 到地址 0x1
WriteMemory 1, 90

' 读取地址 0x1 的值
value = ReadMemory(1)

' 校验写入的值是否成功
If value = 90 Then
    objFile.WriteLine '写入成功,写入值为 0x5a'
Else
    objFile.WriteLine '写入失败,写入值为 ' & value
End If

Sub WriteMemory(address, value)
    Set objShell = CreateObject("WScript.Shell")
    command = "cmd /c 'echo " & value & " > \\.\PhysicalDrive0 -offset " & address & "'"
    objShell.Run command, 0, True
End Sub

Function ReadMemory(address)
    Set objShell = CreateObject("WScript.Shell")
    command = "cmd /c 'dd if=\\.\PhysicalDrive0 bs=1 count=1 skip=" & address & " 2>nul'"
    Set objExec = objShell.Exec(command)
    If Not objExec.StdOut.AtEndOfStream Then
        ReadMemory = Asc(objExec.StdOut.ReadAll)
    End If
End Function

该程序将写入值 0x5a 到地址 0x1,然后读取该地址上的值,并根据读取结果校验写入是否成功。程序运行结果将输出到名为 'output.txt' 的文本文件中。

VBScript 循环程序:写入和校验内存值

原文地址: https://www.cveoy.top/t/topic/oHcK 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录