github.com/iDigitalFlame/xmt@v0.5.4/examples/example_guardian_linkers.go (about) 1 //go:build !wasm && !js 2 // +build !wasm,!js 3 4 // Copyright (C) 2020 - 2023 iDigitalFlame 5 // 6 // This program is free software: you can redistribute it and/or modify 7 // it under the terms of the GNU General Public License as published by 8 // the Free Software Foundation, either version 3 of the License, or 9 // any later version. 10 // 11 // This program is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU General Public License for more details. 15 // 16 // You should have received a copy of the GNU General Public License 17 // along with this program. If not, see <https://www.gnu.org/licenses/>. 18 // 19 20 package main 21 22 import ( 23 "fmt" 24 "os" 25 "os/signal" 26 "syscall" 27 28 "github.com/iDigitalFlame/xmt/man" 29 ) 30 31 func exampleGuardianLinkers() { 32 if len(os.Args) == 1 { 33 fmt.Printf("g1 = %t\n", man.Check(man.Pipe, "1guard1")) 34 fmt.Printf("g2 = %t\n", man.Check(man.TCP, ":5011")) 35 fmt.Printf("g3 = %t\n", man.Check(man.Mutex, "1guard2")) 36 fmt.Printf("g4 = %t\n", man.Check(man.Event, "1guard3")) 37 fmt.Printf("g5 = %t\n", man.Check(man.Semaphore, "1guard4")) 38 fmt.Printf("g6 = %t\n", man.Check(man.Mailslot, "1guard5")) 39 40 var s man.Sentinel 41 s.SetInclude("derp.exe", "explorer.exe").SetElevated(true) 42 s.AddExecute("cmd1.exe") 43 s.AddDownload("http://google.com") 44 s.AddExecute("cc.exe") 45 s.Save(nil, "a.txt") 46 47 v, _ := man.File(nil, "a.txt") 48 fmt.Println(v, v.Include) 49 return 50 } 51 52 g1 := man.MustGuard(man.Pipe, "1guard1") 53 g2 := man.MustGuard(man.TCP, ":5011") 54 g3 := man.MustGuard(man.Mutex, "1guard2") 55 g4 := man.MustGuard(man.Event, "1guard3") 56 g5 := man.MustGuard(man.Semaphore, "1guard4") 57 g6 := man.MustGuard(man.Mailslot, "1guard5") 58 59 e := make(chan os.Signal, 1) 60 signal.Notify(e, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) 61 62 <-e 63 64 g1.Close() 65 g2.Close() 66 g3.Close() 67 g4.Close() 68 g5.Close() 69 g6.Close() 70 }