From cf1a24a97d2ecc54a2ecec523112289f676f3c82 Mon Sep 17 00:00:00 2001 From: David Pinedo Date: Tue, 15 Mar 2016 11:07:19 -0600 Subject: winrtinstaller: Verify vulkan-1-*dll has correct file name format --- .../ConfigLayersAndVulkanDLL.ps1 | 49 +++++++++++++++++----- 1 file changed, 39 insertions(+), 10 deletions(-) (limited to 'windowsRuntimeInstaller') diff --git a/windowsRuntimeInstaller/ConfigLayersAndVulkanDLL.ps1 b/windowsRuntimeInstaller/ConfigLayersAndVulkanDLL.ps1 index d7f2ba7f..4666f334 100644 --- a/windowsRuntimeInstaller/ConfigLayersAndVulkanDLL.ps1 +++ b/windowsRuntimeInstaller/ConfigLayersAndVulkanDLL.ps1 @@ -50,6 +50,15 @@ $vulkandll = "vulkan-"+$majorabi+".dll" $windrive = $env:SYSTEMDRIVE $winfolder = $env:SYSTEMROOT +function notNumeric ($x) { + try { + 0 + $x | Out-Null + return $false + } catch { + return $true + } +} + # The name of the versioned vulkan dll file is one of the following: # # vulkan------- @@ -80,6 +89,7 @@ $winfolder = $env:SYSTEMROOT # from the file name. They are used later to find the path to the SDK # install directory for the given filename. + function UpdateVulkanSysFolder([string]$dir, [int]$writeSdkName) { # Push the current path on the stack and go to $dir @@ -91,6 +101,17 @@ function UpdateVulkanSysFolder([string]$dir, [int]$writeSdkName) # Find all DLL objects in this directory dir -name vulkan-$majorabi-*.dll | ForEach-Object { + if ($_ -match "=" -or + $_ -match "@" -or + $_ -match " " -or + ($_.Split('-').count -lt 6) -or + ($_.Split('-').count -gt 8)) + { + # If a file name contains "=", "@", or " ", or it contains less then 5 dashes or more than + # 7 dashes, it wasn't installed by the Vulkan Run Time. + # Note that we need to use return inside of ForEach-Object is to continue with iteration. + return + } $major=$_.Split('-')[2] $majorOrig=$major $minor=$_.Split('-')[3] @@ -100,17 +121,16 @@ function UpdateVulkanSysFolder([string]$dir, [int]$writeSdkName) $buildno=$_.Split('-')[5] if ($buildno -match ".dll") { - # and are not in the name - $buildno=$buildno -replace ".dll","" - $buildnoOrig=$buildno - $prerelease="z"*10 - $prereleaseOrig="" - $prebuildno="z"*10 - $prebuildnoOrig="" + # prerelease and prebuildno are not in the name + # Extract buildno, and set prerelease and prebuildno to "z"s + $buildno=$buildno -replace ".dll","" + $buildnoOrig=$buildno + $prerelease="z"*10 + $prereleaseOrig="" + $prebuildno="z"*10 + $prebuildnoOrig="" } else { - - # We assume we don't have more than 5 dashes - + # Extract buildno, prerelease, and prebuildno $f=$_ -replace ".dll","" $buildno=$f.Split('-')[5] $buildnoOrig=$buildno @@ -134,6 +154,15 @@ function UpdateVulkanSysFolder([string]$dir, [int]$writeSdkName) } } + # Make sure fields that are supposed to be numbers are numbers + if (notNumeric($major)) {return} + if (notNumeric($minor)) {return} + if (notNumeric($patch)) {return} + if (notNumeric($buildno)) {return} + if (notNumeric($prebuildno)) { + if ($prebuildno -ne "z"*10) {return} + } + $major = $major.padleft(10,'0') $minor = $minor.padleft(10,'0') $patch = $patch.padleft(10,'0') -- cgit v1.2.3