Module: wine Branch: master Commit: d203af0fd74a72ffc01e4f3c090d8d285bad7742 URL: https://gitlab.winehq.org/wine/wine/-/commit/d203af0fd74a72ffc01e4f3c090d8d2...
Author: Alexandre Julliard julliard@winehq.org Date: Wed May 24 09:11:48 2023 +0200
kernelbase: Add support for the PROC_THREAD_ATTRIBUTE_MACHINE_TYPE attribute.
---
dlls/kernelbase/process.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/dlls/kernelbase/process.c b/dlls/kernelbase/process.c index 3be5fc22596..54a524abe04 100644 --- a/dlls/kernelbase/process.c +++ b/dlls/kernelbase/process.c @@ -257,13 +257,14 @@ struct _PROC_THREAD_ATTRIBUTE_LIST static NTSTATUS create_nt_process( HANDLE token, HANDLE debug, SECURITY_ATTRIBUTES *psa, SECURITY_ATTRIBUTES *tsa, DWORD process_flags, RTL_USER_PROCESS_PARAMETERS *params, - RTL_USER_PROCESS_INFORMATION *info, HANDLE parent, + RTL_USER_PROCESS_INFORMATION *info, + HANDLE parent, USHORT machine, const struct proc_thread_attr *handle_list, const struct proc_thread_attr *job_list) { OBJECT_ATTRIBUTES process_attr, thread_attr; PS_CREATE_INFO create_info; - ULONG_PTR buffer[offsetof( PS_ATTRIBUTE_LIST, Attributes[8] ) / sizeof(ULONG_PTR)]; + ULONG_PTR buffer[offsetof( PS_ATTRIBUTE_LIST, Attributes[9] ) / sizeof(ULONG_PTR)]; PS_ATTRIBUTE_LIST *attr = (PS_ATTRIBUTE_LIST *)buffer; UNICODE_STRING nameW; NTSTATUS status; @@ -330,6 +331,14 @@ static NTSTATUS create_nt_process( HANDLE token, HANDLE debug, SECURITY_ATTRIBUT attr->Attributes[pos].ReturnLength = NULL; pos++; } + if (machine) + { + attr->Attributes[pos].Attribute = PS_ATTRIBUTE_MACHINE_TYPE; + attr->Attributes[pos].Size = sizeof(machine); + attr->Attributes[pos].Value = machine; + attr->Attributes[pos].ReturnLength = NULL; + pos++; + } attr->TotalLength = offsetof( PS_ATTRIBUTE_LIST, Attributes[pos] );
InitializeObjectAttributes( &process_attr, NULL, 0, NULL, psa ? psa->lpSecurityDescriptor : NULL ); @@ -371,7 +380,7 @@ static NTSTATUS create_vdm_process( HANDLE token, HANDLE debug, SECURITY_ATTRIBU winevdm, params->ImagePathName.Buffer, params->CommandLine.Buffer ); RtlInitUnicodeString( ¶ms->ImagePathName, winevdm ); RtlInitUnicodeString( ¶ms->CommandLine, newcmdline ); - status = create_nt_process( token, debug, psa, tsa, flags, params, info, NULL, NULL, NULL ); + status = create_nt_process( token, debug, psa, tsa, flags, params, info, 0, 0, NULL, NULL ); HeapFree( GetProcessHeap(), 0, newcmdline ); return status; } @@ -400,7 +409,7 @@ static NTSTATUS create_cmd_process( HANDLE token, HANDLE debug, SECURITY_ATTRIBU swprintf( newcmdline, len, L"%s /s/c "%s"", comspec, params->CommandLine.Buffer ); RtlInitUnicodeString( ¶ms->ImagePathName, comspec ); RtlInitUnicodeString( ¶ms->CommandLine, newcmdline ); - status = create_nt_process( token, debug, psa, tsa, flags, params, info, NULL, NULL, NULL ); + status = create_nt_process( token, debug, psa, tsa, flags, params, info, 0, 0, NULL, NULL ); RtlFreeHeap( GetProcessHeap(), 0, newcmdline ); return status; } @@ -510,6 +519,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessInternalW( HANDLE token, const WCHAR RTL_USER_PROCESS_INFORMATION rtl_info; HANDLE parent = 0, debug = 0; ULONG nt_flags = 0; + USHORT machine = 0; NTSTATUS status;
/* Process the AppName and/or CmdLine to get module name and path */ @@ -602,6 +612,10 @@ BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessInternalW( HANDLE token, const WCHAR TRACE( "PROC_THREAD_ATTRIBUTE_JOB_LIST handle count %Iu.\n", attrs->attrs[i].size / sizeof(HANDLE) ); break; + case PROC_THREAD_ATTRIBUTE_MACHINE_TYPE: + machine = *(USHORT *)attrs->attrs[i].value; + TRACE( "PROC_THREAD_ATTRIBUTE_MACHINE %x.\n", machine ); + break; default: FIXME("Unsupported attribute %#Ix.\n", attrs->attrs[i].attr); break; @@ -616,7 +630,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessInternalW( HANDLE token, const WCHAR if (flags & CREATE_SUSPENDED) nt_flags |= PROCESS_CREATE_FLAGS_SUSPENDED;
status = create_nt_process( token, debug, process_attr, thread_attr, - nt_flags, params, &rtl_info, parent, handle_list, job_list ); + nt_flags, params, &rtl_info, parent, machine, handle_list, job_list ); switch (status) { case STATUS_SUCCESS: @@ -1722,6 +1736,9 @@ static inline DWORD validate_proc_thread_attribute( DWORD_PTR attr, SIZE_T size case PROC_THREAD_ATTRIBUTE_JOB_LIST: if ((size / sizeof(HANDLE)) * sizeof(HANDLE) != size) return ERROR_BAD_LENGTH; break; + case PROC_THREAD_ATTRIBUTE_MACHINE_TYPE: + if (size != sizeof(USHORT)) return ERROR_BAD_LENGTH; + break; default: FIXME( "Unhandled attribute %Iu\n", attr & PROC_THREAD_ATTRIBUTE_NUMBER ); return ERROR_NOT_SUPPORTED;