diff --git a/Projects/PhoenixPE/PhoenixAPI.script b/Projects/PhoenixPE/PhoenixAPI.script index 88dd603..a042391 100644 --- a/Projects/PhoenixPE/PhoenixAPI.script +++ b/Projects/PhoenixPE/PhoenixAPI.script @@ -32,7 +32,7 @@ Title=PhoenixPE API Author=Homes32 Description=PhoenixPE scripting support library. -Version=1.9.0.0 +Version=1.9.1.0 Date=2024-01-02 Level=0 Selected=None @@ -40,249 +40,53 @@ Selected=None [Variables] [Macros] -// Registry -RegLoadHives=Run,%API%,_PhoenixAPI_RegLoadHives -RegUnloadHives=Run,%API%,_PhoenixAPI_RegUnloadHives -RegCopyDriver=Run,%API%,_PhoenixAPI_RegCopyDriver -Associate=Run,%API%,_PhoenixAPI_Associate - -// Shortcuts/Autorun -RunFromRam=Run,%API%,_PhoenixAPI_RunFromRam +7z=Run,%API%,_PhoenixAPI_7z +//7zExtract=NOT IMPLIMENTED AddAutoRun=Run,%API%,_PhoenixAPI_AddAutoRun +AddPostProcess=Run,%API%,_PhoenixAPI_AddPostProcess AddShortcut=Run,%API%,_PhoenixAPI_AddShortcut -PinShortcut=Run,%API%,_PhoenixAPI_PinShortcut AddStartupConfig=Run,%API%,_PhoenixAPI_AddStartupConfig - -// File/Dir Handling +ApplyBitMask=Run,%API%,_PhoenixAPI_ApplyBitMask +Associate=Run,%API%,_PhoenixAPI_Associate +Binmay=Run,%API%,_PhoenixAPI_Binmay +BitClear=Run,%API%,_PhoenixAPI_BitClear +BitSet=Run,%API%,_PhoenixAPI_BitSet +BitToggle=Run,%API%,_PhoenixAPI_BitToggle +ConvertImage=Run,%API%,_PhoenixAPI_ConvertImage DirDeleteEx=Run,%API%,_PhoenixAPI_DirDeleteEx +DISM=Run,%API%,_PhoenixAPI_DISM FileCopyEx=Run,%API%,_PhoenixAPI_FileCopyEx FileDeleteEx=Run,%API%,_PhoenixAPI_FileDeleteEx FileSearch=Run,%API%,_PhoenixAPI_FileSearch -InnoCleanup=Run,%API%,_PhoenixAPI_InnoCleanup -InnoRename=Run,%API%,_PhoenixAPI_InnoRename - -// ACL Management -SetFileACL=Run,%API%,_PhoenixAPI_SetFileACL -SetRegACL=Run,%API%,_PhoenixAPI_SetRegACL - -// Include Files -RequireDriver=Run,%API%,_PhoenixAPI_RequireDriver -RequireFile=Run,%API%,_PhoenixAPI_RequireFile -RequireFileEx=Run,%API%,_PhoenixAPI_RequireFileEx - -// Utility -Binmay=Run,%API%,_PhoenixAPI_Binmay -ConvertImage=Run,%API%,_PhoenixAPI_ConvertImage -DISM=Run,%API%,_PhoenixAPI_DISM -AddPostProcess=Run,%API%,_PhoenixAPI_AddPostProcess GetBinaryResource=Run,%API%,_PhoenixAPI_GetBinaryResource -//GetStringResource=Run,%API%,_PhoenixAPI_GetStringResource - -// Compression/Decompression -7z=Run,%API%,_PhoenixAPI_7z -//7zExtract=NOT IMPLIMENTED +GetStringResource=Run,%API%,_PhoenixAPI_GetStringResource +InnoCleanup=Run,%API%,_PhoenixAPI_InnoCleanup InnoExtract=Run,%API%,_PhoenixAPI_InnoExtract +InnoRename=Run,%API%,_PhoenixAPI_InnoRename Innounp=Run,%API%,_PhoenixAPI_Innounp -MSIExtract=Run,%API%,_PhoenixAPI_MSIExtract -WixExtract=Run,%API%,_PhoenixAPI_WixExtract - -// JSON JSONCompact=Run,%API%,_PhoenixAPI_JSONCompact JSONDelete=Run,%API%,_PhoenixAPI_JSONDelete JSONPretty=Run,%API%,_PhoenixAPI_JSONPretty JSONRead=Run,%API%,_PhoenixAPI_JSONRead -//JSON2INI=NOT IMPLIMENTED -//INI2JSON=NOT IMPLIMENTED JSONWrite=Run,%API%,_PhoenixAPI_JSONWrite - -// XML +MSIExtract=Run,%API%,_PhoenixAPI_MSIExtract +PinShortcut=Run,%API%,_PhoenixAPI_PinShortcut +RegCopyDriver=Run,%API%,_PhoenixAPI_RegCopyDriver +RegLoadHives=Run,%API%,_PhoenixAPI_RegLoadHives +RegUnloadHives=Run,%API%,_PhoenixAPI_RegUnloadHives +RequireDriver=Run,%API%,_PhoenixAPI_RequireDriver +RequireFile=Run,%API%,_PhoenixAPI_RequireFile +RequireFileEx=Run,%API%,_PhoenixAPI_RequireFileEx +RunFromRam=Run,%API%,_PhoenixAPI_RunFromRam +SetFileACL=Run,%API%,_PhoenixAPI_SetFileACL +SetRegACL=Run,%API%,_PhoenixAPI_SetRegACL +WixExtract=Run,%API%,_PhoenixAPI_WixExtract XMLAdd=Run,%API%,_PhoenixAPI_XMLAdd XMLDelete=Run,%API%,_PhoenixAPI_XMLDelete XMLRead=Run,%API%,_PhoenixAPI_XMLRead XMLRename=Run,%API%,_PhoenixAPI_XMLRename XMLUpdate=Run,%API%,_PhoenixAPI_XMLUpdate -// Bitmask Handling -ApplyBitMask=Run,%API%,_PhoenixAPI_ApplyBitMask -BitClear=Run,%API%,_PhoenixAPI_BitClear -BitSet=Run,%API%,_PhoenixAPI_BitSet -BitToggle=Run,%API%,_PhoenixAPI_BitToggle - -[#_PhoenixAPI_RegLoadHives#] -// =============================================================================================================================== -// Name...........: RegLoadHives -// Description....: Mount Source and Build registry hives. -// Syntax.........: RegLoadHives -// Parameters.....: -// Return values..: -// Author.........: Homes32 -// Remarks........: -// Related........: -// =============================================================================================================================== -[_PhoenixAPI_RegLoadHives] -RegHiveLoad,Tmp_Default,%RegDefault% -RegHiveLoad,Tmp_Drivers,%RegDrivers% -RegHiveLoad,Tmp_Software,%RegSoftware% -RegHiveLoad,Tmp_System,%RegSystem% -RegHiveLoad,Tmp_Install_Default,%RegInstallDefault% -RegHiveLoad,Tmp_Install_Drivers,%RegInstallDrivers% -RegHiveLoad,Tmp_Install_Software,%RegInstallSoftware% -RegHiveLoad,Tmp_Install_System,%RegInstallSystem% - -[#_PhoenixAPI_RegUnloadHives#] -// =============================================================================================================================== -// Name...........: RegUnloadHives -// Description....: UnMount Source and Build registry hives. -// Syntax.........: RegUnLoadHives[,FORCE][,HKEY=][,Target=] -// Parameters.....: Force - Force hive unload using HiveUnload.exe -// HKEY= - Unload hives from this root key. (HKLM, HKU) -// Target= - Unload hives from this directory. -// Return values..: ExitCode provided by the HiveUnload.exe application -// 0 - All registry hives unloaded successfully. -// 1 - Not all registry hives could be unloaded. -// 2 - No loaded registry hives were found. -// You must handle ExitCode. The script will not Exit/Halt. -// Author.........: Homes32 -// Remarks........: HiveUnload.exe is open-source software developed by BlueLife -// Related........: -// =============================================================================================================================== -[_PhoenixAPI_RegUnloadHives] -System,SetLocal - -GetParam,1,%Arg1% -GetParam,2,%Arg2% -GetParam,3,%Arg3% - -Set,%ForceUnmount%,False -Set,%HKEY%,"HKLM" -Set,%UnloadTarget%,"ALL" - -Run,%API%,__PhoenixAPI_RegUnloadHives_Process_Arg,%Arg1% -Run,%API%,__PhoenixAPI_RegUnloadHives_Process_Arg,%Arg2% -Run,%API%,__PhoenixAPI_RegUnloadHives_Process_Arg,%Arg3% - -If,%ForceUnmount%,Equal,True,Begin - If,ExistFile,"%Tools%\x86\HiveUnload.exe",ShellExecute,Hide,"%Tools%\x86\HiveUnload.exe","/%HKEY% /Target:%UnloadTarget%" - If,%ExitCode%,Equal,0,Echo,"HiveUnload: All registry hives unloaded successfully." - If,%ExitCode%,Equal,1,Echo,"HiveUnload: Warning: Not all registry hives could be unloaded! Please verify that regedit is not running and try again.",Warn - If,%ExitCode%,Equal,2,Echo,"HiveUnload: No loaded registry hives were found." -End -Else,Begin - RegHiveUnload,Tmp_Default - RegHiveUnload,Tmp_Drivers - RegHiveUnload,Tmp_Software - RegHiveUnload,Tmp_System - RegHiveUnload,Tmp_Install_Default - RegHiveUnload,Tmp_Install_Drivers - RegHiveUnload,Tmp_Install_Software - RegHiveUnload,Tmp_Install_System -End - -System,EndLocal - -[#__PhoenixAPI_RegUnloadHives_Process_Arg#] -// =============================================================================================================================== -// Name...........: __PhoenixAPI_RegUnloadHives_Process_Arg -// Description....: Process RegUnloadHives optional arguments -// Syntax.........: __PhoenixAPI_RegUnloadHives_Process_Arg, -// Parameters.....: #1 Arg - The argument to process -// Return values..: -// Author.........: Homes32 -// Remarks........: Internal Function -// Do not call System,SetLocal here. We need this function to run in the same scope as the caller -// Related........: _PhoenixAPI_RegUnloadHives -// =============================================================================================================================== -[__PhoenixAPI_RegUnloadHives_Process_Arg] - -If,#1,Equal,"Force",Set,%ForceUnmount%,True -Else,Begin - StrFormat,Split,#1,"=",1,%ArgKey% - If,Not,%ArgKey%,Equal,"",Begin - If,%ArgKey%,Equal,"HKEY",StrFormat,Split,#1,"=",2,%HKEY% - Else,If,%ArgKey%,Equal,"TARGET",StrFormat,Split,#1,"=",2,%UnloadTarget% - Else,Halt,"SYNTAX ERROR: Invalid Argument [#1]" - End -End - -[#_PhoenixAPI_RegCopyDriver#] -// =============================================================================================================================== -// Name...........: RegCopyDriver -// Description....: Copy the driver entries from the INSTALL.WIM driver database to the target registry driver database. -// Both the DRIVERS hive and SYSTEM\Drivers store are processed. -// Syntax.........: RegCopyDriver, -// Parameters.....: InfFile - The name of the driver's .inf file -// Return values..: -// Author.........: Homes32 -// Remarks........: This function uses a modified version of ChrisR's RegAddDriver.cmd as PEBakery does not have a good way -// to enum/query registry keys yet... -// Registry hives Tmp_Install_Drivers, Tmp_Install_System, Tmp_Drivers, Tmp_System must be loaded before calling. -// Related........: Depends on %Tools%\RegCopyDriver.cmd -// =============================================================================================================================== -[_PhoenixAPI_RegCopyDriver] -System,SetLocal -Set,%Debug%,False - -If,#1,Equal,"",Halt,"Syntax Error: You must specify the name of the driver's .inf to register." -GetParam,1,%InfFile% - -Echo,"Processing [%InfFile%] registration..." -If,%Debug%,Equal,True,TXTReplace,"%Tools%\RegCopyDriver.cmd",":::","" - -ShellExecute,Hide,"cmd.exe","/D /C RegCopyDriver.cmd #$q%InfFile%#$q",%Tools% - -System,EndLocal - -[#_PhoenixAPI_RequireDriver#] -// =============================================================================================================================== -// Name...........: RequireDriver -// Description....: Copy the driver support files and driver entries from the INSTALL.WIM driver database to the target registry driver database. -// Both the DRIVERS hive and SYSTEM\Drivers store are processed. -// -// You must still copy additional/supporting driver files yourself if they have a different name then the .inf file itself. -// Ex. RequireDriver,netrndis.inf - you still need to copy \Windows\System32\drivers\usb8023.sys yourself. -// -// Syntax.........: RequireDriver, -// Parameters.....: InfFile - The name of the driver's .inf file -// NOREG - (Optional) Don't copy registry (driver database) -// Return values..: -// Author.........: Homes32 -// Remarks........: This function uses a modified version of ChrisR's RegAddDriver.cmd as PEBakery does not have a good way -// to enum/query registry keys yet... -// Registry hives Tmp_Install_Drivers, Tmp_Install_System, Tmp_Drivers, Tmp_System must be loaded before calling. -// Related........: Depends on %Tools%\RegCopyDriver.cmd -// =============================================================================================================================== -[_PhoenixAPI_RequireDriver] -System,SetLocal - -If,#1,Equal,"",Halt,"Syntax Error: You must specify the name of the driver's .inf to include/register." -GetParam,1,%InfFile% -GetParam,2,%Arg2% - -If,%Arg2%,Equal,NOREG,Set,%NOREG%,True -Else,Set,%NOREG%,False - -StrFormat,RTRIM,%InfFile%,3,%InfFileNoExt% - -Set,%RequireDriver-Listfile%,%ProjectTemp%\RequireDriver-ListFile.txt -FileDeleteEx,%RequireDriver-Listfile% - -Echo,"Extracting [%InfFile%] Driver Support Files..." -TxtAddline,%RequireDriver-Listfile%,"\Windows\INF\%InfFileNoExt%*",Append -TxtAddline,%RequireDriver-Listfile%,"\Windows\System32\%InfFileNoExt%*",Append -TxtAddline,%RequireDriver-Listfile%,"\Windows\System32\Drivers\%InfFileNoExt%*",Append -TxtAddline,%RequireDriver-Listfile%,"\Windows\System32\Driverstore\??-??\%InfFile%_loc",Append -TxtAddline,%RequireDriver-Listfile%,"\Windows\System32\DriverStore\FileRepository\%InfFile%*",Append -TxtAddline,%RequireDriver-Listfile%,"\Windows\System32\??-??\%InfFileNoExt%*",Append -TxtAddline,%RequireDriver-Listfile%,"\Windows\SystemResources\%InfFileNoExt%*",Append -WimExtractBulk,%SourceInstallWim%,%SourceInstallWimImage%,%RequireDriver-Listfile%,%TargetDir%,NOACL,NOATTRIB,NOERR - -If,%NOREG%,Equal,False,Begin - Echo,"Registering [%InfFile%] Driver..." - RegCopyDriver,%InfFile% -End - -System,EndLocal - [#_PhoenixAPI_7z#] // =============================================================================================================================== // Name...........: 7z @@ -307,593 +111,6 @@ Return,%ExitCode% System,EndLocal -[#_PhoenixAPI_DISM#] -// =============================================================================================================================== -// Name...........: DISM -// Description....: Execute DISM with the provided arguments. -// Syntax.........: DISM,[,] -// Parameters.....: #1 Args - The arguments to pass to the 7z executable. -// #2 WorkDir - The full path to the working directory. Default is the exe path. -// Return values..: ExitCode provided by the DISM application -// Author.........: Homes32 -// Remarks........: This command is provided as compatibility shim to allow using DISM on Win10 images from a Win7 Host. -// The version of DISM provided with Win7 does not recognize Win10 images when using the /image: argument. -// In order to work around this limitation and allow DISM operations (Localization, driver integration, etc) on Win7 -// we use DISM from Win10 AIK tools, downloaded using JFX's GetWaikTools.exe during Pre-Flight Check. -// * Win10+ - Executes DISM.exe from the HostOS -// * Win7/8 - Executes Win10 AIK DISM.exe -// -// Eventually GetWaikTools will no longer be able to download an AIK that works on Win7, at which time it will -// no longer be possible to build PhoenixPE on Win7. What do you expect running an unsupported OS? ;-) -// -// Related........: Depends on %Tools%\%HostArch%\GWT.exe -// =============================================================================================================================== -[_PhoenixAPI_DISM] -System,SetLocal -If,#1,Equal,"",Halt,"DISM Error: You must provide the dism.exe arguments." - -GetParam,1,%Args% -Getparam,2,%WorkDir% - -System,GetEnv,windir,%HostWinDir% -FileVersion,"%HostWinDir%\System32\ntdll.dll",%HostOSVer% - -If,%HostOSVer%,Bigger,10.0.0.0,ShellExecute,Hide,"dism.exe",%Args%,%WorkDir% -Else,ShellExecute,Hide,"%Tools%\%HostArch%\DISM\dism.exe",%Args%,%WorkDir% - -Return,%ExitCode% - -System,EndLocal - -[#_PhoenixAPI_AddPostProcess#] -// =============================================================================================================================== -// Name...........: AddPostProcess -// Description....: Define a section to process during Build Post-Process -// Syntax.........: AddPostProcess,