Files
overlord/Overlord-Client/cmd/agent/privacy/privacy.go
T

58 lines
1.1 KiB
Go
Raw Normal View History

2026-07-10 23:44:46 -05:00
package privacy
import (
"sync"
"sync/atomic"
)
2026-07-11 14:55:26 -05:00
// Keep the full marker on 64-bit builds and let the runtime conversion retain
// its low 32 bits on 32-bit builds. dwExtraInfo is pointer-sized, so the sender
// and the low-level hooks observe the same value on either architecture.
var inputMarkerValue uint64 = 0x00D5E7B00B5
2026-07-10 23:44:46 -05:00
type Manager struct {
mu sync.Mutex
enabled int32
}
var global = &Manager{}
func Get() *Manager { return global }
func (m *Manager) IsEnabled() bool {
return atomic.LoadInt32(&m.enabled) != 0
}
func (m *Manager) Enable() error {
m.mu.Lock()
defer m.mu.Unlock()
if atomic.LoadInt32(&m.enabled) != 0 {
return nil
}
if err := enablePlatform(); err != nil {
atomic.StoreInt32(&m.enabled, 0)
return err
}
atomic.StoreInt32(&m.enabled, 1)
return nil
}
func (m *Manager) Disable() {
m.mu.Lock()
defer m.mu.Unlock()
if atomic.SwapInt32(&m.enabled, 0) == 0 {
return
}
disablePlatform()
}
func Start() error { return Get().Enable() }
func Stop() { Get().Disable() }
func IsEnabled() bool { return Get().IsEnabled() }
2026-07-11 14:55:26 -05:00
func InputMarker() uintptr { return uintptr(inputMarkerValue) }