|
本帖最后由 xzf680 于 2015-10-18 02:47 编辑
测试过了,有些会乱码,以下为电脑店配置:
#!PECMD
#!code=936
@LOGS **ON=0
FIND $%&__LOGS%=, IFEX XU.LOG, LOGS **ON=1 **2 **nl=1 * XU.LOG
ENVI^ EnviMode=1 //閬垮厤鎰忓閿欒锛岀┖鍙橀噺锛屽閮ㄥ彉閲忥紝
ENVI^ ForceLocal=1
SET$ &NL=0D 0A
SET$ &TAB=09
//{TP_MBR=1, TP_OS=2, TP_PEOUT=3, TP_DISK=4, TP_PE_PART=5, TP_PE_DISK, TP_PE_ISO=7, TP_PART, TP_DATA=9, TP_ISO=10, TP_RAW, TP_LIST, TP_FILE, TP_XFILE};
SET-def TP_MBR=0x01
SET-def TP_PE_ISO=0x07
SET-def TP_DATA=0x09
SET-def TP_ISO=0x0A
SET-def TP_SYSBAK=0xF0
SET-def TP_EFILDR=0xF1
SET-def TP_BIOSBOT=0xF3
TEAM ENVI &&SZ=-1| ENVI &&OFF=-1| ENVI &&FAT=-1| SET &PART_TP=hd| SET &BEFI=0
TEAM SET &PART0=| SET &PARTS=| SET &PARTX=| SET PARTN=0
SET-def SECPARAM=65 //鎬诲弬鏁拌〃
SET &mhide=0
SET &mall=0
SET &mountdrvs=
SET &mnom=0
SET &OnlyOne=0
SET &OnlySoft=0
SET &ClearTmp=0 //娓呴櫎涓存椂MBROS鍚姩鍔犺浇
SET &umount=0
CALC -base=16 #&&CLEARMBROSTAGOFF=36s + 0x1C3
CALC -base=16 #&&CLEARMBROSTAGLEN=11
CALC -base=16 #&&CLEARMBROSTAGOFF2=36s + 0x1CE //澶囦唤鐨勫垎鍖鸿〃
SET-def CLEARMBROSTAG=0x43 0x4C 0x45 0x41 0x52 0x4D 0x42 0x52 0x4F 0x73 0x00 //CLEARMBROs\0
SET-def CLEARMBROSTAG2=0x43 0x4C 0x45 0x41 0x52 0x4D 0x42 0x52 0x4F 0x53 0x00 //CLEARMBROS\0
SET-def CLEARMBROSTAG3=0x43 0x4C 0x45 0x41 0x52 0x4D 0x42 0x52 0x4F 0x70 0x00 //CLEARMBROp\0
SET-def CLEARMBROSTAG4=0x43 0x4C 0x45 0x41 0x52 0x4D 0x42 0x52 0x4F 0x50 0x00 //CLEARMBROP\0
SET &va=%~1
FIND $%va%=ClearTmpMBROSAll, TEAM ClearTmpMBROSAll| EXIT FILE
FIND $%va%=moun, SET &va=mount
//MOUNT [-m] [-w] [-u|-ud|-uh|-muh|-muhg] [-mall] [-mhide] [-onlys] [-Cleartmp[Only]] \\.\PhysicalDrive1 Z:
FIND $%va%=mount,
{*
SET &mountdrvs=ZYXWVUTSRQPONMLKJIHGFEBAD //榛樿鍙嶅簭
SET &_exe=
SET &mountop=-o ro
SET &retv=
SET &BWin=0
ENVI &&I=2
ENVI &&umount=0
SET &retnm=
SET &udmid=-0x8000000
SET &udid=-0x8000000
SET &_uplus=0
SET &_w=0
SET &_udfs=0
SET &_udm_=0
SET &udimg=
SET &udmask=0
SET &_mh=-0x8000
LOOP #1=1,
{
MSTR &&va=<~%I%>%*
LSTR &&c1=1,%va%
FIND $%c1%<>-, EXIT LOOP
FIND $-exe=%va%, SET _exe=-exe
FIND $-udfs=%va%, SET _udfs=1
FIND $-udm-=%va%, SET _udm_=1
FIND $-m=%va%, SET BWin=m
FIND $-w=%va%, TEAM SET mountop=| SET _w=1
FIND $-u=%va%, SET umount=1 //鍜?ud鍚屼簡
FIND $-ud=%va%, SET umount=1
FIND $-uh=%va%, SET umount=2
FIND $-muh=%va%, SET umount=0x22
FIND $-muhg=%va%, SET umount=0x62 //杞厜鐩樹篃鍗歌浇
FIND $-mhide=%va%, SET mhide=1
FIND $-mhide-=%va%, SET mhide=0
FIND $-mall=%va%, SET mall=1
FIND $-mnom=%va%, SET mnom=1
FIND $-onlys=%va%, SET OnlySoft=1
FIND $-Cleartmp=%va%, CALC #ClearTmp=%ClearTmp% | 1
FIND $-CleartmpOnly=%va%, SET ClearTmp=2
FIND $[ -ret:=%va% | -ret=%va% ], TEAM CALC I=%I% + 1| MSTR retnm=<~%I%>%*
FIND $-udmid:=%va%, TEAM CALC I=%I% + 1| MSTR udmid=<~%I%>%*
FIND $-udid:=%va%, TEAM CALC I=%I% + 1| MSTR udid=<~%I%>%*
FIND $-udimg:=%va%, TEAM CALC I=%I% + 1| MSTR udimg=<~%I%>%*
FIND $-udmask:=%va%, TEAM CALC I=%I% + 1| MSTR udmask=<~%I%>%*
FIND $-mh:=%va%, TEAM CALC I=%I% + 1| MSTR _mh=<~%I%>%*
FIND $-u+=%va%, SET _uplus=1
CALC &I=%I% + 1
}
FIND $%_mh%=efi, SET _mh=-1
FIND $%_mh%=auto, SET _mh=0
CALC -err=-0x8000 #_mh=(%_mh%) + 0
--udmid[%udmid%]
MSTR &&DEV=<~%I%>%*
CALC &I=%I% + 1
MSTR &&drv=<~%I%>%*
CALL ParseDrviList
TEAM SET &MountDrv=| GetFreeDrive &MountDrv
IFEX $[ %_udfs%>0 & ( %hd%>=0 | %_mh%<-1 ) ], MAPUD "%&DEV%" "%&drv%" &retv
IFEX $%_uplus%>0, MountUplus "%&DEV%" "%&MountDrv%" %_w%
IFEX $%_uplus%>0, IFEX $[ %udmid%<>-0x8000000 && %udmid%<0 ], EXIT FILE
//THREAD+$ MESS. [MountMBROS "%mountop%" "%&DEV%" "%&drv%" &ret %&_exe%]@debug
IFEX $%_udm_%<1, CALL MountMBROS "%mountop%" "%&DEV%" "%&drv%" &retv %_exe%
FIND $%retnm%<>, ENVI-ret %retnm%=%&retv%
EXIT= 0
EXIT FILE
}
// listudm -ret: 杩斿洖鍚? 璁惧鍚?
//////////////// listudm ////
FIND $%~1=listudm,
{*
SET &retnm=
SET &I=2
MSTR &&va=<~%I%>%*
FIND $[ -ret:=%va% | -ret=%va% ], TEAM CALC I=%I% + 1| MSTR retnm=<~%I%>%*| CALC I=%I% + 1
MSTR &&IMG=<~%I%>%*
ChekHD &&hd "%IMG%"
--IMG[%IMG%] hd[%hd%]
SET &FN=%IMG%
SET &MBROS=%IMG%
SET &PARTS=
SET &PARTN=0
SET &PARTX=
SET &PART0=
SET &PARTN=0
EXIT= 0
FIND $%IMG%<>, GetUDPart %IMG% "" //all
ENVI-ret %retnm%=%PARTX%
EXIT FILE
}
FIND $%~1=listud,
{*
SET &retnm=
SET &I=2
MSTR &&va=<~%I%>%*
FIND $[ -ret:=%va% | -ret=%va% ], TEAM CALC I=%I% + 1| MSTR retnm=<~%I%>%*| CALC I=%I% + 1
MSTR &&IMG=<~%I%>%*
ChekHD &&hd "%IMG%"
--IMG[%IMG%] hd[%hd%]
EXIT= 0
SET &Vlist=
IFEX $%hd%>=0, GETPUDMAP \\.\PhysicalDrive%hd% &Vlist
ENVI-ret %retnm%=%Vlist%
EXIT FILE
}
FIND $%~1=sync,
{* SET &&_cmd=%*
EXIT= 0
%&_cmd%
EXIT FILE
}
EXIT FILE
_SUB GetCFG *
SET &IMG=%~1
SET &EFIBOOTOFF=-1 //閿欒鍊?
SET &EFIBOOTSZ=-1
CALC -base=16 &&p=%SECPARAM%s + 3
GETF %&IMG%,%p%#10,&&DAT
FIND $%DAT%<>0x4D 0x42 0x52 0x4F 0x53 0x50 0x41 0x52 0x41 0x4D, EXIT // MBROSOPARAM
GETF# %&IMG%,%SECPARAM%s#0x40,&&DAT
FIND $0xFFFFFFFF=%DAT%, EXIT
SET?long &DAT=&EFIBOOTOFF:0x28 //EFIBOOT浣嶇疆 锛?x3F01锛?
SET?long &DAT=&EFIBOOTSZ:0x2C //EFIBOOT闀垮害 锛?x821=0x800+33锛?//1M
_END
_SUB ParseDrviList
MSTR &&c1=1,1,%drv%
MSTR &&c2=2,1,%drv%
FIND $%c2%=:, TEAM SET c2=| SET OnlyOne=1
FIND $%c1%<>, FIND $%c2%=, SET mountdrvs=%c1%
FIND $%c2%<>, FIND $%c2%<>-, SET mountdrvs=%drv%
FIND $%c1%<>, SET drv=%c1%: //鍒濆DRIVE
FIND $%c2%=-,
{
SET mountdrvs=
FORX * A B C D E F G H I J K L M N O P Q R S T U V W Y Z,&&d, FIND $%d%>=%c1%, SET mountdrvs=%mountdrvs%%d%
}
_END
//ChekHD 杩斿洖鍚?鏂囦欢鍚?
_SUB ChekHD
LSTR &&LDEV=17,%~2
ENVI &&hd=-0x8000
SET &&c1=
FIND $\\.\PhysicalDrive=%&LDEV%, MSTR &&c1=18,1,%&MBROS%
MSTR &&c2=19,1,%&MBROS%
MSTR &&c3=20,1,%&MBROS%
CALC #&hd=%&hd%
FIND $%&c1%>9, TEAM SET c1=
FIND $%&c2%>9, TEAM SET c2=
FIND $%&c3%>9, TEAM SET c3=
FIND $%&c1%<0, TEAM SET c2=| SET c3=|
FIND $%&c2%<0, TEAM SET c3=|
FIND $%&c1%>=0, CALC #&hd=%c1%
FIND $%&c2%>=0, CALC #&hd=%&hd% * 10 + %&c2%
FIND $%&c3%>=0, CALC #&hd=%&hd% * 10 + %&c3%
ENVI-ret %~1=%&hd%
_END
// GetWimName Name dev Off Len
_SUB GetWimName *
ENVI %~1=%~2#%~3#%~4$
//%s#%s#%s p, sOff, sLen
_END
//FINDImdisk id鍚? 鐩樼鍚?鏂囦欢鍚?
_SUB FINDImdisk
SET-def id=-1
SET-def drv=
SET-def FN=%~3
STRL &&len=%FN%
CALC &&len2=%len% - 1 //鏃х増
SET &FN2=%FN%
LSTR &&L4=4,%FN%
FIND $\??\=%L4%, SET len=0! LSTR FN2=%len2%,%FN%
RAMD ImDisk*&&all -n -l
SET-def vi=
SET-def nm=
FORX * %&all%,&&i,
{
RAMD ImDisk*&&v -n -l -u %&i%
READ -*,1,&vi,&v
//Z: = \BaseNamedObjects\Global\PhysicalDrive1#aaa_bbb
//Z: = \??\D:\MDY\DESKTOP\ttt\MBROS.MOS
MSTR &nm=6,%len%,%&vi%
FIND $%&FN%=%&nm%,! FIND $%&FN2%=%&nm%,! EXIT -
MSTR &drv=1,2,%&vi%
ENVI &id=%&i%
EXIT FORX
}
ENVI-ret %~1=%&id%
ENVI-ret %~2=%&drv%
_END
// GetUDPart 鏂囦欢鍚?鍋忕Щ鍚?闀垮害鍚?
_SUB GetUDPart
ENVI^ ForceLocal=1
ENVI &&FN=%~1
SET &un=%~2
//MESS. un=[%un%]
GETF %FN%,0x7E36#5,&&V
FIND $0x46 0x41 0x54 0x31 0x36=%V%, ENVI &FAT=16 //FAT16
FIND $0x46 0x41 0x54 0x31 0x32=%V%, ENVI &FAT=12 //FAT12
GETF %FN%,0x7E52#5,&&V
FIND $0x46 0x41 0x54 0x33 0x32=%V%, ENVI &FAT=32 //FAT32
IFEX $%FAT%>0,
{ GETF %FN%,0x7E20#4,&V //ts32
FIND $0x00 0x00 0x00 0x00=%V%, GETF %FN%,0x7E13#2,&V //ts16
MSTR &&V1,&&V2,&&V3,&&v4=<1*>%V% 0 0 0 0
CALC #&SZ=%V1% + %V2% * 0x100 + %V3% * 0x10000 + %V4% * 0x1000000
GETF %FN%,0x7E1C#2,&V //nhs_pre
MSTR &&V1,&&V2,&&V3,&&v4=<1*>%V% 0 0
CALC #&OFF=%V1% + %V2% * 0x100
}
GETF %FN%,0x7FFE#2,&&V
FIND $0x55 0xAA=%V%,! ENVI &SZ=-1
GETF %FN%,0x7FB4#4,&&V
FIND $0x4D 0x42 0x52 0x53=%V%,! ENVI &SZ=-1 //"MBRS"
SET PARTN=0
SET &init1=0
IFEX $%SZ%>0, SET &init1=1
//FIND $%un%=-u,!! SET &init1=0
FIND $%&&init1%=1,
{
CALL * GetWimName &&WimName PhysicalDrive%hd% %OFF% %SZ%
FINDImdisk &&id &&drvm "\BaseNamedObjects\Global\%&WimName%"
CALC &&SZK=%SZ% / 2
SET PART0=鏍稿績UDM鍒嗗尯 %SZK%K MBROS //[%OFF% %SZ% 0x00]
SET PARTS=%PART0%
SET PARTX=鏍稿績UDM鍒嗗尯 %OFF% %SZ% 0x01 0x00 "MBROS" "%&drvm%" 鏍稿績UDM鍒嗗尯
SET PARTN=1
//THREAD+$ MESS %&PARTX% @1111
}
SET &FNx=%FN%
SET &SECUMBR=66
@TEAM SET &bUPARAM=0
CALC -base=16 &&addr=65s + 0x3
GETF %FN%,%addr%#10,&&V
FIND $%V%=0x4D 0x42 0x52 0x4F 0x53 0x50 0x41 0x52 0x41 0x4D, SET bUPARAM=1
CALC -base=16 &&addr=65s + 0xE
GETF %FN%,%addr%#1,&&V
IFEX $%bUPARAM%>0, IFEX $%V%>=4, SET bUPARAM=4
IFEX $%bUPARAM%>=4, SET &SZ1=0x40! SET &SZ1=0x20
CALC #&&SZP=1s / %SZ1% - 1
CALC -base=16 &&addr=65s + 0x14
GETF %FN%,%addr%#4,&&V
MSTR &&V1,&&V2,&&V3,&&v4=<1*>%V% 0 0 0 0
CALC #&NPS=%V1% + %V2% * 0x100
IFEX $%NPS%>0x40, SET NPS=0x40
SET &MAX=0
CALC #&&len=%SZP% * %SZ1%
GETF %FN%,%SECUMBR%s#0x10,&V
SET &I=0
CALC -base=16 &&addr0=%SECUMBR%s
LOOP #%I%<%NPS%,
{* CALC -base=16 &&addr=%SECUMBR%s + %I%s + 0x3
GETF %FN%,%addr%#9,&&V1
CALC -base=16 #&&addr=%SECUMBR%s + %I%s + 0x10
CALC I=%I% + 1
FIND $%V1%<>0x4D 0x42 0x52 0x4F 0x53 0x50 0x41 0x52 0x54, EXIT
GETF %FN%,%addr%#%len%,&V1
@SET< V= %V1%
CALC #&MAX=%MAX% + %SZP%
}
SET &bUMBR=%MAX%
SET &I=0
CALC &&IOF=0x11 - %SZ1%
CALC &&ISZ=0x15 - %SZ1%
CALC &&ITP=0x19 - %SZ1% //FSTP 绫诲瀷 灞炴 |
|