user32: Move unpack_message call to User32CallWindowProc.
[wine.git] / dlls / wow64 / process.c
blob82ca4181116894d7d33b1ea0adf49c43a64ee908
1 /*
2 * WoW64 process (and thread) functions
4 * Copyright 2021 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #include "ntstatus.h"
24 #define WIN32_NO_STATUS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winnt.h"
28 #include "winternl.h"
29 #include "wow64_private.h"
30 #include "wine/asm.h"
31 #include "wine/exception.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(wow);
37 static SIZE_T get_machine_context_size( USHORT machine )
39 switch (machine)
41 case IMAGE_FILE_MACHINE_I386: return sizeof(I386_CONTEXT);
42 case IMAGE_FILE_MACHINE_ARMNT: return sizeof(ARM_CONTEXT);
43 case IMAGE_FILE_MACHINE_AMD64: return sizeof(AMD64_CONTEXT);
44 case IMAGE_FILE_MACHINE_ARM64: return sizeof(ARM64_NT_CONTEXT);
45 default: return 0;
50 static BOOL is_process_wow64( HANDLE handle )
52 ULONG_PTR info;
54 if (handle == GetCurrentProcess()) return TRUE;
55 if (NtQueryInformationProcess( handle, ProcessWow64Information, &info, sizeof(info), NULL ))
56 return FALSE;
57 return !!info;
61 static BOOL is_process_id_wow64( const CLIENT_ID *id )
63 HANDLE handle;
64 BOOL ret = FALSE;
66 if (id->UniqueProcess == ULongToHandle(GetCurrentProcessId())) return TRUE;
67 if (!NtOpenProcess( &handle, PROCESS_QUERY_LIMITED_INFORMATION, NULL, id ))
69 ret = is_process_wow64( handle );
70 NtClose( handle );
72 return ret;
76 static EXCEPTION_RECORD *exception_record_32to64( const EXCEPTION_RECORD32 *rec32 )
78 EXCEPTION_RECORD *rec;
79 unsigned int i;
81 rec = Wow64AllocateTemp( sizeof(*rec) );
82 rec->ExceptionCode = rec32->ExceptionCode;
83 rec->ExceptionFlags = rec32->ExceptionFlags;
84 rec->ExceptionRecord = rec32->ExceptionRecord ? exception_record_32to64( ULongToPtr(rec32->ExceptionRecord) ) : NULL;
85 rec->ExceptionAddress = ULongToPtr( rec32->ExceptionAddress );
86 rec->NumberParameters = rec32->NumberParameters;
87 for (i = 0; i < EXCEPTION_MAXIMUM_PARAMETERS; i++)
88 rec->ExceptionInformation[i] = rec32->ExceptionInformation[i];
89 return rec;
93 static RTL_USER_PROCESS_PARAMETERS *process_params_32to64( RTL_USER_PROCESS_PARAMETERS **params,
94 RTL_USER_PROCESS_PARAMETERS32 *params32 )
96 UNICODE_STRING image, dllpath, curdir, cmdline, title, desktop, shell, runtime;
97 RTL_USER_PROCESS_PARAMETERS *ret;
99 *params = NULL;
100 if (RtlCreateProcessParametersEx( &ret, unicode_str_32to64( &image, &params32->ImagePathName ),
101 unicode_str_32to64( &dllpath, &params32->DllPath ),
102 unicode_str_32to64( &curdir, &params32->CurrentDirectory.DosPath ),
103 unicode_str_32to64( &cmdline, &params32->CommandLine ),
104 ULongToPtr( params32->Environment ),
105 unicode_str_32to64( &title, &params32->WindowTitle ),
106 unicode_str_32to64( &desktop, &params32->Desktop ),
107 unicode_str_32to64( &shell, &params32->ShellInfo ),
108 unicode_str_32to64( &runtime, &params32->RuntimeInfo ),
109 PROCESS_PARAMS_FLAG_NORMALIZED ))
110 return NULL;
112 ret->DebugFlags = params32->DebugFlags;
113 ret->ConsoleHandle = LongToHandle( params32->ConsoleHandle );
114 ret->ConsoleFlags = params32->ConsoleFlags;
115 ret->hStdInput = LongToHandle( params32->hStdInput );
116 ret->hStdOutput = LongToHandle( params32->hStdOutput );
117 ret->hStdError = LongToHandle( params32->hStdError );
118 ret->dwX = params32->dwX;
119 ret->dwY = params32->dwY;
120 ret->dwXSize = params32->dwXSize;
121 ret->dwYSize = params32->dwYSize;
122 ret->dwXCountChars = params32->dwXCountChars;
123 ret->dwYCountChars = params32->dwYCountChars;
124 ret->dwFillAttribute = params32->dwFillAttribute;
125 ret->dwFlags = params32->dwFlags;
126 ret->wShowWindow = params32->wShowWindow;
127 ret->EnvironmentVersion = params32->EnvironmentVersion;
128 ret->PackageDependencyData = ULongToPtr( params32->PackageDependencyData );
129 ret->ProcessGroupId = params32->ProcessGroupId;
130 ret->LoaderThreads = params32->LoaderThreads;
131 *params = ret;
132 return ret;
136 static void put_ps_create_info( PS_CREATE_INFO32 *info32, const PS_CREATE_INFO *info )
138 info32->State = info->State;
139 switch (info->State)
141 case PsCreateInitialState:
142 info32->InitState.InitFlags = info->InitState.InitFlags;
143 info32->InitState.AdditionalFileAccess = info->InitState.AdditionalFileAccess;
144 break;
145 case PsCreateFailOnSectionCreate:
146 info32->FailSection.FileHandle = HandleToLong( info->FailSection.FileHandle );
147 break;
148 case PsCreateFailExeFormat:
149 info32->ExeFormat.DllCharacteristics = info->ExeFormat.DllCharacteristics;
150 break;
151 case PsCreateFailExeName:
152 info32->ExeName.IFEOKey = HandleToLong( info->ExeName.IFEOKey );
153 break;
154 case PsCreateSuccess:
155 info32->SuccessState.OutputFlags = info->SuccessState.OutputFlags;
156 info32->SuccessState.FileHandle = HandleToLong( info->SuccessState.FileHandle );
157 info32->SuccessState.SectionHandle = HandleToLong( info->SuccessState.SectionHandle );
158 info32->SuccessState.UserProcessParametersNative = info->SuccessState.UserProcessParametersNative;
159 info32->SuccessState.UserProcessParametersWow64 = info->SuccessState.UserProcessParametersWow64;
160 info32->SuccessState.CurrentParameterFlags = info->SuccessState.CurrentParameterFlags;
161 info32->SuccessState.PebAddressNative = info->SuccessState.PebAddressNative;
162 info32->SuccessState.PebAddressWow64 = info->SuccessState.PebAddressWow64;
163 info32->SuccessState.ManifestAddress = info->SuccessState.ManifestAddress;
164 info32->SuccessState.ManifestSize = info->SuccessState.ManifestSize;
165 break;
166 default:
167 break;
172 static PS_ATTRIBUTE_LIST *ps_attributes_32to64( PS_ATTRIBUTE_LIST **attr, const PS_ATTRIBUTE_LIST32 *attr32 )
174 PS_ATTRIBUTE_LIST *ret;
175 ULONG i, count;
177 if (!attr32) return NULL;
178 count = (attr32->TotalLength - sizeof(attr32->TotalLength)) / sizeof(PS_ATTRIBUTE32);
179 ret = Wow64AllocateTemp( offsetof(PS_ATTRIBUTE_LIST, Attributes[count]) );
180 ret->TotalLength = offsetof( PS_ATTRIBUTE_LIST, Attributes[count] );
181 for (i = 0; i < count; i++)
183 ret->Attributes[i].Attribute = attr32->Attributes[i].Attribute;
184 ret->Attributes[i].Size = attr32->Attributes[i].Size;
185 ret->Attributes[i].Value = attr32->Attributes[i].Value;
186 ret->Attributes[i].ReturnLength = NULL;
187 switch (ret->Attributes[i].Attribute)
189 case PS_ATTRIBUTE_IMAGE_NAME:
191 OBJECT_ATTRIBUTES attr;
192 UNICODE_STRING path;
194 path.Length = ret->Attributes[i].Size;
195 path.Buffer = ret->Attributes[i].ValuePtr;
196 InitializeObjectAttributes( &attr, &path, OBJ_CASE_INSENSITIVE, 0, 0 );
197 if (get_file_redirect( &attr ))
199 ret->Attributes[i].Size = attr.ObjectName->Length;
200 ret->Attributes[i].ValuePtr = attr.ObjectName->Buffer;
203 break;
204 case PS_ATTRIBUTE_HANDLE_LIST:
205 case PS_ATTRIBUTE_JOB_LIST:
207 ULONG j, handles_count = attr32->Attributes[i].Size / sizeof(ULONG);
209 ret->Attributes[i].Size = handles_count * sizeof(HANDLE);
210 ret->Attributes[i].ValuePtr = Wow64AllocateTemp( ret->Attributes[i].Size );
211 for (j = 0; j < handles_count; j++)
212 ((HANDLE *)ret->Attributes[i].ValuePtr)[j] =
213 LongToHandle( ((LONG *)ULongToPtr(attr32->Attributes[i].Value))[j] );
215 break;
216 case PS_ATTRIBUTE_PARENT_PROCESS:
217 ret->Attributes[i].Size = sizeof(HANDLE);
218 ret->Attributes[i].ValuePtr = LongToHandle( attr32->Attributes[i].Value );
219 break;
220 case PS_ATTRIBUTE_CLIENT_ID:
221 ret->Attributes[i].Size = sizeof(CLIENT_ID);
222 ret->Attributes[i].ValuePtr = Wow64AllocateTemp( ret->Attributes[i].Size );
223 break;
224 case PS_ATTRIBUTE_IMAGE_INFO:
225 ret->Attributes[i].Size = sizeof(SECTION_IMAGE_INFORMATION);
226 ret->Attributes[i].ValuePtr = Wow64AllocateTemp( ret->Attributes[i].Size );
227 break;
228 case PS_ATTRIBUTE_TEB_ADDRESS:
229 ret->Attributes[i].Size = sizeof(TEB *);
230 ret->Attributes[i].ValuePtr = Wow64AllocateTemp( ret->Attributes[i].Size );
231 break;
234 *attr = ret;
235 return ret;
239 static void put_ps_attributes( PS_ATTRIBUTE_LIST32 *attr32, const PS_ATTRIBUTE_LIST *attr )
241 ULONG i;
243 if (!attr32) return;
244 for (i = 0; i < (attr32->TotalLength - sizeof(attr32->TotalLength)) / sizeof(PS_ATTRIBUTE32); i++)
246 switch (attr->Attributes[i].Attribute)
248 case PS_ATTRIBUTE_CLIENT_ID:
250 CLIENT_ID32 id32;
251 ULONG size = min( attr32->Attributes[i].Size, sizeof(id32) );
252 put_client_id( &id32, attr->Attributes[i].ValuePtr );
253 memcpy( ULongToPtr( attr32->Attributes[i].Value ), &id32, size );
254 if (attr32->Attributes[i].ReturnLength)
255 *(ULONG *)ULongToPtr(attr32->Attributes[i].ReturnLength) = size;
256 break;
258 case PS_ATTRIBUTE_IMAGE_INFO:
260 SECTION_IMAGE_INFORMATION32 info32;
261 ULONG size = min( attr32->Attributes[i].Size, sizeof(info32) );
262 put_section_image_info( &info32, attr->Attributes[i].ValuePtr );
263 memcpy( ULongToPtr( attr32->Attributes[i].Value ), &info32, size );
264 if (attr32->Attributes[i].ReturnLength)
265 *(ULONG *)ULongToPtr(attr32->Attributes[i].ReturnLength) = size;
266 break;
268 case PS_ATTRIBUTE_TEB_ADDRESS:
270 TEB **teb = attr->Attributes[i].ValuePtr;
271 ULONG teb32 = PtrToUlong( *teb ) + 0x2000;
272 ULONG size = min( attr->Attributes[i].Size, sizeof(teb32) );
273 memcpy( ULongToPtr( attr32->Attributes[i].Value ), &teb32, size );
274 if (attr32->Attributes[i].ReturnLength)
275 *(ULONG *)ULongToPtr(attr32->Attributes[i].ReturnLength) = size;
276 break;
283 void put_vm_counters( VM_COUNTERS_EX32 *info32, const VM_COUNTERS_EX *info, ULONG size )
285 info32->PeakVirtualSize = info->PeakVirtualSize;
286 info32->VirtualSize = info->VirtualSize;
287 info32->PageFaultCount = info->PageFaultCount;
288 info32->PeakWorkingSetSize = info->PeakWorkingSetSize;
289 info32->WorkingSetSize = info->WorkingSetSize;
290 info32->QuotaPeakPagedPoolUsage = info->QuotaPeakPagedPoolUsage;
291 info32->QuotaPagedPoolUsage = info->QuotaPagedPoolUsage;
292 info32->QuotaPeakNonPagedPoolUsage = info->QuotaPeakNonPagedPoolUsage;
293 info32->QuotaNonPagedPoolUsage = info->QuotaNonPagedPoolUsage;
294 info32->PagefileUsage = info->PagefileUsage;
295 info32->PeakPagefileUsage = info->PeakPagefileUsage;
296 if (size == sizeof(VM_COUNTERS_EX32)) info32->PrivateUsage = info->PrivateUsage;
300 static void call_user_exception_dispatcher( EXCEPTION_RECORD32 *rec, void *ctx32_ptr, void *ctx64_ptr )
302 switch (current_machine)
304 case IMAGE_FILE_MACHINE_I386:
306 struct stack_layout
308 ULONG rec_ptr; /* first arg for KiUserExceptionDispatcher */
309 ULONG context_ptr; /* second arg for KiUserExceptionDispatcher */
310 EXCEPTION_RECORD32 rec;
311 I386_CONTEXT context;
312 } *stack;
313 I386_CONTEXT *context, ctx = { CONTEXT_I386_ALL };
314 CONTEXT_EX *context_ex, *src_ex = NULL;
315 ULONG size, flags;
317 NtQueryInformationThread( GetCurrentThread(), ThreadWow64Context, &ctx, sizeof(ctx), NULL );
319 if (ctx32_ptr)
321 I386_CONTEXT *ctx32 = ctx32_ptr;
323 if ((ctx32->ContextFlags & CONTEXT_I386_XSTATE) == CONTEXT_I386_XSTATE)
324 src_ex = (CONTEXT_EX *)(ctx32 + 1);
326 else if (native_machine == IMAGE_FILE_MACHINE_AMD64)
328 AMD64_CONTEXT *ctx64 = ctx64_ptr;
330 if ((ctx64->ContextFlags & CONTEXT_AMD64_FLOATING_POINT) == CONTEXT_AMD64_FLOATING_POINT)
331 memcpy( ctx.ExtendedRegisters, &ctx64->FltSave, sizeof(ctx.ExtendedRegisters) );
332 if ((ctx64->ContextFlags & CONTEXT_AMD64_XSTATE) == CONTEXT_AMD64_XSTATE)
333 src_ex = (CONTEXT_EX *)(ctx64 + 1);
336 flags = ctx.ContextFlags;
337 if (src_ex) flags |= CONTEXT_I386_XSTATE;
338 RtlGetExtendedContextLength( flags, &size );
339 size = ((size + 15) & ~15) + offsetof(struct stack_layout,context);
341 stack = (struct stack_layout *)(ULONG_PTR)(ctx.Esp - size);
342 stack->rec_ptr = PtrToUlong( &stack->rec );
343 stack->rec = *rec;
344 RtlInitializeExtendedContext( &stack->context, flags, &context_ex );
345 context = RtlLocateLegacyContext( context_ex, NULL );
346 *context = ctx;
347 context->ContextFlags = flags;
348 stack->context_ptr = PtrToUlong( context );
350 if (src_ex)
352 XSTATE *src_xs = (XSTATE *)((char *)src_ex + src_ex->XState.Offset);
353 XSTATE *dst_xs = (XSTATE *)((char *)context_ex + context_ex->XState.Offset);
355 dst_xs->Mask = src_xs->Mask & ~(ULONG64)3;
356 dst_xs->CompactionMask = src_xs->CompactionMask;
357 if ((dst_xs->Mask & 4) &&
358 src_ex->XState.Length >= sizeof(XSTATE) &&
359 context_ex->XState.Length >= sizeof(XSTATE))
360 memcpy( &dst_xs->YmmContext, &src_xs->YmmContext, sizeof(dst_xs->YmmContext) );
363 ctx.Esp = PtrToUlong( stack );
364 ctx.Eip = pLdrSystemDllInitBlock->pKiUserExceptionDispatcher;
365 ctx.EFlags &= ~(0x100|0x400|0x40000);
366 NtSetInformationThread( GetCurrentThread(), ThreadWow64Context, &ctx, sizeof(ctx) );
368 TRACE( "exception %08lx dispatcher %08lx stack %08lx eip %08lx\n",
369 rec->ExceptionCode, ctx.Eip, ctx.Esp, stack->context.Eip );
371 break;
373 case IMAGE_FILE_MACHINE_ARMNT:
375 struct stack_layout
377 ARM_CONTEXT context;
378 EXCEPTION_RECORD32 rec;
379 } *stack;
380 ARM_CONTEXT ctx = { CONTEXT_ARM_ALL };
382 NtQueryInformationThread( GetCurrentThread(), ThreadWow64Context, &ctx, sizeof(ctx), NULL );
383 stack = (struct stack_layout *)(ULONG_PTR)(ctx.Sp & ~3) - 1;
384 stack->rec = *rec;
385 stack->context = ctx;
387 ctx.R0 = PtrToUlong( &stack->rec ); /* first arg for KiUserExceptionDispatcher */
388 ctx.R1 = PtrToUlong( &stack->context ); /* second arg for KiUserExceptionDispatcher */
389 ctx.Sp = PtrToUlong( stack );
390 ctx.Pc = pLdrSystemDllInitBlock->pKiUserExceptionDispatcher;
391 if (ctx.Pc & 1) ctx.Cpsr |= 0x20;
392 else ctx.Cpsr &= ~0x20;
393 NtSetInformationThread( GetCurrentThread(), ThreadWow64Context, &ctx, sizeof(ctx) );
395 TRACE( "exception %08lx dispatcher %08lx stack %08lx pc %08lx\n",
396 rec->ExceptionCode, ctx.Pc, ctx.Sp, stack->context.Sp );
398 break;
403 /* based on RtlRaiseException: call NtRaiseException with context setup to return to caller */
404 void WINAPI raise_exception( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL first_chance ) DECLSPEC_HIDDEN;
405 #ifdef __x86_64__
406 __ASM_GLOBAL_FUNC( raise_exception,
407 "sub $0x28,%rsp\n\t"
408 __ASM_SEH(".seh_stackalloc 0x28\n\t")
409 __ASM_SEH(".seh_endprologue\n\t")
410 __ASM_CFI(".cfi_adjust_cfa_offset 0x28\n\t")
411 "movq %rcx,(%rsp)\n\t"
412 "movq %rdx,%rcx\n\t"
413 "call " __ASM_NAME("RtlCaptureContext") "\n\t"
414 "leaq 0x30(%rsp),%rax\n\t" /* orig stack pointer */
415 "movq %rax,0x98(%rdx)\n\t" /* context->Rsp */
416 "movq (%rsp),%rcx\n\t" /* original first parameter */
417 "movq 0x28(%rsp),%rax\n\t" /* return address */
418 "movq %rax,0xf8(%rdx)\n\t" /* context->Rip */
419 "movq %rax,0x10(%rcx)\n\t" /* rec->ExceptionAddress */
420 "call " __ASM_NAME("NtRaiseException") )
421 #elif defined(__aarch64__)
422 __ASM_GLOBAL_FUNC( raise_exception,
423 "stp x29, x30, [sp, #-32]!\n\t"
424 __ASM_SEH(".seh_stackalloc 32\n\t")
425 __ASM_SEH(".seh_save_fplr 0\n\t")
426 __ASM_SEH(".seh_endprologue\n\t")
427 __ASM_CFI(".cfi_def_cfa x29, 32\n\t")
428 __ASM_CFI(".cfi_offset x30, -24\n\t")
429 __ASM_CFI(".cfi_offset x29, -32\n\t")
430 "mov x29, sp\n\t"
431 "stp x0, x1, [sp, #16]\n\t"
432 "mov x0, x1\n\t"
433 "bl " __ASM_NAME("RtlCaptureContext") "\n\t"
434 "ldp x0, x1, [sp, #16]\n\t" /* orig parameters */
435 "ldp x4, x5, [sp]\n\t" /* frame pointer, return address */
436 "stp x4, x5, [x1, #0xf0]\n\t" /* context->Fp, Lr */
437 "add x4, sp, #32\n\t" /* orig stack pointer */
438 "stp x4, x5, [x1, #0x100]\n\t" /* context->Sp, Pc */
439 "str x5, [x0, #0x10]\n\t" /* rec->ExceptionAddress */
440 "bl " __ASM_NAME("NtRaiseException") )
441 #endif
444 /**********************************************************************
445 * wow64_NtAlertResumeThread
447 NTSTATUS WINAPI wow64_NtAlertResumeThread( UINT *args )
449 HANDLE handle = get_handle( &args );
450 ULONG *count = get_ptr( &args );
452 return NtAlertResumeThread( handle, count );
456 /**********************************************************************
457 * wow64_NtAlertThread
459 NTSTATUS WINAPI wow64_NtAlertThread( UINT *args )
461 HANDLE handle = get_handle( &args );
463 return NtAlertThread( handle );
467 /**********************************************************************
468 * wow64_NtAlertThreadByThreadId
470 NTSTATUS WINAPI wow64_NtAlertThreadByThreadId( UINT *args )
472 HANDLE tid = get_handle( &args );
474 return NtAlertThreadByThreadId( tid );
478 /**********************************************************************
479 * wow64_NtAssignProcessToJobObject
481 NTSTATUS WINAPI wow64_NtAssignProcessToJobObject( UINT *args )
483 HANDLE job = get_handle( &args );
484 HANDLE process = get_handle( &args );
486 return NtAssignProcessToJobObject( job, process );
490 /**********************************************************************
491 * wow64_NtContinue
493 NTSTATUS WINAPI wow64_NtContinue( UINT *args )
495 void *context = get_ptr( &args );
496 BOOLEAN alertable = get_ulong( &args );
498 NtSetInformationThread( GetCurrentThread(), ThreadWow64Context,
499 context, get_machine_context_size( current_machine ));
500 if (alertable) NtTestAlert();
501 return STATUS_SUCCESS;
505 /**********************************************************************
506 * wow64_NtCreateThread
508 NTSTATUS WINAPI wow64_NtCreateThread( UINT *args )
510 ULONG *handle_ptr = get_ptr( &args );
511 ACCESS_MASK access = get_ulong( &args );
512 OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args );
513 HANDLE process = get_handle( &args );
514 CLIENT_ID32 *id32 = get_ptr( &args );
515 I386_CONTEXT *context = get_ptr( &args );
516 void *initial_teb = get_ptr( &args );
517 BOOLEAN suspended = get_ulong( &args );
519 FIXME( "%p %lx %p %p %p %p %p %u: stub\n", handle_ptr, access, attr32, process,
520 id32, context, initial_teb, suspended );
521 return STATUS_NOT_IMPLEMENTED;
525 /**********************************************************************
526 * wow64_NtCreateThreadEx
528 NTSTATUS WINAPI wow64_NtCreateThreadEx( UINT *args )
530 ULONG *handle_ptr = get_ptr( &args );
531 ACCESS_MASK access = get_ulong( &args );
532 OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args );
533 HANDLE process = get_handle( &args );
534 PRTL_THREAD_START_ROUTINE start = get_ptr( &args );
535 void *param = get_ptr( &args );
536 ULONG flags = get_ulong( &args );
537 ULONG_PTR zero_bits = get_ulong( &args );
538 SIZE_T stack_commit = get_ulong( &args );
539 SIZE_T stack_reserve = get_ulong( &args );
540 PS_ATTRIBUTE_LIST32 *attr_list32 = get_ptr( &args );
542 struct object_attr64 attr;
543 PS_ATTRIBUTE_LIST *attr_list;
544 HANDLE handle = 0;
545 NTSTATUS status;
547 *handle_ptr = 0;
548 if (is_process_wow64( process ))
550 status = NtCreateThreadEx( &handle, access, objattr_32to64( &attr, attr32 ), process,
551 start, param, flags, get_zero_bits( zero_bits ),
552 stack_commit, stack_reserve,
553 ps_attributes_32to64( &attr_list, attr_list32 ));
554 put_ps_attributes( attr_list32, attr_list );
556 else status = STATUS_ACCESS_DENIED;
558 put_handle( handle_ptr, handle );
559 return status;
563 /**********************************************************************
564 * wow64_NtCreateUserProcess
566 NTSTATUS WINAPI wow64_NtCreateUserProcess( UINT *args )
568 ULONG *process_handle_ptr = get_ptr( &args );
569 ULONG *thread_handle_ptr = get_ptr( &args );
570 ACCESS_MASK process_access = get_ulong( &args );
571 ACCESS_MASK thread_access = get_ulong( &args );
572 OBJECT_ATTRIBUTES32 *process_attr32 = get_ptr( &args );
573 OBJECT_ATTRIBUTES32 *thread_attr32 = get_ptr( &args );
574 ULONG process_flags = get_ulong( &args );
575 ULONG thread_flags = get_ulong( &args );
576 RTL_USER_PROCESS_PARAMETERS32 *params32 = get_ptr( &args );
577 PS_CREATE_INFO32 *info32 = get_ptr( &args );
578 PS_ATTRIBUTE_LIST32 *attr32 = get_ptr( &args );
580 struct object_attr64 process_attr, thread_attr;
581 RTL_USER_PROCESS_PARAMETERS *params;
582 PS_CREATE_INFO info;
583 PS_ATTRIBUTE_LIST *attr;
584 HANDLE process_handle = 0, thread_handle = 0;
586 NTSTATUS status;
588 *process_handle_ptr = *thread_handle_ptr = 0;
589 status = NtCreateUserProcess( &process_handle, &thread_handle, process_access, thread_access,
590 objattr_32to64( &process_attr, process_attr32 ),
591 objattr_32to64( &thread_attr, thread_attr32 ),
592 process_flags, thread_flags,
593 process_params_32to64( &params, params32),
594 &info, ps_attributes_32to64( &attr, attr32 ));
595 put_handle( process_handle_ptr, process_handle );
596 put_handle( thread_handle_ptr, thread_handle );
597 put_ps_create_info( info32, &info );
598 put_ps_attributes( attr32, attr );
599 RtlDestroyProcessParameters( params );
600 return status;
604 /**********************************************************************
605 * wow64_NtDebugActiveProcess
607 NTSTATUS WINAPI wow64_NtDebugActiveProcess( UINT *args )
609 HANDLE process = get_handle( &args );
610 HANDLE debug = get_handle( &args );
612 return NtDebugActiveProcess( process, debug );
616 /**********************************************************************
617 * wow64_NtFlushInstructionCache
619 NTSTATUS WINAPI wow64_NtFlushInstructionCache( UINT *args )
621 HANDLE process = get_handle( &args );
622 const void *addr = get_ptr( &args );
623 SIZE_T size = get_ulong( &args );
625 return NtFlushInstructionCache( process, addr, size );
629 /**********************************************************************
630 * wow64_NtFlushProcessWriteBuffers
632 NTSTATUS WINAPI wow64_NtFlushProcessWriteBuffers( UINT *args )
634 NtFlushProcessWriteBuffers();
635 return STATUS_SUCCESS;
639 /**********************************************************************
640 * wow64_NtGetContextThread
642 NTSTATUS WINAPI wow64_NtGetContextThread( UINT *args )
644 HANDLE handle = get_handle( &args );
645 WOW64_CONTEXT *context = get_ptr( &args );
647 return NtQueryInformationThread( handle, ThreadWow64Context, context,
648 get_machine_context_size( current_machine ), NULL );
652 /**********************************************************************
653 * wow64_NtGetNextThread
655 NTSTATUS WINAPI wow64_NtGetNextThread( UINT *args )
657 HANDLE process = get_handle( &args );
658 HANDLE thread = get_handle( &args );
659 ACCESS_MASK access = get_ulong( &args );
660 ULONG attributes = get_ulong( &args );
661 ULONG flags = get_ulong( &args );
662 ULONG *handle_ptr = get_ptr( &args );
664 HANDLE handle = 0;
665 NTSTATUS status;
667 *handle_ptr = 0;
668 status = NtGetNextThread( process, thread, access, attributes, flags, &handle );
669 put_handle( handle_ptr, handle );
670 return status;
674 /**********************************************************************
675 * wow64_NtIsProcessInJob
677 NTSTATUS WINAPI wow64_NtIsProcessInJob( UINT *args )
679 HANDLE process = get_handle( &args );
680 HANDLE job = get_handle( &args );
682 return NtIsProcessInJob( process, job );
686 /**********************************************************************
687 * wow64_NtOpenProcess
689 NTSTATUS WINAPI wow64_NtOpenProcess( UINT *args )
691 ULONG *handle_ptr = get_ptr( &args );
692 ACCESS_MASK access = get_ulong( &args );
693 OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args );
694 CLIENT_ID32 *id32 = get_ptr( &args );
696 struct object_attr64 attr;
697 HANDLE handle = 0;
698 CLIENT_ID id;
699 NTSTATUS status;
701 *handle_ptr = 0;
702 status = NtOpenProcess( &handle, access, objattr_32to64( &attr, attr32 ), client_id_32to64( &id, id32 ));
703 put_handle( handle_ptr, handle );
704 return status;
708 /**********************************************************************
709 * wow64_NtOpenThread
711 NTSTATUS WINAPI wow64_NtOpenThread( UINT *args )
713 ULONG *handle_ptr = get_ptr( &args );
714 ACCESS_MASK access = get_ulong( &args );
715 OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args );
716 CLIENT_ID32 *id32 = get_ptr( &args );
718 struct object_attr64 attr;
719 HANDLE handle = 0;
720 CLIENT_ID id;
721 NTSTATUS status;
723 *handle_ptr = 0;
724 status = NtOpenThread( &handle, access, objattr_32to64( &attr, attr32 ), client_id_32to64( &id, id32 ));
725 put_handle( handle_ptr, handle );
726 return status;
730 /**********************************************************************
731 * wow64_NtQueryInformationProcess
733 NTSTATUS WINAPI wow64_NtQueryInformationProcess( UINT *args )
735 HANDLE handle = get_handle( &args );
736 PROCESSINFOCLASS class = get_ulong( &args );
737 void *ptr = get_ptr( &args );
738 ULONG len = get_ulong( &args );
739 ULONG *retlen = get_ptr( &args );
741 NTSTATUS status;
743 switch (class)
745 case ProcessBasicInformation: /* PROCESS_BASIC_INFORMATION */
746 if (len == sizeof(PROCESS_BASIC_INFORMATION32))
748 PROCESS_BASIC_INFORMATION info;
749 PROCESS_BASIC_INFORMATION32 *info32 = ptr;
751 if (!(status = NtQueryInformationProcess( handle, class, &info, sizeof(info), NULL )))
753 if (is_process_wow64( handle ))
754 info32->PebBaseAddress = PtrToUlong( info.PebBaseAddress ) + 0x1000;
755 else
756 info32->PebBaseAddress = 0;
757 info32->ExitStatus = info.ExitStatus;
758 info32->AffinityMask = info.AffinityMask;
759 info32->BasePriority = info.BasePriority;
760 info32->UniqueProcessId = info.UniqueProcessId;
761 info32->InheritedFromUniqueProcessId = info.InheritedFromUniqueProcessId;
762 if (retlen) *retlen = sizeof(*info32);
764 return status;
766 if (retlen) *retlen = sizeof(PROCESS_BASIC_INFORMATION32);
767 return STATUS_INFO_LENGTH_MISMATCH;
769 case ProcessIoCounters: /* IO_COUNTERS */
770 case ProcessTimes: /* KERNEL_USER_TIMES */
771 case ProcessDefaultHardErrorMode: /* ULONG */
772 case ProcessPriorityClass: /* PROCESS_PRIORITY_CLASS */
773 case ProcessHandleCount: /* ULONG */
774 case ProcessSessionInformation: /* ULONG */
775 case ProcessDebugFlags: /* ULONG */
776 case ProcessExecuteFlags: /* ULONG */
777 case ProcessCookie: /* ULONG */
778 /* FIXME: check buffer alignment */
779 return NtQueryInformationProcess( handle, class, ptr, len, retlen );
781 case ProcessVmCounters: /* VM_COUNTERS_EX */
782 if (len == sizeof(VM_COUNTERS32) || len == sizeof(VM_COUNTERS_EX32))
784 VM_COUNTERS_EX info;
785 VM_COUNTERS_EX32 *info32 = ptr;
787 if (!(status = NtQueryInformationProcess( handle, class, &info, sizeof(info), NULL )))
789 put_vm_counters( info32, &info, len );
790 if (retlen) *retlen = len;
792 return status;
794 if (retlen) *retlen = sizeof(VM_COUNTERS_EX32);
795 return STATUS_INFO_LENGTH_MISMATCH;
797 case ProcessDebugPort: /* ULONG_PTR */
798 case ProcessAffinityMask: /* ULONG_PTR */
799 case ProcessWow64Information: /* ULONG_PTR */
800 case ProcessDebugObjectHandle: /* HANDLE */
801 if (len == sizeof(ULONG))
803 ULONG_PTR data;
805 if (!(status = NtQueryInformationProcess( handle, class, &data, sizeof(data), NULL )))
807 *(ULONG *)ptr = data;
808 if (retlen) *retlen = sizeof(ULONG);
810 else if (status == STATUS_PORT_NOT_SET) *(ULONG *)ptr = 0;
811 return status;
813 if (retlen) *retlen = sizeof(ULONG);
814 return STATUS_INFO_LENGTH_MISMATCH;
816 case ProcessImageFileName:
817 case ProcessImageFileNameWin32: /* UNICODE_STRING + string */
819 ULONG retsize, size = len + sizeof(UNICODE_STRING) - sizeof(UNICODE_STRING32);
820 UNICODE_STRING *str = Wow64AllocateTemp( size );
821 UNICODE_STRING32 *str32 = ptr;
823 if (!(status = NtQueryInformationProcess( handle, class, str, size, &retsize )))
825 str32->Length = str->Length;
826 str32->MaximumLength = str->MaximumLength;
827 str32->Buffer = PtrToUlong( str32 + 1 );
828 memcpy( str32 + 1, str->Buffer, str->MaximumLength );
830 if (retlen) *retlen = retsize + sizeof(UNICODE_STRING32) - sizeof(UNICODE_STRING);
831 return status;
834 case ProcessImageInformation: /* SECTION_IMAGE_INFORMATION */
835 if (len == sizeof(SECTION_IMAGE_INFORMATION32))
837 SECTION_IMAGE_INFORMATION info;
838 SECTION_IMAGE_INFORMATION32 *info32 = ptr;
840 if (!(status = NtQueryInformationProcess( handle, class, &info, sizeof(info), NULL )))
842 put_section_image_info( info32, &info );
843 if (retlen) *retlen = sizeof(*info32);
845 return status;
847 if (retlen) *retlen = sizeof(SECTION_IMAGE_INFORMATION32);
848 return STATUS_INFO_LENGTH_MISMATCH;
850 default:
851 FIXME( "unsupported class %u\n", class );
852 return STATUS_INVALID_INFO_CLASS;
857 /**********************************************************************
858 * wow64_NtQueryInformationThread
860 NTSTATUS WINAPI wow64_NtQueryInformationThread( UINT *args )
862 HANDLE handle = get_handle( &args );
863 THREADINFOCLASS class = get_ulong( &args );
864 void *ptr = get_ptr( &args );
865 ULONG len = get_ulong( &args );
866 ULONG *retlen = get_ptr( &args );
868 NTSTATUS status;
870 switch (class)
872 case ThreadBasicInformation: /* THREAD_BASIC_INFORMATION */
874 THREAD_BASIC_INFORMATION32 info32;
875 THREAD_BASIC_INFORMATION info;
877 status = NtQueryInformationThread( handle, class, &info, sizeof(info), NULL );
878 if (!status)
880 info32.ExitStatus = info.ExitStatus;
881 info32.TebBaseAddress = is_process_id_wow64( &info.ClientId ) ?
882 PtrToUlong(info.TebBaseAddress) + 0x2000 : 0;
883 info32.ClientId.UniqueProcess = HandleToULong( info.ClientId.UniqueProcess );
884 info32.ClientId.UniqueThread = HandleToULong( info.ClientId.UniqueThread );
885 info32.AffinityMask = info.AffinityMask;
886 info32.Priority = info.Priority;
887 info32.BasePriority = info.BasePriority;
888 memcpy( ptr, &info32, min( len, sizeof(info32) ));
889 if (retlen) *retlen = min( len, sizeof(info32) );
891 return status;
894 case ThreadTimes: /* KERNEL_USER_TIMES */
895 case ThreadEnableAlignmentFaultFixup: /* set only */
896 case ThreadAmILastThread: /* ULONG */
897 case ThreadIsIoPending: /* ULONG */
898 case ThreadHideFromDebugger: /* BOOLEAN */
899 case ThreadSuspendCount: /* ULONG */
900 /* FIXME: check buffer alignment */
901 return NtQueryInformationThread( handle, class, ptr, len, retlen );
903 case ThreadAffinityMask: /* ULONG_PTR */
904 case ThreadQuerySetWin32StartAddress: /* PRTL_THREAD_START_ROUTINE */
906 ULONG_PTR data;
908 status = NtQueryInformationThread( handle, class, &data, sizeof(data), NULL );
909 if (!status)
911 memcpy( ptr, &data, min( len, sizeof(ULONG) ));
912 if (retlen) *retlen = min( len, sizeof(ULONG) );
914 return status;
917 case ThreadDescriptorTableEntry: /* THREAD_DESCRIPTOR_INFORMATION */
918 return RtlWow64GetThreadSelectorEntry( handle, ptr, len, retlen );
920 case ThreadWow64Context: /* WOW64_CONTEXT* */
921 return STATUS_INVALID_INFO_CLASS;
923 case ThreadGroupInformation: /* GROUP_AFFINITY */
925 GROUP_AFFINITY info;
927 status = NtQueryInformationThread( handle, class, &info, sizeof(info), NULL );
928 if (!status)
930 GROUP_AFFINITY32 info32 = { info.Mask, info.Group };
931 memcpy( ptr, &info32, min( len, sizeof(info32) ));
932 if (retlen) *retlen = min( len, sizeof(info32) );
934 return status;
937 case ThreadNameInformation: /* THREAD_NAME_INFORMATION */
939 THREAD_NAME_INFORMATION *info;
940 THREAD_NAME_INFORMATION32 *info32 = ptr;
941 ULONG size, ret_size;
943 if (len >= sizeof(*info32))
945 size = sizeof(*info) + len - sizeof(*info32);
946 info = Wow64AllocateTemp( size );
947 status = NtQueryInformationThread( handle, class, info, size, &ret_size );
948 if (!status)
950 info32->ThreadName.Length = info->ThreadName.Length;
951 info32->ThreadName.MaximumLength = info->ThreadName.MaximumLength;
952 info32->ThreadName.Buffer = PtrToUlong( info32 + 1 );
953 memcpy( info32 + 1, info + 1, min( len, info->ThreadName.MaximumLength ));
956 else status = NtQueryInformationThread( handle, class, NULL, 0, &ret_size );
958 if (retlen && (status == STATUS_SUCCESS || status == STATUS_BUFFER_TOO_SMALL))
959 *retlen = sizeof(*info32) + ret_size - sizeof(*info);
960 return status;
963 default:
964 FIXME( "unsupported class %u\n", class );
965 return STATUS_INVALID_INFO_CLASS;
970 /**********************************************************************
971 * wow64_NtQueueApcThread
973 NTSTATUS WINAPI wow64_NtQueueApcThread( UINT *args )
975 HANDLE handle = get_handle( &args );
976 ULONG func = get_ulong( &args );
977 ULONG arg1 = get_ulong( &args );
978 ULONG arg2 = get_ulong( &args );
979 ULONG arg3 = get_ulong( &args );
981 return NtQueueApcThread( handle, apc_32to64( func ),
982 (ULONG_PTR)apc_param_32to64( func, arg1 ), arg2, arg3 );
986 /**********************************************************************
987 * wow64_NtRaiseException
989 NTSTATUS WINAPI wow64_NtRaiseException( UINT *args )
991 EXCEPTION_RECORD32 *rec32 = get_ptr( &args );
992 void *context32 = get_ptr( &args );
993 BOOL first_chance = get_ulong( &args );
995 EXCEPTION_RECORD *rec = exception_record_32to64( rec32 );
996 CONTEXT context;
998 NtSetInformationThread( GetCurrentThread(), ThreadWow64Context,
999 context32, get_machine_context_size( current_machine ));
1001 __TRY
1003 raise_exception( rec, &context, first_chance );
1005 __EXCEPT_ALL
1007 call_user_exception_dispatcher( rec32, context32, &context );
1009 __ENDTRY
1010 return STATUS_SUCCESS;
1014 /**********************************************************************
1015 * wow64_NtRemoveProcessDebug
1017 NTSTATUS WINAPI wow64_NtRemoveProcessDebug( UINT *args )
1019 HANDLE process = get_handle( &args );
1020 HANDLE debug = get_handle( &args );
1022 return NtRemoveProcessDebug( process, debug );
1026 /**********************************************************************
1027 * wow64_NtResumeProcess
1029 NTSTATUS WINAPI wow64_NtResumeProcess( UINT *args )
1031 HANDLE handle = get_handle( &args );
1033 return NtResumeProcess( handle );
1037 /**********************************************************************
1038 * wow64_NtResumeThread
1040 NTSTATUS WINAPI wow64_NtResumeThread( UINT *args )
1042 HANDLE handle = get_handle( &args );
1043 ULONG *count = get_ptr( &args );
1045 return NtResumeThread( handle, count );
1049 /**********************************************************************
1050 * wow64_NtSetContextThread
1052 NTSTATUS WINAPI wow64_NtSetContextThread( UINT *args )
1054 HANDLE handle = get_handle( &args );
1055 WOW64_CONTEXT *context = get_ptr( &args );
1057 return NtSetInformationThread( handle, ThreadWow64Context,
1058 context, get_machine_context_size( current_machine ));
1062 /**********************************************************************
1063 * wow64_NtSetInformationProcess
1065 NTSTATUS WINAPI wow64_NtSetInformationProcess( UINT *args )
1067 HANDLE handle = get_handle( &args );
1068 PROCESSINFOCLASS class = get_ulong( &args );
1069 void *ptr = get_ptr( &args );
1070 ULONG len = get_ulong( &args );
1072 NTSTATUS status;
1074 switch (class)
1076 case ProcessDefaultHardErrorMode: /* ULONG */
1077 case ProcessPriorityClass: /* PROCESS_PRIORITY_CLASS */
1078 return NtSetInformationProcess( handle, class, ptr, len );
1080 case ProcessAffinityMask: /* ULONG_PTR */
1081 if (len == sizeof(ULONG))
1083 ULONG_PTR mask = *(ULONG *)ptr;
1084 return NtSetInformationProcess( handle, class, &mask, sizeof(mask) );
1086 else return STATUS_INVALID_PARAMETER;
1088 case ProcessExecuteFlags: /* ULONG */
1089 return STATUS_ACCESS_DENIED;
1091 case ProcessInstrumentationCallback: /* PROCESS_INSTRUMENTATION_CALLBACK_INFORMATION */
1092 if (len == sizeof(PROCESS_INSTRUMENTATION_CALLBACK_INFORMATION32))
1094 FIXME( "ProcessInstrumentationCallback stub\n" );
1095 return STATUS_SUCCESS;
1097 else return STATUS_INFO_LENGTH_MISMATCH;
1099 case ProcessThreadStackAllocation: /* PROCESS_STACK_ALLOCATION_INFORMATION(_EX) */
1100 if (len == sizeof(PROCESS_STACK_ALLOCATION_INFORMATION_EX32))
1102 PROCESS_STACK_ALLOCATION_INFORMATION_EX32 *stack = ptr;
1103 PROCESS_STACK_ALLOCATION_INFORMATION_EX info;
1105 info.PreferredNode = stack->PreferredNode;
1106 info.Reserved0 = stack->Reserved0;
1107 info.Reserved1 = stack->Reserved1;
1108 info.Reserved2 = stack->Reserved2;
1109 info.AllocInfo.ReserveSize = stack->AllocInfo.ReserveSize;
1110 info.AllocInfo.ZeroBits = get_zero_bits( stack->AllocInfo.ZeroBits );
1111 if (!(status = NtSetInformationProcess( handle, class, &info, sizeof(info) )))
1112 stack->AllocInfo.StackBase = PtrToUlong( info.AllocInfo.StackBase );
1113 return status;
1115 else if (len == sizeof(PROCESS_STACK_ALLOCATION_INFORMATION32))
1117 PROCESS_STACK_ALLOCATION_INFORMATION32 *stack = ptr;
1118 PROCESS_STACK_ALLOCATION_INFORMATION info;
1120 info.ReserveSize = stack->ReserveSize;
1121 info.ZeroBits = stack->ZeroBits ? stack->ZeroBits : 0x7fffffff;
1122 if (!(status = NtSetInformationProcess( handle, class, &info, sizeof(info) )))
1123 stack->StackBase = PtrToUlong( info.StackBase );
1124 return status;
1126 else return STATUS_INFO_LENGTH_MISMATCH;
1128 case ProcessWineMakeProcessSystem: /* HANDLE* */
1129 if (len == sizeof(ULONG))
1131 HANDLE event = 0;
1132 status = NtSetInformationProcess( handle, class, &event, sizeof(HANDLE *) );
1133 put_handle( ptr, event );
1134 return status;
1136 else return STATUS_INFO_LENGTH_MISMATCH;
1138 default:
1139 FIXME( "unsupported class %u\n", class );
1140 return STATUS_INVALID_INFO_CLASS;
1145 /**********************************************************************
1146 * wow64_NtSetInformationThread
1148 NTSTATUS WINAPI wow64_NtSetInformationThread( UINT *args )
1150 HANDLE handle = get_handle( &args );
1151 THREADINFOCLASS class = get_ulong( &args );
1152 void *ptr = get_ptr( &args );
1153 ULONG len = get_ulong( &args );
1155 switch (class)
1157 case ThreadZeroTlsCell: /* ULONG */
1158 case ThreadBasePriority: /* ULONG */
1159 case ThreadHideFromDebugger: /* void */
1160 case ThreadEnableAlignmentFaultFixup: /* BOOLEAN */
1161 return NtSetInformationThread( handle, class, ptr, len );
1163 case ThreadImpersonationToken: /* HANDLE */
1164 if (len == sizeof(ULONG))
1166 HANDLE token = LongToHandle( *(ULONG *)ptr );
1167 return NtSetInformationThread( handle, class, &token, sizeof(token) );
1169 else return STATUS_INVALID_PARAMETER;
1171 case ThreadAffinityMask: /* ULONG_PTR */
1172 case ThreadQuerySetWin32StartAddress: /* PRTL_THREAD_START_ROUTINE */
1173 if (len == sizeof(ULONG))
1175 ULONG_PTR mask = *(ULONG *)ptr;
1176 return NtSetInformationThread( handle, class, &mask, sizeof(mask) );
1178 else return STATUS_INVALID_PARAMETER;
1180 case ThreadWow64Context: /* WOW64_CONTEXT* */
1181 return STATUS_INVALID_INFO_CLASS;
1183 case ThreadGroupInformation: /* GROUP_AFFINITY */
1184 if (len == sizeof(GROUP_AFFINITY32))
1186 GROUP_AFFINITY32 *info32 = ptr;
1187 GROUP_AFFINITY info = { info32->Mask, info32->Group };
1189 return NtSetInformationThread( handle, class, &info, sizeof(info) );
1191 else return STATUS_INVALID_PARAMETER;
1193 case ThreadNameInformation: /* THREAD_NAME_INFORMATION */
1194 if (len == sizeof(THREAD_NAME_INFORMATION32))
1196 THREAD_NAME_INFORMATION32 *info32 = ptr;
1197 THREAD_NAME_INFORMATION info;
1199 if (!unicode_str_32to64( &info.ThreadName, &info32->ThreadName ))
1200 return STATUS_ACCESS_VIOLATION;
1201 return NtSetInformationThread( handle, class, &info, sizeof(info) );
1203 else return STATUS_INFO_LENGTH_MISMATCH;
1205 default:
1206 FIXME( "unsupported class %u\n", class );
1207 return STATUS_INVALID_INFO_CLASS;
1212 /**********************************************************************
1213 * wow64_NtSetThreadExecutionState
1215 NTSTATUS WINAPI wow64_NtSetThreadExecutionState( UINT *args )
1217 EXECUTION_STATE new_state = get_ulong( &args );
1218 EXECUTION_STATE *old_state = get_ptr( &args );
1220 return NtSetThreadExecutionState( new_state, old_state );
1224 /**********************************************************************
1225 * wow64_NtSuspendProcess
1227 NTSTATUS WINAPI wow64_NtSuspendProcess( UINT *args )
1229 HANDLE handle = get_handle( &args );
1231 return NtSuspendProcess( handle );
1235 /**********************************************************************
1236 * wow64_NtSuspendThread
1238 NTSTATUS WINAPI wow64_NtSuspendThread( UINT *args )
1240 HANDLE handle = get_handle( &args );
1241 ULONG *count = get_ptr( &args );
1243 return NtSuspendThread( handle, count );
1247 /**********************************************************************
1248 * wow64_NtTerminateProcess
1250 NTSTATUS WINAPI wow64_NtTerminateProcess( UINT *args )
1252 HANDLE handle = get_handle( &args );
1253 LONG exit_code = get_ulong( &args );
1255 return NtTerminateProcess( handle, exit_code );
1259 /**********************************************************************
1260 * wow64_NtTerminateThread
1262 NTSTATUS WINAPI wow64_NtTerminateThread( UINT *args )
1264 HANDLE handle = get_handle( &args );
1265 LONG exit_code = get_ulong( &args );
1267 return NtTerminateThread( handle, exit_code );
1271 /**********************************************************************
1272 * Wow64PassExceptionToGuest (wow64.@)
1274 void WINAPI Wow64PassExceptionToGuest( EXCEPTION_POINTERS *ptrs )
1276 EXCEPTION_RECORD *rec = ptrs->ExceptionRecord;
1277 EXCEPTION_RECORD32 rec32;
1278 ULONG i;
1280 rec32.ExceptionCode = rec->ExceptionCode;
1281 rec32.ExceptionFlags = rec->ExceptionFlags;
1282 rec32.ExceptionRecord = PtrToUlong( rec->ExceptionRecord );
1283 rec32.ExceptionAddress = PtrToUlong( rec->ExceptionAddress );
1284 rec32.NumberParameters = rec->NumberParameters;
1285 for (i = 0; i < rec->NumberParameters; i++)
1286 rec32.ExceptionInformation[i] = rec->ExceptionInformation[i];
1288 call_user_exception_dispatcher( &rec32, NULL, ptrs->ContextRecord );