Andrea Rossini
Andrea Rossini

Reputation: 330

Are there special values Windows never uses for a processID?

During a code review I found the original programmer making the assumption his program will never get the 1010 (one thousand and ten) PID.

So there is an hard coded test on PID 1010.

Thank you.

Upvotes: 1

Views: 129

Answers (1)

MC ND
MC ND

Reputation: 70923

No program can obtain a 1010 (one thousand and ten) PID. All PID (and all kernel handles) will be multipes of four as the two lower bits of its value will be 0

Extracted from ntdef.h

//
// Low order two bits of a handle are ignored by the system and available
// for use by application code as tag bits.  The remaining bits are opaque
// and used to store a serial number and table index.
//

Upvotes: 2

Related Questions