From 66ba13c374c18f97c0d48805707183f52eb728d5 Mon Sep 17 00:00:00 2001 From: Kostiantyn Kostiuk Date: Fri, 27 Feb 2026 17:52:55 +0200 Subject: [PATCH 1/3] Add error flag and action messages to project package JSON output - Extend New-ProjectPackage with iserror and messages properties - Collect action messages and set iserror when createprojectpackage runs with -json - Include driver add result, supplemental files, and playlist unload in messages - Lets JSON consumers get operation result without parsing stdout Signed-off-by: Kostiantyn Kostiuk --- tools/toolsHCK.ps1 | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/tools/toolsHCK.ps1 b/tools/toolsHCK.ps1 index 163f63f..b0667b7 100644 --- a/tools/toolsHCK.ps1 +++ b/tools/toolsHCK.ps1 @@ -77,10 +77,12 @@ function New-PackageProgressInfo($current, $maximum, $message) { # # ProjectPackage -function New-ProjectPackage($name, $projectpackagepath) { +function New-ProjectPackage($name, $projectpackagepath, $iserror, $actionMessages) { $projectpackage = New-Object PSObject $projectpackage | Add-Member -type NoteProperty -Name name -Value $name $projectpackage | Add-Member -type NoteProperty -Name projectpackagepath -Value $projectpackagepath + $projectpackage | Add-Member -type NoteProperty -Name iserror -Value $iserror + $projectpackage | Add-Member -type NoteProperty -Name messages -Value $actionMessages return $projectpackage } @@ -2151,11 +2153,18 @@ function createprojectpackage { } } + $actionMessages = @() + $iserror = $false + $PlaylistManager = $null if (-Not [String]::IsNullOrEmpty($playlist)) { $PlaylistManager = New-Object Microsoft.Windows.Kits.Hardware.ObjectModel.PlaylistManager($WntdProject) - if (-Not $json) { Write-Output "Loading playlist $($playlist)..." } + if (-Not $json) { + Write-Output "Loading playlist $($playlist)..." + } else { + $actionMessages += "Loading playlist $($playlist)..." + } $PlaylistManager.LoadPlaylist($playlist) | Out-Null } @@ -2204,10 +2213,20 @@ function createprojectpackage { if ($AddDriverResult) { Write-Output "Driver added to package from $driver" } else { + $iserror = $true Write-Output "Warning: Driver signability check did not pass" foreach ($err in $ErrorMessages) { Write-Output " Error: $err" } foreach ($warn in $WarningMessages) { Write-Output " Warning: $warn" } } + } else { + if ($AddDriverResult) { + $actionMessages += "Driver added to package from $driver" + } else { + $iserror = $true + $actionMessages += "Warning: Driver signability check did not pass" + foreach ($err in $ErrorMessages) { $actionMessages += "Error: $err" } + foreach ($warn in $WarningMessages) { $actionMessages += "Warning: $warn" } + } } } } @@ -2217,7 +2236,11 @@ function createprojectpackage { if (-Not [String]::IsNullOrEmpty($supplemental)) { if (Test-Path $supplemental) { $PackageWriter.AddSupplementalFiles($supplemental) - if (-Not $json) { Write-Output "Supplemental files added from $supplemental" } + if (-Not $json) { + Write-Output "Supplemental files added from $supplemental" + } else { + $actionMessages += "Supplemental files added from $supplemental" + } } } @@ -2226,7 +2249,11 @@ function createprojectpackage { $PackageWriter.Dispose() if ($PlaylistManager) { - if (-Not $json) { Write-Output "Unloading playlist" } + if (-Not $json) { + Write-Output "Unloading playlist" + } else { + $actionMessages += "Unloading playlist" + } $PlaylistManager.UnloadPlaylist() } @@ -2234,7 +2261,7 @@ function createprojectpackage { if (-Not $json) { Write-Output "Packaged to $($PackagePath)..." } else { - @(New-ProjectPackage $WntdProject.Name $PackagePath) | ConvertTo-Json -Compress + @(New-ProjectPackage $WntdProject.Name $PackagePath $iserror $actionMessages) | ConvertTo-Json -Compress } } # From bb75b1ecd51152f2e577e6e80e27afd8d40adafd Mon Sep 17 00:00:00 2001 From: Kostiantyn Kostiuk Date: Sat, 28 Feb 2026 12:38:20 +0200 Subject: [PATCH 2/3] Update createprojectpackage usage for driver, supplemental, rph and JSON output Made-with: Cursor Signed-off-by: Kostiantyn Kostiuk --- tools/toolsHCK.ps1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/toolsHCK.ps1 b/tools/toolsHCK.ps1 index b0667b7..dffe23b 100644 --- a/tools/toolsHCK.ps1 +++ b/tools/toolsHCK.ps1 @@ -2089,7 +2089,7 @@ function createprojectpackage { Write-Output "" Write-Output "Usage:" Write-Output "" - Write-Output "createprojectpackage [] [-help] [-playlist]" + Write-Output "createprojectpackage [] [-help] [-playlist] [-driver ] [-supplemental ] [-rph]" Write-Output "" Write-Output "Any parameter in [] is optional." Write-Output "" @@ -2101,6 +2101,14 @@ function createprojectpackage { Write-Output "" Write-Output " playlist = Path to the playlist file." Write-Output "" + Write-Output " driver = Path to the driver to add to the package." + Write-Output "" + Write-Output " supplemental = Path to supplemental files to add to the package." + Write-Output "" + Write-Output " rph = Enable progress action handler (interactive package progress)." + Write-Output "" + Write-Output "With [json], output is JSON with name, projectpackagepath, iserror, and messages." + Write-Output "" Write-Output "NOTE: Windows HCK\HLK Studio should be installed on the machine running the script!" } From d63ce335fbc04af417b2514a5925684c4beb60c1 Mon Sep 17 00:00:00 2001 From: Kostiantyn Kostiuk Date: Sat, 28 Feb 2026 15:16:49 +0200 Subject: [PATCH 3/3] Add ability to remove driver signature Made-with: Cursor Signed-off-by: Kostiantyn Kostiuk --- lib/rtoolsHCK.rb | 6 +++++- tools/toolsHCK.ps1 | 27 +++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/lib/rtoolsHCK.rb b/lib/rtoolsHCK.rb index d78b557..3940c75 100755 --- a/lib/rtoolsHCK.rb +++ b/lib/rtoolsHCK.rb @@ -1039,7 +1039,10 @@ def handle_create_project_package(cmd_line, handler) # # +driver_path+:: Provide a driver path to include, (can be nil) # +supplemental_path+:: Provide a supplemental path to include, (can be nil) - def create_project_package(project, playlist = nil, handler = nil, driver_path = nil, supplemental_path = nil) + # +remove_driver_signatures+:: If true, remove driver signatures before + # packaging (default: false) + def create_project_package(project, playlist = nil, handler = nil, driver_path = nil, supplemental_path = nil, + remove_driver_signatures: false) handle_action_exceptions(__method__) do cmd_line = ["createprojectpackage '#{project}' -rph"] cmd_line << 'json' if @json @@ -1051,6 +1054,7 @@ def create_project_package(project, playlist = nil, handler = nil, driver_path = cmd_line << "-driver '#{driver_path}'" unless driver_path.nil? cmd_line << "-supplemental '#{supplemental_path}'" unless supplemental_path.nil? + cmd_line << '-removedriversignatures' if remove_driver_signatures handler = dummy_package_progress_info_handler if handler.nil? handle_create_project_package(cmd_line.join(' '), handler) diff --git a/tools/toolsHCK.ps1 b/tools/toolsHCK.ps1 index dffe23b..077a505 100644 --- a/tools/toolsHCK.ps1 +++ b/tools/toolsHCK.ps1 @@ -2078,7 +2078,7 @@ function ziptestresultlogs { # CreateProjectPackage function createprojectpackage { [CmdletBinding()] - param([Switch]$help, [Switch]$rph, [String]$playlist, [Parameter(Position=1)][String]$project, [Parameter(Position=2)][String]$package, [String]$driver, [String]$supplemental) + param([Switch]$help, [Switch]$rph, [Switch]$removedriversignatures, [String]$playlist, [Parameter(Position=1)][String]$project, [Parameter(Position=2)][String]$package, [String]$driver, [String]$supplemental) function Usage { Write-Output "createprojectpackage:" @@ -2089,7 +2089,7 @@ function createprojectpackage { Write-Output "" Write-Output "Usage:" Write-Output "" - Write-Output "createprojectpackage [] [-help] [-playlist] [-driver ] [-supplemental ] [-rph]" + Write-Output "createprojectpackage [] [-help] [-playlist] [-driver ] [-supplemental ] [-rph] [-removedriversignatures]" Write-Output "" Write-Output "Any parameter in [] is optional." Write-Output "" @@ -2107,6 +2107,8 @@ function createprojectpackage { Write-Output "" Write-Output " rph = Enable progress action handler (interactive package progress)." Write-Output "" + Write-Output "removedriversignatures = Remove driver signatures before packaging (default: do not remove)." + Write-Output "" Write-Output "With [json], output is JSON with name, projectpackagepath, iserror, and messages." Write-Output "" Write-Output "NOTE: Windows HCK\HLK Studio should be installed on the machine running the script!" @@ -2215,6 +2217,27 @@ function createprojectpackage { New-Item -ItemType Directory -Path $symbolPath | Out-Null Get-ChildItem -Path $driver -Filter *.pdb -Recurse | ForEach-Object { Move-Item -Path $_.FullName -Destination $symbolPath -Force } + # Remove driver signatures before packaging to avoid embedded company signatures (only when -removeDriverSignatures) + if ($removedriversignatures) { + Get-ChildItem -Path $driver -Include *.sys, *.dll, *.exe -Recurse | ForEach-Object { + if (-Not $json) { + Write-Output "Removing signature from file '$($_.FullName)' before packaging" + } else { + $actionMessages += "Removing signature from file '$($_.FullName)' before packaging" + } + + $process = Start-Process -Wait -FilePath "$env:WTTSTDIO\..\Tests\amd64\Signtool.exe" -ArgumentList 'remove', '/s', $_.FullName -PassThru + if ($process.ExitCode -ne 0) { + $iserror = $true + if (-Not $json) { + Write-Output "Warning: Failed to remove signature from file '$($_.FullName)'. Signtool exit code: $($process.ExitCode)" + } else { + $actionMessages += "Warning: Failed to remove signature from file '$($_.FullName)'. Signtool exit code: $($process.ExitCode)" + } + } + } + } + $AddDriverResult = $PackageWriter.AddDriver($driver, $symbolPath, $TargetList, $LocaleList, [ref]$ErrorMessages, [ref]$WarningMessages) if (-Not $json) {