set tsk = wscript.createobject("wscript.shell") '游戏正在运行的话,不做任何操作
for each ho in getobject("winmgmts:").instancesof("win32_process")
if lcase(ho.name) = lcase(prog) then
msgbox "RO正在运行,请先关闭游戏!!",64," RO"
wscript.quit
exit for
end if
next
set fso = createobject("scripting.filesystemobject") '去掉文件的只读属性
if fso.fileexists(prog) then
set fsf = fso.getfile(prog)
if fsf.attributes and 1 then fsf.attributes = fsf.attributes xor 1
set xml1 = createobject("microsoft.xmldom") '加载文件
xml1.loadxml "<?xml version=""1.0""?>"
set node1 = xml1.createelement("binary")
node1.datatype = "bin.hex"
set stream1 = createobject("adodb.stream")
stream1.type = 1
stream1.open
stream1.loadfromfile prog
node1.nodetypedvalue = stream1.read
stream1.close
data = node1.text
find1 = instr(1,data,code1,1)
if find1 <> 0 then
if instr(find1+16,data,code1,1) <> 0 then '找到两处就不改了
msgbox prog& " 版本过新,无法修改!! =..=",64," RO"
else
data = replace(data,code1,code2,1,1,1) '只找到一处, 开始修改, 并备份
set xml2 = createobject("microsoft.xmldom")
xml2.loadxml "<?xml version=""1.0""?>"
set node2 = xml2.createelement("binary")
node2.datatype = "bin.hex"
node2.nodetypedvalue = data
prog2 = replace("备份"&now&" "&prog,":",".")
prog2 = replace(prog2,"/","-")
fso.copyfile prog,prog2
set stream2 = createobject("adodb.stream")
stream2.type = 1
stream2.open
stream2.write node2.nodetypedvalue
stream2.savetofile prog,2
stream2.close
msgbox prog& " 修改成功!!"&chr(10)& "原文件已备份为:"&chr(10)&prog2,64," RO"
end if
else
find2 = instr(1,data,code2,1)
if find2 <> 0 then
msgbox prog& " 已经是无限视野,无需修改!!",64," RO" '已经是无限视野的话不做修改
else
msgbox prog& " 版本未知!! 无法修改!! 可能CODE已失效...",64," RO" '找不到特征码
end if
end if
else
msgbox "找不到 " &prog& " !!",64," RO" '找不到文件
end if