Commit 179cd78f authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

kernel32: Implement higher level API to access thread description.

parent b934f662
@ stub GetProcessDefaultCpuSets
@ stub GetProcessInformation
@ stub GetSystemCpuSetInformation
@ stub GetThreadDescription
@ stdcall GetThreadDescription(long ptr) kernel32.GetThreadDescription
@ stub GetThreadSelectedCpuSets
@ stub SetProcessDefaultCpuSets
@ stub SetProcessInformation
......
......@@ -847,6 +847,7 @@
@ stdcall -import GetTempPathA(long ptr)
@ stdcall -import GetTempPathW(long ptr)
@ stdcall -import GetThreadContext(long ptr)
@ stdcall -import GetThreadDescription(long ptr)
@ stdcall -import GetThreadErrorMode()
@ stdcall -import GetThreadGroupAffinity(long ptr)
@ stdcall -import GetThreadIOPendingFlag(long ptr)
......
......@@ -2125,7 +2125,7 @@ static void test_thread_description(void)
if (!pGetThreadDescription)
{
skip("Thread description API is not supported.\n");
win_skip("Thread description API is not supported.\n");
return;
}
......
......@@ -711,7 +711,7 @@
@ stdcall GetTempPathA(long ptr)
@ stdcall GetTempPathW(long ptr)
@ stdcall GetThreadContext(long ptr)
# @ stub GetThreadDescription
@ stdcall GetThreadDescription(long ptr)
@ stdcall GetThreadErrorMode()
@ stdcall GetThreadGroupAffinity(long ptr)
@ stdcall GetThreadIOPendingFlag(long ptr)
......
......@@ -20,6 +20,7 @@
#include <stdarg.h>
#include <string.h>
#include <limits.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
......@@ -33,6 +34,7 @@
#include "wine/exception.h"
#include "wine/asm.h"
#include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(thread);
......@@ -390,12 +392,64 @@ BOOL WINAPI DECLSPEC_HOTPATCH SetThreadContext( HANDLE thread, const CONTEXT *co
/***********************************************************************
* SetThreadDescription (kernelbase.@)
*/
HRESULT WINAPI /* DECLSPEC_HOTPATCH */ SetThreadDescription( HANDLE thread, PCWSTR description )
HRESULT WINAPI DECLSPEC_HOTPATCH SetThreadDescription( HANDLE thread, PCWSTR description )
{
FIXME( "(%p %s): stub\n", thread, debugstr_w( description ));
return E_NOTIMPL;
THREAD_DESCRIPTION_INFORMATION info;
int length;
TRACE( "(%p, %s)\n", thread, debugstr_w( description ));
length = description ? lstrlenW( description ) * sizeof(WCHAR) : 0;
if (length > USHRT_MAX)
return HRESULT_FROM_NT(STATUS_INVALID_PARAMETER);
info.Length = length << 16 | length;
info.Description = (WCHAR *)description;
return HRESULT_FROM_NT(NtSetInformationThread( thread, ThreadDescription, &info, sizeof(info) ));
}
/***********************************************************************
* GetThreadDescription (kernelbase.@)
*/
HRESULT WINAPI DECLSPEC_HOTPATCH GetThreadDescription( HANDLE thread, WCHAR **description )
{
THREAD_DESCRIPTION_INFORMATION *info;
NTSTATUS status;
ULONG length;
TRACE( "(%p, %p)\n", thread, description );
*description = NULL;
length = 0;
status = NtQueryInformationThread( thread, ThreadDescription, NULL, 0, &length );
if (status != STATUS_BUFFER_TOO_SMALL)
return HRESULT_FROM_NT(status);
if (!(info = heap_alloc( length )))
return HRESULT_FROM_NT(STATUS_NO_MEMORY);
status = NtQueryInformationThread( thread, ThreadDescription, info, length, &length );
if (!status)
{
length = info->Length & 0xffff;
if (!(*description = LocalAlloc( 0, length + sizeof(WCHAR))))
status = STATUS_NO_MEMORY;
else
{
if (length)
memcpy(*description, info->Description, length);
(*description)[length / sizeof(WCHAR)] = 0;
}
}
heap_free(info);
return HRESULT_FROM_NT(status);
}
/***********************************************************************
* SetThreadErrorMode (kernelbase.@)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment