From b6ea0f8aa796a0cb04aa6f55165cb88523c8cfb8 Mon Sep 17 00:00:00 2001 From: Chris Norman <17420369+chrnorm@users.noreply.github.com> Date: Tue, 1 Oct 2024 10:25:03 -0700 Subject: [PATCH] windows native messaging fixes - write to the correct registry key (it needs to be a subkey rather than a string value) - fix the executable to be 'granted', rather than 'assumego.exe' (assumego.exe was not working) --- pkg/chromemsg/configure_windows.go | 8 +++++++- pkg/chromemsg/write_manifest.go | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pkg/chromemsg/configure_windows.go b/pkg/chromemsg/configure_windows.go index 769369ae..524fdacd 100644 --- a/pkg/chromemsg/configure_windows.go +++ b/pkg/chromemsg/configure_windows.go @@ -39,7 +39,13 @@ func configureWindows() error { } defer key.Close() - if err = key.SetStringValue("io.commonfate.granted", manifestPath); err != nil { + gkey, _, err := registry.CreateKey(key, "io.commonfate.granted", registry.QUERY_VALUE|registry.SET_VALUE) + if err != nil { + continue + } + defer gkey.Close() + + if err = gkey.SetStringValue("", manifestPath); err != nil { return err } } diff --git a/pkg/chromemsg/write_manifest.go b/pkg/chromemsg/write_manifest.go index 3b0fd6e7..d92c5d51 100644 --- a/pkg/chromemsg/write_manifest.go +++ b/pkg/chromemsg/write_manifest.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "path/filepath" + "runtime" "github.com/common-fate/granted/internal/build" ) @@ -28,6 +29,12 @@ func writeManifest(manifestPath string) error { return err } + if runtime.GOOS == "windows" { + // on windows, the file needs to be 'granted.exe' rather than 'assumego.exe'. + parent := filepath.Dir(executablePath) + executablePath = filepath.Join(parent, build.GrantedBinaryName()+".exe") + } + manifest := HostManifest{ Name: "io.commonfate.granted", Description: "Granted BrowserSupport",