Commit d8582d97 authored by Alexandre Julliard's avatar Alexandre Julliard

kernel32: Move process/thread attribute list functions to kernelbase.

parent 09f588ee
......@@ -365,7 +365,7 @@
# @ stub DeleteFileTransactedA
# @ stub DeleteFileTransactedW
@ stdcall DeleteFileW(wstr)
@ stdcall DeleteProcThreadAttributeList(ptr)
@ stdcall -import DeleteProcThreadAttributeList(ptr)
# @ stub DisableThreadProfiling
@ stdcall DisassociateCurrentThreadFromCallback(ptr) ntdll.TpDisassociateCallback
@ stdcall DeleteTimerQueue(long)
......@@ -949,7 +949,7 @@
@ stdcall InitializeCriticalSection(ptr) ntdll.RtlInitializeCriticalSection
@ stdcall -import InitializeCriticalSectionAndSpinCount(ptr long)
@ stdcall -import InitializeCriticalSectionEx(ptr long long)
@ stdcall InitializeProcThreadAttributeList(ptr long long ptr)
@ stdcall -import InitializeProcThreadAttributeList(ptr long long ptr)
@ stdcall InitializeSListHead(ptr) ntdll.RtlInitializeSListHead
@ stdcall InitializeSRWLock(ptr) ntdll.RtlInitializeSRWLock
@ stdcall -arch=i386 InterlockedCompareExchange (ptr long long)
......@@ -1543,7 +1543,7 @@
@ stdcall UnregisterWait(long)
@ stdcall -import UnregisterWaitEx(long long)
# @ stub UpdateCalendarDayOfWeek
@ stdcall UpdateProcThreadAttribute(ptr long long ptr long ptr ptr)
@ stdcall -import UpdateProcThreadAttribute(ptr long long ptr long ptr ptr)
@ stdcall UpdateResourceA(long str str long ptr long)
@ stdcall UpdateResourceW(long wstr wstr long ptr long)
@ stub VDMConsoleOperation
......
......@@ -4113,135 +4113,6 @@ HRESULT WINAPI UnregisterApplicationRestart(void)
return S_OK;
}
struct proc_thread_attr
{
DWORD_PTR attr;
SIZE_T size;
void *value;
};
struct _PROC_THREAD_ATTRIBUTE_LIST
{
DWORD mask; /* bitmask of items in list */
DWORD size; /* max number of items in list */
DWORD count; /* number of items in list */
DWORD pad;
DWORD_PTR unk;
struct proc_thread_attr attrs[1];
};
/***********************************************************************
* InitializeProcThreadAttributeList (KERNEL32.@)
*/
BOOL WINAPI InitializeProcThreadAttributeList(struct _PROC_THREAD_ATTRIBUTE_LIST *list,
DWORD count, DWORD flags, SIZE_T *size)
{
SIZE_T needed;
BOOL ret = FALSE;
TRACE("(%p %d %x %p)\n", list, count, flags, size);
needed = FIELD_OFFSET(struct _PROC_THREAD_ATTRIBUTE_LIST, attrs[count]);
if (list && *size >= needed)
{
list->mask = 0;
list->size = count;
list->count = 0;
list->unk = 0;
ret = TRUE;
}
else
SetLastError(ERROR_INSUFFICIENT_BUFFER);
*size = needed;
return ret;
}
/***********************************************************************
* UpdateProcThreadAttribute (KERNEL32.@)
*/
BOOL WINAPI UpdateProcThreadAttribute(struct _PROC_THREAD_ATTRIBUTE_LIST *list,
DWORD flags, DWORD_PTR attr, void *value, SIZE_T size,
void *prev_ret, SIZE_T *size_ret)
{
DWORD mask;
struct proc_thread_attr *entry;
TRACE("(%p %x %08lx %p %ld %p %p)\n", list, flags, attr, value, size, prev_ret, size_ret);
if (list->count >= list->size)
{
SetLastError(ERROR_GEN_FAILURE);
return FALSE;
}
switch (attr)
{
case PROC_THREAD_ATTRIBUTE_PARENT_PROCESS:
if (size != sizeof(HANDLE))
{
SetLastError(ERROR_BAD_LENGTH);
return FALSE;
}
break;
case PROC_THREAD_ATTRIBUTE_HANDLE_LIST:
if ((size / sizeof(HANDLE)) * sizeof(HANDLE) != size)
{
SetLastError(ERROR_BAD_LENGTH);
return FALSE;
}
break;
case PROC_THREAD_ATTRIBUTE_IDEAL_PROCESSOR:
if (size != sizeof(PROCESSOR_NUMBER))
{
SetLastError(ERROR_BAD_LENGTH);
return FALSE;
}
break;
case PROC_THREAD_ATTRIBUTE_CHILD_PROCESS_POLICY:
if (size != sizeof(DWORD) && size != sizeof(DWORD64))
{
SetLastError(ERROR_BAD_LENGTH);
return FALSE;
}
break;
case PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY:
if (size != sizeof(DWORD) && size != sizeof(DWORD64) && size != sizeof(DWORD64) * 2)
{
SetLastError(ERROR_BAD_LENGTH);
return FALSE;
}
break;
default:
SetLastError(ERROR_NOT_SUPPORTED);
FIXME("Unhandled attribute number %lu\n", attr & PROC_THREAD_ATTRIBUTE_NUMBER);
return FALSE;
}
mask = 1 << (attr & PROC_THREAD_ATTRIBUTE_NUMBER);
if (list->mask & mask)
{
SetLastError(ERROR_OBJECT_NAME_EXISTS);
return FALSE;
}
list->mask |= mask;
entry = list->attrs + list->count;
entry->attr = attr;
entry->size = size;
entry->value = value;
list->count++;
return TRUE;
}
/***********************************************************************
* CreateUmsCompletionList (KERNEL32.@)
*/
......@@ -4263,14 +4134,6 @@ BOOL WINAPI CreateUmsThreadContext(PUMS_CONTEXT *ctx)
}
/***********************************************************************
* DeleteProcThreadAttributeList (KERNEL32.@)
*/
void WINAPI DeleteProcThreadAttributeList(struct _PROC_THREAD_ATTRIBUTE_LIST *list)
{
return;
}
/***********************************************************************
* DeleteUmsCompletionList (KERNEL32.@)
*/
BOOL WINAPI DeleteUmsCompletionList(PUMS_COMPLETION_LIST list)
......
......@@ -252,7 +252,7 @@
@ stdcall DeleteFiber(ptr)
@ stdcall DeleteFileA(str) kernel32.DeleteFileA
@ stdcall DeleteFileW(wstr) kernel32.DeleteFileW
@ stdcall DeleteProcThreadAttributeList(ptr) kernel32.DeleteProcThreadAttributeList
@ stdcall DeleteProcThreadAttributeList(ptr)
# @ stub DeleteStateAtomValue
# @ stub DeleteStateContainer
# @ stub DeleteStateContainerValue
......@@ -805,7 +805,7 @@
@ stdcall InitializeCriticalSectionAndSpinCount(ptr long)
@ stdcall InitializeCriticalSectionEx(ptr long long)
# @ stub InitializeEnclave
@ stdcall InitializeProcThreadAttributeList(ptr long long ptr) kernel32.InitializeProcThreadAttributeList
@ stdcall InitializeProcThreadAttributeList(ptr long long ptr)
# @ stub InitializeProcessForWsWatch
@ stdcall InitializeSListHead(ptr) ntdll.RtlInitializeSListHead
@ stdcall InitializeSRWLock(ptr) ntdll.RtlInitializeSRWLock
......@@ -1627,7 +1627,7 @@
# @ stub UnsubscribeStateChangeNotification
# @ stub UpdatePackageStatus
# @ stub UpdatePackageStatusForUser
@ stdcall UpdateProcThreadAttribute(ptr long long ptr long ptr ptr) kernel32.UpdateProcThreadAttribute
@ stdcall UpdateProcThreadAttribute(ptr long long ptr long ptr ptr)
@ stdcall UrlApplySchemeA(str ptr ptr long)
@ stdcall UrlApplySchemeW(wstr ptr ptr long)
@ stdcall UrlCanonicalizeA(str ptr ptr long)
......
......@@ -344,3 +344,144 @@ BOOL WINAPI DECLSPEC_HOTPATCH TerminateProcess( HANDLE handle, DWORD exit_code )
}
return set_ntstatus( NtTerminateProcess( handle, exit_code ));
}
/***********************************************************************
* Process/thread attribute lists
***********************************************************************/
struct proc_thread_attr
{
DWORD_PTR attr;
SIZE_T size;
void *value;
};
struct _PROC_THREAD_ATTRIBUTE_LIST
{
DWORD mask; /* bitmask of items in list */
DWORD size; /* max number of items in list */
DWORD count; /* number of items in list */
DWORD pad;
DWORD_PTR unk;
struct proc_thread_attr attrs[1];
};
/***********************************************************************
* InitializeProcThreadAttributeList (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH InitializeProcThreadAttributeList( struct _PROC_THREAD_ATTRIBUTE_LIST *list,
DWORD count, DWORD flags, SIZE_T *size )
{
SIZE_T needed;
BOOL ret = FALSE;
TRACE( "(%p %d %x %p)\n", list, count, flags, size );
needed = FIELD_OFFSET( struct _PROC_THREAD_ATTRIBUTE_LIST, attrs[count] );
if (list && *size >= needed)
{
list->mask = 0;
list->size = count;
list->count = 0;
list->unk = 0;
ret = TRUE;
}
else SetLastError( ERROR_INSUFFICIENT_BUFFER );
*size = needed;
return ret;
}
/***********************************************************************
* UpdateProcThreadAttribute (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH UpdateProcThreadAttribute( struct _PROC_THREAD_ATTRIBUTE_LIST *list,
DWORD flags, DWORD_PTR attr, void *value,
SIZE_T size, void *prev_ret, SIZE_T *size_ret )
{
DWORD mask;
struct proc_thread_attr *entry;
TRACE( "(%p %x %08lx %p %ld %p %p)\n", list, flags, attr, value, size, prev_ret, size_ret );
if (list->count >= list->size)
{
SetLastError( ERROR_GEN_FAILURE );
return FALSE;
}
switch (attr)
{
case PROC_THREAD_ATTRIBUTE_PARENT_PROCESS:
if (size != sizeof(HANDLE))
{
SetLastError( ERROR_BAD_LENGTH );
return FALSE;
}
break;
case PROC_THREAD_ATTRIBUTE_HANDLE_LIST:
if ((size / sizeof(HANDLE)) * sizeof(HANDLE) != size)
{
SetLastError( ERROR_BAD_LENGTH );
return FALSE;
}
break;
case PROC_THREAD_ATTRIBUTE_IDEAL_PROCESSOR:
if (size != sizeof(PROCESSOR_NUMBER))
{
SetLastError( ERROR_BAD_LENGTH );
return FALSE;
}
break;
case PROC_THREAD_ATTRIBUTE_CHILD_PROCESS_POLICY:
if (size != sizeof(DWORD) && size != sizeof(DWORD64))
{
SetLastError( ERROR_BAD_LENGTH );
return FALSE;
}
break;
case PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY:
if (size != sizeof(DWORD) && size != sizeof(DWORD64) && size != sizeof(DWORD64) * 2)
{
SetLastError( ERROR_BAD_LENGTH );
return FALSE;
}
break;
default:
SetLastError( ERROR_NOT_SUPPORTED );
FIXME( "Unhandled attribute %lu\n", attr & PROC_THREAD_ATTRIBUTE_NUMBER );
return FALSE;
}
mask = 1 << (attr & PROC_THREAD_ATTRIBUTE_NUMBER);
if (list->mask & mask)
{
SetLastError( ERROR_OBJECT_NAME_EXISTS );
return FALSE;
}
list->mask |= mask;
entry = list->attrs + list->count;
entry->attr = attr;
entry->size = size;
entry->value = value;
list->count++;
return TRUE;
}
/***********************************************************************
* DeleteProcThreadAttributeList (kernelbase.@)
*/
void WINAPI DECLSPEC_HOTPATCH DeleteProcThreadAttributeList( struct _PROC_THREAD_ATTRIBUTE_LIST *list )
{
return;
}
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