On Fri Oct 31 00:41:32 2025 +0000, Marc-Aurel Zent wrote:
We could use `GetCurrentProcessToken()`, but `NtCurrentProcessToken()` is a fixed compile time constant instead of a function and is a bit more pleasant to use (especially to initialize arrays). I also think it would be nice to have both the NT versions and Win32 ones for all of the pseudo-handles for consistencies sake.
I am so far failing to see practical difference, that is inline function defined in header now: ``` static FORCEINLINE HANDLE WINAPI GetCurrentProcessToken(void) { return (HANDLE)~(ULONG_PTR)3; } ``` In practice for any *relatively* new compiler (as in less than a couple of decades old at least probably), there is no slightest performance difference between this and '#define constant', the constant will be inlined either way. The only difference in having '#define' could be for initializing static variables but I doubt this is an actual usecase.
I think the other handles exist as Nt...() because they are frequently used in Wine Unix libs (and you don't add such usage in the patches for tokens). Even there, in ntdll Unix part, there are a lot of usages of GetCurrentProcess() besides NtCurrentProcess(), I don't think that matters much really. And as soon as it doesn't matter and new functions are not used IMO it makes sense not to introduce unneeded changes.