Skip to content

Conversation

@zjmletang
Copy link

  • Added PowerShell script for fixing NDIS driver signatures
  • Included configuration file for driver management
  • Added .gitignore for the tool directory

Resolves issue where NDIS drivers lack proper signatures in HLK2022 testing environment.

- Added PowerShell script for fixing NDIS driver signatures
- Included configuration file for driver management
- Added .gitignore for the tool directory

Resolves issue where NDIS drivers lack proper signatures in HLK2022 testing environment.

Signed-off-by: Zhang JianMing <zhangjianming.zjm@alibaba-inc.com>
@gemini-code-assist
Copy link

Summary of Changes

Hello @zjmletang, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new tool designed to resolve a critical issue in the HLK2022 testing environment where NDIS drivers are found to be unsigned. The tool, consisting of a PowerShell script and a configuration file, automates the process of identifying these unsigned drivers and replacing them with properly signed versions from existing backup locations within the HLK installation, thereby ensuring test stability and compliance.

Highlights

  • NDIS Driver Signature Fix: A new PowerShell script has been introduced to automatically resolve issues with unsigned NDIS drivers encountered within the HLK2022 testing environment.
  • Tool Configuration: A dedicated configuration file (config.json) is now included to manage the deployment and execution parameters of the NDIS driver fix tool, specifying its installation timing and command-line arguments.
  • Version Control Exclusions: A .gitignore file has been added to the new NDIS_Driver_Fix directory, ensuring that only essential tool files are tracked in version control.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a PowerShell script to fix issues with unsigned NDIS drivers in the HLK environment. The script is well-structured and addresses the problem described. My review includes a few suggestions to improve its robustness and performance. Specifically, I've recommended dynamically determining the HLK installation path instead of hardcoding it, using a more efficient method for collecting unsigned drivers, and reconsidering the use of Start-Sleep at the end of the script. These changes will make the script more reliable and maintainable.

Write-Output ""

# Base path for HLK installation
$hlkBasePath = "C:\Program Files (x86)\Windows Kits\10\Hardware Lab Kit\Tests\amd64\NetHlk"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The HLK base path is hardcoded. This will cause the script to fail if the Hardware Lab Kit is installed in a different location or on a different drive. It's more robust to determine this path dynamically by querying the registry, with a fallback to the default path if the registry key is not found. I'd also recommend adding a check to ensure the path exists before proceeding.

$kitRootPath = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows Kits\Installed Roots" -Name "KitsRoot10" -ErrorAction SilentlyContinue).KitsRoot10
$hlkBasePath = if ($kitRootPath) {
    Join-Path $kitRootPath "Hardware Lab Kit\Tests\amd64\NetHlk"
}
else {
    Write-Warning "Could not find HLK installation path in registry. Falling back to default."
    "C:\Program Files (x86)\Windows Kits\10\Hardware Lab Kit\Tests\amd64\NetHlk"
}

if (-not (Test-Path $hlkBasePath)) {
    Write-Error "HLK path not found at '$hlkBasePath'. Script cannot continue."
}

Comment on lines +73 to +86
$unsignedCount = 0
$unsignedDrivers = @()

foreach ($driver in $protocolDrivers) {
$isSigned = Test-DriverSigned -FilePath $driver.FullName
if (-not $isSigned) {
Write-Output " [UNSIGNED] $($driver.Name)"
$unsignedCount++
$unsignedDrivers += $driver
}
else {
Write-Output " [SIGNED] $($driver.Name)"
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Appending elements to an array using += inside a loop is inefficient as it recreates the array on each addition. A more idiomatic and performant approach in PowerShell is to capture the output of the loop directly. This avoids the overhead of repeated array copying.

    $unsignedDrivers = @(foreach ($driver in $protocolDrivers) {
        $isSigned = Test-DriverSigned -FilePath $driver.FullName
        if (-not $isSigned) {
            Write-Output "  [UNSIGNED] $($driver.Name)"
            $driver # Output the driver object to be collected in the array
        }
        else {
            Write-Output "  [SIGNED] $($driver.Name)"
        }
    })
    $unsignedCount = $unsignedDrivers.Count

Comment on lines +178 to +179
# Wait a few seconds to ensure output is visible
Start-Sleep -Seconds 5

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The Start-Sleep at the end of the script introduces an unconditional 5-second delay. This is likely unnecessary for automated execution (as suggested by the config.json) and can slow down processes. If a pause is required for interactive debugging, it's better to use Read-Host 'Press Enter to continue...' and perhaps make it conditional (e.g., based on a script parameter). For purely automated runs, this can be removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant