Skip to content

Latest commit

 

History

History
98 lines (76 loc) · 5.17 KB

nf-processthreadsapi-tlsalloc.md

File metadata and controls

98 lines (76 loc) · 5.17 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:processthreadsapi.TlsAlloc
TlsAlloc function (processthreadsapi.h)
Allocates a thread local storage (TLS) index. Any thread of the process can subsequently use this index to store and retrieve values that are local to the thread, because each thread receives its own slot for the index.
TlsAlloc
TlsAlloc function
_win32_tlsalloc
base.tlsalloc
processthreadsapi/TlsAlloc
winbase/TlsAlloc
base\tlsalloc.htm
processthreadsapi
cbb3d832-cd92-4875-8366-6b69be7a536f
12/05/2024
TlsAlloc, TlsAlloc function, _win32_tlsalloc, base.tlsalloc, processthreadsapi/TlsAlloc, winbase/TlsAlloc
processthreadsapi.h
Windows.h on Windows Vista, Windows 7, Windows Server 2008 Windows Server 2008 R2
Windows
Windows XP [desktop apps \| UWP apps]
Windows Server 2003 [desktop apps \| UWP apps]
Kernel32.lib; WindowsPhoneCore.lib on Windows Phone 8.1
KernelBase.dll on Windows Phone 8.1; Kernel32.dll
Windows
19H1
TlsAlloc
processthreadsapi/TlsAlloc
c++
APIRef
kbSyntax
DllExport
KernelBase.dll
Kernel32.dll
API-MS-Win-Core-ProcessThreads-l1-1-0.dll
MinKernelBase.dll
API-MS-Win-Core-ProcessThreads-l1-1-1.dll
API-MS-Win-Core-ProcessThreads-l1-1-2.dll
api-ms-win-downlevel-kernel32-l1-1-0.dll
API-MS-Win-Core-ProcessThreads-L1-1-3.dll
vertdll.dll
TlsAlloc

TlsAlloc function

-description

Allocates a thread local storage (TLS) index. Any thread of the process can subsequently use this index to store and retrieve values that are local to the thread, because each thread receives its own slot for the index.

-returns

If the function succeeds, the return value is a TLS index. The slots for the index are initialized to zero.

If the function fails, the return value is TLS_OUT_OF_INDEXES. To get extended error information, call GetLastError.

-remarks

Windows Phone 8.1: This function is supported for Windows Phone Store apps on Windows Phone 8.1 and later. When a Windows Phone Store app calls this function, it is replaced with an inline call to FlsAlloc. Refer to FlsAlloc for function documentation.

Windows 8.1, Windows Server 2012 R2, and Windows 10, version 1507: This function is supported for Windows Store apps on Windows 8.1, Windows Server 2012 R2, and Windows 10, version 1507. When a Windows Store app calls this function, it is replaced with an inline call to FlsAlloc. Refer to FlsAlloc for function documentation.

Windows 10, version 1511 and Windows 10, version 1607: This function is fully supported for Universal Windows Platform (UWP) apps, and is no longer replaced with an inline call to FlsAlloc.

The threads of the process can use the TLS index in subsequent calls to the TlsFree, TlsSetValue, or TlsGetValue functions. The value of the TLS index should be treated as an opaque value; do not assume that it is an index into a zero-based array.

TLS indexes are typically allocated during process or dynamic-link library (DLL) initialization. When a TLS index is allocated, its storage slots are initialized to NULL. After a TLS index has been allocated, each thread of the process can use it to access its own TLS storage slot. To store a value in its TLS slot, a thread specifies the index in a call to TlsSetValue. The thread specifies the same index in a subsequent call to TlsGetValue, to retrieve the stored value.

TLS indexes are not valid across process boundaries. A DLL cannot assume that an index assigned in one process is valid in another process.

Examples

For an example, see Using Thread Local Storage or Using Thread Local Storage in a Dynamic-Link Library.

-see-also

Process and Thread Functions

Thread Local Storage

TlsFree

TlsGetValue

TlsSetValue

Vertdll APIs available in VBS enclaves