On Thu Mar 13 14:24:27 2025 +0000, Jacek Caban wrote:
I think that one of more interesting optimizations is `IsWindow`, for which we need shared handle table and handle validation on top of that. Your approach will always need a server call for invalid handles.
You can name it differently, but you'll still have to have an object
expected id (name it handle, `object_id_t` or anything) and its offset. No, you don't need any expected id. As I said, unlike with NT handles, lifetime of the handle is the same lifetime of its underlying object. Handle validation is enough and it's something that would be good to have anyway (see above). We'd indeed need an offset, but that's it.
The entry layout in your branch doesn't seem to match what I'm seeing
on latest Windows 10, there's TID, object type and handle generation, and maybe what seems to be an offset at a different position but that's about it, no obvious client/server pointers, no PID either. The offset is all you need. Whatever is missing in the handle table could be a part of the struct referenced by that offset.
The offset is ephemeral by nature: the struct referenced by the offset can always be freed and reused by another object at any time, even during a read from a client. We still need a way to verify that the "read critical section" is consistently reading from the same USER object throughout the duration of the critical section, instead of some dangling/freed offset due to an abrupt replacement/destruction of the object.
One obvious way to resolve is to make the USER handle (itself consisting of index + generation) a part of the struct referenced by that offset. This is what I assume Rémi is referring to as the "ID".