26#define WINE_NO_INLINE_STRING
29#define WIN32_NO_STATUS
39#define THREAD_ALL_ACCESS_NT4 (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3ff)
44#define USE_EXTENDED_PRIORITIES 0
57# define __EXCEPT __except
66#elif defined __x86_64__
70#elif defined __aarch64__
161 return sync_id == my_id;
201 ? (obeying_ars = +1) \
202 : ((obeying_ars = -1), \
203 trace("not restricted, assuming consistent behaviour\n"))) \
204 : (obeying_ars < 0) \
205 ? ok(!(x), "access restrictions obeyed\n") \
206 : ok( (x), "access restrictions not obeyed\n"))
219 "TlsSetValue failed\n");
229 ok(tstruct->
threadmem[
i] != 0,
"expected threadmem[%d] != 0\n",
i);
232 ok(
lstrlenA( (
char *)0xdeadbeef ) == 0,
"lstrlenA: unexpected success\n" );
236 "TlsGetValue failed\n");
307 cur = (
void*)0xdeadbeef;
308 ret = pGetCurrentActCtx(&
cur);
343 skip(
"child process wasn't mapped at same address, so can't do CreateRemoteThread tests.\n");
360 win_skip(
"CreateRemoteThread is not implemented\n");
364 ok(
tid != 0,
"null tid\n");
389 hRemoteEvent, 0, &
tid);
398 hRemoteEvent, 0, &
tid);
408 if (
ret)
ok(exitcode == 0,
"SetEvent succeeded, expected to fail\n");
432 ok(
lstrlenA( (
char *)0xdeadbeef ) == 0,
"lstrlenA: unexpected success\n" );
453 &tstruct[
i],0,&threadid[
i]);
464 ok(exitCode==
i+
NUM_THREADS,
"Thread returned an incorrect exit code\n");
475 if (threadmem[
i]==threadmem[
j]) {
479 ok(!
error && threadmem[
i]==threadid[
i] && threadmem[
i]!=curthreadId,
480 "Thread did not execute successfully\n");
488 "GetLastError: expected 0xCAFEF00D, got %08x\n",
GetLastError());
494 "GetLastError: expected ERROR_INVALID_PARAMETER, got %08x\n",
GetLastError());
501 ok(
GLE==0xFACEaBAD,
"CreateThread set last error to %d, expected 4207848365\n",
GLE);
505 ok(
ret!=0,
"GetExitCodeThread returned %d (expected nonzero)\n",
ret);
506 ok(exitCode==99,
"threadFunc2 exited with code: %d (expected 99)\n", exitCode);
533 "ResumeThread should not have actually started the thread\n");
537 "Thread did not resume\n");
543 ok(suspend_count == -1,
"SuspendThread returned %d, expected -1\n", suspend_count);
546 ok(suspend_count == 0 ||
547 broken(suspend_count == -1),
548 "ResumeThread returned %d, expected 0\n", suspend_count);
577 ok(
error==1,
"SuspendThread did not work\n");
582 ok(access_thread!=
NULL,
"OpenThread returned an invalid handle\n");
583 if (access_thread!=
NULL) {
591 "Thread did not really suspend\n");
595 "Thread did not resume\n");
612 DWORD threadId,exitCode;
622 "TerminateThread didn't work\n");
627 ok(access_thread!=
NULL,
"OpenThread returned an invalid handle\n");
628 if (access_thread!=
NULL) {
636 "TerminateThread didn't work\n");
638 "TerminateThread should not leave the thread 'STILL_ACTIVE'\n");
639 ok(exitCode==99,
"TerminateThread returned invalid exit code\n");
656 DWORD threadId,exitCode;
661 ok(sysInfo.
dwPageSize>0,
"GetSystemInfo should return a valid page size\n");
663 threadFunc5,&exitCode,
666 "TerminateThread didn't work\n");
667 ok(exitCode==1,
"CreateThread did not obey stack-size-limit\n");
675 HANDLE curthread,access_thread;
676 DWORD curthreadId,exitCode;
677 int min_priority=-2,max_priority=2;
690 "GetThreadPriority Failed\n");
697 ok(access_thread!=
NULL,
"OpenThread returned an invalid handle\n");
698 if (access_thread!=
NULL) {
702 ok(
CloseHandle(access_thread),
"Error Closing thread handle\n");
705#if USE_EXTENDED_PRIORITIES
706 min_priority=-7; max_priority=6;
708 for(
i=min_priority;
i<=max_priority;
i++) {
710 "SetThreadPriority Failed for priority: %d\n",
i);
712 "GetThreadPriority Failed for priority: %d\n",
i);
715 "SetThreadPriority Failed\n");
717 "GetThreadPriority Failed\n");
719 "SetThreadPriority Failed\n");
721 "GetThreadPriority Failed\n");
730 ok(rc ==
FALSE,
"SetThreadPriority passed with a bad argument\n");
733 "SetThreadPriority error %d, expected ERROR_INVALID_PARAMETER or ERROR_INVALID_PRIORITY\n",
736 "GetThreadPriority didn't return min_priority\n");
742 ok(rc ==
FALSE,
"SetThreadPriority passed with a bad argument\n");
745 "SetThreadPriority error %d, expected ERROR_INVALID_PARAMETER or ERROR_INVALID_PRIORITY\n",
748 "GetThreadPriority didn't return max_priority\n");
751 if (!pGetThreadPriorityBoost || !pSetThreadPriorityBoost)
755 rc=pGetThreadPriorityBoost(curthread,&disabled);
758 win_skip(
"GetThreadPriorityBoost is not implemented on WinME\n");
769 ok(access_thread!=
NULL,
"OpenThread returned an invalid handle\n");
770 if (access_thread!=
NULL) {
773 ok(
CloseHandle(access_thread),
"Error Closing thread handle\n");
777 rc = pSetThreadPriorityBoost(curthread,1);
780 rc=pGetThreadPriorityBoost(curthread,&disabled);
781 ok(rc!=0 && disabled==1,
782 "rc=%d error=%d disabled=%d\n",rc,
GetLastError(),disabled);
785 rc = pSetThreadPriorityBoost(curthread,0);
787 rc=pGetThreadPriorityBoost(curthread,&disabled);
788 ok(rc!=0 && disabled==0,
789 "rc=%d error=%d disabled=%d\n",rc,
GetLastError(),disabled);
796 FILETIME creationTime,exitTime,kernelTime,userTime;
809 "OpenThread returned an invalid handle\n");
813 "ResumeThread didn't work\n");
820 &kernelTime,&userTime);
823 win_skip(
"GetThreadTimes is not implemented\n");
825 ok(
error!=0,
"GetThreadTimes failed\n");
827 "creationTime was invalid\n");
829 "exitTime was invalid\n");
831 "kernelTimewas invalid\n");
833 "userTime was invalid\n");
835 if(access_thread!=
NULL)
838 &kernelTime,&userTime);
842 if(access_thread!=
NULL) {
853 DWORD_PTR processMask,systemMask,retMask;
863 "GetSystemInfo failed to return a valid # of processors\n");
866 ok(curthread!=
NULL,
"GetCurrentThread failed\n");
868 ok(curproc!=
NULL,
"GetCurrentProcess failed\n");
871 "GetProcessAffinityMask failed\n");
873 "SetThreadAffinityMask failed\n");
875 "SetThreadAffinityMask passed for an illegal processor\n");
878 ok(
broken(retMask==0) || retMask==processMask,
879 "SetThreadAffinityMask(thread,-1) failed to request all processors.\n");
881 if (retMask == processMask)
893 ok(retMask == processMask,
"SetThreadAffinityMask failed\n");
895 ok(retMask == processMask,
"SetThreadAffinityMask failed\n");
898 if (pSetThreadIdealProcessor)
901 error=pSetThreadIdealProcessor(curthread,0);
904 ok(
error!=-1,
"SetThreadIdealProcessor failed\n");
914 error=pSetThreadIdealProcessor(curthread,65);
915 ok(
error==-1,
"SetThreadIdealProcessor succeeded with an illegal processor #\n");
917 "Expected ERROR_INVALID_PARAMETER, got %d\n",
GetLastError());
923 ok(
error==-1,
"SetThreadIdealProcessor succeeded with an illegal processor #\n");
925 "Expected ERROR_INVALID_PARAMETER, got %d\n",
GetLastError());
929 ok(
error!=-1,
"SetThreadIdealProcessor failed\n");
932 win_skip(
"SetThreadIdealProcessor is not implemented\n");
935 if (pGetThreadGroupAffinity && pSetThreadGroupAffinity)
941 ok(pGetThreadGroupAffinity(curthread, &
affinity),
"GetThreadGroupAffinity failed\n");
944 ok(!pGetThreadGroupAffinity(curthread,
NULL),
"GetThreadGroupAffinity succeeded\n");
946 "Expected ERROR_INVALID_PARAMETER, got %d\n",
GetLastError());
949 memset(&affinity_new, 0,
sizeof(affinity_new));
950 affinity_new.
Group = 0;
952 ok(pSetThreadGroupAffinity(curthread, &affinity_new, &
affinity),
"SetThreadGroupAffinity failed\n");
953 ok(affinity_new.
Mask ==
affinity.Mask,
"Expected old affinity mask %lx, got %lx\n",
957 affinity_new.
Group = 0;
958 affinity_new.
Mask = ~0
u;
960 ok(!pSetThreadGroupAffinity(curthread, &affinity_new,
NULL),
"SetThreadGroupAffinity succeeded\n");
962 "Expected ERROR_INVALID_PARAMETER, got %d\n",
GetLastError());
964 affinity_new.
Group = 1;
965 affinity_new.
Mask = 0x1;
967 ok(!pSetThreadGroupAffinity(curthread, &affinity_new,
NULL),
"SetThreadGroupAffinity succeeded\n");
969 "Expected ERROR_INVALID_PARAMETER, got %d\n",
GetLastError());
972 ok(!pSetThreadGroupAffinity(curthread,
NULL,
NULL),
"SetThreadGroupAffinity succeeded\n");
979 "Expected STATUS_ACCESS_VIOLATION, got %08x\n",
status);
982 affinity_new.
Group = 0;
985 ok(pSetThreadGroupAffinity(curthread, &affinity_new, &
affinity),
"SetThreadGroupAffinity failed\n");
986 ok(affinity_new.
Mask ==
affinity.Mask,
"Expected old affinity mask %lx, got %lx\n",
990 win_skip(
"Get/SetThreadGroupAffinity not available\n");
995 DWORD exitCode, threadid;
1000 ok(
ret==0,
"GetExitCodeThread returned non zero value: %d\n",
ret);
1009 "GetExitCodeThread returned %d (expected 1 or %d)\n",
ret, exitCode);
1010 ok(exitCode==99,
"threadFunc2 exited with code %d (expected 99)\n", exitCode);
1019static void WINAPI set_test_val(
int val )
1033static void test_SetThreadContext(
void)
1048 trace(
"Thread creation failed, skipping rest of test\n");
1066 ctx.Esp -= 2 *
sizeof(
int *);
1075 ok ( prevcount == 1,
"Previous suspend count (%d) instead of 1, last error : (%d)\n",
1087 "got %d with %u (expected FALSE with ERROR_GEN_FAILURE or ERROR_ACCESS_DENIED)\n",
1095 "got %d with %u (expected FALSE with ERROR_GEN_FAILURE or ERROR_ACCESS_DENIED)\n",
1101static void test_GetThreadSelectorEntry(
void)
1113 ok(!
HIWORD(
ctx.SegCs),
"expected HIWORD(SegCs) == 0, got %u\n",
ctx.SegCs);
1114 ok(!
HIWORD(
ctx.SegDs),
"expected HIWORD(SegDs) == 0, got %u\n",
ctx.SegDs);
1115 ok(!
HIWORD(
ctx.SegFs),
"expected HIWORD(SegFs) == 0, got %u\n",
ctx.SegFs);
1125 entry.HighWord.Bits.Type &= ~1;
1127 base = (
void *)((
entry.HighWord.Bits.BaseHi << 24) | (
entry.HighWord.Bits.BaseMid << 16) |
entry.BaseLow);
1131 ok(
limit == 0x0fff ||
limit == 0x4000,
"expected 0x0fff or 0x4000, got %#x\n",
limit);
1132 ok(
entry.HighWord.Bits.Type == 0x12,
"expected 0x12, got %#x\n",
entry.HighWord.Bits.Type);
1133 ok(
entry.HighWord.Bits.Dpl == 3,
"expected 3, got %u\n",
entry.HighWord.Bits.Dpl);
1134 ok(
entry.HighWord.Bits.Pres == 1,
"expected 1, got %u\n",
entry.HighWord.Bits.Pres);
1135 ok(
entry.HighWord.Bits.Sys == 0,
"expected 0, got %u\n",
entry.HighWord.Bits.Sys);
1136 ok(
entry.HighWord.Bits.Reserved_0 == 0,
"expected 0, got %u\n",
entry.HighWord.Bits.Reserved_0);
1137 ok(
entry.HighWord.Bits.Default_Big == 1,
"expected 1, got %u\n",
entry.HighWord.Bits.Default_Big);
1138 ok(
entry.HighWord.Bits.Granularity == 0,
"expected 0, got %u\n",
entry.HighWord.Bits.Granularity);
1141static void test_NtSetLdtEntries(
void)
1153 if (!pNtSetLdtEntries)
1155 win_skip(
"NtSetLdtEntries is not available on this platform\n");
1161 win_skip(
"NtSetLdtEntries is not implemented on this platform\n");
1165 ret = pNtSetLdtEntries(0, 0, 0, 0, 0, 0);
1166 ok(!
ret,
"NtSetLdtEntries failed: %08x\n",
ret);
1170 ok(
ret,
"GetThreadContext failed\n");
1174 ok(!
ret,
"NtQueryInformationThread failed: %08x\n",
ret);
1175 ds_entry = tdi.
Entry;
1186 ok(!
ret,
"GetThreadSelectorEntry should fail\n");
1189 ok(!
ret,
"GetThreadSelectorEntry should fail\n");
1191 memset(&sel.entry, 0x9a,
sizeof(sel.entry));
1193 ok(
ret,
"GetThreadSelectorEntry failed\n");
1194 ok(!
memcmp(&ds_entry, &sel.entry,
sizeof(ds_entry)),
"entries do not match\n");
1196 ret = pNtSetLdtEntries(0x000f, sel.dw[0], sel.dw[1], 0x001f, sel.dw[0], sel.dw[1]);
1201 memset(&sel.entry, 0x9a,
sizeof(sel.entry));
1203 ok(
ret,
"GetThreadSelectorEntry failed\n");
1204 ok(!
memcmp(&ds_entry, &sel.entry,
sizeof(ds_entry)),
"entries do not match\n");
1206 memset(&sel.entry, 0x9a,
sizeof(sel.entry));
1208 ok(
ret,
"GetThreadSelectorEntry failed\n");
1209 ok(!
memcmp(&ds_entry, &sel.entry,
sizeof(ds_entry)),
"entries do not match\n");
1222 if (executed == 100)
1234 if (!pQueueUserWorkItem)
return;
1240 for (
i = 0;
i < 100;
i++)
1250 ok(wait_result ==
WAIT_OBJECT_0,
"wait failed with error 0x%x\n", wait_result);
1259 ok(!TimerOrWaitFired,
"wait shouldn't have timed out\n");
1266 ok(TimerOrWaitFired,
"wait should have timed out\n");
1276 if (!pRegisterWaitForSingleObject || !pUnregisterWait)
1278 win_skip(
"RegisterWaitForSingleObject or UnregisterWait not implemented\n");
1294 ret = pUnregisterWait(wait_handle);
1304 ret = pUnregisterWait(wait_handle);
1316 ret = pUnregisterWait(wait_handle);
1321 ok(!
ret,
"Expected UnregisterWait to fail\n");
1323 "Expected ERROR_INVALID_HANDLE, got %d\n",
GetLastError());
1351 return pFlsAlloc(
NULL);
1401 ok(
val ==
NULL,
"Slot not initialized correctly\n");
1406 ok(
val ==
NULL,
"Slot not initialized correctly\n");
1415 ok(
val ==
NULL,
"Slot not initialized correctly\n");
1420 ok(
val ==
NULL,
"Slot not initialized correctly\n");
1431 ok(
val == (
LPVOID) 1,
"Slot not initialized correctly\n");
1436 ok(
val == (
LPVOID) 2,
"Slot not initialized correctly\n");
1444 ok(
val ==
NULL,
"Slot not initialized correctly\n");
1448 ok(
val ==
NULL,
"Slot not initialized correctly\n");
1458 ok(
val == (
LPVOID) 3,
"Slot not initialized correctly\n");
1462 ok(
val == (
LPVOID) 4,
"Slot not initialized correctly\n");
1473 ok(
val == (
LPVOID) 1,
"Slot not initialized correctly\n");
1477 ok(
val == (
LPVOID) 2,
"Slot not initialized correctly\n");
1515 for (
i = 0;
i < 2; ++
i)
1526 for (
i = 0;
i < 2; ++
i)
1553 if (!pFlsAlloc || !pFlsFree || !pFlsGetValue || !pFlsSetValue)
1555 win_skip(
"Fiber Local Storage not supported\n");
1562 LS_GetValueFunc = pFlsGetValue;
1563 LS_SetValueFunc = pFlsSetValue;
1564 LS_FreeFunc = pFlsFree;
1581 if (!pSetThreadErrorMode || !pGetThreadErrorMode)
1583 win_skip(
"SetThreadErrorMode and/or GetThreadErrorMode unavailable (added in Windows 7)\n");
1587 if (!pRtlGetThreadErrorMode) {
1588 win_skip(
"RtlGetThreadErrorMode not available\n");
1592 oldmode = pGetThreadErrorMode();
1594 ret = pSetThreadErrorMode(0, &
mode);
1595 ok(
ret,
"SetThreadErrorMode failed\n");
1597 "SetThreadErrorMode returned old mode 0x%x, expected 0x%x\n",
1599 mode = pGetThreadErrorMode();
1600 ok(
mode == 0,
"GetThreadErrorMode returned mode 0x%x, expected 0\n",
mode);
1601 rtlmode = pRtlGetThreadErrorMode();
1603 "RtlGetThreadErrorMode returned mode 0x%x, expected 0\n",
mode);
1606 ok(
ret,
"SetThreadErrorMode failed\n");
1608 "SetThreadErrorMode returned old mode 0x%x, expected 0\n",
mode);
1609 mode = pGetThreadErrorMode();
1611 "GetThreadErrorMode returned mode 0x%x, expected SEM_FAILCRITICALERRORS\n",
1613 rtlmode = pRtlGetThreadErrorMode();
1615 "RtlGetThreadErrorMode returned mode 0x%x, expected 0x10\n",
mode);
1618 ok(
ret,
"SetThreadErrorMode failed\n");
1620 "SetThreadErrorMode returned old mode 0x%x, expected SEM_FAILCRITICALERRORS\n",
1622 mode = pGetThreadErrorMode();
1624 "GetThreadErrorMode returned mode 0x%x, expected SEM_NOGPFAULTERRORBOX\n",
1626 rtlmode = pRtlGetThreadErrorMode();
1628 "RtlGetThreadErrorMode returned mode 0x%x, expected 0x20\n",
mode);
1631 ok(
ret,
"SetThreadErrorMode failed\n");
1632 mode = pGetThreadErrorMode();
1634 "GetThreadErrorMode returned mode 0x%x, expected SEM_NOOPENFILEERRORBOX\n",
1636 rtlmode = pRtlGetThreadErrorMode();
1638 "RtlGetThreadErrorMode returned mode 0x%x, expected 0x40\n", rtlmode);
1648 "SetThreadErrorMode(0x%x,NULL) failed with error %d\n",
1655 "SetThreadErrorMode(0x%x,NULL) succeeded, expected failure\n",
1658 "SetThreadErrorMode(0x%x,NULL) failed with %d, "
1659 "expected ERROR_INVALID_PARAMETER\n",
1664 pSetThreadErrorMode(oldmode,
NULL);
1667#if (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) || (defined(_MSC_VER) && defined(__i386__))
1668static inline void set_fpu_cw(
WORD cw)
1672 __asm { fldcw [cw] }
1674 __asm__ volatile (
"fnclex; fldcw %0" : :
"m" (cw));
1678static inline WORD get_fpu_cw(
void)
1682 __asm { fnstcw [cw] }
1684 __asm__ volatile (
"fnstcw %0" :
"=m" (cw));
1689struct fpu_thread_ctx
1697 struct fpu_thread_ctx *
ctx =
param;
1700 ctx->cw = get_fpu_cw();
1708static WORD get_thread_fpu_cw(
void)
1710 struct fpu_thread_ctx
ctx;
1715 ok(!!
ctx.finished,
"Failed to create event, last error %#x.\n",
GetLastError());
1730static void test_thread_fpu_cw(
void)
1732 WORD initial_cw, cw;
1734 initial_cw = get_fpu_cw();
1735 ok(initial_cw == 0x27f,
"Expected FPU control word 0x27f, got %#x.\n", initial_cw);
1737 cw = get_thread_fpu_cw();
1738 ok(cw == 0x27f,
"Expected FPU control word 0x27f, got %#x.\n", cw);
1742 ok(cw == 0xf60,
"Expected FPU control word 0xf60, got %#x.\n", cw);
1744 cw = get_thread_fpu_cw();
1745 ok(cw == 0x27f,
"Expected FPU control word 0x27f, got %#x.\n", cw);
1748 ok(cw == 0xf60,
"Expected FPU control word 0xf60, got %#x.\n", cw);
1750 set_fpu_cw(initial_cw);
1752 ok(cw == initial_cw,
"Expected FPU control word %#x, got %#x.\n", initial_cw, cw);
1757"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
1758"<assemblyIdentity version=\"1.2.3.4\" name=\"testdep1\" type=\"win32\" processorArchitecture=\"" ARCH "\"/>"
1759" <file name=\"testdep.dll\" />"
1763"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
1764"<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\" />"
1766" <dependentAssembly>"
1767" <assemblyIdentity type=\"win32\" name=\"testdep1\" version=\"1.2.3.4\" processorArchitecture=\"" ARCH "\" />"
1768" </dependentAssembly>"
1793 actctx.cbSize =
sizeof(ACTCTXW);
1802 ok(
actctx.wProcessorArchitecture == 0,
"wProcessorArchitecture=%d\n",
actctx.wProcessorArchitecture);
1804 ok(
actctx.lpAssemblyDirectory ==
NULL,
"lpAssemblyDirectory=%p\n",
actctx.lpAssemblyDirectory);
1806 ok(
actctx.lpApplicationName ==
NULL,
"lpApplicationName=%p\n",
actctx.lpApplicationName);
1820 if (!pActivateActCtx)
1822 win_skip(
"skipping activation context tests\n");
1833 handle = (
void*)0xdeadbeef;
1834 b = pGetCurrentActCtx(&
handle);
1839 param.thread_context = (
void*)0xdeadbeef;
1846 ok(
param.thread_context ==
NULL,
"got wrong thread context %p\n",
param.thread_context);
1853 b = pGetCurrentActCtx(&
handle);
1855 ok(
handle != 0,
"no active context\n");
1859 b = pGetCurrentActCtx(&
param.handle);
1862 param.thread_context = (
void*)0xdeadbeef;
1869 pReleaseActCtx(
param.thread_context);
1873 param.thread_context = (
void*)0xdeadbeef;
1880 pReleaseActCtx(
param.thread_context);
1883 pReleaseActCtx(
param.handle);
1885 b = pDeactivateActCtx(0,
cookie);
1904 if (!pCreateThreadpool) {
1905 win_skip(
"thread pool apis not supported.\n");
1911 pSubmitThreadpoolWork(work);
1912 pWaitForThreadpoolWorkCallbacks(work,
FALSE);
1913 pCloseThreadpoolWork(work);
1915 ok (workcalled == 1,
"expected work to be called once, got %d\n", workcalled);
1918 ok (
pool !=
NULL,
"CreateThreadpool failed\n");
1919 pCloseThreadpool(
pool);
1929 if(!pIsWow64Process) {
1930 win_skip(
"Skipping reserved TLS slot on too old Windows.\n");
1935 ok(!
val,
"TlsGetValue(0) = %p\n",
val);
1943 ok(!
val,
"TlsGetValue(0) = %p\n",
val);
1955 ok(
val == (
void*)1,
"TlsGetValue(0) = %p\n",
val);
1962 static const ULONG info_size[] =
1989 win_skip(
"OpenThread is not available on this platform\n");
1993 if (!pNtQueryInformationThread)
1995 win_skip(
"NtQueryInformationThread is not available on this platform\n");
2002 win_skip(
"THREAD_QUERY_LIMITED_INFORMATION is not supported on this platform\n");
2006 for (
i = 0;
i <
sizeof(info_size)/
sizeof(info_size[0]);
i++)
2038 "for info %u expected STATUS_SUCCESS, got %08x (ret_len %u)\n",
i,
status,
ret_len);
2071#define X(f) p##f = (void*)GetProcAddress(hKernel32, #f)
2080 X(SetThreadErrorMode);
2081 X(GetThreadErrorMode);
2088 X(CreateThreadpool);
2090 X(CreateThreadpoolWork);
2091 X(SubmitThreadpoolWork);
2092 X(WaitForThreadpoolWorkCallbacks);
2093 X(CloseThreadpoolWork);
2095 X(GetThreadGroupAffinity);
2096 X(SetThreadGroupAffinity);
2104#define X(f) p##f = (void*)GetProcAddress(ntdll, #f)
2142 "Thread did not exit in time\n");
2162 test_SetThreadContext();
2163 test_GetThreadSelectorEntry();
2164 test_NtSetLdtEntries();
2171#if (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) || (defined(_MSC_VER) && defined(__i386__))
2172 test_thread_fpu_cw();
int strcmp(const char *String1, const char *String2)
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
ACPI_SIZE strlen(const char *String)
#define InterlockedIncrement
#define InterlockedDecrement
#define STATUS_NOT_IMPLEMENTED
static HINSTANCE instance
#define ERROR_CALL_NOT_IMPLEMENTED
#define ERROR_INVALID_PARAMETER
struct _THREAD_BASIC_INFORMATION THREAD_BASIC_INFORMATION
#define INVALID_HANDLE_VALUE
@ ThreadDescriptorTableEntry
@ ThreadQuerySetWin32StartAddress
#define GetCurrentProcess()
#define ERROR_NO_MORE_ITEMS
#define ERROR_INVALID_HANDLE
#define FILE_ATTRIBUTE_NORMAL
#define MultiByteToWideChar
#define ERROR_ACCESS_DENIED
static void cleanup(void)
VOID WINAPI ReleaseActCtx(IN HANDLE hActCtx)
BOOL WINAPI DeactivateActCtx(IN DWORD dwFlags, IN ULONG_PTR ulCookie)
BOOL WINAPI GetCurrentActCtx(OUT PHANDLE phActCtx)
BOOL WINAPI ActivateActCtx(IN HANDLE hActCtx, OUT PULONG_PTR ulCookie)
PVOID WINAPI FlsGetValue(DWORD dwFlsIndex)
BOOL WINAPI FlsSetValue(DWORD dwFlsIndex, PVOID lpFlsData)
BOOL WINAPI FlsFree(DWORD dwFlsIndex)
DWORD WINAPI FlsAlloc(PFLS_CALLBACK_FUNCTION lpCallback)
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
BOOL WINAPI DuplicateHandle(IN HANDLE hSourceProcessHandle, IN HANDLE hSourceHandle, IN HANDLE hTargetProcessHandle, OUT LPHANDLE lpTargetHandle, IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwOptions)
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
BOOL WINAPI GetProcessAffinityMask(IN HANDLE hProcess, OUT PDWORD_PTR lpProcessAffinityMask, OUT PDWORD_PTR lpSystemAffinityMask)
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
LPVOID WINAPI TlsGetValue(IN DWORD Index)
DWORD WINAPI ResumeThread(IN HANDLE hThread)
BOOL WINAPI SetThreadPriority(IN HANDLE hThread, IN int nPriority)
HANDLE WINAPI CreateRemoteThread(IN HANDLE hProcess, IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
DWORD_PTR WINAPI SetThreadAffinityMask(IN HANDLE hThread, IN DWORD_PTR dwThreadAffinityMask)
BOOL WINAPI SetThreadContext(IN HANDLE hThread, IN CONST CONTEXT *lpContext)
DWORD WINAPI TlsAlloc(VOID)
DWORD WINAPI SuspendThread(IN HANDLE hThread)
BOOL NTAPI GetThreadTimes(IN HANDLE hThread, OUT LPFILETIME lpCreationTime, OUT LPFILETIME lpExitTime, OUT LPFILETIME lpKernelTime, OUT LPFILETIME lpUserTime)
VOID WINAPI ExitThread(IN DWORD uExitCode)
HANDLE WINAPI OpenThread(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwThreadId)
BOOL WINAPI QueueUserWorkItem(IN LPTHREAD_START_ROUTINE Function, IN PVOID Context, IN ULONG Flags)
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
BOOL WINAPI GetThreadSelectorEntry(IN HANDLE hThread, IN DWORD dwSelector, OUT LPLDT_ENTRY lpSelectorEntry)
DWORD WINAPI SetThreadIdealProcessor(IN HANDLE hThread, IN DWORD dwIdealProcessor)
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
BOOL WINAPI TerminateThread(IN HANDLE hThread, IN DWORD dwExitCode)
BOOL WINAPI TlsFree(IN DWORD Index)
BOOL WINAPI GetThreadPriorityBoost(IN HANDLE hThread, OUT PBOOL pDisablePriorityBoost)
BOOL NTAPI SetThreadPriorityBoost(IN HANDLE hThread, IN BOOL bDisablePriorityBoost)
int WINAPI GetThreadPriority(IN HANDLE hThread)
BOOL WINAPI GetExitCodeThread(IN HANDLE hThread, OUT LPDWORD lpExitCode)
BOOL WINAPI GetThreadContext(IN HANDLE hThread, OUT LPCONTEXT lpContext)
DWORD WINAPI GetTickCount(VOID)
HANDLE WINAPI CreateActCtxW(PCACTCTXW pActCtx)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
#define MAXIMUM_PROCESSORS
GLboolean GLboolean GLboolean b
GLenum GLuint GLenum GLsizei const GLchar * buf
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
#define THREAD_QUERY_INFORMATION
REFIID LPVOID DWORD_PTR dw
NTSYSAPI DWORD WINAPI RtlGetThreadErrorMode(void)
struct _THREAD_DESCRIPTOR_INFORMATION THREAD_DESCRIPTOR_INFORMATION
#define THREAD_SUSPEND_RESUME
int WINAPI lstrlenA(LPCSTR lpString)
_In_ BOOL _In_ HANDLE hProcess
#define sprintf(buf, format,...)
#define THREAD_QUERY_LIMITED_INFORMATION
static void test_create(void)
static JOBOBJECTINFOCLASS LPVOID DWORD LPDWORD ret_len
static HANDLE ULONG_PTR DWORD threads
static const char * LS_SetValueFuncName
static DWORD WINAPI threadFunc1(LPVOID p)
static const char * LS_AllocFuncName
static DWORD CALLBACK work_function(void *p)
static VOID test_GetThreadTimes(void)
static WAITORTIMERCALLBACK
static void test_thread_actctx(void)
static VOID test_CreateThread_stack(void)
static void test_threadpool(void)
static VOID test_SuspendThread(void)
static const char manifest_dep[]
static void create_function_addr_events(HANDLE events[2])
static DWORD WINAPI threadFunc3(LPVOID p)
static const char * LS_FreeFuncName
static void cleanup_thread_sync_helpers(void)
static void CALLBACK timeout_function(PVOID p, BOOLEAN TimerOrWaitFired)
static DWORD WINAPI LS_InheritanceProc(LPVOID p)
static VOID test_CreateThread_basic(void)
static DWORD WINAPI threadFunc_SetEvent(LPVOID p)
static VOID test_CreateThread_suspended(void)
static void test_RegisterWaitForSingleObject(void)
static void create_manifest_file(const char *filename, const char *manifest)
static HANDLE finish_event
static DWORD WINAPI threadFunc_CloseHandle(LPVOID p)
static HANDLE create_target_process(const char *arg)
#define THREAD_ALL_ACCESS_NT4
static VOID test_thread_processor(void)
static VOID test_thread_priority(void)
static VOID test_CreateRemoteThread(void)
static DWORD WINAPI threadFunc4(LPVOID p)
static void test_reserved_tls(void)
static void WINAPI threadpool_workcallback(PTP_CALLBACK_INSTANCE instance, void *context, PTP_WORK work)
static void CALLBACK signaled_function(PVOID p, BOOLEAN TimerOrWaitFired)
static DWORD WINAPI threadFunc2(LPVOID p)
static DWORD WINAPI thread_actctx_func(void *p)
static void resync_after_run(void)
static GROUP_AFFINITY *static const GROUP_AFFINITY GROUP_AFFINITY *static LPCVOID
static void test_FLS(void)
static void run_LS_tests(void)
static HANDLE start_event
static DWORD WINAPI LS_ThreadProc(LPVOID p)
static VOID test_TerminateThread(void)
static BOOL sync_threads_and_run_one(DWORD sync_id, DWORD my_id)
static void init_funcs(void)
static void test_QueueUserWorkItem(void)
static DWORD WINAPI FLS_AllocFuncThunk(void)
static PTP_CALLBACK_ENVIRON
static void init_thread_sync_helpers(void)
static void test_TLS(void)
static LONG times_executed
static void test_thread_info(void)
static void test_ThreadErrorMode(void)
static const char * LS_GetValueFuncName
static VOID test_GetThreadExitCode(void)
static DWORD LS_OutOfIndexesValue
static const char manifest_main[]
static HANDLE complete_event
#define SEM_FAILCRITICALERRORS
#define SEM_NOGPFAULTERRORBOX
#define SEM_NOOPENFILEERRORBOX
#define THREAD_SET_INFORMATION
NTSTATUS NTAPI NtSetLdtEntries(ULONG Selector1, LDT_ENTRY LdtEntry1, ULONG Selector2, LDT_ENTRY LdtEntry2)
NTSTATUS NTAPI NtQueryInformationThread(IN HANDLE ThreadHandle, IN THREADINFOCLASS ThreadInformationClass, OUT PVOID ThreadInformation, IN ULONG ThreadInformationLength, OUT PULONG ReturnLength OPTIONAL)
NTSTATUS NTAPI NtSetInformationThread(IN HANDLE ThreadHandle, IN THREADINFOCLASS ThreadInformationClass, IN PVOID ThreadInformation, IN ULONG ThreadInformationLength)
#define STATUS_INVALID_LDT_DESCRIPTOR
#define STATUS_ACCESS_VIOLATION
#define STATUS_INVALID_INFO_CLASS
__asm__(".p2align 4, 0x90\n" ".seh_proc __seh2_global_filter_func\n" "__seh2_global_filter_func:\n" "\tsub %rbp, %rax\n" "\tpush %rbp\n" "\t.seh_pushreg %rbp\n" "\tsub $32, %rsp\n" "\t.seh_stackalloc 32\n" "\t.seh_endprologue\n" "\tsub %rax, %rdx\n" "\tmov %rdx, %rbp\n" "\tjmp *%r8\n" "__seh2_global_filter_func_exit:\n" "\t.p2align 4\n" "\tadd $32, %rsp\n" "\tpop %rbp\n" "\tret\n" "\t.seh_endproc")
int winetest_get_mainargs(char ***pargv)
DWORD dwNumberOfProcessors
DWORD WINAPI WaitForMultipleObjects(IN DWORD nCount, IN CONST HANDLE *lpHandles, IN BOOL bWaitAll, IN DWORD dwMilliseconds)
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
BOOL WINAPI RegisterWaitForSingleObject(OUT PHANDLE phNewWaitObject, IN HANDLE hObject, IN WAITORTIMERCALLBACK Callback, IN PVOID Context, IN ULONG dwMilliseconds, IN ULONG dwFlags)
BOOL WINAPI UnregisterWait(IN HANDLE WaitHandle)
__inline int before(__u32 seq1, __u32 seq2)
__inline int after(__u32 seq1, __u32 seq2)
union _LARGE_INTEGER LARGE_INTEGER
#define STATUS_ACCESS_DENIED
#define STATUS_UNSUCCESSFUL
static const CHAR manifest[]
DWORD WINAPI GetLastError(void)
HANDLE WINAPI GetCurrentThread(void)
#define FLS_OUT_OF_INDEXES
DWORD WINAPI GetCurrentThreadId(void)
VOID(WINAPI * PFLS_CALLBACK_FUNCTION)(PVOID)
#define TLS_OUT_OF_INDEXES
#define THREAD_PRIORITY_TIME_CRITICAL
DWORD(WINAPI * LPTHREAD_START_ROUTINE)(LPVOID)
#define THREAD_PRIORITY_ERROR_RETURN
#define THREAD_PRIORITY_NORMAL
#define THREAD_PRIORITY_IDLE
#define ERROR_INVALID_PRIORITY
#define ERROR_GEN_FAILURE
struct _TP_CALLBACK_INSTANCE * PTP_CALLBACK_INSTANCE
#define WT_EXECUTEONLYONCE
struct _TP_WORK * PTP_WORK
VOID(NTAPI * PTP_WORK_CALLBACK)(_Inout_ PTP_CALLBACK_INSTANCE Instance, _Inout_opt_ PVOID Context, _Inout_ PTP_WORK Work)
struct _TP_POOL * PTP_POOL
#define WT_EXECUTEDEFAULT
#define DUPLICATE_SAME_ACCESS