标签:
.foreach
.foreach 关键字分析一个或多个命令的输出并将该输出中每一个值作为另一个或多个命令的输入
.foreach [Options] ( Variable { InCommands } ) { OutCommands }
.foreach [Options] /s ( Variable "InString" ) { OutCommands }
.foreach [Options] /f ( Variable "InFile" ) { OutCommands }
Options
可以是下面选项的任意组合:
/pS InitialSkipNumber
使得开头的一些符号被跳过。InitialSkipNumber 指定不传递给OutCommands 的输出关键字的数量。
/ps SkipNumber
每次执行命令时都会跳过一些符号。每次将符号传递给OutCommands 之后,SkipNumber 个数的符号都会被忽略
我们首先搜索下带字符T的地址有哪些:
- 0:000> s -[1]a 0029eeec L1000 "T"
- 0x0029eefb
- 0x0029ef03
- 0x0029ef0b
- 0x0029ef15
- 0x0029f034
- 0x0029f06a
- 0x0029f07a
- 0x0029f08a
- 0x0029f09e
- 0x0029f356
- 0x0029f7f0
- 0x0029f989
- 0x0029fa50
然后我们用.foreach把它们da出来
- 0:000> .foreach(place{s -[1]a 0029eeec L1000 "T"}){da ${place}}
- ^ Syntax error in ‘.foreach(place{s -[1]a 0029eeec L1000 "T"}){da ${place}}‘
- 0:000> .foreach(place {s -[1]a 0029eeec L1000 "T"}){da ${place}}
- 0029eefb "Tencent\TSVulFw\TSVulFW.DAT"
- 0029ef03 "TSVulFw\TSVulFW.DAT"
- 0029ef0b "TSVulFW.DAT"
- 0029ef15 "T"
- 0029f034 "T"
- 0029f06a "T"
- 0029f07a "T"
- 0029f08a "T"
- 0029f09e "T"
- 0029f356 "TxSignDemo"
- 0029f7f0 "T.)"
- 0029f989 "Ti.."
- 0029fa50 "T.)"
注意place和{之间必须有空格!
现在从第三个开始,每隔一个显示一个:
- 0:000> .foreach/pS3 /ps1(place {s -[1]a 0029eeec L1000 "T"}){da ${place}}
- 0029ef15 "T"
- 0029f06a "T"
- 0029f08a "T"
- 0029f356 "TxSignDemo"
- 0029f989 "Ti.."
InFile
和/f 一起使用。指定要解析的文本文件;结果会传递给OutCommands 。文件名InFile 必须用引号括起来我们在C盘建立个2.txt,内容为:
- 0x0029eefb
- 0x0029ef03
- 0x0029ef0b
- 0x0029ef15
- 0x0029f034
- 0x0029f06a
- 0x0029f07a
- 0x0029f08a
- 0x0029f09e
- 0x0029f356
- 0x0029f7f0
- 0x0029f989
- 0x0029fa50
运行命令:
- 0:000> .foreach/f (place "c:\2.txt"){da ${place}}
- 0029eefb "Tencent\TSVulFw\TSVulFW.DAT"
- 0029ef03 "TSVulFw\TSVulFW.DAT"
- 0029ef0b "TSVulFW.DAT"
- 0029ef15 "T"
- 0029f034 "T"
- 0029f06a "T"
- 0029f07a "T"
- 0029f08a "T"
- 0029f09e "T"
- 0029f356 "TxSignDemo"
- 0029f7f0 "T.)"
- 0029f989 "Ti.."
- 0029fa50 "T.)"
当InCommands 的输出、InString 字符串或InFile 被解析时,任何数量的空格、tab符或回车都将会被当作单个分隔符。文本被分隔成的小片段被用来替换OutCommands 中的Variable
和/s 一起使用。指定一个要解析的字符串;结果会传递给OutCommands
- 0:000> .foreach/s (place "0029ef03;0029ef0b"){da ${place} }
- 0029ef03 "TSVulFw\TSVulFW.DAT"
- ^ Syntax error in ‘da 0029ef03;0029ef0b ‘
- 0:000> .foreach/s (place "0029ef03 0029ef0b"){da ${place}}
- 0029ef03 "TSVulFw\TSVulFW.DAT"
- 0029ef0b "TSVulFW.DAT"
所以,只是把空格,tab当成分隔符,不是分号!此原则适用于string和file
windbg-.foreach循环输入(windbg script)
标签:
原文地址:http://www.cnblogs.com/renyuan/p/5700966.html