terminal_services: Fix "The operation completed successfully." error (#1548)

This commit is contained in:
Jan-Otto Kröpke 2024-08-05 15:31:29 +02:00 committed by GitHub
parent 9026bc02ff
commit dffc53eff8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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) {
@ -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)
}