VirtualBox

source: vbox/trunk/src/VBox/Runtime/r3/win/thread-win.cpp@ 106426

Last change on this file since 106426 was 106426, checked in by vboxsync, 4 months ago

Runtime/r3/win/thread*-win.cpp: Build fix for arm64, bugref:10392

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 19.8 KB
Line 
1/* $Id: thread-win.cpp 106426 2024-10-17 10:57:54Z vboxsync $ */
2/** @file
3 * IPRT - Threads, Windows.
4 */
5
6/*
7 * Copyright (C) 2006-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37
38/*********************************************************************************************************************************
39* Header Files *
40*********************************************************************************************************************************/
41#define LOG_GROUP RTLOGGROUP_THREAD
42#include <iprt/nt/nt-and-windows.h>
43
44#ifndef IPRT_NO_CRT
45# include <errno.h>
46# include <process.h>
47#endif
48
49#include <iprt/thread.h>
50#include "internal/iprt.h"
51
52#if defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)
53# include <iprt/asm-amd64-x86.h>
54#elif defined(RT_ARCH_ARM64)
55# include <iprt/asm-arm.h>
56#endif
57#include <iprt/assert.h>
58#include <iprt/cpuset.h>
59#include <iprt/err.h>
60#include <iprt/ldr.h>
61#include <iprt/log.h>
62#include <iprt/mem.h>
63#include <iprt/param.h>
64#include "internal/thread.h"
65#include "internal-r3-win.h"
66
67
68/*********************************************************************************************************************************
69* Structures and Typedefs *
70*********************************************************************************************************************************/
71/** SetThreadDescription */
72typedef HRESULT (WINAPI *PFNSETTHREADDESCRIPTION)(HANDLE hThread, WCHAR *pwszName); /* Since W10 1607 */
73
74/** CoInitializeEx */
75typedef HRESULT (WINAPI *PFNCOINITIALIZEEX)(LPVOID, DWORD);
76/** CoUninitialize */
77typedef void (WINAPI *PFNCOUNINITIALIZE)(void);
78/** OleUninitialize */
79typedef void (WINAPI *PFNOLEUNINITIALIZE)(void);
80
81
82
83/*********************************************************************************************************************************
84* Global Variables *
85*********************************************************************************************************************************/
86/** The TLS index allocated for storing the RTTHREADINT pointer. */
87static DWORD g_dwSelfTLS = TLS_OUT_OF_INDEXES;
88/** Pointer to SetThreadDescription (KERNEL32.DLL) if available. */
89static PFNSETTHREADDESCRIPTION g_pfnSetThreadDescription = NULL;
90
91/** Pointer to CoInitializeEx (OLE32.DLL / combase.dll) if available. */
92static PFNCOINITIALIZEEX volatile g_pfnCoInitializeEx = NULL;
93/** Pointer to CoUninitialize (OLE32.DLL / combase.dll) if available. */
94static PFNCOUNINITIALIZE volatile g_pfnCoUninitialize = NULL;
95/** Pointer to OleUninitialize (OLE32.DLL / combase.dll) if available. */
96static PFNOLEUNINITIALIZE volatile g_pfnOleUninitialize = NULL;
97
98
99/*********************************************************************************************************************************
100* Internal Functions *
101*********************************************************************************************************************************/
102static void rtThreadWinTellDebuggerThreadName(uint32_t idThread, const char *pszName);
103DECLINLINE(void) rtThreadWinSetThreadName(PRTTHREADINT pThread, DWORD idThread);
104
105
106DECLHIDDEN(int) rtThreadNativeInit(void)
107{
108 g_dwSelfTLS = TlsAlloc();
109 if (g_dwSelfTLS == TLS_OUT_OF_INDEXES)
110 return VERR_NO_TLS_FOR_SELF;
111
112 g_pfnSetThreadDescription = (PFNSETTHREADDESCRIPTION)GetProcAddress(g_hModKernel32, "SetThreadDescription");
113 return VINF_SUCCESS;
114}
115
116
117DECLHIDDEN(void) rtThreadNativeReInitObtrusive(void)
118{
119 /* nothing to do here. */
120}
121
122
123DECLHIDDEN(void) rtThreadNativeDetach(void)
124{
125 /*
126 * Deal with alien threads.
127 */
128 PRTTHREADINT pThread = (PRTTHREADINT)TlsGetValue(g_dwSelfTLS);
129 if ( pThread
130 && (pThread->fIntFlags & RTTHREADINT_FLAGS_ALIEN))
131 {
132 rtThreadTerminate(pThread, 0);
133 TlsSetValue(g_dwSelfTLS, NULL);
134 }
135}
136
137
138DECLHIDDEN(void) rtThreadNativeDestroy(PRTTHREADINT pThread)
139{
140 if (pThread == (PRTTHREADINT)TlsGetValue(g_dwSelfTLS))
141 TlsSetValue(g_dwSelfTLS, NULL);
142
143 if ((HANDLE)pThread->hThread != INVALID_HANDLE_VALUE)
144 {
145 CloseHandle((HANDLE)pThread->hThread);
146 pThread->hThread = (uintptr_t)INVALID_HANDLE_VALUE;
147 }
148}
149
150
151DECLHIDDEN(int) rtThreadNativeAdopt(PRTTHREADINT pThread)
152{
153 if (!TlsSetValue(g_dwSelfTLS, pThread))
154 return VERR_FAILED_TO_SET_SELF_TLS;
155 rtThreadWinSetThreadName(pThread, GetCurrentThreadId());
156 return VINF_SUCCESS;
157}
158
159
160DECLHIDDEN(void) rtThreadNativeInformDebugger(PRTTHREADINT pThread)
161{
162 rtThreadWinTellDebuggerThreadName((uint32_t)(uintptr_t)pThread->Core.Key, pThread->szName);
163}
164
165
166/**
167 * Communicates the thread name to the debugger, if we're begin debugged that
168 * is.
169 *
170 * See http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx for debugger
171 * interface details.
172 *
173 * @param idThread The thread ID. UINT32_MAX for current thread.
174 * @param pszName The name.
175 */
176static void rtThreadWinTellDebuggerThreadName(uint32_t idThread, const char *pszName)
177{
178 struct
179 {
180 uint32_t uType;
181 const char *pszName;
182 uint32_t idThread;
183 uint32_t fFlags;
184 } Pkg = { 0x1000, pszName, idThread, 0 };
185 __try
186 {
187 RaiseException(0x406d1388, 0, sizeof(Pkg)/sizeof(ULONG_PTR), (ULONG_PTR *)&Pkg);
188 }
189 __except(EXCEPTION_CONTINUE_EXECUTION)
190 {
191
192 }
193}
194
195
196/**
197 * Sets the thread name as best as we can.
198 */
199DECLINLINE(void) rtThreadWinSetThreadName(PRTTHREADINT pThread, DWORD idThread)
200{
201 if (g_pfnIsDebuggerPresent && g_pfnIsDebuggerPresent())
202 rtThreadWinTellDebuggerThreadName(idThread, &pThread->szName[0]);
203
204 /* The SetThreadDescription API introduced in windows 10 1607 / server 2016
205 allows setting the thread name while the debugger isn't attached. Works
206 with WinDbgX, VisualStudio 2017 v15.6+, and presumeably some recent windbg
207 version. */
208 if (g_pfnSetThreadDescription)
209 {
210 /* The name should be ASCII, so we just need to expand 'char' to 'WCHAR'. */
211 WCHAR wszName[RTTHREAD_NAME_LEN];
212 for (size_t i = 0; i < RTTHREAD_NAME_LEN; i++)
213 wszName[i] = pThread->szName[i];
214
215 HRESULT hrc = g_pfnSetThreadDescription(GetCurrentThread(), wszName);
216 Assert(SUCCEEDED(hrc)); RT_NOREF(hrc);
217 }
218}
219
220
221/**
222 * Bitch about dangling COM and OLE references, dispose of them
223 * afterwards so we don't end up deadlocked somewhere below
224 * OLE32!DllMain.
225 */
226static void rtThreadNativeUninitComAndOle(void)
227{
228#if 1 /* experimental code */
229 /*
230 * Read the counters.
231 */
232 struct MySOleTlsData
233 {
234 void *apvReserved0[2]; /**< x86=0x00 W7/64=0x00 */
235 DWORD adwReserved0[3]; /**< x86=0x08 W7/64=0x10 */
236 void *apvReserved1[1]; /**< x86=0x14 W7/64=0x20 */
237 DWORD cComInits; /**< x86=0x18 W7/64=0x28 */
238 DWORD cOleInits; /**< x86=0x1c W7/64=0x2c */
239 DWORD dwReserved1; /**< x86=0x20 W7/64=0x30 */
240 void *apvReserved2[4]; /**< x86=0x24 W7/64=0x38 */
241 DWORD adwReserved2[1]; /**< x86=0x34 W7/64=0x58 */
242 void *pvCurrentCtx; /**< x86=0x38 W7/64=0x60 */
243 IUnknown *pCallState; /**< x86=0x3c W7/64=0x68 */
244 } *pOleTlsData = NULL; /* outside the try/except for debugging */
245 DWORD cComInits = 0;
246 DWORD cOleInits = 0;
247 __try
248 {
249 void *pvTeb = NtCurrentTeb();
250# if defined(RT_ARCH_AMD64) ||defined(RT_ARCH_ARM64)
251 pOleTlsData = *(struct MySOleTlsData **)((uintptr_t)pvTeb + 0x1758); /*TEB.ReservedForOle*/
252# elif defined(RT_ARCH_X86)
253 pOleTlsData = *(struct MySOleTlsData **)((uintptr_t)pvTeb + 0x0f80); /*TEB.ReservedForOle*/
254# else
255# error "Port me!"
256# endif
257 if (pOleTlsData)
258 {
259 cComInits = pOleTlsData->cComInits;
260 cOleInits = pOleTlsData->cOleInits;
261 }
262 }
263 __except(EXCEPTION_EXECUTE_HANDLER)
264 {
265 AssertFailedReturnVoid();
266 }
267
268 /*
269 * Assert sanity. If any of these breaks, the structure layout above is
270 * probably not correct any longer.
271 */
272 AssertMsgReturnVoid(cComInits < 1000, ("%u (%#x)\n", cComInits, cComInits));
273 AssertMsgReturnVoid(cOleInits < 1000, ("%u (%#x)\n", cOleInits, cOleInits));
274 AssertMsgReturnVoid(cComInits >= cOleInits, ("cComInits=%#x cOleInits=%#x\n", cComInits, cOleInits));
275
276 /*
277 * Do the uninitializing.
278 */
279 if (cComInits)
280 {
281 AssertMsgFailed(("cComInits=%u (%#x) cOleInits=%u (%#x) - dangling COM/OLE inits!\n",
282 cComInits, cComInits, cOleInits, cOleInits));
283
284 PFNOLEUNINITIALIZE pfnOleUninitialize = g_pfnOleUninitialize;
285 PFNCOUNINITIALIZE pfnCoUninitialize = g_pfnCoUninitialize;
286 if (pfnCoUninitialize && pfnOleUninitialize)
287 { /* likely */ }
288 else
289 {
290 HMODULE hOle32 = GetModuleHandle("ole32.dll");
291 AssertReturnVoid(hOle32 != NULL);
292
293 pfnOleUninitialize = (PFNOLEUNINITIALIZE)GetProcAddress(hOle32, "OleUninitialize");
294 AssertReturnVoid(pfnOleUninitialize);
295
296 pfnCoUninitialize = (PFNCOUNINITIALIZE)GetProcAddress(hOle32, "CoUninitialize");
297 AssertReturnVoid(pfnCoUninitialize);
298 }
299
300 while (cOleInits-- > 0)
301 {
302 pfnOleUninitialize();
303 cComInits--;
304 }
305
306 while (cComInits-- > 0)
307 pfnCoUninitialize();
308 }
309#endif
310}
311
312
313/**
314 * Implements the RTTHREADFLAGS_COM_MTA and RTTHREADFLAGS_COM_STA flags.
315 *
316 * @returns true if COM uninitialization should be done, false if not.
317 * @param fFlags The thread flags.
318 */
319static bool rtThreadNativeWinCoInitialize(unsigned fFlags)
320{
321 /*
322 * Resolve the ole32 init and uninit functions dynamically.
323 */
324 PFNCOINITIALIZEEX pfnCoInitializeEx = g_pfnCoInitializeEx;
325 PFNCOUNINITIALIZE pfnCoUninitialize = g_pfnCoUninitialize;
326 if (pfnCoInitializeEx && pfnCoUninitialize)
327 { /* likely */ }
328 else
329 {
330 RTLDRMOD hModOle32 = NIL_RTLDRMOD;
331 int rc = RTLdrLoadSystem("ole32.dll", true /*fNoUnload*/, &hModOle32);
332 AssertRCReturn(rc, false);
333
334 PFNOLEUNINITIALIZE pfnOleUninitialize;
335 pfnOleUninitialize = (PFNOLEUNINITIALIZE)RTLdrGetFunction(hModOle32, "OleUninitialize");
336 pfnCoUninitialize = (PFNCOUNINITIALIZE )RTLdrGetFunction(hModOle32, "CoUninitialize");
337 pfnCoInitializeEx = (PFNCOINITIALIZEEX )RTLdrGetFunction(hModOle32, "CoInitializeEx");
338
339 RTLdrClose(hModOle32);
340 AssertReturn(pfnCoInitializeEx && pfnCoUninitialize, false);
341
342 if (pfnOleUninitialize && !g_pfnOleUninitialize)
343 g_pfnOleUninitialize = pfnOleUninitialize;
344 g_pfnCoInitializeEx = pfnCoInitializeEx;
345 g_pfnCoUninitialize = pfnCoUninitialize;
346 }
347
348 /*
349 * Do the initializating.
350 */
351 DWORD fComInit;
352 if (fFlags & RTTHREADFLAGS_COM_MTA)
353 fComInit = COINIT_MULTITHREADED | COINIT_SPEED_OVER_MEMORY | COINIT_DISABLE_OLE1DDE;
354 else
355 fComInit = COINIT_APARTMENTTHREADED | COINIT_SPEED_OVER_MEMORY;
356 HRESULT hrc = pfnCoInitializeEx(NULL, fComInit);
357 AssertMsg(SUCCEEDED(hrc), ("%Rhrc fComInit=%#x\n", hrc, fComInit));
358 return SUCCEEDED(hrc);
359}
360
361
362/**
363 * Wrapper which unpacks the param stuff and calls thread function.
364 */
365#ifndef IPRT_NO_CRT
366static unsigned __stdcall rtThreadNativeMain(void *pvArgs) RT_NOTHROW_DEF
367#else
368static DWORD __stdcall rtThreadNativeMain(void *pvArgs) RT_NOTHROW_DEF
369#endif
370{
371 DWORD dwThreadId = GetCurrentThreadId();
372 PRTTHREADINT pThread = (PRTTHREADINT)pvArgs;
373
374 if (!TlsSetValue(g_dwSelfTLS, pThread))
375 AssertReleaseMsgFailed(("failed to set self TLS. lasterr=%d thread '%s'\n", GetLastError(), pThread->szName));
376 rtThreadWinSetThreadName(pThread, dwThreadId);
377
378 bool fUninitCom = (pThread->fFlags & (RTTHREADFLAGS_COM_MTA | RTTHREADFLAGS_COM_STA)) != 0;
379 if (fUninitCom)
380 fUninitCom = rtThreadNativeWinCoInitialize(pThread->fFlags);
381
382 int rc = rtThreadMain(pThread, dwThreadId, &pThread->szName[0]);
383
384 TlsSetValue(g_dwSelfTLS, NULL); /* rtThreadMain already released the structure. */
385
386 if (fUninitCom && g_pfnCoUninitialize)
387 g_pfnCoUninitialize();
388
389 rtThreadNativeUninitComAndOle();
390#ifndef IPRT_NO_CRT
391 _endthreadex(rc);
392 return rc; /* not reached */
393#else
394 for (;;)
395 ExitThread(rc);
396#endif
397}
398
399
400DECLHIDDEN(int) rtThreadNativeCreate(PRTTHREADINT pThread, PRTNATIVETHREAD pNativeThread)
401{
402 AssertReturn(pThread->cbStack < ~(unsigned)0, VERR_INVALID_PARAMETER);
403
404 /*
405 * If a stack size is given, make sure it's not a multiple of 64KB so that we
406 * get one or more pages for overflow protection. (ASSUMES 64KB alloc align.)
407 */
408 unsigned cbStack = (unsigned)pThread->cbStack;
409 if (cbStack > 0 && RT_ALIGN_T(cbStack, _64K, unsigned) == cbStack)
410 cbStack += PAGE_SIZE;
411
412 /*
413 * Create the thread.
414 */
415 pThread->hThread = (uintptr_t)INVALID_HANDLE_VALUE;
416#ifndef IPRT_NO_CRT
417 unsigned uThreadId = 0;
418 uintptr_t hThread = _beginthreadex(NULL /*pSecAttrs*/, cbStack, rtThreadNativeMain, pThread, 0 /*fFlags*/, &uThreadId);
419 if (hThread != 0 && hThread != ~0U)
420 {
421 pThread->hThread = hThread;
422 *pNativeThread = uThreadId;
423 return VINF_SUCCESS;
424 }
425 return RTErrConvertFromErrno(errno);
426#else
427 DWORD idThread = 0;
428 HANDLE hThread = CreateThread(NULL /*pSecAttrs*/, cbStack, rtThreadNativeMain, pThread, 0 /*fFlags*/, &idThread);
429 if (hThread != NULL)
430 {
431 pThread->hThread = (uintptr_t)hThread;
432 *pNativeThread = idThread;
433 return VINF_SUCCESS;
434 }
435 return RTErrConvertFromWin32(GetLastError());
436#endif
437}
438
439
440DECLHIDDEN(bool) rtThreadNativeIsAliveKludge(PRTTHREADINT pThread)
441{
442 PPEB_COMMON pPeb = NtCurrentPeb();
443 if (!pPeb || !pPeb->Ldr || !pPeb->Ldr->ShutdownInProgress)
444 return true;
445 DWORD rcWait = WaitForSingleObject((HANDLE)pThread->hThread, 0);
446 return rcWait != WAIT_OBJECT_0;
447}
448
449
450RTDECL(RTTHREAD) RTThreadSelf(void)
451{
452 PRTTHREADINT pThread = (PRTTHREADINT)TlsGetValue(g_dwSelfTLS);
453 /** @todo import alien threads ? */
454 return pThread;
455}
456
457
458#if 0 /* noone is using this ... */
459/**
460 * Returns the processor number the current thread was running on during this call
461 *
462 * @returns processor nr
463 */
464static int rtThreadGetCurrentProcessorNumber(void)
465{
466 static bool fInitialized = false;
467 static DWORD (WINAPI *pfnGetCurrentProcessorNumber)(void) = NULL;
468 if (!fInitialized)
469 {
470 HMODULE hmodKernel32 = GetModuleHandle("kernel32.dll");
471 if (hmodKernel32)
472 pfnGetCurrentProcessorNumber = (DWORD (WINAPI*)(void))GetProcAddress(hmodKernel32, "GetCurrentProcessorNumber");
473 fInitialized = true;
474 }
475 if (pfnGetCurrentProcessorNumber)
476 return pfnGetCurrentProcessorNumber();
477 return -1;
478}
479#endif
480
481
482RTR3DECL(int) RTThreadSetAffinity(PCRTCPUSET pCpuSet)
483{
484 /* The affinity functionality was added in NT 3.50, so we resolve the APIs
485 dynamically to be able to run on NT 3.1. */
486 if (g_pfnSetThreadAffinityMask)
487 {
488 DWORD_PTR fNewMask = pCpuSet ? RTCpuSetToU64(pCpuSet) : ~(DWORD_PTR)0;
489 DWORD_PTR dwRet = g_pfnSetThreadAffinityMask(GetCurrentThread(), fNewMask);
490 if (dwRet)
491 return VINF_SUCCESS;
492
493 int iLastError = GetLastError();
494 AssertMsgFailed(("SetThreadAffinityMask failed, LastError=%d\n", iLastError));
495 return RTErrConvertFromWin32(iLastError);
496 }
497 return VERR_NOT_SUPPORTED;
498}
499
500
501RTR3DECL(int) RTThreadGetAffinity(PRTCPUSET pCpuSet)
502{
503 /* The affinity functionality was added in NT 3.50, so we resolve the APIs
504 dynamically to be able to run on NT 3.1. */
505 if ( g_pfnSetThreadAffinityMask
506 && g_pfnGetProcessAffinityMask)
507 {
508 /*
509 * Haven't found no query api, but the set api returns the old mask, so let's use that.
510 */
511 DWORD_PTR dwIgnored;
512 DWORD_PTR dwProcAff = 0;
513 if (g_pfnGetProcessAffinityMask(GetCurrentProcess(), &dwProcAff, &dwIgnored))
514 {
515 HANDLE hThread = GetCurrentThread();
516 DWORD_PTR dwRet = g_pfnSetThreadAffinityMask(hThread, dwProcAff);
517 if (dwRet)
518 {
519 DWORD_PTR dwSet = g_pfnSetThreadAffinityMask(hThread, dwRet);
520 Assert(dwSet == dwProcAff); NOREF(dwRet);
521
522 RTCpuSetFromU64(pCpuSet, (uint64_t)dwSet);
523 return VINF_SUCCESS;
524 }
525 }
526
527 int iLastError = GetLastError();
528 AssertMsgFailed(("SetThreadAffinityMask or GetProcessAffinityMask failed, LastError=%d\n", iLastError));
529 return RTErrConvertFromWin32(iLastError);
530 }
531 return VERR_NOT_SUPPORTED;
532}
533
534
535RTR3DECL(int) RTThreadGetExecutionTimeMilli(uint64_t *pcMsKernelTime, uint64_t *pcMsUserTime)
536{
537 uint64_t u64CreationTime, u64ExitTime, u64KernelTime, u64UserTime;
538
539 if (GetThreadTimes(GetCurrentThread(), (LPFILETIME)&u64CreationTime, (LPFILETIME)&u64ExitTime, (LPFILETIME)&u64KernelTime, (LPFILETIME)&u64UserTime))
540 {
541 *pcMsKernelTime = u64KernelTime / 10000; /* GetThreadTimes returns time in 100 ns units */
542 *pcMsUserTime = u64UserTime / 10000; /* GetThreadTimes returns time in 100 ns units */
543 return VINF_SUCCESS;
544 }
545
546 DWORD const dwErr = GetLastError();
547 AssertMsgFailed(("GetThreadTimes failed, LastError=%d\n", dwErr));
548 return RTErrConvertFromWin32(dwErr);
549}
550
551
552/**
553 * Gets the native thread handle for a IPRT thread.
554 *
555 * @returns The thread handle. INVALID_HANDLE_VALUE on failure.
556 * @param hThread The IPRT thread handle.
557 *
558 * @note Windows only.
559 * @note Only valid after parent returns from the thread creation call.
560 */
561RTDECL(uintptr_t) RTThreadGetNativeHandle(RTTHREAD hThread)
562{
563 PRTTHREADINT pThread = rtThreadGet(hThread);
564 if (pThread)
565 {
566 uintptr_t hHandle = pThread->hThread;
567 rtThreadRelease(pThread);
568 return hHandle;
569 }
570 return (uintptr_t)INVALID_HANDLE_VALUE;
571}
572RT_EXPORT_SYMBOL(RTThreadGetNativeHandle);
573
574
575RTDECL(int) RTThreadPoke(RTTHREAD hThread)
576{
577 AssertReturn(hThread != RTThreadSelf(), VERR_INVALID_PARAMETER);
578 if (g_pfnNtAlertThread)
579 {
580 PRTTHREADINT pThread = rtThreadGet(hThread);
581 AssertReturn(pThread, VERR_INVALID_HANDLE);
582
583 NTSTATUS rcNt = g_pfnNtAlertThread((HANDLE)pThread->hThread);
584
585 rtThreadRelease(pThread);
586 if (NT_SUCCESS(rcNt))
587 return VINF_SUCCESS;
588 return RTErrConvertFromNtStatus(rcNt);
589 }
590 return VERR_NOT_IMPLEMENTED;
591}
592
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette