authorgravatar for rsdimenus@gmail.comDimenus <rsdimenus@gmail.com> 2017-11-01 14:33:14-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-11-01 15:33:14-04:00
log38f05d4ac59aa799f947ae1fb4671acafcc283cb
tree1fecfc847e94b56b5f8ccda5a5d0ee79464725cd
parentb35689b70de2da0c28d4d6ab56e2987cddf80e77

WIN32: Linking with the CRT at runtime. (#570)

Disclaimer: Forgive me if my format sucks, I've never submitted a PR before! Fixes: #517 I added a few things to allow zig to link with the CRT properly both statically and dynamically. In Visual Studio 2017, Microsoft changed how the c-runtime is factored again. With this change, they also added a COM interface to allow you to query the respective Visual Studio instance for two of them. This does that and also falls back on a registry query for 2015 support. If you're using a Visual Studio instance older than 2015, you'll have to use the existing options available with the zig compiler. Changes are listed below along with a general description of the changes. all_types.cpp: The separate variables for msvc/kern32 have been removed and all win32 libc directory paths have been combined into a ZigList since we're querying more than two directories and differentiating one from another doesn't matter to lld. analyze.cpp: The existing functions were extended to support querying libc libs & libc headers at runtime. codegen.cpp/hpp: Microsoft uses the new 'Universal C Runtime' name now. Doesn't matter from a functionality standpoint. I left the compiler switches as is to not introduce any breaking changes. link.cpp: We're linking 4 libs and generating another in order to support the UCRT. Dynamic: msvcrt/d, vcruntime/d, ucrt/d, legacy_stdio_definitions.lib Static: libcmt/d, libvcruntime/d libucrt/d, legacy_stdio_definitions.lib main.cpp: Update function call names. os.cpp/hpp: COM/Registry interface for querying Windows UCRT/SDK. Sources: [Windows CRT](https://docs.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features) [VS 2015 Breaking Changes](https://msdn.microsoft.com/en-us/library/bb531344.aspx)

11 files changed, 1316 insertions(+), 86 deletions(-)

src/all_types.hpp+3-2
......@@ -35,6 +35,7 @@ struct IrInstruction;
3535struct IrInstructionCast;
3636struct IrBasicBlock;
3737struct ScopeDecls;
38struct ZigWindowsSDK;
3839
3940struct IrGotoItem {
4041 AstNode *source_node;
......@@ -1461,17 +1462,17 @@ struct CodeGen {
14611462 bool have_winmain_crt_startup;
14621463 bool have_dllmain_crt_startup;
14631464 bool have_pub_panic;
1465 ZigList<Buf*> libc_lib_dirs_list;
14641466 Buf *libc_lib_dir;
14651467 Buf *libc_static_lib_dir;
14661468 Buf *libc_include_dir;
1467 Buf *msvc_lib_dir;
1468 Buf *kernel32_lib_dir;
14691469 Buf *zig_lib_dir;
14701470 Buf *zig_std_dir;
14711471 Buf *zig_c_headers_dir;
14721472 Buf *zig_std_special_dir;
14731473 Buf *dynamic_linker;
14741474 Buf *ar_path;
1475 ZigWindowsSDK *win_sdk;
14751476 Buf triple_str;
14761477 BuildMode build_mode;
14771478 bool is_test_build;
src/analyze.cpp+39-47
......@@ -1,4 +1,4 @@
1/*
1/*
22 * Copyright (c) 2015 Andrew Kelley
33 *
44 * This file is part of zig, which is MIT licensed.
......@@ -3371,65 +3371,57 @@ bool handle_is_ptr(TypeTableEntry *type_entry) {
33713371}
33723372
33733373void find_libc_include_path(CodeGen *g) {
3374#ifdef ZIG_OS_WINDOWS
33743375 if (!g->libc_include_dir || buf_len(g->libc_include_dir) == 0) {
3376 if (g->win_sdk == nullptr) {
3377 if (os_find_windows_sdk(&g->win_sdk)) {
3378 zig_panic("Unable to determine Windows SDK path.");
3379 }
3380 }
3381
3382 if (g->zig_target.os == ZigLLVM_Win32) {
3383 if (os_get_win32_ucrt_include_path(g->win_sdk, g->libc_include_dir)) {
3384 zig_panic("Unable to determine libc include path.");
3385 }
3386 }
3387 }
3388 return;
3389#endif
3390 // TODO find libc at runtime for other operating systems
3391 if(!g->libc_include_dir || buf_len(g->libc_include_dir) == 0) {
33753392 zig_panic("Unable to determine libc include path.");
33763393 }
33773394}
33783395
33793396void find_libc_lib_path(CodeGen *g) {
33803397#ifdef ZIG_OS_WINDOWS
3381 if (!g->msvc_lib_dir && g->zig_target.os == ZigLLVM_Win32) {
3382 Buf *msvc_lib_dir;
3383 if (g->zig_target.arch.arch == ZigLLVM_arm) {
3384 msvc_lib_dir = buf_create_from_str("C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\lib\\arm");
3385 } else if (g->zig_target.arch.arch == ZigLLVM_x86_64) {
3386 msvc_lib_dir = buf_create_from_str("C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\lib\\amd64");
3387 } else if (g->zig_target.arch.arch == ZigLLVM_x86) {
3388 msvc_lib_dir = buf_create_from_str("C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\lib");
3389 } else {
3390 zig_panic("unable to determine msvc lib path");
3391 }
3392 Buf *test_path = buf_alloc();
3393 os_path_join(msvc_lib_dir, buf_create_from_str("vcruntime.lib"), test_path);
3394 bool result;
3395 int err;
3396 if ((err = os_file_exists(test_path, &result))) {
3397 result = false;
3398 }
3399 if (result) {
3400 g->msvc_lib_dir = msvc_lib_dir;
3401 } else {
3402 zig_panic("Unable to determine msvc lib path.");
3398 if (g->zig_target.os == ZigLLVM_Win32) {
3399 if (g->win_sdk == nullptr) {
3400 if (os_find_windows_sdk(&g->win_sdk)) {
3401 zig_panic("Unable to determine Windows SDK path.");
3402 }
34033403 }
3404 }
34053404
3406 if (!g->kernel32_lib_dir && g->zig_target.os == ZigLLVM_Win32) {
3407 Buf *kernel32_lib_dir;
3408 if (g->zig_target.arch.arch == ZigLLVM_arm) {
3409 kernel32_lib_dir = buf_create_from_str(
3410 "C:\\Program Files (x86)\\Windows Kits\\8.1\\Lib\\winv6.3\\um\\arm");
3411 } else if (g->zig_target.arch.arch == ZigLLVM_x86_64) {
3412 kernel32_lib_dir = buf_create_from_str(
3413 "C:\\Program Files (x86)\\Windows Kits\\8.1\\Lib\\winv6.3\\um\\x64");
3414 } else if (g->zig_target.arch.arch == ZigLLVM_x86) {
3415 kernel32_lib_dir = buf_create_from_str(
3416 "C:\\Program Files (x86)\\Windows Kits\\8.1\\Lib\\winv6.3\\um\\x86");
3417 } else {
3418 zig_panic("unable to determine kernel32 lib path");
3405 Buf* vc_lib_dir = buf_alloc();
3406 if (os_get_win32_vcruntime_path(vc_lib_dir, g->zig_target.arch.arch)) {
3407 zig_panic("Unable to determine vcruntime path.");
34193408 }
3420 Buf *test_path = buf_alloc();
3421 os_path_join(kernel32_lib_dir, buf_create_from_str("kernel32.lib"), test_path);
3422 bool result;
3423 int err;
3424 if ((err = os_file_exists(test_path, &result))) {
3425 result = false;
3409
3410 Buf* ucrt_lib_path = buf_alloc();
3411 if (os_get_win32_ucrt_lib_path(g->win_sdk, ucrt_lib_path, g->zig_target.arch.arch)) {
3412 zig_panic("Unable to determine ucrt path.");
34263413 }
3427 if (result) {
3428 g->kernel32_lib_dir = kernel32_lib_dir;
3429 } else {
3430 zig_panic("Unable to determine kernel32 lib path.");
3414
3415 Buf* kern_lib_path = buf_alloc();
3416 if (os_get_win32_kern32_path(g->win_sdk, kern_lib_path, g->zig_target.arch.arch)) {
3417 zig_panic("Unable to determine kernel32 path.");
34313418 }
3419
3420 g->libc_lib_dirs_list.append(vc_lib_dir);
3421 g->libc_lib_dirs_list.append(ucrt_lib_path);
3422 g->libc_lib_dirs_list.append(kern_lib_path);
34323423 }
3424 return;
34333425#endif
34343426
34353427 // later we can handle this better by reporting an error via the normal mechanism
src/codegen.cpp+9-16
......@@ -85,7 +85,6 @@ CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out
8585 g->external_prototypes.init(8);
8686 g->is_test_build = false;
8787 g->want_h_file = (out_type == OutTypeObj || out_type == OutTypeLib);
88
8988 buf_resize(&g->global_asm, 0);
9089
9190 // reserve index 0 to indicate no error
......@@ -106,31 +105,25 @@ CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out
106105 g->zig_std_special_dir = buf_alloc();
107106 os_path_join(g->zig_std_dir, buf_sprintf("special"), g->zig_std_special_dir);
108107
109
110108 if (target) {
111109 // cross compiling, so we can't rely on all the configured stuff since
112110 // that's for native compilation
113111 g->zig_target = *target;
114112 resolve_target_object_format(&g->zig_target);
115
116113 g->dynamic_linker = buf_create_from_str("");
117114 g->libc_lib_dir = buf_create_from_str("");
118115 g->libc_static_lib_dir = buf_create_from_str("");
119116 g->libc_include_dir = buf_create_from_str("");
120 g->msvc_lib_dir = nullptr;
121 g->kernel32_lib_dir = nullptr;
122117 g->each_lib_rpath = false;
123118 } else {
124119 // native compilation, we can rely on the configuration stuff
125120 g->is_native_target = true;
126121 get_native_target(&g->zig_target);
127
128122 g->dynamic_linker = buf_create_from_str(ZIG_DYNAMIC_LINKER);
129123 g->libc_lib_dir = buf_create_from_str(ZIG_LIBC_LIB_DIR);
130124 g->libc_static_lib_dir = buf_create_from_str(ZIG_LIBC_STATIC_LIB_DIR);
131125 g->libc_include_dir = buf_create_from_str(ZIG_LIBC_INCLUDE_DIR);
132 g->msvc_lib_dir = nullptr; // find it at runtime
133 g->kernel32_lib_dir = nullptr; // find it at runtime
126
134127#ifdef ZIG_EACH_LIB_RPATH
135128 g->each_lib_rpath = true;
136129#endif
......@@ -228,14 +221,6 @@ void codegen_set_libc_include_dir(CodeGen *g, Buf *libc_include_dir) {
228221 g->libc_include_dir = libc_include_dir;
229222}
230223
231void codegen_set_msvc_lib_dir(CodeGen *g, Buf *msvc_lib_dir) {
232 g->msvc_lib_dir = msvc_lib_dir;
233}
234
235void codegen_set_kernel32_lib_dir(CodeGen *g, Buf *kernel32_lib_dir) {
236 g->kernel32_lib_dir = kernel32_lib_dir;
237}
238
239224void codegen_set_dynamic_linker(CodeGen *g, Buf *dynamic_linker) {
240225 g->dynamic_linker = dynamic_linker;
241226}
......@@ -244,6 +229,14 @@ void codegen_add_lib_dir(CodeGen *g, const char *dir) {
244229 g->lib_dirs.append(dir);
245230}
246231
232void codegen_set_ucrt_lib_dir(CodeGen *g, Buf *ucrt_lib_dir) {
233 g->libc_lib_dirs_list.append(ucrt_lib_dir);
234}
235
236void codegen_set_kernel32_lib_dir(CodeGen *g, Buf *kernel32_lib_dir) {
237 g->libc_lib_dirs_list.append(kernel32_lib_dir);
238}
239
247240void codegen_add_rpath(CodeGen *g, const char *name) {
248241 g->rpath_list.append(buf_create_from_str(name));
249242}
src/codegen.hpp+1-1
......@@ -30,7 +30,7 @@ void codegen_set_out_name(CodeGen *codegen, Buf *out_name);
3030void codegen_set_libc_lib_dir(CodeGen *codegen, Buf *libc_lib_dir);
3131void codegen_set_libc_static_lib_dir(CodeGen *g, Buf *libc_static_lib_dir);
3232void codegen_set_libc_include_dir(CodeGen *codegen, Buf *libc_include_dir);
33void codegen_set_msvc_lib_dir(CodeGen *codegen, Buf *msvc_lib_dir);
33void codegen_set_ucrt_lib_dir(CodeGen *g, Buf *ucrt_lib_dir);
3434void codegen_set_kernel32_lib_dir(CodeGen *codegen, Buf *kernel32_lib_dir);
3535void codegen_set_dynamic_linker(CodeGen *g, Buf *dynamic_linker);
3636void codegen_set_windows_subsystem(CodeGen *g, bool mwindows, bool mconsole);
src/link.cpp+16-7
......@@ -402,19 +402,25 @@ static void construct_linker_job_coff(LinkJob *lj) {
402402 lj->args.append(buf_ptr(buf_sprintf("-OUT:%s", buf_ptr(&lj->out_file))));
403403
404404 if (g->libc_link_lib != nullptr) {
405 lj->args.append(buf_ptr(buf_sprintf("-LIBPATH:%s", buf_ptr(g->msvc_lib_dir))));
406 lj->args.append(buf_ptr(buf_sprintf("-LIBPATH:%s", buf_ptr(g->kernel32_lib_dir))));
407
408 lj->args.append(buf_ptr(buf_sprintf("-LIBPATH:%s", buf_ptr(g->libc_lib_dir))));
409 lj->args.append(buf_ptr(buf_sprintf("-LIBPATH:%s", buf_ptr(g->libc_static_lib_dir))));
405 if (g->libc_link_lib != nullptr) {
406 for (uint32_t i = 0; i < g->libc_lib_dirs_list.length; ++i) {
407 lj->args.append(buf_ptr(buf_sprintf("-LIBPATH:%s", buf_ptr(g->libc_lib_dirs_list.items[i]))));
408 }
409 }
410410 }
411411
412412 if (lj->link_in_crt) {
413413 const char *lib_str = g->is_static ? "lib" : "";
414414 const char *d_str = (g->build_mode == BuildModeDebug) ? "d" : "";
415415
416 Buf *cmt_lib_name = buf_sprintf("libcmt%s.lib", d_str);
417 lj->args.append(buf_ptr(cmt_lib_name));
416 if (g->is_static) {
417 Buf *cmt_lib_name = buf_sprintf("libcmt%s.lib", d_str);
418 lj->args.append(buf_ptr(cmt_lib_name));
419 }
420 else {
421 Buf *msvcrt_lib_name = buf_sprintf("msvcrt%s.lib", d_str);
422 lj->args.append(buf_ptr(msvcrt_lib_name));
423 }
418424
419425 Buf *vcruntime_lib_name = buf_sprintf("%svcruntime%s.lib", lib_str, d_str);
420426 lj->args.append(buf_ptr(vcruntime_lib_name));
......@@ -422,6 +428,9 @@ static void construct_linker_job_coff(LinkJob *lj) {
422428 Buf *crt_lib_name = buf_sprintf("%sucrt%s.lib", lib_str, d_str);
423429 lj->args.append(buf_ptr(crt_lib_name));
424430
431 //Visual C++ 2015 Conformance Changes
432 //https://msdn.microsoft.com/en-us/library/bb531344.aspx
433 lj->args.append("legacy_stdio_definitions.lib");
425434
426435 //if (shared || dll) {
427436 // lj->args.append(get_libc_file(g, "dllcrt2.o"));
src/main.cpp+1-1
......@@ -758,7 +758,7 @@ int main(int argc, char **argv) {
758758 if (libc_include_dir)
759759 codegen_set_libc_include_dir(g, buf_create_from_str(libc_include_dir));
760760 if (msvc_lib_dir)
761 codegen_set_msvc_lib_dir(g, buf_create_from_str(msvc_lib_dir));
761 codegen_set_ucrt_lib_dir(g, buf_create_from_str(msvc_lib_dir));
762762 if (kernel32_lib_dir)
763763 codegen_set_kernel32_lib_dir(g, buf_create_from_str(kernel32_lib_dir));
764764 if (dynamic_linker)
src/os.cpp+319
......@@ -26,6 +26,7 @@
2626#include <windows.h>
2727#include <io.h>
2828#include <fcntl.h>
29#include "windows_com.hpp"
2930
3031typedef SSIZE_T ssize_t;
3132#else
......@@ -999,3 +1000,321 @@ void os_stderr_set_color(TermColor color) {
9991000 set_color_posix(color);
10001001#endif
10011002}
1003
1004#if defined ZIG_OS_WINDOWS
1005int os_find_windows_sdk(ZigWindowsSDK **out_sdk) {
1006 ZigWindowsSDK *result_sdk = allocate<ZigWindowsSDK>(1);
1007 buf_resize(&result_sdk->path10, 0);
1008 buf_resize(&result_sdk->path81, 0);
1009
1010 HKEY key;
1011 HRESULT rc;
1012 rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots", 0, KEY_QUERY_VALUE | KEY_WOW64_32KEY | KEY_ENUMERATE_SUB_KEYS, &key);
1013 if (rc != ERROR_SUCCESS) {
1014 return ErrorFileNotFound;
1015 }
1016
1017 {
1018 DWORD tmp_buf_len = MAX_PATH;
1019 buf_resize(&result_sdk->path10, tmp_buf_len);
1020 rc = RegQueryValueEx(key, "KitsRoot10", NULL, NULL, (LPBYTE)buf_ptr(&result_sdk->path10), &tmp_buf_len);
1021 if (rc == ERROR_FILE_NOT_FOUND) {
1022 buf_resize(&result_sdk->path10, 0);
1023 } else {
1024 buf_resize(&result_sdk->path10, tmp_buf_len);
1025 }
1026 }
1027 {
1028 DWORD tmp_buf_len = MAX_PATH;
1029 buf_resize(&result_sdk->path81, tmp_buf_len);
1030 rc = RegQueryValueEx(key, "KitsRoot81", NULL, NULL, (LPBYTE)buf_ptr(&result_sdk->path81), &tmp_buf_len);
1031 if (rc == ERROR_FILE_NOT_FOUND) {
1032 buf_resize(&result_sdk->path81, 0);
1033 } else {
1034 buf_resize(&result_sdk->path81, tmp_buf_len);
1035 }
1036 }
1037
1038 if (buf_len(&result_sdk->path10) != 0) {
1039 Buf *sdk_lib_dir = buf_sprintf("%s\\Lib\\*", buf_ptr(&result_sdk->path10));
1040
1041 // enumerate files in sdk path looking for latest version
1042 WIN32_FIND_DATA ffd;
1043 HANDLE hFind = FindFirstFileA(buf_ptr(sdk_lib_dir), &ffd);
1044 if (hFind == INVALID_HANDLE_VALUE) {
1045 return ErrorFileNotFound;
1046 }
1047 int v0 = 0, v1 = 0, v2 = 0, v3 = 0;
1048 bool found_version_dir = false;
1049 for (;;) {
1050 if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
1051 int c0 = 0, c1 = 0, c2 = 0, c3 = 0;
1052 sscanf(ffd.cFileName, "%d.%d.%d.%d", &c0, &c1, &c2, &c3);
1053 if ((c0 > v0) || (c1 > v1) || (c2 > v2) || (c3 > v3)) {
1054 v0 = c0, v1 = c1, v2 = c2, v3 = c3;
1055 buf_init_from_str(&result_sdk->version10, ffd.cFileName);
1056 found_version_dir = true;
1057 }
1058 }
1059 if (FindNextFile(hFind, &ffd) == 0) {
1060 FindClose(hFind);
1061 break;
1062 }
1063 }
1064 if (!found_version_dir) {
1065 buf_resize(&result_sdk->path10, 0);
1066 }
1067 }
1068
1069 if (buf_len(&result_sdk->path81) != 0) {
1070 Buf *sdk_lib_dir = buf_sprintf("%s\\Lib\\winv*", buf_ptr(&result_sdk->path81));
1071
1072 // enumerate files in sdk path looking for latest version
1073 WIN32_FIND_DATA ffd;
1074 HANDLE hFind = FindFirstFileA(buf_ptr(sdk_lib_dir), &ffd);
1075 if (hFind == INVALID_HANDLE_VALUE) {
1076 return ErrorFileNotFound;
1077 }
1078 int v0 = 0, v1 = 0;
1079 bool found_version_dir = false;
1080 for (;;) {
1081 if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
1082 int c0 = 0, c1 = 0;
1083 sscanf(ffd.cFileName, "winv%d.%d", &c0, &c1);
1084 if ((c0 > v0) || (c1 > v1)) {
1085 v0 = c0, v1 = c1;
1086 buf_init_from_str(&result_sdk->version81, ffd.cFileName);
1087 found_version_dir = true;
1088 }
1089 }
1090 if (FindNextFile(hFind, &ffd) == 0) {
1091 FindClose(hFind);
1092 break;
1093 }
1094 }
1095 if (!found_version_dir) {
1096 buf_resize(&result_sdk->path81, 0);
1097 }
1098 }
1099
1100 *out_sdk = result_sdk;
1101 return 0;
1102}
1103
1104int os_get_win32_vcruntime_path(Buf* output_buf, ZigLLVM_ArchType platform_type) {
1105 buf_resize(output_buf, 0);
1106 //COM Smart Pointerse requires explicit scope
1107 {
1108 HRESULT rc;
1109 rc = CoInitializeEx(NULL, COINIT_MULTITHREADED);
1110 if (rc != S_OK) {
1111 goto com_done;
1112 }
1113
1114 //This COM class is installed when a VS2017
1115 ISetupConfigurationPtr setup_config;
1116 rc = setup_config.CreateInstance(__uuidof(SetupConfiguration));
1117 if (rc != S_OK) {
1118 goto com_done;
1119 }
1120
1121 IEnumSetupInstancesPtr all_instances;
1122 rc = setup_config->EnumInstances(&all_instances);
1123 if (rc != S_OK) {
1124 goto com_done;
1125 }
1126
1127 ISetupInstance* curr_instance;
1128 ULONG found_inst;
1129 while ((rc = all_instances->Next(1, &curr_instance, &found_inst) == S_OK)) {
1130 BSTR bstr_inst_path;
1131 rc = curr_instance->GetInstallationPath(&bstr_inst_path);
1132 if (rc != S_OK) {
1133 goto com_done;
1134 }
1135 //BSTRs are UTF-16 encoded, so we need to convert the string & adjust the length
1136 UINT bstr_path_len = *((UINT*)bstr_inst_path - 1);
1137 ULONG tmp_path_len = bstr_path_len / 2 + 1;
1138 char* conv_path = (char*)bstr_inst_path;
1139 char *tmp_path = (char*)alloca(tmp_path_len);
1140 memset(tmp_path, 0, tmp_path_len);
1141 uint32_t c = 0;
1142 for (uint32_t i = 0; i < bstr_path_len; i += 2) {
1143 tmp_path[c] = conv_path[i];
1144 ++c;
1145 assert(c != tmp_path_len);
1146 }
1147
1148 buf_append_str(output_buf, tmp_path);
1149 buf_append_char(output_buf, '\\');
1150
1151 Buf* tmp_buf = buf_alloc();
1152 buf_append_buf(tmp_buf, output_buf);
1153 buf_append_str(tmp_buf, "VC\\Auxiliary\\Build\\Microsoft.VCToolsVersion.default.txt");
1154 FILE* tools_file = fopen(buf_ptr(tmp_buf), "r");
1155 if (!tools_file) {
1156 goto com_done;
1157 }
1158 memset(tmp_path, 0, tmp_path_len);
1159 fgets(tmp_path, tmp_path_len, tools_file);
1160 strtok(tmp_path, " \r\n");
1161 fclose(tools_file);
1162 buf_appendf(output_buf, "VC\\Tools\\MSVC\\%s\\lib\\", tmp_path);
1163 switch (platform_type) {
1164 case ZigLLVM_x86:
1165 buf_append_str(output_buf, "x86\\");
1166 break;
1167 case ZigLLVM_x86_64:
1168 buf_append_str(output_buf, "x64\\");
1169 break;
1170 case ZigLLVM_arm:
1171 buf_append_str(output_buf, "arm\\");
1172 break;
1173 default:
1174 zig_panic("Attemped to use vcruntime for non-supported platform.");
1175 }
1176 buf_resize(tmp_buf, 0);
1177 buf_append_buf(tmp_buf, output_buf);
1178 buf_append_str(tmp_buf, "vcruntime.lib");
1179
1180 if (GetFileAttributesA(buf_ptr(tmp_buf)) != INVALID_FILE_ATTRIBUTES) {
1181 return 0;
1182 }
1183 }
1184 }
1185
1186com_done:;
1187 HKEY key;
1188 HRESULT rc;
1189 rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7", 0, KEY_QUERY_VALUE | KEY_WOW64_32KEY, &key);
1190 if (rc != ERROR_SUCCESS) {
1191 return ErrorFileNotFound;
1192 }
1193
1194 DWORD dw_type = 0;
1195 DWORD cb_data = 0;
1196 rc = RegQueryValueEx(key, "14.0", NULL, &dw_type, NULL, &cb_data);
1197 if ((rc == ERROR_FILE_NOT_FOUND) || (REG_SZ != dw_type)) {
1198 return ErrorFileNotFound;
1199 }
1200
1201 Buf* tmp_buf = buf_alloc_fixed(cb_data);
1202 RegQueryValueExA(key, "14.0", NULL, NULL, (LPBYTE)buf_ptr(tmp_buf), &cb_data);
1203 //RegQueryValueExA returns the length of the string INCLUDING the null terminator
1204 buf_resize(tmp_buf, cb_data-1);
1205 buf_append_str(tmp_buf, "VC\\Lib\\");
1206 switch (platform_type) {
1207 case ZigLLVM_x86:
1208 //x86 is in the root of the Lib folder
1209 break;
1210 case ZigLLVM_x86_64:
1211 buf_append_str(tmp_buf, "amd64\\");
1212 break;
1213 case ZigLLVM_arm:
1214 buf_append_str(tmp_buf, "arm\\");
1215 break;
1216 default:
1217 zig_panic("Attemped to use vcruntime for non-supported platform.");
1218 }
1219
1220 buf_append_buf(output_buf, tmp_buf);
1221 buf_append_str(tmp_buf, "vcruntime.lib");
1222
1223 if (GetFileAttributesA(buf_ptr(tmp_buf)) != INVALID_FILE_ATTRIBUTES) {
1224 return 0;
1225 } else {
1226 buf_resize(output_buf, 0);
1227 return ErrorFileNotFound;
1228 }
1229}
1230
1231int os_get_win32_ucrt_lib_path(ZigWindowsSDK *sdk, Buf* output_buf, ZigLLVM_ArchType platform_type) {
1232 buf_resize(output_buf, 0);
1233 buf_appendf(output_buf, "%s\\Lib\\%s\\ucrt\\", buf_ptr(&sdk->path10), buf_ptr(&sdk->version10));
1234 switch (platform_type) {
1235 case ZigLLVM_x86:
1236 buf_append_str(output_buf, "x86\\");
1237 break;
1238 case ZigLLVM_x86_64:
1239 buf_append_str(output_buf, "x64\\");
1240 break;
1241 case ZigLLVM_arm:
1242 buf_append_str(output_buf, "arm\\");
1243 break;
1244 default:
1245 zig_panic("Attemped to use vcruntime for non-supported platform.");
1246 }
1247 Buf* tmp_buf = buf_alloc();
1248 buf_init_from_buf(tmp_buf, output_buf);
1249 buf_append_str(tmp_buf, "ucrt.lib");
1250 if (GetFileAttributesA(buf_ptr(tmp_buf)) != INVALID_FILE_ATTRIBUTES) {
1251 return 0;
1252 }
1253 else {
1254 buf_resize(output_buf, 0);
1255 return ErrorFileNotFound;
1256 }
1257}
1258
1259int os_get_win32_ucrt_include_path(ZigWindowsSDK *sdk, Buf* output_buf) {
1260 buf_resize(output_buf, 0);
1261 buf_appendf(output_buf, "%s\\Include\\%s\\ucrt", buf_ptr(&sdk->path10), buf_ptr(&sdk->version10));
1262 if (GetFileAttributesA(buf_ptr(output_buf)) != INVALID_FILE_ATTRIBUTES) {
1263 return 0;
1264 }
1265 else {
1266 buf_resize(output_buf, 0);
1267 return ErrorFileNotFound;
1268 }
1269}
1270
1271int os_get_win32_kern32_path(ZigWindowsSDK *sdk, Buf* output_buf, ZigLLVM_ArchType platform_type) {
1272 {
1273 buf_resize(output_buf, 0);
1274 buf_appendf(output_buf, "%s\\Lib\\%s\\um\\", buf_ptr(&sdk->path10), buf_ptr(&sdk->version10));
1275 switch (platform_type) {
1276 case ZigLLVM_x86:
1277 buf_append_str(output_buf, "x86\\");
1278 break;
1279 case ZigLLVM_x86_64:
1280 buf_append_str(output_buf, "x64\\");
1281 break;
1282 case ZigLLVM_arm:
1283 buf_append_str(output_buf, "arm\\");
1284 break;
1285 default:
1286 zig_panic("Attemped to use vcruntime for non-supported platform.");
1287 }
1288 Buf* tmp_buf = buf_alloc();
1289 buf_init_from_buf(tmp_buf, output_buf);
1290 buf_append_str(tmp_buf, "kernel32.lib");
1291 if (GetFileAttributesA(buf_ptr(tmp_buf)) != INVALID_FILE_ATTRIBUTES) {
1292 return 0;
1293 }
1294 }
1295 {
1296 buf_resize(output_buf, 0);
1297 buf_appendf(output_buf, "%s\\Lib\\%s\\um\\", buf_ptr(&sdk->path81), buf_ptr(&sdk->version81));
1298 switch (platform_type) {
1299 case ZigLLVM_x86:
1300 buf_append_str(output_buf, "x86\\");
1301 break;
1302 case ZigLLVM_x86_64:
1303 buf_append_str(output_buf, "x64\\");
1304 break;
1305 case ZigLLVM_arm:
1306 buf_append_str(output_buf, "arm\\");
1307 break;
1308 default:
1309 zig_panic("Attemped to use vcruntime for non-supported platform.");
1310 }
1311 Buf* tmp_buf = buf_alloc();
1312 buf_init_from_buf(tmp_buf, output_buf);
1313 buf_append_str(tmp_buf, "kernel32.lib");
1314 if (GetFileAttributesA(buf_ptr(tmp_buf)) != INVALID_FILE_ATTRIBUTES) {
1315 return 0;
1316 }
1317 }
1318 return ErrorFileNotFound;
1319}
1320#endif
src/os.hpp+15
......@@ -11,6 +11,7 @@
1111#include "list.hpp"
1212#include "buffer.hpp"
1313#include "error.hpp"
14#include "zig_llvm.hpp"
1415
1516#include <stdio.h>
1617#include <inttypes.h>
......@@ -85,6 +86,20 @@ int os_self_exe_path(Buf *out_path);
8586#define ZIG_OS_UNKNOWN
8687#endif
8788
89struct ZigWindowsSDK {
90 Buf path10;
91 Buf version10;
92 Buf path81;
93 Buf version81;
94};
95#if defined(ZIG_OS_WINDOWS)
96int os_find_windows_sdk(ZigWindowsSDK **out_sdk);
97int os_get_win32_vcruntime_path(Buf *output_buf, ZigLLVM_ArchType platform_type);
98int os_get_win32_ucrt_include_path(ZigWindowsSDK *sdk, Buf *output_buf);
99int os_get_win32_ucrt_lib_path(ZigWindowsSDK *sdk, Buf *output_buf, ZigLLVM_ArchType platform_type);
100int os_get_win32_kern32_path(ZigWindowsSDK *sdk, Buf *output_buf, ZigLLVM_ArchType platform_type);
101#endif
102
88103#if defined(__x86_64__)
89104#define ZIG_ARCH_X86_64
90105#else
src/parsec.cpp+3-3
......@@ -138,9 +138,9 @@ static AstNode *trans_create_node_fn_call_1(Context *c, AstNode *fn_ref_expr, As
138138
139139static AstNode *trans_create_node_field_access(Context *c, AstNode *container, Buf *field_name) {
140140 AstNode *node = trans_create_node(c, NodeTypeFieldAccessExpr);
141 if (container->type == NodeTypeSymbol) {
142 assert(container->data.symbol_expr.symbol != nullptr);
143 }
141 if (container->type == NodeTypeSymbol) {
142 assert(container->data.symbol_expr.symbol != nullptr);
143 }
144144 node->data.field_access_expr.struct_expr = container;
145145 node->data.field_access_expr.field_name = field_name;
146146 return node;
src/util.hpp+9-9
......@@ -48,17 +48,17 @@ static inline void zig_unreachable(void) {
4848
4949#if defined(_MSC_VER)
5050static inline int clzll(unsigned long long mask) {
51 unsigned long lz;
51 unsigned long lz;
5252#if defined(_WIN64)
53 if (_BitScanReverse64(&lz, mask))
54 return static_cast<int>(63 - lz);
55 zig_unreachable();
53 if (_BitScanReverse64(&lz, mask))
54 return static_cast<int>(63 - lz);
55 zig_unreachable();
5656#else
57 if (_BitScanReverse(&lz, mask >> 32))
58 lz += 32;
59 else
60 _BitScanReverse(&lz, mask & 0xffffffff);
61 return 63 - lz;
57 if (_BitScanReverse(&lz, mask >> 32))
58 lz += 32;
59 else
60 _BitScanReverse(&lz, mask & 0xffffffff);
61 return 63 - lz;
6262#endif
6363}
6464#else
src/windows_com.hpp created+901
......@@ -0,0 +1,901 @@
1// The MIT License(MIT)
2// Copyright(C) Microsoft Corporation.All rights reserved.
3//
4// Permission is hereby granted, free of charge, to any person obtaining a copy
5// of this software and associated documentation files(the "Software"), to deal
6// in the Software without restriction, including without limitation the rights
7// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
8// copies of the Software, and to permit persons to whom the Software is
9// furnished to do so, subject to the following conditions :
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
17// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20// IN THE SOFTWARE.
21//
22
23#pragma once
24
25// Windows headers
26#include <windows.h>
27#include <fcntl.h>
28#include <io.h>
29#include <shellapi.h>
30
31// COM support header files
32#include <comdef.h>
33
34// Constants
35//
36#ifndef E_NOTFOUND
37#define E_NOTFOUND HRESULT_FROM_WIN32(ERROR_NOT_FOUND)
38#endif
39
40#ifndef E_FILENOTFOUND
41#define E_FILENOTFOUND HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)
42#endif
43
44#ifndef E_NOTSUPPORTED
45#define E_NOTSUPPORTED HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED)
46#endif
47
48// Enumerations
49//
50/// <summary>
51/// The state of an instance.
52/// </summary>
53enum InstanceState
54{
55 /// <summary>
56 /// The instance state has not been determined.
57 /// </summary>
58 eNone = 0,
59
60 /// <summary>
61 /// The instance installation path exists.
62 /// </summary>
63 eLocal = 1,
64
65 /// <summary>
66 /// A product is registered to the instance.
67 /// </summary>
68 eRegistered = 2,
69
70 /// <summary>
71 /// No reboot is required for the instance.
72 /// </summary>
73 eNoRebootRequired = 4,
74
75 /// <summary>
76 /// No errors were reported for the instance.
77 /// </summary>
78 eNoErrors = 8,
79
80 /// <summary>
81 /// The instance represents a complete install.
82 /// </summary>
83 eComplete = UINT_MAX,
84};
85
86// Forward interface declarations
87//
88#ifndef __ISetupInstance_FWD_DEFINED__
89#define __ISetupInstance_FWD_DEFINED__
90typedef struct ISetupInstance ISetupInstance;
91#endif
92
93#ifndef __ISetupInstance2_FWD_DEFINED__
94#define __ISetupInstance2_FWD_DEFINED__
95typedef struct ISetupInstance2 ISetupInstance2;
96#endif
97
98#ifndef __ISetupInstanceCatalog_FWD_DEFINED__
99#define __ISetupInstanceCatalog_FWD_DEFINED__
100typedef struct ISetupInstanceCatalog ISetupInstanceCatalog;
101#endif
102
103#ifndef __ISetupLocalizedProperties_FWD_DEFINED__
104#define __ISetupLocalizedProperties_FWD_DEFINED__
105typedef struct ISetupLocalizedProperties ISetupLocalizedProperties;
106#endif
107
108#ifndef __IEnumSetupInstances_FWD_DEFINED__
109#define __IEnumSetupInstances_FWD_DEFINED__
110typedef struct IEnumSetupInstances IEnumSetupInstances;
111#endif
112
113#ifndef __ISetupConfiguration_FWD_DEFINED__
114#define __ISetupConfiguration_FWD_DEFINED__
115typedef struct ISetupConfiguration ISetupConfiguration;
116#endif
117
118#ifndef __ISetupConfiguration2_FWD_DEFINED__
119#define __ISetupConfiguration2_FWD_DEFINED__
120typedef struct ISetupConfiguration2 ISetupConfiguration2;
121#endif
122
123#ifndef __ISetupPackageReference_FWD_DEFINED__
124#define __ISetupPackageReference_FWD_DEFINED__
125typedef struct ISetupPackageReference ISetupPackageReference;
126#endif
127
128#ifndef __ISetupHelper_FWD_DEFINED__
129#define __ISetupHelper_FWD_DEFINED__
130typedef struct ISetupHelper ISetupHelper;
131#endif
132
133#ifndef __ISetupErrorState_FWD_DEFINED__
134#define __ISetupErrorState_FWD_DEFINED__
135typedef struct ISetupErrorState ISetupErrorState;
136#endif
137
138#ifndef __ISetupErrorState2_FWD_DEFINED__
139#define __ISetupErrorState2_FWD_DEFINED__
140typedef struct ISetupErrorState2 ISetupErrorState2;
141#endif
142
143#ifndef __ISetupFailedPackageReference_FWD_DEFINED__
144#define __ISetupFailedPackageReference_FWD_DEFINED__
145typedef struct ISetupFailedPackageReference ISetupFailedPackageReference;
146#endif
147
148#ifndef __ISetupFailedPackageReference2_FWD_DEFINED__
149#define __ISetupFailedPackageReference2_FWD_DEFINED__
150typedef struct ISetupFailedPackageReference2 ISetupFailedPackageReference2;
151#endif
152
153#ifndef __ISetupPropertyStore_FWD_DEFINED__
154#define __ISetupPropertyStore_FWD_DEFINED__
155typedef struct ISetupPropertyStore ISetupPropertyStore;
156#endif
157
158#ifndef __ISetupLocalizedPropertyStore_FWD_DEFINED__
159#define __ISetupLocalizedPropertyStore_FWD_DEFINED__
160typedef struct ISetupLocalizedPropertyStore ISetupLocalizedPropertyStore;
161#endif
162
163// Forward class declarations
164//
165#ifndef __SetupConfiguration_FWD_DEFINED__
166#define __SetupConfiguration_FWD_DEFINED__
167
168#ifdef __cplusplus
169typedef class SetupConfiguration SetupConfiguration;
170#endif
171
172#endif
173
174#ifndef _MSC_VER
175#define _Deref_out_opt_
176#endif
177
178#ifdef __cplusplus
179extern "C" {
180#endif
181
182 // Interface definitions
183 //
184 EXTERN_C const IID IID_ISetupInstance;
185
186#if defined(__cplusplus) && !defined(CINTERFACE)
187 /// <summary>
188 /// Information about an instance of a product.
189 /// </summary>
190 struct DECLSPEC_UUID("B41463C3-8866-43B5-BC33-2B0676F7F42E") DECLSPEC_NOVTABLE ISetupInstance : public IUnknown
191 {
192 /// <summary>
193 /// Gets the instance identifier (should match the name of the parent instance directory).
194 /// </summary>
195 /// <param name="pbstrInstanceId">The instance identifier.</param>
196 /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist.</returns>
197 STDMETHOD(GetInstanceId)(
198 _Out_ BSTR* pbstrInstanceId
199 ) = 0;
200
201 /// <summary>
202 /// Gets the local date and time when the installation was originally installed.
203 /// </summary>
204 /// <param name="pInstallDate">The local date and time when the installation was originally installed.</param>
205 /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the property is not defined.</returns>
206 STDMETHOD(GetInstallDate)(
207 _Out_ LPFILETIME pInstallDate
208 ) = 0;
209
210 /// <summary>
211 /// Gets the unique name of the installation, often indicating the branch and other information used for telemetry.
212 /// </summary>
213 /// <param name="pbstrInstallationName">The unique name of the installation, often indicating the branch and other information used for telemetry.</param>
214 /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the property is not defined.</returns>
215 STDMETHOD(GetInstallationName)(
216 _Out_ BSTR* pbstrInstallationName
217 ) = 0;
218
219 /// <summary>
220 /// Gets the path to the installation root of the product.
221 /// </summary>
222 /// <param name="pbstrInstallationPath">The path to the installation root of the product.</param>
223 /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the property is not defined.</returns>
224 STDMETHOD(GetInstallationPath)(
225 _Out_ BSTR* pbstrInstallationPath
226 ) = 0;
227
228 /// <summary>
229 /// Gets the version of the product installed in this instance.
230 /// </summary>
231 /// <param name="pbstrInstallationVersion">The version of the product installed in this instance.</param>
232 /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the property is not defined.</returns>
233 STDMETHOD(GetInstallationVersion)(
234 _Out_ BSTR* pbstrInstallationVersion
235 ) = 0;
236
237 /// <summary>
238 /// Gets the display name (title) of the product installed in this instance.
239 /// </summary>
240 /// <param name="lcid">The LCID for the display name.</param>
241 /// <param name="pbstrDisplayName">The display name (title) of the product installed in this instance.</param>
242 /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the property is not defined.</returns>
243 STDMETHOD(GetDisplayName)(
244 _In_ LCID lcid,
245 _Out_ BSTR* pbstrDisplayName
246 ) = 0;
247
248 /// <summary>
249 /// Gets the description of the product installed in this instance.
250 /// </summary>
251 /// <param name="lcid">The LCID for the description.</param>
252 /// <param name="pbstrDescription">The description of the product installed in this instance.</param>
253 /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the property is not defined.</returns>
254 STDMETHOD(GetDescription)(
255 _In_ LCID lcid,
256 _Out_ BSTR* pbstrDescription
257 ) = 0;
258
259 /// <summary>
260 /// Resolves the optional relative path to the root path of the instance.
261 /// </summary>
262 /// <param name="pwszRelativePath">A relative path within the instance to resolve, or NULL to get the root path.</param>
263 /// <param name="pbstrAbsolutePath">The full path to the optional relative path within the instance. If the relative path is NULL, the root path will always terminate in a backslash.</param>
264 /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the property is not defined.</returns>
265 STDMETHOD(ResolvePath)(
266 _In_opt_z_ LPCOLESTR pwszRelativePath,
267 _Out_ BSTR* pbstrAbsolutePath
268 ) = 0;
269 };
270#endif
271
272 EXTERN_C const IID IID_ISetupInstance2;
273
274#if defined(__cplusplus) && !defined(CINTERFACE)
275 /// <summary>
276 /// Information about an instance of a product.
277 /// </summary>
278 struct DECLSPEC_UUID("89143C9A-05AF-49B0-B717-72E218A2185C") DECLSPEC_NOVTABLE ISetupInstance2 : public ISetupInstance
279 {
280 /// <summary>
281 /// Gets the state of the instance.
282 /// </summary>
283 /// <param name="pState">The state of the instance.</param>
284 /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist.</returns>
285 STDMETHOD(GetState)(
286 _Out_ InstanceState* pState
287 ) = 0;
288
289 /// <summary>
290 /// Gets an array of package references registered to the instance.
291 /// </summary>
292 /// <param name="ppsaPackages">Pointer to an array of <see cref="ISetupPackageReference"/>.</param>
293 /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the packages property is not defined.</returns>
294 STDMETHOD(GetPackages)(
295 _Out_ LPSAFEARRAY* ppsaPackages
296 ) = 0;
297
298 /// <summary>
299 /// Gets a pointer to the <see cref="ISetupPackageReference"/> that represents the registered product.
300 /// </summary>
301 /// <param name="ppPackage">Pointer to an instance of <see cref="ISetupPackageReference"/>. This may be NULL if <see cref="GetState"/> does not return <see cref="eComplete"/>.</param>
302 /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the packages property is not defined.</returns>
303 STDMETHOD(GetProduct)(
304 _Outptr_result_maybenull_ ISetupPackageReference** ppPackage
305 ) = 0;
306
307 /// <summary>
308 /// Gets the relative path to the product application, if available.
309 /// </summary>
310 /// <param name="pbstrProductPath">The relative path to the product application, if available.</param>
311 /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist.</returns>
312 STDMETHOD(GetProductPath)(
313 _Outptr_result_maybenull_ BSTR* pbstrProductPath
314 ) = 0;
315
316 /// <summary>
317 /// Gets the error state of the instance, if available.
318 /// </summary>
319 /// <param name="pErrorState">The error state of the instance, if available.</param>
320 /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist.</returns>
321 STDMETHOD(GetErrors)(
322 _Outptr_result_maybenull_ ISetupErrorState** ppErrorState
323 ) = 0;
324
325 /// <summary>
326 /// Gets a value indicating whether the instance can be launched.
327 /// </summary>
328 /// <param name="pfIsLaunchable">Whether the instance can be launched.</param>
329 /// <returns>Standard HRESULT indicating success or failure.</returns>
330 /// <remarks>
331 /// An instance could have had errors during install but still be launched. Some features may not work correctly, but others will.
332 /// </remarks>
333 STDMETHOD(IsLaunchable)(
334 _Out_ VARIANT_BOOL* pfIsLaunchable
335 ) = 0;
336
337 /// <summary>
338 /// Gets a value indicating whether the instance is complete.
339 /// </summary>
340 /// <param name="pfIsLaunchable">Whether the instance is complete.</param>
341 /// <returns>Standard HRESULT indicating success or failure.</returns>
342 /// <remarks>
343 /// An instance is complete if it had no errors during install, resume, or repair.
344 /// </remarks>
345 STDMETHOD(IsComplete)(
346 _Out_ VARIANT_BOOL* pfIsComplete
347 ) = 0;
348
349 /// <summary>
350 /// Gets product-specific properties.
351 /// </summary>
352 /// <param name="ppPropeties">A pointer to an instance of <see cref="ISetupPropertyStore"/>. This may be NULL if no properties are defined.</param>
353 /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist.</returns>
354 STDMETHOD(GetProperties)(
355 _Outptr_result_maybenull_ ISetupPropertyStore** ppProperties
356 ) = 0;
357
358 /// <summary>
359 /// Gets the directory path to the setup engine that installed the instance.
360 /// </summary>
361 /// <param name="pbstrEnginePath">The directory path to the setup engine that installed the instance.</param>
362 /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist.</returns>
363 STDMETHOD(GetEnginePath)(
364 _Outptr_result_maybenull_ BSTR* pbstrEnginePath
365 ) = 0;
366 };
367#endif
368
369 EXTERN_C const IID IID_ISetupInstanceCatalog;
370
371#if defined(__cplusplus) && !defined(CINTERFACE)
372 /// <summary>
373 /// Information about a catalog used to install an instance.
374 /// </summary>
375 struct DECLSPEC_UUID("9AD8E40F-39A2-40F1-BF64-0A6C50DD9EEB") DECLSPEC_NOVTABLE ISetupInstanceCatalog : public IUnknown
376 {
377 /// <summary>
378 /// Gets catalog information properties.
379 /// </summary>
380 /// <param name="ppCatalogInfo">A pointer to an instance of <see cref="ISetupPropertyStore"/>.</param>
381 /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the property does not exist.</returns>
382 STDMETHOD(GetCatalogInfo)(
383 _Out_ ISetupPropertyStore** ppCatalogInfo
384 ) = 0;
385
386 /// <summary>
387 /// Gets a value indicating whether the catalog is a prerelease.
388 /// </summary>
389 /// <param name="pfIsPrerelease">Whether the catalog for the instance is a prerelease version.</param>
390 /// <returns>Standard HRESULT indicating success or failure, including E_FILENOTFOUND if the instance state does not exist and E_NOTFOUND if the property does not exist.</returns>
391 STDMETHOD(IsPrerelease)(
392 _Out_ VARIANT_BOOL* pfIsPrerelease
393 ) = 0;
394 };
395#endif
396
397 EXTERN_C const IID IID_ISetupLocalizedProperties;
398
399#if defined(__cplusplus) && !defined(CINTERFACE)
400 /// <summary>
401 /// Provides localized properties of an instance of a product.
402 /// </summary>
403 struct DECLSPEC_UUID("F4BD7382-FE27-4AB4-B974-9905B2A148B0") DECLSPEC_NOVTABLE ISetupLocalizedProperties : public IUnknown
404 {
405 /// <summary>
406 /// Gets localized product-specific properties.
407 /// </summary>
408 /// <param name="ppLocalizedProperties">A pointer to an instance of <see cref="ISetupLocalizedPropertyStore"/>. This may be NULL if no properties are defined.</param>
409 /// <returns>Standard HRESULT indicating success or failure.</returns>
410 STDMETHOD(GetLocalizedProperties)(
411 _Outptr_result_maybenull_ ISetupLocalizedPropertyStore** ppLocalizedProperties
412 ) = 0;
413
414 /// <summary>
415 /// Gets localized channel-specific properties.
416 /// </summary>
417 /// <param name="ppLocalizedChannelProperties">A pointer to an instance of <see cref="ISetupLocalizedPropertyStore"/>. This may be NULL if no channel properties are defined.</param>
418 /// <returns>Standard HRESULT indicating success or failure.</returns>
419 STDMETHOD(GetLocalizedChannelProperties)(
420 _Outptr_result_maybenull_ ISetupLocalizedPropertyStore** ppLocalizedChannelProperties
421 ) = 0;
422 };
423#endif
424
425 EXTERN_C const IID IID_IEnumSetupInstances;
426
427#if defined(__cplusplus) && !defined(CINTERFACE)
428 /// <summary>
429 /// An enumerator of installed <see cref="ISetupInstance"/> objects.
430 /// </summary>
431 struct DECLSPEC_UUID("6380BCFF-41D3-4B2E-8B2E-BF8A6810C848") DECLSPEC_NOVTABLE IEnumSetupInstances : public IUnknown
432 {
433 /// <summary>
434 /// Retrieves the next set of product instances in the enumeration sequence.
435 /// </summary>
436 /// <param name="celt">The number of product instances to retrieve.</param>
437 /// <param name="rgelt">A pointer to an array of <see cref="ISetupInstance"/>.</param>
438 /// <param name="pceltFetched">A pointer to the number of product instances retrieved. If <paramref name="celt"/> is 1 this parameter may be NULL.</param>
439 /// <returns>S_OK if the number of elements were fetched, S_FALSE if nothing was fetched (at end of enumeration), E_INVALIDARG if <paramref name="celt"/> is greater than 1 and pceltFetched is NULL, or E_OUTOFMEMORY if an <see cref="ISetupInstance"/> could not be allocated.</returns>
440 STDMETHOD(Next)(
441 _In_ ULONG celt,
442 _Out_writes_to_(celt, *pceltFetched) ISetupInstance** rgelt,
443 _Out_opt_ _Deref_out_range_(0, celt) ULONG* pceltFetched
444 ) = 0;
445
446 /// <summary>
447 /// Skips the next set of product instances in the enumeration sequence.
448 /// </summary>
449 /// <param name="celt">The number of product instances to skip.</param>
450 /// <returns>S_OK if the number of elements could be skipped; otherwise, S_FALSE;</returns>
451 STDMETHOD(Skip)(
452 _In_ ULONG celt
453 ) = 0;
454
455 /// <summary>
456 /// Resets the enumeration sequence to the beginning.
457 /// </summary>
458 /// <returns>Always returns S_OK;</returns>
459 STDMETHOD(Reset)(void) = 0;
460
461 /// <summary>
462 /// Creates a new enumeration object in the same state as the current enumeration object: the new object points to the same place in the enumeration sequence.
463 /// </summary>
464 /// <param name="ppenum">A pointer to a pointer to a new <see cref="IEnumSetupInstances"/> interface. If the method fails, this parameter is undefined.</param>
465 /// <returns>S_OK if a clone was returned; otherwise, E_OUTOFMEMORY.</returns>
466 STDMETHOD(Clone)(
467 _Deref_out_opt_ IEnumSetupInstances** ppenum
468 ) = 0;
469 };
470#endif
471
472 EXTERN_C const IID IID_ISetupConfiguration;
473
474#if defined(__cplusplus) && !defined(CINTERFACE)
475
476#ifdef __GNUC__
477 __CRT_UUID_DECL(ISetupConfiguration, 0x42843719, 0xDB4C, 0x46C2, 0x8E, 0x7C, 0x64, 0xF1, 0x81, 0x6E, 0xFD, 0x5B);
478#endif
479
480 /// <summary>
481 /// Gets information about product instances installed on the machine.
482 /// </summary>
483 struct DECLSPEC_UUID("42843719-DB4C-46C2-8E7C-64F1816EFD5B") DECLSPEC_NOVTABLE ISetupConfiguration : public IUnknown
484 {
485 /// <summary>
486 /// Enumerates all launchable product instances installed.
487 /// </summary>
488 /// <param name="ppEnumInstances">An enumeration of completed, installed product instances.</param>
489 /// <returns>Standard HRESULT indicating success or failure.</returns>
490 STDMETHOD(EnumInstances)(
491 _Out_ IEnumSetupInstances** ppEnumInstances
492 ) = 0;
493
494 /// <summary>
495 /// Gets the instance for the current process path.
496 /// </summary>
497 /// <param name="ppInstance">The instance for the current process path.</param>
498 /// <returns>
499 /// The instance for the current process path, or E_NOTFOUND if not found.
500 /// The <see cref="ISetupInstance::GetState"/> may indicate the instance is invalid.
501 /// </returns>
502 /// <remarks>
503 /// The returned instance may not be launchable.
504 /// </remarks>
505 STDMETHOD(GetInstanceForCurrentProcess)(
506 _Out_ ISetupInstance** ppInstance
507 ) = 0;
508
509 /// <summary>
510 /// Gets the instance for the given path.
511 /// </summary>
512 /// <param name="ppInstance">The instance for the given path.</param>
513 /// <returns>
514 /// The instance for the given path, or E_NOTFOUND if not found.
515 /// The <see cref="ISetupInstance::GetState"/> may indicate the instance is invalid.
516 /// </returns>
517 /// <remarks>
518 /// The returned instance may not be launchable.
519 /// </remarks>
520 STDMETHOD(GetInstanceForPath)(
521 _In_z_ LPCWSTR wzPath,
522 _Out_ ISetupInstance** ppInstance
523 ) = 0;
524 };
525#endif
526
527 EXTERN_C const IID IID_ISetupConfiguration2;
528
529#if defined(__cplusplus) && !defined(CINTERFACE)
530 /// <summary>
531 /// Gets information about product instances.
532 /// </summary>
533 struct DECLSPEC_UUID("26AAB78C-4A60-49D6-AF3B-3C35BC93365D") DECLSPEC_NOVTABLE ISetupConfiguration2 : public ISetupConfiguration
534 {
535 /// <summary>
536 /// Enumerates all product instances.
537 /// </summary>
538 /// <param name="ppEnumInstances">An enumeration of all product instances.</param>
539 /// <returns>Standard HRESULT indicating success or failure.</returns>
540 STDMETHOD(EnumAllInstances)(
541 _Out_ IEnumSetupInstances** ppEnumInstances
542 ) = 0;
543 };
544#endif
545
546 EXTERN_C const IID IID_ISetupPackageReference;
547
548#if defined(__cplusplus) && !defined(CINTERFACE)
549 /// <summary>
550 /// A reference to a package.
551 /// </summary>
552 struct DECLSPEC_UUID("da8d8a16-b2b6-4487-a2f1-594ccccd6bf5") DECLSPEC_NOVTABLE ISetupPackageReference : public IUnknown
553 {
554 /// <summary>
555 /// Gets the general package identifier.
556 /// </summary>
557 /// <param name="pbstrId">The general package identifier.</param>
558 /// <returns>Standard HRESULT indicating success or failure.</returns>
559 STDMETHOD(GetId)(
560 _Out_ BSTR* pbstrId
561 ) = 0;
562
563 /// <summary>
564 /// Gets the version of the package.
565 /// </summary>
566 /// <param name="pbstrVersion">The version of the package.</param>
567 /// <returns>Standard HRESULT indicating success or failure.</returns>
568 STDMETHOD(GetVersion)(
569 _Out_ BSTR* pbstrVersion
570 ) = 0;
571
572 /// <summary>
573 /// Gets the target process architecture of the package.
574 /// </summary>
575 /// <param name="pbstrChip">The target process architecture of the package.</param>
576 /// <returns>Standard HRESULT indicating success or failure.</returns>
577 STDMETHOD(GetChip)(
578 _Out_ BSTR* pbstrChip
579 ) = 0;
580
581 /// <summary>
582 /// Gets the language and optional region identifier.
583 /// </summary>
584 /// <param name="pbstrLanguage">The language and optional region identifier.</param>
585 /// <returns>Standard HRESULT indicating success or failure.</returns>
586 STDMETHOD(GetLanguage)(
587 _Out_ BSTR* pbstrLanguage
588 ) = 0;
589
590 /// <summary>
591 /// Gets the build branch of the package.
592 /// </summary>
593 /// <param name="pbstrBranch">The build branch of the package.</param>
594 /// <returns>Standard HRESULT indicating success or failure.</returns>
595 STDMETHOD(GetBranch)(
596 _Out_ BSTR* pbstrBranch
597 ) = 0;
598
599 /// <summary>
600 /// Gets the type of the package.
601 /// </summary>
602 /// <param name="pbstrType">The type of the package.</param>
603 /// <returns>Standard HRESULT indicating success or failure.</returns>
604 STDMETHOD(GetType)(
605 _Out_ BSTR* pbstrType
606 ) = 0;
607
608 /// <summary>
609 /// Gets the unique identifier consisting of all defined tokens.
610 /// </summary>
611 /// <param name="pbstrUniqueId">The unique identifier consisting of all defined tokens.</param>
612 /// <returns>Standard HRESULT indicating success or failure, including E_UNEXPECTED if no Id was defined (required).</returns>
613 STDMETHOD(GetUniqueId)(
614 _Out_ BSTR* pbstrUniqueId
615 ) = 0;
616
617 /// <summary>
618 /// Gets a value indicating whether the package refers to an external extension.
619 /// </summary>
620 /// <param name="pfIsExtension">A value indicating whether the package refers to an external extension.</param>
621 /// <returns>Standard HRESULT indicating success or failure, including E_UNEXPECTED if no Id was defined (required).</returns>
622 STDMETHOD(GetIsExtension)(
623 _Out_ VARIANT_BOOL* pfIsExtension
624 ) = 0;
625 };
626#endif
627
628 EXTERN_C const IID IID_ISetupHelper;
629
630#if defined(__cplusplus) && !defined(CINTERFACE)
631 /// <summary>
632 /// Helper functions.
633 /// </summary>
634 /// <remarks>
635 /// You can query for this interface from the <see cref="SetupConfiguration"/> class.
636 /// </remarks>
637 struct DECLSPEC_UUID("42b21b78-6192-463e-87bf-d577838f1d5c") DECLSPEC_NOVTABLE ISetupHelper : public IUnknown
638 {
639 /// <summary>
640 /// Parses a dotted quad version string into a 64-bit unsigned integer.
641 /// </summary>
642 /// <param name="pwszVersion">The dotted quad version string to parse, e.g. 1.2.3.4.</param>
643 /// <param name="pullVersion">A 64-bit unsigned integer representing the version. You can compare this to other versions.</param>
644 /// <returns>Standard HRESULT indicating success or failure, including E_INVALIDARG if the version is not valid.</returns>
645 STDMETHOD(ParseVersion)(
646 _In_ LPCOLESTR pwszVersion,
647 _Out_ PULONGLONG pullVersion
648 ) = 0;
649
650 /// <summary>
651 /// Parses a dotted quad version string into a 64-bit unsigned integer.
652 /// </summary>
653 /// <param name="pwszVersionRange">The string containing 1 or 2 dotted quad version strings to parse, e.g. [1.0,) that means 1.0.0.0 or newer.</param>
654 /// <param name="pullMinVersion">A 64-bit unsigned integer representing the minimum version, which may be 0. You can compare this to other versions.</param>
655 /// <param name="pullMaxVersion">A 64-bit unsigned integer representing the maximum version, which may be MAXULONGLONG. You can compare this to other versions.</param>
656 /// <returns>Standard HRESULT indicating success or failure, including E_INVALIDARG if the version range is not valid.</returns>
657 STDMETHOD(ParseVersionRange)(
658 _In_ LPCOLESTR pwszVersionRange,
659 _Out_ PULONGLONG pullMinVersion,
660 _Out_ PULONGLONG pullMaxVersion
661 ) = 0;
662 };
663#endif
664
665 EXTERN_C const IID IID_ISetupErrorState;
666
667#if defined(__cplusplus) && !defined(CINTERFACE)
668 /// <summary>
669 /// Information about the error state of an instance.
670 /// </summary>
671 struct DECLSPEC_UUID("46DCCD94-A287-476A-851E-DFBC2FFDBC20") DECLSPEC_NOVTABLE ISetupErrorState : public IUnknown
672 {
673 /// <summary>
674 /// Gets an array of failed package references.
675 /// </summary>
676 /// <param name="ppsaPackages">Pointer to an array of <see cref="ISetupFailedPackageReference"/>, if packages have failed.</param>
677 /// <returns>Standard HRESULT indicating success or failure.</returns>
678 STDMETHOD(GetFailedPackages)(
679 _Outptr_result_maybenull_ LPSAFEARRAY* ppsaFailedPackages
680 ) = 0;
681
682 /// <summary>
683 /// Gets an array of skipped package references.
684 /// </summary>
685 /// <param name="ppsaPackages">Pointer to an array of <see cref="ISetupPackageReference"/>, if packages have been skipped.</param>
686 /// <returns>Standard HRESULT indicating success or failure.</returns>
687 STDMETHOD(GetSkippedPackages)(
688 _Outptr_result_maybenull_ LPSAFEARRAY* ppsaSkippedPackages
689 ) = 0;
690 };
691#endif
692
693 EXTERN_C const IID IID_ISetupErrorState2;
694
695#if defined(__cplusplus) && !defined(CINTERFACE)
696 /// <summary>
697 /// Information about the error state of an instance.
698 /// </summary>
699 struct DECLSPEC_UUID("9871385B-CA69-48F2-BC1F-7A37CBF0B1EF") DECLSPEC_NOVTABLE ISetupErrorState2 : public ISetupErrorState
700 {
701 /// <summary>
702 /// Gets the path to the error log.
703 /// </summary>
704 /// <param name="pbstrChip">The path to the error log.</param>
705 /// <returns>Standard HRESULT indicating success or failure.</returns>
706 STDMETHOD(GetErrorLogFilePath)(
707 _Outptr_result_maybenull_ BSTR* pbstrErrorLogFilePath
708 ) = 0;
709
710 /// <summary>
711 /// Gets the path to the main setup log.
712 /// </summary>
713 /// <param name="pbstrChip">The path to the main setup log.</param>
714 /// <returns>Standard HRESULT indicating success or failure.</returns>
715 STDMETHOD(GetLogFilePath)(
716 _Outptr_result_maybenull_ BSTR* pbstrLogFilePath
717 ) = 0;
718 };
719#endif
720
721 EXTERN_C const IID IID_ISetupFailedPackageReference;
722
723#if defined(__cplusplus) && !defined(CINTERFACE)
724 /// <summary>
725 /// A reference to a failed package.
726 /// </summary>
727 struct DECLSPEC_UUID("E73559CD-7003-4022-B134-27DC650B280F") DECLSPEC_NOVTABLE ISetupFailedPackageReference : public ISetupPackageReference
728 {
729 };
730
731#endif
732
733 EXTERN_C const IID IID_ISetupFailedPackageReference2;
734
735#if defined(__cplusplus) && !defined(CINTERFACE)
736 /// <summary>
737 /// A reference to a failed package.
738 /// </summary>
739 struct DECLSPEC_UUID("0FAD873E-E874-42E3-B268-4FE2F096B9CA") DECLSPEC_NOVTABLE ISetupFailedPackageReference2 : public ISetupFailedPackageReference
740 {
741 /// <summary>
742 /// Gets the path to the optional package log.
743 /// </summary>
744 /// <param name="pbstrId">The path to the optional package log.</param>
745 /// <returns>Standard HRESULT indicating success or failure.</returns>
746 STDMETHOD(GetLogFilePath)(
747 _Outptr_result_maybenull_ BSTR* pbstrLogFilePath
748 ) = 0;
749
750 /// <summary>
751 /// Gets the description of the package failure.
752 /// </summary>
753 /// <param name="pbstrId">The description of the package failure.</param>
754 /// <returns>Standard HRESULT indicating success or failure.</returns>
755 STDMETHOD(GetDescription)(
756 _Outptr_result_maybenull_ BSTR* pbstrDescription
757 ) = 0;
758
759 /// <summary>
760 /// Gets the signature to use for feedback reporting.
761 /// </summary>
762 /// <param name="pbstrId">The signature to use for feedback reporting.</param>
763 /// <returns>Standard HRESULT indicating success or failure.</returns>
764 STDMETHOD(GetSignature)(
765 _Outptr_result_maybenull_ BSTR* pbstrSignature
766 ) = 0;
767
768 /// <summary>
769 /// Gets the array of details for this package failure.
770 /// </summary>
771 /// <param name="ppsaDetails">Pointer to an array of details as BSTRs.</param>
772 /// <returns>Standard HRESULT indicating success or failure.</returns>
773 STDMETHOD(GetDetails)(
774 _Out_ LPSAFEARRAY* ppsaDetails
775 ) = 0;
776
777 /// <summary>
778 /// Gets an array of packages affected by this package failure.
779 /// </summary>
780 /// <param name="ppsaPackages">Pointer to an array of <see cref="ISetupPackageReference"/> for packages affected by this package failure. This may be NULL.</param>
781 /// <returns>Standard HRESULT indicating success or failure.</returns>
782 STDMETHOD(GetAffectedPackages)(
783 _Out_ LPSAFEARRAY* ppsaAffectedPackages
784 ) = 0;
785 };
786
787#endif
788
789 EXTERN_C const IID IID_ISetupPropertyStore;
790
791#if defined(__cplusplus) && !defined(CINTERFACE)
792 /// <summary>
793 /// Provides named properties.
794 /// </summary>
795 /// <remarks>
796 /// You can get this from an <see cref="ISetupInstance"/>, <see cref="ISetupPackageReference"/>, or derivative.
797 /// </remarks>
798 struct DECLSPEC_UUID("C601C175-A3BE-44BC-91F6-4568D230FC83") DECLSPEC_NOVTABLE ISetupPropertyStore : public IUnknown
799 {
800 /// <summary>
801 /// Gets an array of property names in this property store.
802 /// </summary>
803 /// <param name="ppsaNames">Pointer to an array of property names as BSTRs.</param>
804 /// <returns>Standard HRESULT indicating success or failure.</returns>
805 STDMETHOD(GetNames)(
806 _Out_ LPSAFEARRAY* ppsaNames
807 ) = 0;
808
809 /// <summary>
810 /// Gets the value of a named property in this property store.
811 /// </summary>
812 /// <param name="pwszName">The name of the property to get.</param>
813 /// <param name="pvtValue">The value of the property.</param>
814 /// <returns>Standard HRESULT indicating success or failure, including E_NOTFOUND if the property is not defined or E_NOTSUPPORTED if the property type is not supported.</returns>
815 STDMETHOD(GetValue)(
816 _In_ LPCOLESTR pwszName,
817 _Out_ LPVARIANT pvtValue
818 ) = 0;
819 };
820
821#endif
822
823 EXTERN_C const IID IID_ISetupLocalizedPropertyStore;
824
825#if defined(__cplusplus) && !defined(CINTERFACE)
826 /// <summary>
827 /// Provides localized named properties.
828 /// </summary>
829 /// <remarks>
830 /// You can get this from an <see cref="ISetupLocalizedProperties"/>.
831 /// </remarks>
832 struct DECLSPEC_UUID("5BB53126-E0D5-43DF-80F1-6B161E5C6F6C") DECLSPEC_NOVTABLE ISetupLocalizedPropertyStore : public IUnknown
833 {
834 /// <summary>
835 /// Gets an array of property names in this property store.
836 /// </summary>
837 /// <param name="lcid">The LCID for the property names.</param>
838 /// <param name="ppsaNames">Pointer to an array of property names as BSTRs.</param>
839 /// <returns>Standard HRESULT indicating success or failure.</returns>
840 STDMETHOD(GetNames)(
841 _In_ LCID lcid,
842 _Out_ LPSAFEARRAY* ppsaNames
843 ) = 0;
844
845 /// <summary>
846 /// Gets the value of a named property in this property store.
847 /// </summary>
848 /// <param name="pwszName">The name of the property to get.</param>
849 /// <param name="lcid">The LCID for the property.</param>
850 /// <param name="pvtValue">The value of the property.</param>
851 /// <returns>Standard HRESULT indicating success or failure, including E_NOTFOUND if the property is not defined or E_NOTSUPPORTED if the property type is not supported.</returns>
852 STDMETHOD(GetValue)(
853 _In_ LPCOLESTR pwszName,
854 _In_ LCID lcid,
855 _Out_ LPVARIANT pvtValue
856 ) = 0;
857 };
858
859#endif
860
861 // Class declarations
862 //
863 EXTERN_C const CLSID CLSID_SetupConfiguration;
864
865#ifdef __cplusplus
866
867#ifdef __GNUC__
868 __CRT_UUID_DECL(SetupConfiguration, 0x177F0C4A, 0x1CD3, 0x4DE7, 0xA3, 0x2C, 0x71, 0xDB, 0xBB, 0x9F, 0xA3, 0x6D);
869#endif
870
871 /// <summary>
872 /// This class implements <see cref="ISetupConfiguration"/>, <see cref="ISetupConfiguration2"/>, and <see cref="ISetupHelper"/>.
873 /// </summary>
874 class DECLSPEC_UUID("177F0C4A-1CD3-4DE7-A32C-71DBBB9FA36D") SetupConfiguration;
875#endif
876 // Function declarations
877 //
878 /// <summary>
879 /// Gets an <see cref="ISetupConfiguration"/> that provides information about product instances installed on the machine.
880 /// </summary>
881 /// <param name="ppConfiguration">The <see cref="ISetupConfiguration"/> that provides information about product instances installed on the machine.</param>
882 /// <param name="pReserved">Reserved for future use.</param>
883 /// <returns>Standard HRESULT indicating success or failure.</returns>
884 STDMETHODIMP GetSetupConfiguration(
885 _Out_ ISetupConfiguration** ppConfiguration,
886 _Reserved_ LPVOID pReserved
887 );
888
889#ifdef __cplusplus
890}
891#endif
892
893_COM_SMARTPTR_TYPEDEF(ISetupInstance, __uuidof(ISetupInstance));
894_COM_SMARTPTR_TYPEDEF(ISetupInstance2, __uuidof(ISetupInstance2));
895_COM_SMARTPTR_TYPEDEF(IEnumSetupInstances, __uuidof(IEnumSetupInstances));
896_COM_SMARTPTR_TYPEDEF(ISetupConfiguration, __uuidof(ISetupConfiguration));
897_COM_SMARTPTR_TYPEDEF(ISetupConfiguration2, __uuidof(ISetupConfiguration2));
898_COM_SMARTPTR_TYPEDEF(ISetupHelper, __uuidof(ISetupHelper));
899_COM_SMARTPTR_TYPEDEF(ISetupPackageReference, __uuidof(ISetupPackageReference));
900_COM_SMARTPTR_TYPEDEF(ISetupPropertyStore, __uuidof(ISetupPropertyStore));
901_COM_SMARTPTR_TYPEDEF(ISetupInstanceCatalog, __uuidof(ISetupInstanceCatalog));