Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RM_PROCESS_INFO::TSSessionId is unsigned but RM_INVALID_TS_SESSION is signed #1927

Open
KalleOlaviNiemitalo opened this issue Jun 16, 2024 · 2 comments

Comments

@KalleOlaviNiemitalo
Copy link

RM_INVALID_TS_SESSION is intended to be compared to RM_PROCESS_INFO::TSSessionId but they have different types; one is signed and the other is unsigned. That then requires an unchecked cast when these are compared in C#.

// Uninitialized value for TS Session ID
#define RM_INVALID_TS_SESSION -1
DWORD TSSessionId; // Terminal Service session ID of
// process (-1 if n/a)

Can the same type be used for both? I guess it would have to be the unsigned type, for consistency with WTS_CURRENT_SESSION, WTSQuerySessionInformationW, and others.

@KalleOlaviNiemitalo
Copy link
Author

Similar considerations may apply to RM_INVALID_PROCESS vs. RM_UNIQUE_PROCESS::dwProcessId, but I haven't found any formal documentation on the intended use of RM_INVALID_PROCESS.

// Uninitialized value for Process ID
#define RM_INVALID_PROCESS -1

@mikebattista
Copy link
Contributor

I wouldn't change the type of the struct fields. Should the constant values be changed to reflect any implicit conversions that C is doing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants