本帖最后由 batman 于 2011-4-23 11:19 编辑
加入debug的测试
代码:- @echo off&setlocal enabledelayedexpansion
- call :lp 1 10 random
- call :lp 11 100 random
- del /q db
- goto :eof
- :lp
- for /l %%a in (%1,1,%2) do set "_%%a=!%3!"
- (echo d2cl2
- echo q
- echo,
- )>db
- (for /f "skip=1 tokens=2,3" %%a in ('debug^<db') do (
- echo d%%b%%a:0380&echo q&echo,
- ))>tem
- del /q db&ren tem db
- debug<db>%1.txt
- start %1.txt
复制代码 1.txt- -d0D96:0380
-
- 0D96:0380 00 5F 31 3D 36 31 33 35-00 5F 31 30 3D 32 38 36 ._1=6135._10=286
- 0D96:0390 31 32 00 5F 32 3D 32 39-36 38 30 00 5F 33 3D 32 12._2=29680._3=2
- 0D96:03A0 33 30 36 39 00 5F 34 3D-33 31 32 32 37 00 5F 35 3069._4=31227._5
- 0D96:03B0 3D 38 34 37 37 00 5F 36-3D 32 33 39 38 38 00 5F =8477._6=23988._
- 0D96:03C0 37 3D 33 32 36 31 36 00-5F 38 3D 32 39 35 38 00 7=32616._8=2958.
- 0D96:03D0 5F 39 3D 32 37 37 32 31-00 42 4C 41 53 54 45 52 _9=27721.BLASTER
- 0D96:03E0 3D 41 32 32 30 20 49 35-20 44 31 20 50 33 33 30 =A220 I5 D1 P330
- 0D96:03F0 20 54 33 00 00 01 00 43-3A 5C 57 49 4E 44 4F 57 T3....C:\WINDOW
- -q
复制代码 11.txt- -d0E0D:0380
-
- 0E0D:0380 00 5F 31 3D 36 31 33 35-00 5F 31 30 3D 32 38 36 ._1=6135._10=286
- 0E0D:0390 31 32 00 5F 31 30 30 3D-31 34 36 31 34 00 5F 31 12._100=14614._1
- 0E0D:03A0 31 3D 35 33 30 37 00 5F-31 32 3D 33 30 32 38 37 1=5307._12=30287
- 0E0D:03B0 00 5F 31 33 3D 31 30 35-31 00 5F 31 34 3D 35 39 ._13=1051._14=59
- 0E0D:03C0 36 37 00 5F 31 35 3D 32-37 34 37 38 00 5F 31 36 67._15=27478._16
- 0E0D:03D0 3D 31 35 33 37 33 00 5F-31 37 3D 31 37 30 31 33 =15373._17=17013
- 0E0D:03E0 00 5F 31 38 3D 32 36 38-31 37 00 5F 31 39 3D 38 ._18=26817._19=8
- 0E0D:03F0 31 33 31 00 5F 32 3D 32-39 36 38 30 00 5F 32 30 131._2=29680._20
- -q
复制代码 由此可见cmd在变量有变化的情况下会重新分配内存的储存地址,1.txt和11.txt中开始的地址分别为0D96:0380和0E0D:0380,而这一存储过程是按变量名+=号+值的全字符(实际上就是变量名,因为cmd是不会允许有同名变量的存在的)的ansi序列先后进行的。 |