isSingleInstance checks if there is a single instance of the Fibratus process running in the system. This is accomplished by creating a global event object. If such an object already exists, we can conclude Fibratus process is already running.
()
| 435 | // an object already exists, we can conclude Fibratus process |
| 436 | // is already running. |
| 437 | func (f *App) isSingleInstance() bool { |
| 438 | name, err := windows.UTF16PtrFromString("Global\\Fibratus") |
| 439 | if err != nil { |
| 440 | return false |
| 441 | } |
| 442 | event, err := windows.CreateEvent(nil, 0, 0, name) |
| 443 | return event != 0 && !errors.Is(err, windows.ERROR_ALREADY_EXISTS) |
| 444 | } |
no outgoing calls
no test coverage detected