diff options
| author | Reuben Dunnington <reuben.dunnington@gmail.com> | 2025-01-05 19:36:52 -0800 |
|---|---|---|
| committer | Alex Rønne Petersen <alex@alexrp.com> | 2025-01-06 15:56:21 +0100 |
| commit | a7a5f3506b74651235ba7112ce38b7c3205d0527 (patch) | |
| tree | 1fffaeeb79b7e9fc3527257b61597d13dc824c2b /src/Compilation.zig | |
| parent | 745d3ed0ac1ad1ec8c72d1b432f79e40a1917cde (diff) | |
| download | zig-a7a5f3506b74651235ba7112ce38b7c3205d0527.tar.gz zig-a7a5f3506b74651235ba7112ce38b7c3205d0527.zip | |
fix win32 manifest ID for DLLs
* MSDN documentation page covering what resource IDs manifests should have:
https://learn.microsoft.com/en-us/windows/win32/sbscs/using-side-by-side-assemblies-as-a-resource
* This change ensures shared libraries that embed win32 manifests use the
proper ID of 2 instead of 1, which is only allowed for .exes. If the manifest
uses the wrong ID, it will not be found and is essentially ignored.
Diffstat (limited to 'src/Compilation.zig')
| -rw-r--r-- | src/Compilation.zig | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index be501646a3..241386f10c 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -5056,9 +5056,17 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32 } }.fmtRcEscape; - // 1 is CREATEPROCESS_MANIFEST_RESOURCE_ID which is the default ID used for RT_MANIFEST resources + // https://learn.microsoft.com/en-us/windows/win32/sbscs/using-side-by-side-assemblies-as-a-resource + // WinUser.h defines: + // CREATEPROCESS_MANIFEST_RESOURCE_ID to 1, which is the default + // ISOLATIONAWARE_MANIFEST_RESOURCE_ID to 2, which must be used for .dlls + const resource_id: u32 = if (comp.config.output_mode == .Lib and comp.config.link_mode == .dynamic) 2 else 1; + // 24 is RT_MANIFEST - const input = try std.fmt.allocPrint(arena, "1 24 \"{s}\"", .{fmtRcEscape(src_path)}); + const resource_type = 24; + + const input = try std.fmt.allocPrint(arena, "{} {} \"{s}\"", .{ resource_id, resource_type, fmtRcEscape(src_path) }); + try o_dir.writeFile(.{ .sub_path = rc_basename, .data = input }); var argv = std.ArrayList([]const u8).init(comp.gpa); |
