Skip to content

Commit

Permalink
terminal_services: Fix "The operation completed successfully." error (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jkroepke authored Aug 5, 2024
1 parent 9026bc0 commit dffc53e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/headers/wtsapi32/wtsapi32.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,17 @@ func WTSCloseServer(server syscall.Handle) error {
}

func WTSFreeMemoryEx(class WTSTypeClass, pMemory uintptr, NumberOfEntries uint32) error {
_, _, err := procWTSFreeMemoryEx.Call(
r1, _, err := procWTSFreeMemoryEx.Call(
uintptr(class),
pMemory,
uintptr(NumberOfEntries),
)

return err
if r1 != 1 {
return fmt.Errorf("failed to free memory: %w", err)
}

return nil
}

func WTSEnumerateSessionsEx(server syscall.Handle, logger log.Logger) ([]WTSSession, error) {
Expand All @@ -168,7 +172,7 @@ func WTSEnumerateSessionsEx(server syscall.Handle, logger log.Logger) ([]WTSSess
defer func(class WTSTypeClass, pMemory uintptr, NumberOfEntries uint32) {
err := WTSFreeMemoryEx(class, pMemory, NumberOfEntries)
if err != nil {
_ = level.Error(logger).Log("msg", "failed to free memory", "err", err)
_ = level.Error(logger).Log("msg", "failed to free memory", "err", fmt.Errorf("WTSEnumerateSessionsEx: %w", err))
}
}(WTSTypeSessionInfoLevel1, sessionInfoPointer, count)
}
Expand Down

0 comments on commit dffc53e

Please sign in to comment.