summaryrefslogtreecommitdiff
path: root/windowsRuntimeInstaller
diff options
context:
space:
mode:
authorLenny Komow <lenny@lunarg.com>2016-08-12 13:26:20 -0600
committerLenny Komow <lenny@lunarg.com>2016-08-12 14:35:24 -0600
commitb859c5022ed956f59ce676044c2c315593254191 (patch)
tree6cb29afa78c49a0bc2b60d0894f0eb6a1c7e92d4 /windowsRuntimeInstaller
parent95c200f23c36f48d44c2fcef0aa793a0b300ddd0 (diff)
winsdk: Clean up confiure_runtime.c and docs
Diffstat (limited to 'windowsRuntimeInstaller')
-rw-r--r--windowsRuntimeInstaller/InstallerRT.nsi46
-rw-r--r--windowsRuntimeInstaller/README.txt12
-rw-r--r--windowsRuntimeInstaller/configure_runtime.c133
3 files changed, 85 insertions, 106 deletions
diff --git a/windowsRuntimeInstaller/InstallerRT.nsi b/windowsRuntimeInstaller/InstallerRT.nsi
index da193934..79c7a5f7 100644
--- a/windowsRuntimeInstaller/InstallerRT.nsi
+++ b/windowsRuntimeInstaller/InstallerRT.nsi
@@ -233,17 +233,17 @@ VIAddVersionKey "LegalCopyright" ""
!endif
-# Function to run ConfigLayersAndVulkanDll ps script.
+# Function to run ConfigureRT program.
# Return value is in $0 - 0 is success, all else is failure.
!macro ConfigLayersAndVulkanDLL un
Function ${un}ConfigLayersAndVulkanDLL
-
- # Execute the configuration program
- nsExec::ExecToStack 'ConfigureRT.exe --abi-major ${VERSION_ABI_MAJOR}'
- Rename "configure_rt.log" "$TEMP\VulkanRT\configure_rt.log"
- pop $0
-
- # Ignore errors. If something went wrong, the return value will indicate it.
+
+ # Execute the configuration program
+ nsExec::ExecToStack 'ConfigureRT.exe --abi-major ${VERSION_ABI_MAJOR}'
+ Rename "configure_rt.log" "$TEMP\VulkanRT\configure_rt.log"
+ pop $0
+
+ # Ignore errors. If something went wrong, the return value will indicate it.
ClearErrors
FunctionEnd
@@ -252,13 +252,13 @@ FunctionEnd
!insertmacro ConfigLayersAndVulkanDLL "un."
-# Function to run diagnostics if ConfigLayersAndVulkanDll ps script failed.
-# On entry $0, contains the return value from ConfigLayersAndVulkanDll.ps1. It shouldn't be changed.
+# Function to run diagnostics if ConfigureRT program failed.
+# On entry $0, contains the return value from ConfigureRT.exe. It shouldn't be changed.
!macro DiagConfigLayersAndVulkanDLL un
-Function ${un}DiagConfigLayersAndVulkanDLL
- # Report the failure
- LogText "ConfigureRT.exe failed with return code $0"
-
+Function ${un}DiagConfigLayersAndVulkanDLL
+ # Report the failure
+ LogText "ConfigureRT.exe failed with return code $0"
+
# Ignore errors
ClearErrors
@@ -330,7 +330,7 @@ Section
File ${ICOFILE}
File VULKANRT_LICENSE.RTF
File /oname=LICENSE.txt ..\COPYRIGHT.txt
- File Release\ConfigureRT.exe
+ File Release\ConfigureRT.exe
StrCpy $1 15
Call CheckForError
@@ -466,7 +466,7 @@ Section
${Endif}
- # Run the ConfigLayersAndVulkanDLL.ps1 script to copy the most recent version of
+ # Run the ConfigureRT program to copy the most recent version of
# vulkan-<abimajor>-*.dll to vulkan-<abimajor>.dll, and to set up layer registry
# entries to use layers from the corresponding SDK
SetOutPath "$INSTDIR"
@@ -475,7 +475,7 @@ Section
SetOutPath "$INSTDIR"
Call DiagConfigLayersAndVulkanDLL
- # The Powershell script failed, and we don't know why.
+ # The program failed, and we don't know why.
# Simply configure system to use our loader and vulkaninfo.
MessageBox MB_OK "Warning!$\n$\nPowershell script called by VulkanRT Installer failed with error $0. Is Powershell installed on your system?$\n$\nWill configure system with Vulkan $FileVersion." /SD IDOK
${If} ${RunningX64}
@@ -493,9 +493,9 @@ Section
StrCpy $1 60
Call CheckForError
- # We are done using ConfigLayersAndVulkanDLL.ps1, delete it. It will be re-installed
+ # We are done using ConfigureRT.exe, delete it. It will be re-installed
# by the uninstaller when it needs to be run again during uninstall.
- Delete ConfigureRT.exe
+ Delete ConfigureRT.exe
# Finish logging and move log file to TEMP dir
LogSet off
@@ -568,9 +568,9 @@ Section "uninstall"
Call un.CheckForError
- # Install the ConfigLayersAndVulkanDLL.ps1 so we can run it.
+ # Install ConfigureRT.exe so we can run it.
# It will be deleted later when we remove the install directory.
- File Release\ConfigureRT.exe
+ File Release\ConfigureRT.exe
# If running on a 64-bit OS machine
${If} ${RunningX64}
@@ -615,7 +615,7 @@ Section "uninstall"
${Endif}
- # Run the ConfigLayersAndVulkanDLL.ps1 script to copy the most recent version of
+ # Run the ConfigureRT.exe program to copy the most recent version of
# vulkan-<abimajor>-*.dll to vulkan-<abimajor>.dll, and to set up layer registry
# entries to use layers from the corresponding SDK
SetOutPath "$IDir"
@@ -644,7 +644,7 @@ Section "uninstall"
Delete /REBOOTOK "$IDir\LICENSE.txt"
Delete /REBOOTOK "$IDir\Uninstall${PRODUCTNAME}.exe"
Delete /REBOOTOK "$IDir\V.ico"
- Delete /REBOOTOK "$IDir\ConfigureRT.exe"
+ Delete /REBOOTOK "$IDir\ConfigureRT.exe"
Delete /REBOOTOK "$IDir\vulkaninfo.exe"
# If running on a 64-bit OS machine
diff --git a/windowsRuntimeInstaller/README.txt b/windowsRuntimeInstaller/README.txt
index 02dce106..a8f7df52 100644
--- a/windowsRuntimeInstaller/README.txt
+++ b/windowsRuntimeInstaller/README.txt
@@ -78,7 +78,7 @@ Some notes on the behavior of the Windows Vulkan Runtime Installer:
the Vulkan runtime. When it is run on a 32-bit version of
Windows, it will install the 32 bit version of the Vulkan runtime.
- o The VulkanRT-<version>-Installer.exe created with the above steps
+ o The VulkanRT-<version>-Installer.exe created with the above ste`
can be run in silent mode by using the /S command line option when
invoking the installer.
@@ -109,9 +109,9 @@ Some notes on the behavior of the Windows Vulkan Runtime Installer:
o The Vulkan Runtime Installer installs the Vulkan loader as
C:\Windows\System32\vulkan-<version>.dll. It then runs the
- Powershell script ConfigLayersAndVulkanDLL.ps1, that compares
- versions of the loader in C:\Windows\System32 that have the
- same VERSION_ABI_MAJOR as the version being installed. The
+ program ConfigureRT.exe (the source for which is included), that
+ compares versions of the loader in C:\Windows\System32 that have
+ the same VERSION_ABI_MAJOR as the version being installed. The
script selects the most recent one of these loader files and
copies it to C:\Windows\System32\vulkan-<VERSION_ABI_MAJOR>.dll.
For example, during the install of Vulkan Runtime version 2.0.1.1,
@@ -145,8 +145,8 @@ Some notes on the behavior of the Windows Vulkan Runtime Installer:
HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\VulkanRT<version>\UninstallString
o The Installer and Uninstaller create log files, which can be
- found in the VulkanrRT folder in the current TEMP folder.
+ found in the VulkanRT folder in the current TEMP folder.
(The TEMP folder is generally identified by the TEMP environment
variable). In addition to installer/uninstaller logs files,
the folder also contains a log from the last run of the
- ConfigLayersAndVulkanDLL.ps1 script.
+ ConfigureRT.exe program.
diff --git a/windowsRuntimeInstaller/configure_runtime.c b/windowsRuntimeInstaller/configure_runtime.c
index 5f80663a..10cf5719 100644
--- a/windowsRuntimeInstaller/configure_runtime.c
+++ b/windowsRuntimeInstaller/configure_runtime.c
@@ -30,9 +30,8 @@
* - Set the layer registry entried to point to the layer json files in
* the Vulkan SDK associated with the most recent vulkan*.dll
*
- * The program must be called with the following two parameters:
+ * The program must be called with the following parameters:
* --major-abi: A single number specifying the major abi version
- * --ossize: A single integer indicating a 32 or 64 bit OS
*/
// Compile with: `cl.exe configure_runtime.c /link advapi32.lib`
@@ -52,6 +51,10 @@
#define snprintf _snprintf
#endif
+#if defined(_WIN64)
+#error "This program is designed only as a 32-bit program. It should not be built as 64-bit."
+#endif
+
#define COPY_BUFFER_SIZE (1024)
#define CHECK_ERROR(statement) { int error = (statement); if(error) return error; }
#define CHECK_ERROR_HANDLED(statement, handler) { int error = (statement); if(error) { { handler } return error; } }
@@ -74,7 +77,6 @@ struct SDKVersion
};
const char* FLAG_ABI_MAJOR = "--abi-major";
-const char* FLAG_OS_SIZE = "--ossize";
const char* PATH_SYSTEM32 = "\\SYSTEM32\\";
const char* PATH_SYSWOW64 = "\\SysWOW64\\";
@@ -94,11 +96,6 @@ int add_explicit_layers(FILE* log, const char* install_path, enum Platform platf
// Returns: Zero if they are equal, below zero if a predates b, greater than zero if b predates a
int compare_versions(const struct SDKVersion* a, const struct SDKVersion* b);
-// Copy a binary file
-//
-// Returns: Zero on success, an error code on failure
-int copy_file(const char* destination, const char* source);
-
// Locate all of the SDK installations
//
// install_paths (output) - A poiner to an array of the installations paths
@@ -163,11 +160,11 @@ int update_registry_layers(FILE* log, enum Platform platform, const struct SDKVe
// extension (input) - The file extensions of the file to be updated
// path (input) - The directory of the file (usually System32 or SysWOW64)
// abi_major (input) - The ABI major version to be updated
-// append_abi_major (input) - Whether or not the ABI number should be appended to the filename
+// leave_abi_major (input) - Whether or not the ABI number be left on the output filename
// latest_version (output) - The version of the runtime which the file was updated to
// Returns: Zero on success, an error code on failure
int update_system_file(FILE* log, const char* name, const char* extension, const char* path,
- long abi_major, bool append_abi_major, struct SDKVersion* latest_version);
+ long abi_major, bool leave_abi_major, struct SDKVersion* latest_version);
// Update vulkan.dll and vulkaninfo.exe in all of the windows directories (System32 and SysWOW64)
//
@@ -221,6 +218,8 @@ int add_explicit_layers(FILE* log, const char* install_path, enum Platform platf
break;
}
+ // If this is a 32 bit system, we allow redirection to point this at the 32-bit registries.
+ // If not, we add the flag KEY_WOW64_64KEY, to disable redirection for this node.
HKEY hKey;
REGSAM flags = KEY_ALL_ACCESS;
if(platform == PLATFORM_X64) {
@@ -283,46 +282,14 @@ int compare_versions(const struct SDKVersion* a, const struct SDKVersion* b)
return strncmp(a->extended, b->extended, SDK_VERSION_BUFFER_SIZE);
}
-int copy_file(const char* destination, const char* source)
-{
- // Open files for reading and writing
- FILE* src = fopen(source, "rb");
- FILE* dest = fopen(destination, "wb");
- if(src == NULL || dest == NULL) {
- return 60;
- }
-
- // Stream the data between the two files
- uint8_t buffer[COPY_BUFFER_SIZE];
- size_t read_size;
- do {
- read_size = fread(buffer, sizeof(uint8_t), COPY_BUFFER_SIZE, src);
- if(ferror(src)) {
- fclose(src);
- fclose(dest);
- return 70;
- }
- size_t write_size = fwrite(buffer, sizeof(uint8_t), read_size, dest);
- if(ferror(dest)) {
- fclose(src);
- fclose(dest);
- return 80;
- }
- } while(read_size == COPY_BUFFER_SIZE);
-
- // Clean up
- fclose(src);
- fclose(dest);
-
- return 0;
-}
-
int find_installations(char*** install_paths, struct SDKVersion** install_versions, size_t* count)
{
*install_paths = malloc(sizeof(char*) * 64);
*install_versions = malloc(sizeof(struct SDKVersion) * 64);
*count = 0;
+ // We want the 64-bit registries on 64-bit windows, and the 32-bit registries on 32-bit Windows.
+ // KEY_WOW64_64KEY accomplishes this because it gets ignored on 32-bit Windows.
HKEY hKey;
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall",
0, KEY_READ | KEY_WOW64_64KEY, &hKey) != ERROR_SUCCESS) {
@@ -502,6 +469,8 @@ int remove_explicit_layers(FILE* log, const char** install_paths, size_t count,
bool removed_one;
do {
+ // If this is a 32 bit system, we allow redirection to point this at the 32-bit registries.
+ // If not, we add the flag KEY_WOW64_64KEY, to disable redirection for this node.
HKEY hKey;
REGSAM flags = KEY_ALL_ACCESS;
if(platform == PLATFORM_X64) {
@@ -585,27 +554,16 @@ int update_registry_layers(FILE* log, enum Platform platform, const struct SDKVe
}
int update_system_file(FILE* log, const char* name, const char* extension, const char* path,
- long abi_major, bool append_abi_major, struct SDKVersion* latest_version)
+ long abi_major, bool leave_abi_major, struct SDKVersion* latest_version)
{
// Generate the filter string
- char* filter;
- if(append_abi_major) {
- const char* pattern = "%s%s-%ld-*-*-*-*%s";
- int filter_size = snprintf(NULL, 0, pattern, path, name, abi_major, extension) + 1;
- if(filter_size < 0) {
- return 180;
- }
- filter = malloc(filter_size);
- snprintf(filter, filter_size, pattern, path, name, abi_major, extension);
- } else {
- const char* pattern = "%s%s-*-*-*-*%s";
- int filter_size = snprintf(NULL, 0, pattern, path, name, extension) + 1;
- if(filter_size < 0) {
- return 190;
- }
- filter = malloc(filter_size);
- snprintf(filter, filter_size, pattern, path, name, extension);
+ const char* pattern = "%s%s-%ld-*-*-*-*%s";
+ int filter_size = snprintf(NULL, 0, pattern, path, name, abi_major, extension) + 1;
+ if(filter_size < 0) {
+ return 180;
}
+ char* filter = malloc(filter_size);
+ snprintf(filter, filter_size, pattern, path, name, abi_major, extension);
// Find all of the files that match the pattern
char* latest_filename = malloc(64);
@@ -622,14 +580,14 @@ int update_system_file(FILE* log, const char* name, const char* extension, const
// Decide if this is the latest file
if(compare_versions(latest_version, &version) < 0) {
*latest_version = version;
- const char* pattern = "%s%s";
- int size = snprintf(NULL, 0, pattern, path, find_data.cFileName) + 1;
+ const char* latestPattern = "%s%s";
+ int size = snprintf(NULL, 0, latestPattern, path, find_data.cFileName) + 1;
if(size < 0) {
free(latest_filename);
return 200;
}
latest_filename = realloc(latest_filename, size);
- snprintf(latest_filename, size, pattern, path, find_data.cFileName);
+ snprintf(latest_filename, size, latestPattern, path, find_data.cFileName);
}
}
FindClose(find);
@@ -645,13 +603,26 @@ int update_system_file(FILE* log, const char* name, const char* extension, const
latest_version->minor, latest_version->patch, latest_version->build);
// Generate output filename
- const char* pattern = "%s%s%s";
- int out_size = snprintf(NULL, 0, pattern, path, name, extension) + 1;
- if(out_size < 0) {
- return 210;
+ char* output_filename;
+ if(leave_abi_major) {
+ const char* outPattern = "%s%s-%ld%s";
+ int out_size = snprintf(NULL, 0, outPattern, path, name, abi_major, extension) + 1;
+ if(out_size < 0) {
+ free(latest_filename);
+ return 205;
+ }
+ output_filename = malloc(out_size);
+ snprintf(output_filename, out_size, outPattern, path, name, abi_major, extension);
+ } else {
+ const char* outPattern = "%s%s%s";
+ int out_size = snprintf(NULL, 0, outPattern, path, name, extension) + 1;
+ if(out_size < 0) {
+ free(latest_filename);
+ return 210;
+ }
+ output_filename = malloc(out_size);
+ snprintf(output_filename, out_size, outPattern, path, name, extension);
}
- char* output_filename = malloc(out_size);
- snprintf(output_filename, out_size, pattern, path, name, extension);
// Remove any older version of the output file
if(remove(output_filename) == 0) {
@@ -661,9 +632,14 @@ int update_system_file(FILE* log, const char* name, const char* extension, const
}
fprintf(log, "Attempting to copy file %s to %s\n", latest_filename, output_filename);
- CHECK_ERROR_HANDLED(copy_file(output_filename, latest_filename), { free(latest_filename); });
+ if(CopyFile(latest_filename, output_filename, false) == 0) {
+ free(latest_filename);
+ free(output_filename);
+ return 215;
+ }
free(latest_filename);
+ free(output_filename);
return 0;
}
@@ -677,25 +653,28 @@ int update_windows_directories(FILE* log, long abi_major, enum Platform platform
strcpy(system_path + windows_path_size - 1, PATH_SYSTEM32);
fprintf(log, "Updating system directory: %s\n", system_path);
- CHECK_ERROR_HANDLED(update_system_file(log, "vulkan-1", ".dll", system_path, abi_major, false,
+ CHECK_ERROR_HANDLED(update_system_file(log, "vulkan", ".dll", system_path, abi_major, true,
latest_runtime_version), { free(system_path); });
- CHECK_ERROR_HANDLED(update_system_file(log, "vulkaninfo", ".exe", system_path, abi_major, true,
+ CHECK_ERROR_HANDLED(update_system_file(log, "vulkaninfo", ".exe", system_path, abi_major, false,
&version), { free(system_path); });
if(compare_versions(latest_runtime_version, &version) != 0) {
+ free(system_path);
return 220;
}
if(platform == PLATFORM_X64) {
strcpy(system_path + windows_path_size - 1, PATH_SYSWOW64);
fprintf(log, "\nUpdating system directory: %s\n", system_path);
- CHECK_ERROR_HANDLED(update_system_file(log, "vulkan-1", ".dll", system_path, abi_major,
- false, &version), { free(system_path); });
+ CHECK_ERROR_HANDLED(update_system_file(log, "vulkan", ".dll", system_path, abi_major,
+ true, &version), { free(system_path); });
if(compare_versions(latest_runtime_version, &version) != 0) {
+ free(system_path);
return 230;
}
CHECK_ERROR_HANDLED(update_system_file(log, "vulkaninfo", ".exe", system_path, abi_major,
- true, &version), { free(system_path); });
+ false, &version), { free(system_path); });
if(compare_versions(latest_runtime_version, &version) != 0) {
+ free(system_path);
return 240;
}
}