| 1 | // Command console-probe is an independent console executable for launcher tests. |
| 2 | package main |
| 3 | |
| 4 | import ( |
| 5 | "fmt" |
| 6 | "os" |
| 7 | "path/filepath" |
| 8 | "syscall" |
| 9 | ) |
| 10 | |
| 11 | func main() { |
| 12 | exe, err := os.Executable() |
| 13 | if err != nil { |
| 14 | panic(err) |
| 15 | } |
| 16 | name := filepath.Base(exe) |
| 17 | kernel := syscall.NewLazyDLL("kernel32.dll") |
| 18 | cp, _, _ := kernel.NewProc("GetConsoleCP").Call() |
| 19 | window, _, _ := kernel.NewProc("GetConsoleWindow").Call() |
| 20 | fmt.Printf("console-state %s %d %d\n", name, cp, window) |
| 21 | if name == "reasonix-guard.exe" { |
| 22 | root := os.Getenv("REASONIX_LAUNCHER_CONSOLE_TEST") |
| 23 | pointer := `{"schemaVersion":1,"activeVersion":"v1.0.0","activeDir":"versions/v1.0.0"}` |
| 24 | if err := os.WriteFile(filepath.Join(root, "current.json"), []byte(pointer), 0o644); err != nil { |
| 25 | panic(err) |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 |