D151 - A thread handle is an address, because the guest dereferences it

decided ยท 2026-08-20

The first version made ThreadHandle a small opaque integer, with a comment explaining that a handle is passed back rather than read through, so it never needs to be an address

The evidence against that was already in the knowledge file, written a day earlier under D125: an unimplemented scePthreadSelf returned the placeholder 0x7FFF0001, and a title faulted with read of 0x5 - that error code being dereferenced at an offset. The guest reads fields out of what this call returns.

A handle of 1 reproduces exactly the same fault at a lower address. The "opaque integer" reasoning was sound in the abstract and contradicted by a measurement this project had already made and written down.

So a handle is the address of a leaked, zeroed, eight-byte-aligned block. Three consequences, each chosen rather than inherited:

The same applies to lock handles, for the same reason.

The general lesson is the one worth keeping: the knowledge file is not a report, it is an input. It contained the answer before the question was asked, and only got consulted because a test failed for an unrelated reason.