Skip to content

Commit

Permalink
Fix usage of PowerUnregisterSuspendResumeNotification
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Aug 8, 2024
1 parent 7beca62 commit 5723a3e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions common/winpowrprof/event_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package winpowrprof
// modify from https://github.com/golang/go/blob/b634f6fdcbebee23b7da709a243f3db217b64776/src/runtime/os_windows.go#L257

import (
"runtime"
"syscall"
"unsafe"

Expand Down Expand Up @@ -83,9 +84,10 @@ func (l *powerEventListener) Start() error {
}

func (l *powerEventListener) Close() error {
_, _, errno := syscall.SyscallN(procPowerUnregisterSuspendResumeNotification.Addr(), uintptr(unsafe.Pointer(&l.handle)))
if errno != 0 {
return errno
r0, _, _ := syscall.SyscallN(procPowerUnregisterSuspendResumeNotification.Addr(), l.handle)
if r0 != windows.NO_ERROR {
return syscall.Errno(r0)
}
runtime.KeepAlive(l)
return nil
}

0 comments on commit 5723a3e

Please sign in to comment.