_SUB AutomaticGuidanceRepair FIND $%&Tstyle%=MBR,CALL BootMBR FIND $%&Tstyle%=GPT,CALL BootGPT_END
_SUB BootMBR TEAM ENVI &&iVer=|&&VerPOS=|&&ThisVer= IFEX %&PARTSEL2%\windows\system32\kernel32.dll, { SITE ?&iVer=FVER,%&PARTSEL2%\windows\system32\kernel32.dll LPOS &VerPOS=.,1,%&iVer% CALC #&VerPOS = %&VerPOS% - 1 LSTR &ThisVer=%&VerPOS%,%&iVer% IFEX $%&ThisVer% > 5, TEAM CALL BootNT60|EXIT _SUB CALL GetActivePartition EXEC -exe:#203 =!bootsect.exe /nt52 %&ActiveDrv% }_END
_SUB BootNT60 CALL GetActivePartition FIND $%&PARTSEL2%=%&ActiveDrv%,CALL TSELeDrv!CALL ActPART _END
_SUB TSELeDrv IFEX %&PARTSEL2%\Boot\BCD,! { EXEC -exe:#202 =!bcdboot.exe %&PARTSEL2%\Windows /s %&ActiveDrv% /f BIOS /l zh-CN EXEC -exe:#203 =!bootsect.exe /nt60 %&ActiveDrv% /mbr } EXEC -exe:#203 =!bootsect.exe /nt60 %&ActiveDrv% _END
_SUB ActPART IFEX %&ActiveDrv%\Boot\BCD,! { EXEC -exe:#202 =!bcdboot.exe %&PARTSEL2%\Windows /s %&ActiveDrv% /f BIOS /l zh-CN EXEC -exe:#203 =!bootsect.exe /nt60 %&ActiveDrv% IFEX %&ActiveDrv%\ntldr,!! IFEX %&ActiveDrv%\boot.ini,!! IFEX %&ActiveDrv%\Windows,!! CALL NT52BCD EXIT _SUB } IFEX %&ActiveDrv%\Boot\BCD,!! IFEX %&ActiveDrv%\BOOTMGR,!! CALL 567HJKI89 _END
_SUB NT52BCD EXEC -exe:*#204 =!bcdedit /store "%&ActiveDrv%\BOOT\BCD" /create {ntldr} /d "Earlier Windows OS Loader" EXEC -exe:*#204 =!bcdedit /store "%&ActiveDrv%\BOOT\BCD" /set {ntldr} device partition=%&ActiveDrv% EXEC -exe:*#204 =!bcdedit /store "%&ActiveDrv%\BOOT\BCD" /set {ntldr} path \ntldr EXEC -exe:*#204 =!bcdedit /store "%&ActiveDrv%\BOOT\BCD" /set {ntldr} description "Windows XP" EXEC -exe:*#204 =!bcdedit /store "%&ActiveDrv%\BOOT\BCD" /displayorder {ntldr} /addlast EXEC -exe:*#204 =!bcdedit /store "%&ActiveDrv%\BOOT\BCD" /timeout 5 EXEC -exe:#203 =!bootsect.exe /nt60 %&ActiveDrv% /mbr _END
_SUB 567HJKI89 TEAM ENVI &&part=|ENVI &&FORM=|ENVI &&M=1|ENVI &&pou=|ENVI &&A1=|ENVI &&A2=|ENVI &&Lett=1|ENVI &&M1= TEAM ENVI &&Lnv=|ENVI &&ID= EXEC* -exe:*#204 &part=!bcdedit /store "%&ActiveDrv%\BOOT\BCD" /enum osloader READ -,-1,&FORM,%&part% LOOP #%&M% <= %&FORM%, { READ -,%&M%,&pou,%&part% MSTR &A1,&A2=<1><2>%&pou% FIND $%&A1%=device,!! FIND $%&A2%=partition=%&PARTSEL2%,!! TEAM ENVI &Lett=0|ENVI &M1=%&M%|EXIT LOOP CALC #&M = %&M% + 1 } IFEX $%&Lett%=0, { CALC #&M1 = %&M1% - 1 READ -,%&M1%,&Lnv,%&part% MSTR &ID=<2>%&Lnv% EXEC -exe:*#204 =!bcdedit /store "%&ActiveDrv%\BOOT\BCD" /delete %&ID% /cleanup TEAM CALL RTYUUIOFFEFFGGHH|EXIT _SUB } IFEX $%&Lett%=1,CALL RTYUUIOFFEFFGGHH_END
_SUB RTYUUIOFFEFFGGHH TEAM ENVI &&iVer=|ENVI &&part22=|ENVI &&A3= HIVE 123,%&PARTSEL2%\Windows\System32\config\SOFTWARE REGI HKEY_LOCAL_MACHINE\123\Microsoft\Windows NT\CurrentVersion\ProductName,&iVer HIVE 123 EXEC* -exe:*#204 &part22=!bcdedit /store "%&ActiveDrv%\BOOT\BCD" /create /d "%&iVer%" /application osloader MSTR &A3=<3>,%&part22% EXEC -exe:*#204 =!bcdedit /store "%&ActiveDrv%\BOOT\BCD" /set %&A3% device partition=%&PARTSEL2% EXEC -exe:*#204 =!bcdedit /store "%&ActiveDrv%\BOOT\BCD" /set %&A3% path \Windows\system32\winload.exe EXEC -exe:*#204 =!bcdedit /store "%&ActiveDrv%\BOOT\BCD" /set %&A3% locale zh-CN EXEC -exe:*#204 =!bcdedit /store "%&ActiveDrv%\BOOT\BCD" /set %&A3% osdevice partition=%&PARTSEL2% EXEC -exe:*#204 =!bcdedit /store "%&ActiveDrv%\BOOT\BCD" /set %&A3% systemroot \Windows EXEC -exe:*#204 =!bcdedit /store "%&ActiveDrv%\BOOT\BCD" /set %&A3% nx OptIn EXEC -exe:*#204 =!bcdedit /store "%&ActiveDrv%\BOOT\BCD" /displayorder %&A3% /addlast EXEC -exe:*#204 =!bcdedit /store "%&ActiveDrv%\BOOT\BCD" /default %&A3% EXEC -exe:*#204 =!bcdedit /store "%&ActiveDrv%\BOOT\BCD" /timeout 10 EXEC -exe:#203 =!bootsect.exe /nt60 %&ActiveDrv%_END
_SUB BootGPT ENVI &&Fexist=0 CALL SetBOOTAndActive FIND $%&EFIDrive%= ,! { ENVI &Fexist=1 IFEX %&EFIDrive%\EFI\Boot\BOOTX64.EFI,! ENVI &Fexist=0 IFEX %&EFIDrive%\EFI\Microsoft\Boot\BCD,! ENVI &Fexist=0 FIND $%&Fexist%=0,TEAM EXEC -exe:#202 =!bcdboot.exe %&PARTSEL2%\Windows /s %&EFIDrive% /f UEFI /l zh-CN|EXIT _SUB FIND $%&Fexist%=1,CALL SetBCDEDIT _END
_SUB SetBCDEDIT TEAM ENVI &&part=|ENVI &&FORM=|ENVI &&M=1|ENVI &&pou=|ENVI &&A1=|ENVI &&A2=|ENVI &&Lett=1|ENVI &&M1= TEAM ENVI &&Lnv=|ENVI &&ID= EXEC* -exe:*#204 &part=!bcdedit /store "%&EFIDrive%\EFI\Microsoft\Boot\BCD" /enum osloader READ -,-1,&FORM,%&part% LOOP #%&M% <= %&FORM%, { READ -,%&M%,&pou,%&part% MSTR &A1,&A2=<1><2>%&pou% FIND $%&A1%=device,!! FIND $%&A2%=partition=%&PARTSEL2%,!! TEAM ENVI &Lett=0|ENVI &M1=%&M%|EXIT LOOP CALC #&M = %&M% + 1 } IFEX $%&Lett%=0, { CALC #&M1 = %&M1% - 1 READ -,%&M1%,&Lnv,%&part% MSTR &ID=<2>%&Lnv% EXEC -exe:*#204 =!bcdedit /store "%&EFIDrive%\EFI\Microsoft\Boot\BCD" /delete %&ID% /cleanup TEAM CALL RREEWWQQUUII|EXIT _SUB } IFEX $%&Lett%=1,CALL RREEWWQQUUII_END
_SUB RREEWWQQUUII TEAM ENVI &&iVer=|ENVI &&part22=|ENVI &&A3= HIVE 123,%&PARTSEL2%\Windows\System32\config\SOFTWARE REGI HKEY_LOCAL_MACHINE\123\Microsoft\Windows NT\CurrentVersion\ProductName,&iVer HIVE 123 EXEC* -exe:*#204 &part22=!bcdedit /store "%&EFIDrive%\EFI\Microsoft\Boot\BCD" /create /d "%&iVer%" /application osloader MSTR &A3=<3>,%&part22% EXEC -exe:*#204 =!bcdedit /store "%&EFIDrive%\EFI\Microsoft\Boot\BCD" /set %&A3% device partition=%&PARTSEL2% EXEC -exe:*#204 =!bcdedit /store "%&EFIDrive%\EFI\Microsoft\Boot\BCD" /set %&A3% path \Windows\system32\winload.efi EXEC -exe:*#204 =!bcdedit /store "%&EFIDrive%\EFI\Microsoft\Boot\BCD" /set %&A3% locale zh-CN EXEC -exe:*#204 =!bcdedit /store "%&EFIDrive%\EFI\Microsoft\Boot\BCD" /set %&A3% osdevice partition=%&PARTSEL2% EXEC -exe:*#204 =!bcdedit /store "%&EFIDrive%\EFI\Microsoft\Boot\BCD" /set %&A3% systemroot \Windows EXEC -exe:*#204 =!bcdedit /store "%&EFIDrive%\EFI\Microsoft\Boot\BCD" /set %&A3% nx OptIn EXEC -exe:*#204 =!bcdedit /store "%&EFIDrive%\EFI\Microsoft\Boot\BCD" /displayorder %&A3% /addlast EXEC -exe:*#204 =!bcdedit /store "%&EFIDrive%\EFI\Microsoft\Boot\BCD" /default %&A3% EXEC -exe:*#204 =!bcdedit /store "%&EFIDrive%\EFI\Microsoft\Boot\BCD" /timeout 5_END
//------------判断还原分区所在硬盘分区表是GPT还是MBR_SUB GetTargetPartitionInfo TEAM ENVI &&vLn=|ENVI &&A1=|ENVI &&A2=|ENVI &&A8=|ENVI &&tPOS=0 LPOS &tPOS=:,1,%&PARTSEL1% CALC #&tPOS = %&tPOS% - 1 LSTR &TDrvNum=%&tPOS%,%&PARTSEL1% FIND $%&PARTSEL2%= ,! { FORX *NL &vFORM,&vLn, { MSTR* &A2,&A8=<2><8>%&vLn% FIND $%&A2%=%&PARTSEL2%,TEAM ENVI &Tstyle=%&A8%|EXIT FORX } EXIT _SUB } FIND $%&PARTSEL1%= ,! { FORX *NL &vFORM,&vLn, { MSTR* &A1,&A8=<1><8>%&vLn% FIND $%&A1%=%&PARTSEL1%,TEAM ENVI &Tstyle=%&A8%|EXIT FORX } }_END
//------------判断mbr分区表下引导盘的盘符_SUB GetActivePartition TEAM ENVI &&vln=|ENVI &&A1=|ENVI &&A2=|ENVI &&A9=|ENVI &&E1=|ENVI &&E2= FORX *NL &vFORM,&vln, { MSTR* &A1,&A2,&A9=<1><2><9>%&vln% IFEX $%&A9% = 1, { LPOS &E1=:,1,%&A1% CALC #&E1 = %&E1% - 1 LSTR &E2=%&E1%,%&A1% IFEX $%&E2% = %&TDrvNum%, TEAM ENVI &ActiveDrv=%&A2%|EXIT _SUB } }_END
//------------判断gpt分区表下引导盘的盘符_SUB SetBOOTAndActive TEAM ENVI &&vLn=|ENVI &&A1=|ENVI &&A2=|ENVI &&A5=|ENVI &&tPOS=|ENVI &&aNum=|ENVI &&Fexist=0 FORX *NL &vFORM,&vLn, { MSTR* &A1,&A2,&A5=<1><2><5>%&vLn% FIND $%&A5%=EFI, { LPOS &tPOS=:,1,%&A1% CALC #&tPOS = %&tPOS% - 1 LSTR &aNum=%&tPOS%,%&A1% IFEX $%&aNum% = %&TDrvNum%, TEAM ENVI &EFIDrive=%&A2%|EXIT FORX } }_END
这是提取CGI自动修复引导的代码,有谁能帮助一下,这个怎么自动运行
这些是代码段,需要写一个能统一调度这些子函数的主函数代码,要好好分析一下,最后用pecmd直接调用主函数
谢谢大佬!我不懂PECMD命令,你能否帮忙分析一下,我只需要自动修复引导这个功能,
w8899 谢谢大佬!我不懂PECMD命令,你能否帮忙分析一下,我只需要自动修复引导这个功能,
有现成的自动修复引导的工具的,很多winpe里都有集成
我知道,我就是自己想要一个自动修复引导的,启动就能运行的,谢谢回复!
看起来不像是CGI的代码啊,比如AutomaticGuidanceRepair这段CGI就没有吧?
你要把完整的CGI代码发上来,你的提取可能不完整。
看不懂了!不过其他PE都有这样的功能 吧