Call of Duty: Black Ops 3, does every one of these calls and is quite senstive to their outcome.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/ntdll/tests/info.c | 27 +++++++++++++++++++++++++++ dlls/ntdll/thread.c | 13 +++++++++++++ 2 files changed, 40 insertions(+)
diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c index cf3f7b9f6f2..eaf2f1a45b7 100644 --- a/dlls/ntdll/tests/info.c +++ b/dlls/ntdll/tests/info.c @@ -2346,6 +2346,7 @@ static void test_affinity(void) DWORD_PTR proc_affinity, thread_affinity; THREAD_BASIC_INFORMATION tbi; SYSTEM_INFO si; + ULONG dummy;
GetSystemInfo(&si); status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi), NULL ); @@ -2450,6 +2451,32 @@ static void test_affinity(void) ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status); ok( tbi.AffinityMask == (1 << si.dwNumberOfProcessors) - 1, "Unexpected thread affinity\n" ); + + dummy = 0; + status = pNtSetInformationThread( GetCurrentThread(), ThreadHideFromDebugger, &dummy, sizeof(ULONG) ); + ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status ); + dummy = 0; + status = pNtSetInformationThread( GetCurrentThread(), ThreadHideFromDebugger, &dummy, 1 ); + ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status ); + status = pNtSetInformationThread( (HANDLE)0xdeadbeef, ThreadHideFromDebugger, NULL, 0 ); + ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08x\n", status ); + status = pNtSetInformationThread( GetCurrentThread(), ThreadHideFromDebugger, NULL, 0 ); + ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status ); + dummy = 0; + status = NtQueryInformationThread( GetCurrentThread(), ThreadHideFromDebugger, &dummy, sizeof(ULONG), NULL ); + if (status == STATUS_INVALID_INFO_CLASS) + win_skip("ThreadHideFromDebugger not available\n"); + else + { + ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status ); + dummy = 0; + status = NtQueryInformationThread( (HANDLE)0xdeadbeef, ThreadHideFromDebugger, &dummy, sizeof(ULONG), NULL ); + ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status ); + dummy = 0; + status = NtQueryInformationThread( GetCurrentThread(), ThreadHideFromDebugger, &dummy, 1, NULL ); + ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status ); + if (status == STATUS_SUCCESS) ok( dummy == 1, "Expected dummy == 1, got %08x\n", dummy ); + } }
static void test_NtGetCurrentProcessorNumber(void) diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c index 18664030df5..6a73d6d3466 100644 --- a/dlls/ntdll/thread.c +++ b/dlls/ntdll/thread.c @@ -643,6 +643,8 @@ NTSTATUS WINAPI NtQueryInformationThread( HANDLE handle, THREADINFOCLASS class, { NTSTATUS status;
+ TRACE("(%p,%d,%p,%x,%p)\n", handle, class, data, length, ret_len); + switch(class) { case ThreadBasicInformation: @@ -860,6 +862,12 @@ NTSTATUS WINAPI NtQueryInformationThread( HANDLE handle, THREADINFOCLASS class, *ret_len = sizeof(*info) + desc_len; } return status; + case ThreadHideFromDebugger: + if (length != sizeof(BOOLEAN)) return STATUS_INFO_LENGTH_MISMATCH; + if (!data) return STATUS_ACCESS_VIOLATION; + *(BOOLEAN*)data = TRUE; + if (ret_len) *ret_len = sizeof(BOOLEAN); + return STATUS_SUCCESS; case ThreadPriority: case ThreadBasePriority: case ThreadImpersonationToken: @@ -885,6 +893,9 @@ NTSTATUS WINAPI NtSetInformationThread( HANDLE handle, THREADINFOCLASS class, LPCVOID data, ULONG length ) { NTSTATUS status; + + TRACE("(%p,%d,%p,%x)\n", handle, class, data, length); + switch(class) { case ThreadZeroTlsCell: @@ -972,6 +983,8 @@ NTSTATUS WINAPI NtSetInformationThread( HANDLE handle, THREADINFOCLASS class, } return status; case ThreadHideFromDebugger: + if (length) return STATUS_INFO_LENGTH_MISMATCH; + if (handle != GetCurrentThread()) return STATUS_INVALID_HANDLE; /* pretend the call succeeded to satisfy some code protectors */ return STATUS_SUCCESS; case ThreadQuerySetWin32StartAddress:
Rémi Bernon rbernon@codeweavers.com writes:
Call of Duty: Black Ops 3, does every one of these calls and is quite senstive to their outcome.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com
dlls/ntdll/tests/info.c | 27 +++++++++++++++++++++++++++ dlls/ntdll/thread.c | 13 +++++++++++++ 2 files changed, 40 insertions(+)
This is causing a test failure:
../../../tools/runtest -q -P wine -T ../../.. -M kernel32.dll -p kernel32_test.exe thread && touch thread.ok thread.c:2230: Test failed: for info 17 expected STATUS_ACCESS_DENIED, got 00000000 (ret_len 1) make: *** [Makefile:948: thread.ok] Error 1
On 2020-06-17 22:00, Alexandre Julliard wrote:
Rémi Bernon rbernon@codeweavers.com writes:
Call of Duty: Black Ops 3, does every one of these calls and is quite senstive to their outcome.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com
dlls/ntdll/tests/info.c | 27 +++++++++++++++++++++++++++ dlls/ntdll/thread.c | 13 +++++++++++++ 2 files changed, 40 insertions(+)
This is causing a test failure:
../../../tools/runtest -q -P wine -T ../../.. -M kernel32.dll -p kernel32_test.exe thread && touch thread.ok thread.c:2230: Test failed: for info 17 expected STATUS_ACCESS_DENIED, got 00000000 (ret_len 1) make: *** [Makefile:948: thread.ok] Error 1
Sorry, I'll have a look.