From e14874699db0ffc6325147a61a4ef3ddae93f037 Mon Sep 17 00:00:00 2001 From: JakobL-MSFT <110699333+JakobL-MSFT@users.noreply.github.com> Date: Sat, 9 Mar 2024 10:47:17 -0800 Subject: Update to WDK NuGet 26080 (#1139) * Update to WDK NuGet 26080 * Update to WDK NuGet 26080 * Update to WDK NuGet 26080 --------- Co-authored-by: Jakob Lichtenberg --- Build-SampleSet.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Build-SampleSet.ps1') diff --git a/Build-SampleSet.ps1 b/Build-SampleSet.ps1 index b2ed104a..a93548b7 100644 --- a/Build-SampleSet.ps1 +++ b/Build-SampleSet.ps1 @@ -65,7 +65,7 @@ if (-not $env:GITHUB_REPOSITORY -eq '') { # elseif(Test-Path(".\packages")) { $build_environment=("NuGet") - $build_number=26074 + $build_number=26080 } # # EWDK sets environment variable BuildLab. For example 'ni_release_svc_prod1.22621.2428'. -- cgit v1.3.1 From 443c6c24b0f5949daa31fb537449ac63460d1575 Mon Sep 17 00:00:00 2001 From: JakobL-MSFT <110699333+JakobL-MSFT@users.noreply.github.com> Date: Sat, 16 Mar 2024 16:36:30 -0700 Subject: Upgrade nuget to 26085 (#1143) * Update to WDK NuGet 26085 * Update to WDK NuGet 26085 --------- Co-authored-by: Jakob Lichtenberg --- Build-SampleSet.ps1 | 2 +- Directory.Build.props | 10 +++++----- packages.config | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'Build-SampleSet.ps1') diff --git a/Build-SampleSet.ps1 b/Build-SampleSet.ps1 index a93548b7..c0c2e5d1 100644 --- a/Build-SampleSet.ps1 +++ b/Build-SampleSet.ps1 @@ -65,7 +65,7 @@ if (-not $env:GITHUB_REPOSITORY -eq '') { # elseif(Test-Path(".\packages")) { $build_environment=("NuGet") - $build_number=26080 + $build_number=26085 } # # EWDK sets environment variable BuildLab. For example 'ni_release_svc_prod1.22621.2428'. diff --git a/Directory.Build.props b/Directory.Build.props index 1f087a50..14afc64c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - - - - - + + + + + diff --git a/packages.config b/packages.config index 071203ec..8ff7eabb 100644 --- a/packages.config +++ b/packages.config @@ -1,8 +1,8 @@  - - - - - + + + + + -- cgit v1.3.1 From 13d4792ee72883cf25ec5ffc2812c9c6d9933ef4 Mon Sep 17 00:00:00 2001 From: JakobL-MSFT <110699333+JakobL-MSFT@users.noreply.github.com> Date: Mon, 25 Mar 2024 14:56:32 -0700 Subject: Upgrade nuget to 26090 (#1145) * Upgrade NuGet to 26090 * Update Build-SampleSet.ps1 * Update Build-SampleSet.ps1 --- Build-SampleSet.ps1 | 2 +- Directory.Build.props | 10 +++++----- packages.config | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'Build-SampleSet.ps1') diff --git a/Build-SampleSet.ps1 b/Build-SampleSet.ps1 index c0c2e5d1..477b43c7 100644 --- a/Build-SampleSet.ps1 +++ b/Build-SampleSet.ps1 @@ -65,7 +65,7 @@ if (-not $env:GITHUB_REPOSITORY -eq '') { # elseif(Test-Path(".\packages")) { $build_environment=("NuGet") - $build_number=26085 + $build_number=26090 } # # EWDK sets environment variable BuildLab. For example 'ni_release_svc_prod1.22621.2428'. diff --git a/Directory.Build.props b/Directory.Build.props index 14afc64c..94d612ab 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - - - - - + + + + + diff --git a/packages.config b/packages.config index 8ff7eabb..a34b81eb 100644 --- a/packages.config +++ b/packages.config @@ -1,8 +1,8 @@  - - - - - + + + + + -- cgit v1.3.1 From 29274858aa27e24fef094ac381cf55821eedd6b4 Mon Sep 17 00:00:00 2001 From: JakobL-MSFT <110699333+JakobL-MSFT@users.noreply.github.com> Date: Thu, 18 Apr 2024 14:30:41 -0700 Subject: Upgrade NuGet 26095.2 (#1161) Upgrade NuGet to 26095.2 --- Build-SampleSet.ps1 | 2 +- Directory.Build.props | 10 +++++----- packages.config | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'Build-SampleSet.ps1') diff --git a/Build-SampleSet.ps1 b/Build-SampleSet.ps1 index 477b43c7..059dc5b2 100644 --- a/Build-SampleSet.ps1 +++ b/Build-SampleSet.ps1 @@ -65,7 +65,7 @@ if (-not $env:GITHUB_REPOSITORY -eq '') { # elseif(Test-Path(".\packages")) { $build_environment=("NuGet") - $build_number=26090 + $build_number=26095 } # # EWDK sets environment variable BuildLab. For example 'ni_release_svc_prod1.22621.2428'. diff --git a/Directory.Build.props b/Directory.Build.props index 60ca0863..2be5d1c4 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - - - - - + + + + + diff --git a/packages.config b/packages.config index 2f0b5148..3b62f4bb 100644 --- a/packages.config +++ b/packages.config @@ -1,8 +1,8 @@  - - - - - + + + + + -- cgit v1.3.1 From 6edffd4b66aff103080aa1f3148815a8c9d827a9 Mon Sep 17 00:00:00 2001 From: JakobL-MSFT <110699333+JakobL-MSFT@users.noreply.github.com> Date: Wed, 22 May 2024 08:56:48 -0700 Subject: Upgrade NuGet to 26100.1 (#1162) * Upgrade NuGet to 10.0.26100.1-preview.ge-release * Upgrade NuGet to 10.0.26100.2 pre * Upgrade NuGet to 10.0.26100 * Upgrade NuGet to 10.0.26100.1 * Update Building-Locally.md * Update Building-Locally.md --- Build-SampleSet.ps1 | 2 +- Building-Locally.md | 17 ++++++++--------- Directory.Build.props | 10 +++++----- packages.config | 10 +++++----- 4 files changed, 19 insertions(+), 20 deletions(-) (limited to 'Build-SampleSet.ps1') diff --git a/Build-SampleSet.ps1 b/Build-SampleSet.ps1 index 059dc5b2..b0da097a 100644 --- a/Build-SampleSet.ps1 +++ b/Build-SampleSet.ps1 @@ -65,7 +65,7 @@ if (-not $env:GITHUB_REPOSITORY -eq '') { # elseif(Test-Path(".\packages")) { $build_environment=("NuGet") - $build_number=26095 + $build_number=26100 } # # EWDK sets environment variable BuildLab. For example 'ni_release_svc_prod1.22621.2428'. diff --git a/Building-Locally.md b/Building-Locally.md index d9ad76e1..bb9fc610 100644 --- a/Building-Locally.md +++ b/Building-Locally.md @@ -78,9 +78,8 @@ To build the Windows Driver Samples you need a "driver build environment". In e * The Windows Driver Kit. ### Option A: Use WDK NuGet Packages -* Note: This option is only available in pre-release form. * See [Download the Windows Driver Kit (WDK)](https://learn.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk) for instructions on how to install Visual Studio, but only complete "Step 1". You do not need to install the SDK or the WDK. -* Install the Visual Studio Windows Driver Kit Extension (WDK.vsix). Open Visual Studio -> Extensions -> Manage Extensions... -> Online -> Visual Studio Market Place -> Windows Driver Kit -> 10.0.26090.10 -> Download +* Install the Visual Studio Windows Driver Kit Extension (WDK.vsix). Open Visual Studio -> Extensions -> Manage Extensions... -> Online -> Visual Studio Market Place -> Windows Driver Kit -> 10.0.26100.0 -> Download * Launch a "Developer Command Prompt for VS 2022". * Restore WDK packages from feed : @@ -93,11 +92,11 @@ To build the Windows Driver Samples you need a "driver build environment". In e ``` >cd path\to\your\repos\Windows-driver-samples >dir /b packages -Microsoft.Windows.SDK.CPP.10.0.26095.2-preview.ge-release -Microsoft.Windows.SDK.CPP.x64.10.0.26095.2-preview.ge-release -Microsoft.Windows.SDK.CPP.arm64.10.0.26095.2-preview.ge-release -Microsoft.Windows.WDK.x64.10.0.26095.2-preview.ge-release -Microsoft.Windows.WDK.arm64.10.0.26095.2-preview.ge-release +Microsoft.Windows.SDK.CPP.10.0.26000.1 +Microsoft.Windows.SDK.CPP.x64.10.0.26000.1 +Microsoft.Windows.SDK.CPP.arm64.10.0.26000.1 +Microsoft.Windows.WDK.x64.10.0.26000.1 +Microsoft.Windows.WDK.arm64.10.0.26000.1 ``` ### Option B: Use the Windows Driver Kit * Here you will install each of above prerequisites one at a time. @@ -106,7 +105,7 @@ Microsoft.Windows.WDK.arm64.10.0.26095.2-preview.ge-release ### Option C: Use an Enterprise WDK * You can also simply use the Enterprise WDK (EWDK), a standalone, self-contained command-line environment for building drivers that contains all prerequisites in one combined ISO. -* Download the Windows 11, version 22H2 EWDK ISO image from the [official site](https://learn.microsoft.com/en-us/legal/windows/hardware/enterprise-wdk-license-2022) +* See [Download the Windows Driver Kit (WDK)](https://learn.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk) for instructions on how to download the EWDK. * Mount ISO image * Open a terminal * `.\LaunchBuildEnv` @@ -145,7 +144,7 @@ Expected output: ``` PS > .\build-AllSamples.ps1 Build Environment: NuGet -Build Number: 26095 +Build Number: 26100 Samples: 132 Configurations: 2 (Debug Release) Platforms: 2 (x64 arm64) diff --git a/Directory.Build.props b/Directory.Build.props index 9f333db0..811c5f30 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - - - - - + + + + + diff --git a/packages.config b/packages.config index 3b62f4bb..257a510d 100644 --- a/packages.config +++ b/packages.config @@ -1,8 +1,8 @@  - - - - - + + + + + -- cgit v1.3.1 From 263b19b4347fcda2e236c14a9daf41e7d518625d Mon Sep 17 00:00:00 2001 From: JakobL-MSFT <110699333+JakobL-MSFT@users.noreply.github.com> Date: Fri, 28 Jun 2024 09:56:29 -0700 Subject: RI develop to main (#1189) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Memory leakage in message "sizeof(SCANNER_MESSAGE) * threadCount * requestCount" bytes long memory is allocated but only "sizeof(SCANNER_MESSAGE) * threadCount" bytes long of it is freed. * Handles malloc function fail case * Refactors comment line * Solves the miscalculation of the message index * simbatt: Fix broken registry read-back The GetSimBattStateFromRegistry function is currently using default settings if GetSimBattStateFromRegistry succeeds, whereas settings from registry are only applied if GetSimBattStateFromRegistry fails. This does not make sense to me. Therefore proposing to remove the `!` negation from `if (!NT_SUCCESS(Status)) {` on the line after `Status = GetSimBattStateFromRegistry(Device, RegState);` so that default settings are loaded when registry read-back fails. * Issue of freeing memory without waiting completion of threads accessing it is fixed * Fixes information leakage warning Fixes the issue of possible information leakage from uninitialized padding bytes * Avoids possible multiplication overflow warning * Avoids possible multiplication overflow warning * CI Pipelines build with WDK Nuget Packages (#1179) Integrate nuget into the workflow pipelines * FI from main to develop (#1188) Fix text and minor issues in Winget configuration files Co-authored-by: Adonais Romero Gonzalez * Improve version info, vsix installation, and update building locally readme * Fix printing vsix version * Refactored vsix install and cleaned up build sampleset --------- Co-authored-by: İsa Yurdagül <38290414+isayrdgl@users.noreply.github.com> Co-authored-by: Fredrik Orderud Co-authored-by: Christian Allred <13487734+cgallred@users.noreply.github.com> Co-authored-by: tristanb-ntdev <60945150+tristanb-ntdev@users.noreply.github.com> Co-authored-by: Matt <138825652+middlemose@users.noreply.github.com> Co-authored-by: Adonais Romero Gonzalez --- .github/scripts/Install-Vsix.ps1 | 38 ++++++++++++++++++++ .github/workflows/Code-Scanning.yml | 56 +++++++++++++++--------------- .github/workflows/ci-pr.yml | 10 +++--- .github/workflows/ci.yml | 13 +++---- Build-SampleSet.ps1 | 51 +++++++++++++++++++++------ Building-Locally.md | 6 +++- filesys/miniFilter/scanner/user/scanUser.c | 52 +++++++++++++-------------- simbatt/func/miniclass.c | 2 +- 8 files changed, 151 insertions(+), 77 deletions(-) create mode 100644 .github/scripts/Install-Vsix.ps1 (limited to 'Build-SampleSet.ps1') diff --git a/.github/scripts/Install-Vsix.ps1 b/.github/scripts/Install-Vsix.ps1 new file mode 100644 index 00000000..50ef088b --- /dev/null +++ b/.github/scripts/Install-Vsix.ps1 @@ -0,0 +1,38 @@ +<# + +.SYNOPSIS +Download and install the latest WDK VSIX. + +#> + +# set uri by resolving amd64 vsix +$uri = "https://marketplace.visualstudio.com$((Invoke-WebRequest -Uri "https://marketplace.visualstudio.com/items?itemName=DriverDeveloperKits-WDK.WDKVsix").Links | Where-Object outerHTML -like '*(amd64)*' | select -expand href)" + +# set download version +$uri_version = ([regex]'(\d+\.)(\d+\.)(\d+\.)(\d+)').Matches($uri).Value + +# set msbuild path +$msbuild_path = (Resolve-Path "$env:ProgramFiles\Microsoft Visual Studio\2022\*\MSBuild\") + +# download vsix, expand, and store the downloaded version extracted from the extension manifest +"Downloading WDK VSIX version: $uri_version..." +Invoke-WebRequest -Uri "$uri" -OutFile wdk.zip +"Expanding WDK VSIX archive..." +Expand-Archive ".\wdk.zip" .\ +"Extracting version from manifest..." +$downloaded_version = ([xml](Get-Content .\extension.vsixmanifest)).PackageManifest.Metadata.Identity.Version +"Downloaded WDK VSIX version: $downloaded_version" + +# copy msbuild files, extension manifest, and check installed version from the extension manifest +"Copying WDK extension files to build path..." +cp (".\`$MSBuild\*", ".\extension.vsixmanifest") "$msbuild_path" -Recurse -Force +"Extracting version from copied manifest..." +$installed_version = ([xml](Get-Content ${msbuild_path}\extension.vsixmanifest)).PackageManifest.Metadata.Identity.Version +"Installed WDK VSIX Version: $installed_version" +if (-not ("$downloaded_version" -eq "$installed_version")) { + "WDK VSIX installation failed due to version mismatch" + exit 1 +} + +# set github environment variable for vsix version +"SAMPLES_VSIX_VERSION=$installed_version" | Out-File -FilePath "$env:GITHUB_ENV" -Append diff --git a/.github/workflows/Code-Scanning.yml b/.github/workflows/Code-Scanning.yml index a18bcf95..cd0d8abf 100644 --- a/.github/workflows/Code-Scanning.yml +++ b/.github/workflows/Code-Scanning.yml @@ -32,31 +32,31 @@ jobs: language: [ 'cpp' ] steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - submodules: 'recursive' - - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: ${{ matrix.language }} - packs: microsoft/windows-drivers - - name: Add MSBuild to PATH - uses: microsoft/setup-msbuild@v2 - - - name: Retrieve and build all available solutions - run: | - .\Build-AllSamples.ps1 -Verbose -ThrottleLimit 1 - env: - WDS_Configuration: Debug - WDS_Platform: x64 - WDS_WipeOutputs: ${{ true }} - - - name: Perform CodeQL analysis - uses: github/codeql-action/analyze@v3 - with: - category: "/language:${{matrix.language}}" - - - + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: Install WDK VSIX + run: .\.github\scripts\Install-Vsix.ps1 + + - name: Install Nuget Packages + run: nuget restore .\packages.config -PackagesDirectory .\packages\ + + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + packs: microsoft/windows-drivers + + - name: Retrieve and build all available solutions + run: .\Build-AllSamples.ps1 -Verbose -ThrottleLimit 1 + env: + WDS_Configuration: Debug + WDS_Platform: x64 + WDS_WipeOutputs: ${{ true }} + + - name: Perform CodeQL analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml index 7640b966..c04f4adb 100644 --- a/.github/workflows/ci-pr.yml +++ b/.github/workflows/ci-pr.yml @@ -22,8 +22,11 @@ jobs: with: submodules: 'recursive' - - name: Add MSBuild to PATH - uses: microsoft/setup-msbuild@v2 + - name: Install WDK VSIX + run: .\.github\scripts\Install-Vsix.ps1 + + - name: Install Nuget Packages + run: nuget restore .\packages.config -PackagesDirectory .\packages\ - name: Get changed files id: get-changed-files @@ -63,8 +66,7 @@ jobs: path: _logs - name: Join and generate global reports - run: | - .\.github\scripts\Join-CsvReports.ps1 + run: .\.github\scripts\Join-CsvReports.ps1 - name: Archive global overview build reports uses: actions/upload-artifact@v3 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad92f83b..c35a81ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,12 +22,14 @@ jobs: with: submodules: 'recursive' - - name: Add MSBuild to PATH - uses: microsoft/setup-msbuild@v2 + - name: Install WDK VSIX + run: .\.github\scripts\Install-Vsix.ps1 + + - name: Install Nuget Packages + run: nuget restore .\packages.config -PackagesDirectory .\packages\ - name: Retrieve and build all available solutions - run: | - .\Build-AllSamples.ps1 -Verbose + run: .\Build-AllSamples.ps1 -Verbose env: WDS_Configuration: ${{ matrix.configuration }} WDS_Platform: ${{ matrix.platform }} @@ -56,8 +58,7 @@ jobs: path: _logs - name: Join and generate global reports - run: | - .\.github\scripts\Join-CsvReports.ps1 + run: .\.github\scripts\Join-CsvReports.ps1 - name: Archive global overview build reports uses: actions/upload-artifact@v3 diff --git a/Build-SampleSet.ps1 b/Build-SampleSet.ps1 index b0da097a..adae8bb0 100644 --- a/Build-SampleSet.ps1 +++ b/Build-SampleSet.ps1 @@ -9,6 +9,14 @@ param( ) $root = Get-Location + +# launch developer powershell (if necessary to prevent multiple developer sessions) +if (-not $env:VSCMD_VER) { + Import-Module (Resolve-Path "$env:ProgramFiles\Microsoft Visual Studio\2022\*\Common7\Tools\Microsoft.VisualStudio.DevShell.dll") + Enter-VsDevShell -VsInstallPath (Resolve-Path "$env:ProgramFiles\Microsoft Visual Studio\2022\*") + cd $root +} + $ThrottleFactor = 5 $LogicalProcessors = (Get-CIMInstance -Class 'CIM_Processor' -Verbose:$false).NumberOfLogicalProcessors @@ -45,27 +53,34 @@ finally { } # -# Determine build environment: 'GitHub', 'NuGet', 'EWDK', or 'WDK'. Only used to determine build number. +# Determine build environment: 'GitHub', 'NuGet', 'EWDK', or 'WDK'. # Determine build number (used for exclusions based on build number). Five digits. Say, '22621'. +# Determine NuGet package version (if applicable). +# Determine WDK vsix version. # $build_environment="" $build_number=0 +$nuget_package_version=0 +$vsix_version="" # -# WDK NuGet will require presence of a folder 'packages' +# In Github we build using NuGet and get the version from packages and vsix version from env var set from the install vsix step. # -# -# Hack: In GitHub we do not have an environment variable where we can see WDK build number, so we have it hard coded. -# -if (-not $env:GITHUB_REPOSITORY -eq '') { +if ($env:GITHUB_REPOSITORY) { $build_environment="GitHub" - $build_number=22621 + $nuget_package_version=([regex]'(?<=x64\.)(\d+\.)(\d+\.)(\d+\.)(\d+)').Matches((Get-Childitem .\packages\*WDK.x64* -Name)).Value + $build_number=$nuget_package_version.split('.')[2] + $vsix_version = $env:SAMPLES_VSIX_VERSION } # -# Hack: If user has hydrated nuget packages, then use those. That will be indicated by presence of a folder named .\packages. +# WDK NuGet will require presence of a folder 'packages'. The version is sourced from repo .\Env-Vars.ps1. +# +# Hack: If user has hydrated nuget packages, then use those. That will be indicated by presence of a folder named '.\packages'. +# Further, we need to test that the directory has been hydrated using '.\packages\*'. # -elseif(Test-Path(".\packages")) { +elseif(Test-Path(".\packages\*")) { $build_environment=("NuGet") - $build_number=26100 + $nuget_package_version=([regex]'(?<=x64\.)(\d+\.)(\d+\.)(\d+\.)(\d+)').Matches((Get-Childitem .\packages\*WDK.x64* -Name)).Value + $build_number=$nuget_package_version.split('.')[2] } # # EWDK sets environment variable BuildLab. For example 'ni_release_svc_prod1.22621.2428'. @@ -91,7 +106,19 @@ else { Write-Error "Could not determine build environment." exit 1 } - +# +# Get the vsix version from packages if not set +if (-not $vsix_version) { + $vsix_version = ls "${env:ProgramData}\Microsoft\VisualStudio\Packages\Microsoft.Windows.DriverKit,version=*" | Select -ExpandProperty Name + if ($vsix_version) { + $vsix_version = $vsix_version.split('=')[1] + } + else { + Write-Error "No version of the WDK VSIX could be found. The WDK VSIX is not installed." + exit 1 + } +} +# # # InfVerif_AdditionalOptions # @@ -155,6 +182,8 @@ $SolutionsTotal = $sampleSet.Count * $Configurations.Count * $Platforms.Count Write-Output ("Build Environment: " + $build_environment) Write-Output ("Build Number: " + $build_number) +if (($build_environment -eq "GitHub") -or ($build_environment -eq "NuGet")) { Write-Output ("Nuget Package Version: " + $nuget_package_version) } +Write-Output ("WDK VSIX Version: " + $vsix_version) Write-Output ("Samples: " + $sampleSet.Count) Write-Output ("Configurations: " + $Configurations.Count + " (" + $Configurations + ")") Write-Output ("Platforms: " + $Platforms.Count + " (" + $Platforms + ")") diff --git a/Building-Locally.md b/Building-Locally.md index bb9fc610..e3db8dde 100644 --- a/Building-Locally.md +++ b/Building-Locally.md @@ -79,7 +79,11 @@ To build the Windows Driver Samples you need a "driver build environment". In e ### Option A: Use WDK NuGet Packages * See [Download the Windows Driver Kit (WDK)](https://learn.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk) for instructions on how to install Visual Studio, but only complete "Step 1". You do not need to install the SDK or the WDK. -* Install the Visual Studio Windows Driver Kit Extension (WDK.vsix). Open Visual Studio -> Extensions -> Manage Extensions... -> Online -> Visual Studio Market Place -> Windows Driver Kit -> 10.0.26100.0 -> Download +* Install the Visual Studio Windows Driver Kit Extension (WDK.vsix). + * Open Visual Studio -> Extensions -> Manage Extensions... -> Browse. + * In the search bar type: `Windows Driver Kit`. + * Find the `Microsoft` signed extension. + * Click the Install button. * Launch a "Developer Command Prompt for VS 2022". * Restore WDK packages from feed : diff --git a/filesys/miniFilter/scanner/user/scanUser.c b/filesys/miniFilter/scanner/user/scanUser.c index e766261c..08b948b3 100644 --- a/filesys/miniFilter/scanner/user/scanUser.c +++ b/filesys/miniFilter/scanner/user/scanUser.c @@ -254,8 +254,6 @@ Return Value } } - free( message ); - return hr; } @@ -268,13 +266,12 @@ main ( { DWORD requestCount = SCANNER_DEFAULT_REQUEST_COUNT; DWORD threadCount = SCANNER_DEFAULT_THREAD_COUNT; - HANDLE threads[SCANNER_MAX_THREAD_COUNT]; + HANDLE threads[SCANNER_MAX_THREAD_COUNT] = { NULL }; SCANNER_THREAD_CONTEXT context; HANDLE port, completion; - PSCANNER_MESSAGE msg; + PSCANNER_MESSAGE messages; DWORD threadId; HRESULT hr; - DWORD i, j; // // Check how many threads and per thread requests are desired. @@ -343,11 +340,23 @@ main ( context.Completion = completion; // - // Create specified number of threads. + // Allocate messages. // - for (i = 0; i < threadCount; i++) { + messages = calloc(((size_t) threadCount) * requestCount, sizeof(SCANNER_MESSAGE)); + + if (messages == NULL) { + hr = ERROR_NOT_ENOUGH_MEMORY; + goto main_cleanup; + } + + // + // Create specified number of threads. + // + + for (DWORD i = 0; i < threadCount; i++) { + threads[i] = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE) ScannerWorker, @@ -366,20 +375,9 @@ main ( goto main_cleanup; } - for (j = 0; j < requestCount; j++) { - - // - // Allocate the message. - // - -#pragma prefast(suppress:__WARNING_MEMORY_LEAK, "msg will not be leaked because it is freed in ScannerWorker") - msg = malloc( sizeof( SCANNER_MESSAGE ) ); - - if (msg == NULL) { - - hr = ERROR_NOT_ENOUGH_MEMORY; - goto main_cleanup; - } + for (DWORD j = 0; j < requestCount; j++) { + + PSCANNER_MESSAGE msg = &(messages[i * requestCount + j]); memset( &msg->Ovlp, 0, sizeof( OVERLAPPED ) ); @@ -393,24 +391,26 @@ main ( &msg->Ovlp ); if (hr != HRESULT_FROM_WIN32( ERROR_IO_PENDING )) { - - free( msg ); goto main_cleanup; } } } hr = S_OK; - - WaitForMultipleObjectsEx( i, threads, TRUE, INFINITE, FALSE ); - + main_cleanup: + for (INT i = 0; threads[i] != NULL; ++i) { + WaitForSingleObjectEx(threads[i], INFINITE, FALSE); + } + printf( "Scanner: All done. Result = 0x%08x\n", hr ); CloseHandle( port ); CloseHandle( completion ); + free(messages); + return hr; } diff --git a/simbatt/func/miniclass.c b/simbatt/func/miniclass.c index ba2df340..612b4c66 100644 --- a/simbatt/func/miniclass.c +++ b/simbatt/func/miniclass.c @@ -202,7 +202,7 @@ Return Value: } Status = GetSimBattStateFromRegistry(Device, RegState); - if (!NT_SUCCESS(Status)) { + if (NT_SUCCESS(Status)) { RtlZeroMemory(RegState, sizeof(SIMBATT_STATE)); WdfWaitLockAcquire(DevExt->StateLock, NULL); -- cgit v1.3.1