commit c8669ebc7266869720cd82347a279d5df95b518f Author: fn-registry agent Date: Thu Apr 30 16:02:59 2026 +0200 chore: sync from fn-registry agent diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dcfaf86 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +set_exe_icon +*.exe +*.bak diff --git a/app.md b/app.md new file mode 100644 index 0000000..c3503ed --- /dev/null +++ b/app.md @@ -0,0 +1,37 @@ +--- +name: set_exe_icon +lang: go +domain: infra +description: "CLI Windows que embebe un .ico en un .exe (post-build) sin dependencias externas. Wrapper sobre la funcion set_exe_icon_go_infra del registry. Crea backup .bak antes de modificar." +tags: [windows, pe, exe, icon, cli] +uses_functions: + - set_exe_icon_go_infra +uses_types: [] +framework: "" +entry_point: "main.go" +dir_path: "apps/set_exe_icon" +--- + +## Build + +```bash +# Linux nativo +go build -o set_exe_icon . + +# Cross-compile a Windows +GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-s -w" -o set_exe_icon.exe . +``` + +## Uso + +```cmd +set_exe_icon.exe miapp.exe logo.ico +``` + +Crea `miapp.exe.bak` y sobrescribe `miapp.exe` con el icono embebido. + +## Limitaciones + +- No soporta .exe que ya tienen seccion `.rsrc` (devuelve error y restaura el backup). +- El checksum PE se pone a 0 (Windows lo ignora salvo para drivers/ntoskrnl). +- Authenticode signing queda invalidado tras la modificacion. diff --git a/main.go b/main.go new file mode 100644 index 0000000..9e96818 --- /dev/null +++ b/main.go @@ -0,0 +1,47 @@ +package main + +import ( + "fmt" + "os" + + "fn-registry/functions/infra" +) + +const usage = `set_exe_icon - embed a .ico into a Windows .exe (post-build, no deps) + +Usage: + set_exe_icon + +Notes: + Modifies the .exe in place (creates a backup at .bak first). + Only supports PE binaries without an existing .rsrc section. +` + +func main() { + if len(os.Args) != 3 { + fmt.Fprint(os.Stderr, usage) + os.Exit(2) + } + exePath, icoPath := os.Args[1], os.Args[2] + + bak := exePath + ".bak" + src, err := os.ReadFile(exePath) + if err != nil { + die("read exe: %v", err) + } + if err := os.WriteFile(bak, src, 0o755); err != nil { + die("write backup: %v", err) + } + + if err := infra.SetExeIcon(exePath, icoPath); err != nil { + _ = os.WriteFile(exePath, src, 0o755) + _ = os.Remove(bak) + die("set icon: %v", err) + } + fmt.Printf("OK: icon embedded in %s (backup: %s)\n", exePath, bak) +} + +func die(format string, a ...any) { + fmt.Fprintf(os.Stderr, "error: "+format+"\n", a...) + os.Exit(1) +}