使用VBS修改二进制文件HEX数据
public binarydata
if (lcase(right(wscript.fullname,11))="wscript.exe") then
wscript.quit(0)
end if
if wscript.arguments.count<4 then
wscript.echo "change file hex. by: lxzzr lxzzr@21cn.com"
wscript.echo ""
wscript.echo "usage: cscript.exe " & wscript.scriptname & " filepath savepath shex dhex"
wscript.echo " : cscript.exe chex.vbs "".\test.exe"" "".\new.exe"" ""80 7a 01 61"" ""80 7a 01 61"""
wscript.quit(0)
end if
shex = replace(lcase(wscript.arguments(2)), " ", "")
dhex = replace(lcase(wscript.arguments(3)), " ", "")
wscript.echo "file: " & wscript.arguments(0)
wscript.echo "shex: " & wscript.arguments(2)
wscript.echo "dhex: " & wscript.arguments(3)
readbinary(wscript.arguments(0))
mydata = replace(binarydata, shex, dhex)
writebinary wscript.arguments(1), mydata
wscript.echo "all done."
wscript.quit(0)
function readbinary(filename)
dim stream, objxml, mynode
set objxml = createobject("microsoft.xmldom")
set mynode = objxml.createelement("binary")
set stream = createobject("adodb.stream")
mynode.datatype = "bin.hex"
stream.type = 1
stream.open
stream.loadfromfile filename
mynode.nodetypedvalue = stream.read
stream.close
binarydata = mynode.text
set mynode = nothing
set stream = nothing
set objxml = nothing
end function
function writebinary(filename, bufferdata)
dim stream, objxml, mynode
set objxml = createobject("microsoft.xmldom")
set mynode = objxml.createelement("binary")
set stream = createobject("adodb.stream")
mynode.datatype = "bin.hex"
mynode.text = bufferdata
stream.type = 1
stream.open
stream.write mynode.nodetypedvalue
stream.savetofile filename, 2
stream.close
set stream = nothing
set mynode = nothing
set objxml = nothing
end function
推荐阅读
-
C#中使用XmlDocument类来创建和修改XML格式的数据文件
-
使用VBS修改二进制文件HEX数据
-
vbs中使用 ADO 读取所有数据均在一行上的文本文件的代码
-
使用bbed修改文件头,推进scn,恢复offlinedrop的数据文件
-
C#中使用XmlDocument类来创建和修改XML格式的数据文件
-
音频文件使用二进制存入数据库,php有什么方法可以把二进制转换成音频文件?该怎么解决
-
使用SQL Server存储过程将BLOB/Image等图片或二进制数据另存为磁盘文件
-
音频文件使用二进制存入数据库,php有什么方法可以把二进制转换成音频文件?该怎么解决
-
音频文件使用二进制存入数据库,php有什么方法可以把二进制转换成音频文件?该怎么解决
-
使用VBS修改二进制文件HEX数据