chore: sync from fn-registry agent
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
set_exe_icon
|
||||||
|
*.exe
|
||||||
|
*.bak
|
||||||
@@ -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.
|
||||||
@@ -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 <exe> <ico>
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
Modifies the .exe in place (creates a backup at <exe>.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)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user