5 ms·
You may be surprised to learn that some windows handles are actually just addresses with no kernel state too. A great example is an HMODULE. In fact windows a
by jdsully 7y ago
You may be surprised to learn that some windows handles are actually just addresses with no kernel state too. A great example is an HMODULE.
In fact windows actually reserves a block of user address space that will never be allocated to disambiguate memory vs non memory handles.
Its really a pitty these two great systems refuse to learn from each other.
- dingu 7y agoWhat does that have to do with anything? You wouldn't use WFMO to implement a futex in Windows. And regardless of anything in Linux, defending WFMO seems like a strange hill to die on. It's not a great API. I'm calling your bluff too. Which one of the supported waitable handles in Windows are just addresses with no other state? I'm more surprised because they all need an access mask at a minimum, and I thought they all involve an ObCreateObject, even a Mutant... these dusty corners of the kernel are visible through the DDK. Anyway, I would be glad to be shown wrong.
- jdsully 7y agoI’m not sure why theres such animosity in your replies. The goal here is not to defend windows but to point out that handles need not aways refer to kernel objects. It would be possible to provide an orthogonal handle based API even if windows doesn’t always live up to that ideal. Ultimately it seems these systems are just too big to maintain a cohesive design - but it is still an ideal to aspire to.
- monocasa 7y agoThe handle is a _kernel_ address... backed by a validly constructed kernel object. EDIT: And since you dirty edited, can you point to an example of HMODULE or any other dataless HANDLE being used on the syscall interface?
- jdsully 7y agoHandles are not kernel addresses in NT and windows will not intentionally leak those to user space. Handle accesses are always through a layer of indirection in the object manager. You will find that windows never makes guarantees of what handles actually are - in case it wants to change them. In windows NT most GDI handles are user mode and not kernel objects. Other objects may or may not be kernel based depending on the version and whims of the implementor.
- monocasa 7y agoI mean, they're very clearly offsets into the HANDLE table kernel space. And can you WFMO on user space only HANDLEs?
- dingu 7y agoAh you edited your response? An HMODULE.. That is weak dude. Calling and HMODULE a HANDLE is cheating... by that definition a UINT is a HANDLE since you can cast it. Can you use HMODULEs orthogonally to common APIs that use Handles? That's what really matters. Just because something is 4 or 8 bytes wide and you call it the same thing isn't interesting. Like can you pass HMODULE to WaitForSingleObject? Oh Ok, I guess that's mean because to be fair, what does "waiting" on a DLL mean. Ok, well surely you can pass that HMODULE to CloseHandle, at least closing should be orthogonal.. Why don't you try that? I'll wait. So what point are you trying to make here? It sound like you're just jerking everyone around, tbh. Edit: Moreover, it's a bit ridiculous to say that an HMODULE is just an address with no kernel state. It uniquely identifies the loaded DLL, so it a key to a tremendous amount of kernel bookkeeping about the loaded module.
- deleted 7y ago[deleted]