You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The timestamp fields in the WTSINFO and WTSINFOEX_LEVEL1 end up with bad values because their offsets within the structure aren't correct. This is due to the SizeConst = USERNAME_LENGTH + 1 of the previous field in WTSINFO messing up the padding. I haven't fiddled with WTSINFOEX_LEVEL1 but I believe it has similar issues.
Changing WTSINFO to use SizeConst = USERNAME_LENGTH + 2 or adding a private char _padding field after UserName fixes it.
What code is involved PInvoke\WTSApi32\WTSApi32.cs
Expected behavior
The timestamp fields should have either 0s or sane values. The CurrentTime field should always be sane.
Repro
if (WTSEnumerateSessionsEx(HWTSSERVER.WTS_CURRENT_SERVER_HANDLE, out var sessionList)) {
foreach (var session in sessionList) {
if (WTSQuerySessionInformation(HWTSSERVER.WTS_CURRENT_SERVER_HANDLE, session.SessionId, WTS_INFO_CLASS.WTSSessionInfo, out var pSessionInfo, out var bytesReturned)) {
using (pSessionInfo) {
var sessionInfo = pSessionInfo.ToStructure<WTSINFO>(bytesReturned);
Console.WriteLine("CurrentTime is {0}", sessionInfo.CurrentTime.ToDateTime());
}
}
}
}
The text was updated successfully, but these errors were encountered:
Describe the bug
The timestamp fields in the
WTSINFO
andWTSINFOEX_LEVEL1
end up with bad values because their offsets within the structure aren't correct. This is due to theSizeConst = USERNAME_LENGTH + 1
of the previous field inWTSINFO
messing up the padding. I haven't fiddled withWTSINFOEX_LEVEL1
but I believe it has similar issues.Changing
WTSINFO
to useSizeConst = USERNAME_LENGTH + 2
or adding aprivate char _padding
field afterUserName
fixes it.What code is involved
PInvoke\WTSApi32\WTSApi32.cs
Expected behavior
The timestamp fields should have either 0s or sane values. The
CurrentTime
field should always be sane.Repro
The text was updated successfully, but these errors were encountered: