!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
-\r
- # Execute the configuration program\r
- nsExec::ExecToStack 'ConfigureRT.exe --abi-major ${VERSION_ABI_MAJOR}'\r
- Rename "configure_rt.log" "$TEMP\VulkanRT\configure_rt.log"\r
- pop $0\r
-\r
- # Ignore errors. If something went wrong, the return value will indicate it.\r
+
+ # 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
!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\r
- # Report the failure\r
- LogText "ConfigureRT.exe failed with return code $0"\r
-\r
+Function ${un}DiagConfigLayersAndVulkanDLL
+ # Report the failure
+ LogText "ConfigureRT.exe failed with return code $0"
+
# Ignore errors
ClearErrors
File ${ICOFILE}
File VULKANRT_LICENSE.RTF
File /oname=LICENSE.txt ..\COPYRIGHT.txt
- File Release\ConfigureRT.exe\r
+ File Release\ConfigureRT.exe
StrCpy $1 15
Call CheckForError
${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"
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}
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\r
+ Delete ConfigureRT.exe
# Finish logging and move log file to TEMP dir
LogSet off
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\r
+ File Release\ConfigureRT.exe
# If running on a 64-bit OS machine
${If} ${RunningX64}
${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"
Delete /REBOOTOK "$IDir\LICENSE.txt"
Delete /REBOOTOK "$IDir\Uninstall${PRODUCTNAME}.exe"
Delete /REBOOTOK "$IDir\V.ico"
- Delete /REBOOTOK "$IDir\ConfigureRT.exe"\r
+ Delete /REBOOTOK "$IDir\ConfigureRT.exe"
Delete /REBOOTOK "$IDir\vulkaninfo.exe"
# If running on a 64-bit OS machine
* - Set the layer registry entried to point to the layer json files in\r
* the Vulkan SDK associated with the most recent vulkan*.dll\r
*\r
- * The program must be called with the following two parameters:\r
+ * The program must be called with the following parameters:\r
* --major-abi: A single number specifying the major abi version\r
- * --ossize: A single integer indicating a 32 or 64 bit OS\r
*/\r
\r
// Compile with: `cl.exe configure_runtime.c /link advapi32.lib`\r
#define snprintf _snprintf\r
#endif\r
\r
+#if defined(_WIN64)\r
+#error "This program is designed only as a 32-bit program. It should not be built as 64-bit."\r
+#endif\r
+\r
#define COPY_BUFFER_SIZE (1024)\r
#define CHECK_ERROR(statement) { int error = (statement); if(error) return error; }\r
#define CHECK_ERROR_HANDLED(statement, handler) { int error = (statement); if(error) { { handler } return error; } }\r
};\r
\r
const char* FLAG_ABI_MAJOR = "--abi-major";\r
-const char* FLAG_OS_SIZE = "--ossize";\r
const char* PATH_SYSTEM32 = "\\SYSTEM32\\";\r
const char* PATH_SYSWOW64 = "\\SysWOW64\\";\r
\r
// Returns: Zero if they are equal, below zero if a predates b, greater than zero if b predates a\r
int compare_versions(const struct SDKVersion* a, const struct SDKVersion* b);\r
\r
-// Copy a binary file\r
-//\r
-// Returns: Zero on success, an error code on failure\r
-int copy_file(const char* destination, const char* source);\r
-\r
// Locate all of the SDK installations\r
//\r
// install_paths (output) - A poiner to an array of the installations paths\r
// extension (input) - The file extensions of the file to be updated\r
// path (input) - The directory of the file (usually System32 or SysWOW64)\r
// abi_major (input) - The ABI major version to be updated\r
-// append_abi_major (input) - Whether or not the ABI number should be appended to the filename\r
+// leave_abi_major (input) - Whether or not the ABI number be left on the output filename\r
// latest_version (output) - The version of the runtime which the file was updated to\r
// Returns: Zero on success, an error code on failure\r
int update_system_file(FILE* log, const char* name, const char* extension, const char* path,\r
- long abi_major, bool append_abi_major, struct SDKVersion* latest_version);\r
+ long abi_major, bool leave_abi_major, struct SDKVersion* latest_version);\r
\r
// Update vulkan.dll and vulkaninfo.exe in all of the windows directories (System32 and SysWOW64)\r
//\r
break;\r
}\r
\r
+ // If this is a 32 bit system, we allow redirection to point this at the 32-bit registries.\r
+ // If not, we add the flag KEY_WOW64_64KEY, to disable redirection for this node.\r
HKEY hKey;\r
REGSAM flags = KEY_ALL_ACCESS;\r
if(platform == PLATFORM_X64) {\r
return strncmp(a->extended, b->extended, SDK_VERSION_BUFFER_SIZE);\r
}\r
\r
-int copy_file(const char* destination, const char* source)\r
-{\r
- // Open files for reading and writing\r
- FILE* src = fopen(source, "rb");\r
- FILE* dest = fopen(destination, "wb");\r
- if(src == NULL || dest == NULL) {\r
- return 60;\r
- }\r
- \r
- // Stream the data between the two files\r
- uint8_t buffer[COPY_BUFFER_SIZE];\r
- size_t read_size;\r
- do {\r
- read_size = fread(buffer, sizeof(uint8_t), COPY_BUFFER_SIZE, src);\r
- if(ferror(src)) {\r
- fclose(src);\r
- fclose(dest);\r
- return 70;\r
- }\r
- size_t write_size = fwrite(buffer, sizeof(uint8_t), read_size, dest);\r
- if(ferror(dest)) {\r
- fclose(src);\r
- fclose(dest);\r
- return 80;\r
- }\r
- } while(read_size == COPY_BUFFER_SIZE);\r
- \r
- // Clean up\r
- fclose(src);\r
- fclose(dest);\r
- \r
- return 0;\r
-}\r
-\r
int find_installations(char*** install_paths, struct SDKVersion** install_versions, size_t* count)\r
{\r
*install_paths = malloc(sizeof(char*) * 64);\r
*install_versions = malloc(sizeof(struct SDKVersion) * 64);\r
*count = 0;\r
\r
+ // We want the 64-bit registries on 64-bit windows, and the 32-bit registries on 32-bit Windows.\r
+ // KEY_WOW64_64KEY accomplishes this because it gets ignored on 32-bit Windows.\r
HKEY hKey;\r
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall",\r
0, KEY_READ | KEY_WOW64_64KEY, &hKey) != ERROR_SUCCESS) {\r
\r
bool removed_one;\r
do {\r
+ // If this is a 32 bit system, we allow redirection to point this at the 32-bit registries.\r
+ // If not, we add the flag KEY_WOW64_64KEY, to disable redirection for this node.\r
HKEY hKey;\r
REGSAM flags = KEY_ALL_ACCESS;\r
if(platform == PLATFORM_X64) {\r
}\r
\r
int update_system_file(FILE* log, const char* name, const char* extension, const char* path,\r
- long abi_major, bool append_abi_major, struct SDKVersion* latest_version)\r
+ long abi_major, bool leave_abi_major, struct SDKVersion* latest_version)\r
{\r
// Generate the filter string\r
- char* filter;\r
- if(append_abi_major) {\r
- const char* pattern = "%s%s-%ld-*-*-*-*%s";\r
- int filter_size = snprintf(NULL, 0, pattern, path, name, abi_major, extension) + 1;\r
- if(filter_size < 0) {\r
- return 180;\r
- }\r
- filter = malloc(filter_size);\r
- snprintf(filter, filter_size, pattern, path, name, abi_major, extension);\r
- } else {\r
- const char* pattern = "%s%s-*-*-*-*%s";\r
- int filter_size = snprintf(NULL, 0, pattern, path, name, extension) + 1;\r
- if(filter_size < 0) {\r
- return 190;\r
- }\r
- filter = malloc(filter_size);\r
- snprintf(filter, filter_size, pattern, path, name, extension);\r
+ const char* pattern = "%s%s-%ld-*-*-*-*%s";\r
+ int filter_size = snprintf(NULL, 0, pattern, path, name, abi_major, extension) + 1;\r
+ if(filter_size < 0) {\r
+ return 180;\r
}\r
+ char* filter = malloc(filter_size);\r
+ snprintf(filter, filter_size, pattern, path, name, abi_major, extension);\r
\r
// Find all of the files that match the pattern\r
char* latest_filename = malloc(64);\r
// Decide if this is the latest file\r
if(compare_versions(latest_version, &version) < 0) {\r
*latest_version = version;\r
- const char* pattern = "%s%s";\r
- int size = snprintf(NULL, 0, pattern, path, find_data.cFileName) + 1;\r
+ const char* latestPattern = "%s%s";\r
+ int size = snprintf(NULL, 0, latestPattern, path, find_data.cFileName) + 1;\r
if(size < 0) {\r
free(latest_filename);\r
return 200;\r
}\r
latest_filename = realloc(latest_filename, size);\r
- snprintf(latest_filename, size, pattern, path, find_data.cFileName);\r
+ snprintf(latest_filename, size, latestPattern, path, find_data.cFileName);\r
}\r
}\r
FindClose(find);\r
latest_version->minor, latest_version->patch, latest_version->build);\r
\r
// Generate output filename\r
- const char* pattern = "%s%s%s";\r
- int out_size = snprintf(NULL, 0, pattern, path, name, extension) + 1;\r
- if(out_size < 0) {\r
- return 210;\r
+ char* output_filename;\r
+ if(leave_abi_major) {\r
+ const char* outPattern = "%s%s-%ld%s";\r
+ int out_size = snprintf(NULL, 0, outPattern, path, name, abi_major, extension) + 1;\r
+ if(out_size < 0) {\r
+ free(latest_filename);\r
+ return 205;\r
+ }\r
+ output_filename = malloc(out_size);\r
+ snprintf(output_filename, out_size, outPattern, path, name, abi_major, extension);\r
+ } else {\r
+ const char* outPattern = "%s%s%s";\r
+ int out_size = snprintf(NULL, 0, outPattern, path, name, extension) + 1;\r
+ if(out_size < 0) {\r
+ free(latest_filename);\r
+ return 210;\r
+ }\r
+ output_filename = malloc(out_size);\r
+ snprintf(output_filename, out_size, outPattern, path, name, extension);\r
}\r
- char* output_filename = malloc(out_size);\r
- snprintf(output_filename, out_size, pattern, path, name, extension);\r
\r
// Remove any older version of the output file\r
if(remove(output_filename) == 0) {\r
}\r
\r
fprintf(log, "Attempting to copy file %s to %s\n", latest_filename, output_filename);\r
- CHECK_ERROR_HANDLED(copy_file(output_filename, latest_filename), { free(latest_filename); });\r
+ if(CopyFile(latest_filename, output_filename, false) == 0) {\r
+ free(latest_filename);\r
+ free(output_filename);\r
+ return 215;\r
+ }\r
\r
free(latest_filename);\r
+ free(output_filename);\r
return 0;\r
}\r
\r
\r
strcpy(system_path + windows_path_size - 1, PATH_SYSTEM32);\r
fprintf(log, "Updating system directory: %s\n", system_path);\r
- CHECK_ERROR_HANDLED(update_system_file(log, "vulkan-1", ".dll", system_path, abi_major, false,\r
+ CHECK_ERROR_HANDLED(update_system_file(log, "vulkan", ".dll", system_path, abi_major, true,\r
latest_runtime_version), { free(system_path); });\r
- CHECK_ERROR_HANDLED(update_system_file(log, "vulkaninfo", ".exe", system_path, abi_major, true,\r
+ CHECK_ERROR_HANDLED(update_system_file(log, "vulkaninfo", ".exe", system_path, abi_major, false,\r
&version), { free(system_path); });\r
if(compare_versions(latest_runtime_version, &version) != 0) {\r
+ free(system_path);\r
return 220;\r
}\r
\r
if(platform == PLATFORM_X64) {\r
strcpy(system_path + windows_path_size - 1, PATH_SYSWOW64);\r
fprintf(log, "\nUpdating system directory: %s\n", system_path);\r
- CHECK_ERROR_HANDLED(update_system_file(log, "vulkan-1", ".dll", system_path, abi_major,\r
- false, &version), { free(system_path); });\r
+ CHECK_ERROR_HANDLED(update_system_file(log, "vulkan", ".dll", system_path, abi_major,\r
+ true, &version), { free(system_path); });\r
if(compare_versions(latest_runtime_version, &version) != 0) {\r
+ free(system_path);\r
return 230;\r
}\r
CHECK_ERROR_HANDLED(update_system_file(log, "vulkaninfo", ".exe", system_path, abi_major,\r
- true, &version), { free(system_path); });\r
+ false, &version), { free(system_path); });\r
if(compare_versions(latest_runtime_version, &version) != 0) {\r
+ free(system_path);\r
return 240;\r
}\r
}\r