Skip to content

Commit a7a5f35

Browse files
rdunningtonalexrp
authored andcommitted
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.
1 parent 745d3ed commit a7a5f35

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Compilation.zig

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5056,9 +5056,17 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
50565056
}
50575057
}.fmtRcEscape;
50585058

5059-
// 1 is CREATEPROCESS_MANIFEST_RESOURCE_ID which is the default ID used for RT_MANIFEST resources
5059+
// https://learn.microsoft.com/en-us/windows/win32/sbscs/using-side-by-side-assemblies-as-a-resource
5060+
// WinUser.h defines:
5061+
// CREATEPROCESS_MANIFEST_RESOURCE_ID to 1, which is the default
5062+
// ISOLATIONAWARE_MANIFEST_RESOURCE_ID to 2, which must be used for .dlls
5063+
const resource_id: u32 = if (comp.config.output_mode == .Lib and comp.config.link_mode == .dynamic) 2 else 1;
5064+
50605065
// 24 is RT_MANIFEST
5061-
const input = try std.fmt.allocPrint(arena, "1 24 \"{s}\"", .{fmtRcEscape(src_path)});
5066+
const resource_type = 24;
5067+
5068+
const input = try std.fmt.allocPrint(arena, "{} {} \"{s}\"", .{ resource_id, resource_type, fmtRcEscape(src_path) });
5069+
50625070
try o_dir.writeFile(.{ .sub_path = rc_basename, .data = input });
50635071

50645072
var argv = std.ArrayList([]const u8).init(comp.gpa);

0 commit comments

Comments
 (0)