From 67980f0b8b9acfb9cc862afe75fd47ce5325cc54 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Sat, 4 Nov 2017 13:35:43 -0700 Subject: [PATCH] Generate RT_GROUP_ICON id before ICON ids This ensures the group icon always has a consistent ID that can be used by the application to find the icon, even when the ico file itself contains a different number of resolution variations. --- rsrc/rsrc.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rsrc/rsrc.go b/rsrc/rsrc.go index 13b5642..ea29f54 100644 --- a/rsrc/rsrc.go +++ b/rsrc/rsrc.go @@ -87,14 +87,14 @@ func addIcon(out *coff.Coff, fname string, newid func() uint16) (io.Closer, erro Type: 1, // magic num. Count: uint16(len(icons)), }} + gid := newid() for _, icon := range icons { id := newid() r := io.NewSectionReader(f, int64(icon.ImageOffset), int64(icon.BytesInRes)) out.AddResource(coff.RT_ICON, id, r) group.Entries = append(group.Entries, _GRPICONDIRENTRY{icon.IconDirEntryCommon, id}) } - id := newid() - out.AddResource(coff.RT_GROUP_ICON, id, group) + out.AddResource(coff.RT_GROUP_ICON, gid, group) // TODO(akavel): reintroduce the Printlns in package main after Embed returns // fmt.Println("Icon ", fname, " ID: ", id) }