Signed-off-by: Myah Caron qsniyg@protonmail.com --- Due to some of the fields being currently unimplemented by wine, the entropy isn't great.
I've opted to not include the rdtsc instruction for the moment, as I believe it'd make the function significantly more complex (through apparently separate inline assembly for i386/x86-64 according to https://stackoverflow.com/a/9887899/13255485), or require compiler-specific intrinsics.
dlls/ntdll/unix/process.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/unix/process.c b/dlls/ntdll/unix/process.c index 5ccf435e9ff..258ddc1c79d 100644 --- a/dlls/ntdll/unix/process.c +++ b/dlls/ntdll/unix/process.c @@ -62,6 +62,7 @@ #define WIN32_NO_STATUS #include "windef.h" #include "winternl.h" +#include "ddk/wdm.h" #include "unix_private.h" #include "wine/exception.h" #include "wine/server.h" @@ -1166,6 +1167,30 @@ void fill_vm_counters( VM_COUNTERS_EX *pvmi, int unix_pid )
#endif
+static ULONG get_process_cookie( void ) +{ + static ULONG process_cookie; + + if (!process_cookie) + { + /* http://blogs.msdn.com/b/michael_howard/archive/2006/08/16/702707.aspx */ + SYSTEM_PERFORMANCE_INFORMATION spi; + ULONG cookie = user_shared_data->TickCount.High1Time; + cookie ^= user_shared_data->TickCount.LowPart; + cookie ^= user_shared_data->InterruptTime.LowPart; + + NtQuerySystemInformation( SystemPerformanceInformation, &spi, sizeof( spi ), NULL ); + cookie ^= spi.SystemCalls; + cookie ^= spi.PageFaults; + + /* todo: cookie ^= (ULONG)rdtsc */ + + InterlockedExchange( (LONG*)&process_cookie, cookie ); + } + + return process_cookie; +} + #define UNIMPLEMENTED_INFO_CLASS(c) \ case c: \ FIXME( "(process=%p) Unimplemented information class: " #c "\n", handle); \ @@ -1541,11 +1566,10 @@ NTSTATUS WINAPI NtQueryInformationProcess( HANDLE handle, PROCESSINFOCLASS class break;
case ProcessCookie: - FIXME( "ProcessCookie (%p,%p,0x%08x,%p) stub\n", handle, info, size, ret_len ); if (handle == NtCurrentProcess()) { len = sizeof(ULONG); - if (size == len) *(ULONG *)info = 0; + if (size == len) *(ULONG *)info = get_process_cookie(); else ret = STATUS_INFO_LENGTH_MISMATCH; } else ret = STATUS_INVALID_PARAMETER; -- 2.28.0