libs: Import upstream code from libjpeg 9d.
[wine.git] / dlls / wow64 / sync.c
blobe2e9468a727823dd76350bc6f9afc25f78938267
1 /*
2 * WoW64 synchronization objects and 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/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(wow);
35 static void put_object_type_info( OBJECT_TYPE_INFORMATION32 *info32, const OBJECT_TYPE_INFORMATION *info )
37 if (info->TypeName.Length)
39 memcpy( info32 + 1, info->TypeName.Buffer, info->TypeName.Length + sizeof(WCHAR) );
40 info32->TypeName.Length = info->TypeName.Length;
41 info32->TypeName.MaximumLength = info->TypeName.Length + sizeof(WCHAR);
42 info32->TypeName.Buffer = PtrToUlong( info32 + 1 );
44 else memset( &info32->TypeName, 0, sizeof(info32->TypeName) );
45 info32->TotalNumberOfObjects = info->TotalNumberOfObjects;
46 info32->TotalNumberOfHandles = info->TotalNumberOfHandles;
47 info32->TotalPagedPoolUsage = info->TotalPagedPoolUsage;
48 info32->TotalNonPagedPoolUsage = info->TotalNonPagedPoolUsage;
49 info32->TotalNamePoolUsage = info->TotalNamePoolUsage;
50 info32->TotalHandleTableUsage = info->TotalHandleTableUsage;
51 info32->HighWaterNumberOfObjects = info->HighWaterNumberOfObjects;
52 info32->HighWaterNumberOfHandles = info->HighWaterNumberOfHandles;
53 info32->HighWaterPagedPoolUsage = info->HighWaterPagedPoolUsage;
54 info32->HighWaterNonPagedPoolUsage = info->HighWaterNonPagedPoolUsage;
55 info32->HighWaterNamePoolUsage = info->HighWaterNamePoolUsage;
56 info32->HighWaterHandleTableUsage = info->HighWaterHandleTableUsage;
57 info32->InvalidAttributes = info->InvalidAttributes;
58 info32->GenericMapping = info->GenericMapping;
59 info32->ValidAccessMask = info->ValidAccessMask;
60 info32->SecurityRequired = info->SecurityRequired;
61 info32->MaintainHandleCount = info->MaintainHandleCount;
62 info32->TypeIndex = info->TypeIndex;
63 info32->ReservedByte = info->ReservedByte;
64 info32->PoolType = info->PoolType;
65 info32->DefaultPagedPoolCharge = info->DefaultPagedPoolCharge;
66 info32->DefaultNonPagedPoolCharge = info->DefaultNonPagedPoolCharge;
70 static JOBOBJECT_BASIC_LIMIT_INFORMATION *job_basic_limit_info_32to64( JOBOBJECT_BASIC_LIMIT_INFORMATION *out,
71 const JOBOBJECT_BASIC_LIMIT_INFORMATION32 *in )
73 out->PerProcessUserTimeLimit = in->PerProcessUserTimeLimit;
74 out->PerJobUserTimeLimit = in->PerJobUserTimeLimit;
75 out->LimitFlags = in->LimitFlags;
76 out->MinimumWorkingSetSize = in->MinimumWorkingSetSize;
77 out->MaximumWorkingSetSize = in->MaximumWorkingSetSize;
78 out->ActiveProcessLimit = in->ActiveProcessLimit;
79 out->Affinity = in->Affinity;
80 out->PriorityClass = in->PriorityClass;
81 out->SchedulingClass = in->SchedulingClass;
82 return out;
86 static void put_job_basic_limit_info( JOBOBJECT_BASIC_LIMIT_INFORMATION32 *info32,
87 const JOBOBJECT_BASIC_LIMIT_INFORMATION *info )
89 info32->PerProcessUserTimeLimit = info->PerProcessUserTimeLimit;
90 info32->PerJobUserTimeLimit = info->PerJobUserTimeLimit;
91 info32->LimitFlags = info->LimitFlags;
92 info32->MinimumWorkingSetSize = info->MinimumWorkingSetSize;
93 info32->MaximumWorkingSetSize = info->MaximumWorkingSetSize;
94 info32->ActiveProcessLimit = info->ActiveProcessLimit;
95 info32->Affinity = info->Affinity;
96 info32->PriorityClass = info->PriorityClass;
97 info32->SchedulingClass = info->SchedulingClass;
101 void put_section_image_info( SECTION_IMAGE_INFORMATION32 *info32, const SECTION_IMAGE_INFORMATION *info )
103 if (info->Machine == IMAGE_FILE_MACHINE_AMD64 || info->Machine == IMAGE_FILE_MACHINE_ARM64)
105 info32->TransferAddress = 0x81231234; /* sic */
106 info32->MaximumStackSize = 0x100000;
107 info32->CommittedStackSize = 0x10000;
109 else
111 info32->TransferAddress = PtrToUlong( info->TransferAddress );
112 info32->MaximumStackSize = info->MaximumStackSize;
113 info32->CommittedStackSize = info->CommittedStackSize;
115 info32->ZeroBits = info->ZeroBits;
116 info32->SubSystemType = info->SubSystemType;
117 info32->MinorSubsystemVersion = info->MinorSubsystemVersion;
118 info32->MajorSubsystemVersion = info->MajorSubsystemVersion;
119 info32->MajorOperatingSystemVersion = info->MajorOperatingSystemVersion;
120 info32->MinorOperatingSystemVersion = info->MinorOperatingSystemVersion;
121 info32->ImageCharacteristics = info->ImageCharacteristics;
122 info32->DllCharacteristics = info->DllCharacteristics;
123 info32->Machine = info->Machine;
124 info32->ImageContainsCode = info->ImageContainsCode;
125 info32->ImageFlags = info->ImageFlags;
126 info32->LoaderFlags = info->LoaderFlags;
127 info32->ImageFileSize = info->ImageFileSize;
128 info32->CheckSum = info->CheckSum;
132 /**********************************************************************
133 * wow64_NtAcceptConnectPort
135 NTSTATUS WINAPI wow64_NtAcceptConnectPort( UINT *args )
137 ULONG *handle_ptr = get_ptr( &args );
138 ULONG id = get_ulong( &args );
139 LPC_MESSAGE *msg = get_ptr( &args );
140 BOOLEAN accept = get_ulong( &args );
141 LPC_SECTION_WRITE *write = get_ptr( &args );
142 LPC_SECTION_READ *read = get_ptr( &args );
144 FIXME( "%p %u %p %u %p %p: stub\n", handle_ptr, id, msg, accept, write, read );
145 return STATUS_NOT_IMPLEMENTED;
149 /**********************************************************************
150 * wow64_NtCancelTimer
152 NTSTATUS WINAPI wow64_NtCancelTimer( UINT *args )
154 HANDLE handle = get_handle( &args );
155 BOOLEAN *state = get_ptr( &args );
157 return NtCancelTimer( handle, state );
161 /**********************************************************************
162 * wow64_NtClearEvent
164 NTSTATUS WINAPI wow64_NtClearEvent( UINT *args )
166 HANDLE handle = get_handle( &args );
168 return NtClearEvent( handle );
172 /**********************************************************************
173 * wow64_NtCompleteConnectPort
175 NTSTATUS WINAPI wow64_NtCompleteConnectPort( UINT *args )
177 HANDLE handle = get_handle( &args );
179 return NtCompleteConnectPort( handle );
183 /**********************************************************************
184 * wow64_NtConnectPort
186 NTSTATUS WINAPI wow64_NtConnectPort( UINT *args )
188 ULONG *handle_ptr = get_ptr( &args );
189 UNICODE_STRING32 *name32 = get_ptr( &args );
190 SECURITY_QUALITY_OF_SERVICE *qos = get_ptr( &args );
191 LPC_SECTION_WRITE *write = get_ptr( &args );
192 LPC_SECTION_READ *read = get_ptr( &args );
193 ULONG *max_len = get_ptr( &args );
194 void *info = get_ptr( &args );
195 ULONG *info_len = get_ptr( &args );
197 FIXME( "%p %p %p %p %p %p %p %p: stub\n",
198 handle_ptr, name32, qos, write, read, max_len, info, info_len );
199 return STATUS_NOT_IMPLEMENTED;
203 /**********************************************************************
204 * wow64_NtCreateDebugObject
206 NTSTATUS WINAPI wow64_NtCreateDebugObject( UINT *args )
208 ULONG *handle_ptr = get_ptr( &args );
209 ACCESS_MASK access = get_ulong( &args );
210 OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args );
211 ULONG flags = get_ulong( &args );
213 struct object_attr64 attr;
214 HANDLE handle = 0;
215 NTSTATUS status;
217 *handle_ptr = 0;
218 status = NtCreateDebugObject( &handle, access, objattr_32to64( &attr, attr32 ), flags );
219 put_handle( handle_ptr, handle );
220 return status;
224 /**********************************************************************
225 * wow64_NtCreateDirectoryObject
227 NTSTATUS WINAPI wow64_NtCreateDirectoryObject( UINT *args )
229 ULONG *handle_ptr = get_ptr( &args );
230 ACCESS_MASK access = get_ulong( &args );
231 OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args );
233 struct object_attr64 attr;
234 HANDLE handle = 0;
235 NTSTATUS status;
237 *handle_ptr = 0;
238 status = NtCreateDirectoryObject( &handle, access, objattr_32to64( &attr, attr32 ));
239 put_handle( handle_ptr, handle );
240 return status;
244 /**********************************************************************
245 * wow64_NtCreateEvent
247 NTSTATUS WINAPI wow64_NtCreateEvent( UINT *args )
249 ULONG *handle_ptr = get_ptr( &args );
250 ACCESS_MASK access = get_ulong( &args );
251 OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args );
252 EVENT_TYPE type = get_ulong( &args );
253 BOOLEAN state = get_ulong( &args );
255 struct object_attr64 attr;
256 HANDLE handle = 0;
257 NTSTATUS status;
259 *handle_ptr = 0;
260 status = NtCreateEvent( &handle, access, objattr_32to64( &attr, attr32 ), type, state );
261 put_handle( handle_ptr, handle );
262 return status;
266 /**********************************************************************
267 * wow64_NtCreateIoCompletion
269 NTSTATUS WINAPI wow64_NtCreateIoCompletion( UINT *args )
271 ULONG *handle_ptr = get_ptr( &args );
272 ACCESS_MASK access = get_ulong( &args );
273 OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args );
274 ULONG threads = get_ulong( &args );
276 struct object_attr64 attr;
277 HANDLE handle = 0;
278 NTSTATUS status;
280 *handle_ptr = 0;
281 status = NtCreateIoCompletion( &handle, access, objattr_32to64( &attr, attr32 ), threads );
282 put_handle( handle_ptr, handle );
283 return status;
287 /**********************************************************************
288 * wow64_NtCreateJobObject
290 NTSTATUS WINAPI wow64_NtCreateJobObject( UINT *args )
292 ULONG *handle_ptr = get_ptr( &args );
293 ACCESS_MASK access = get_ulong( &args );
294 OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args );
296 struct object_attr64 attr;
297 HANDLE handle = 0;
298 NTSTATUS status;
300 *handle_ptr = 0;
301 status = NtCreateJobObject( &handle, access, objattr_32to64( &attr, attr32 ));
302 put_handle( handle_ptr, handle );
303 return status;
307 /**********************************************************************
308 * wow64_NtCreateKeyedEvent
310 NTSTATUS WINAPI wow64_NtCreateKeyedEvent( UINT *args )
312 ULONG *handle_ptr = get_ptr( &args );
313 ACCESS_MASK access = get_ulong( &args );
314 OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args );
315 ULONG flags = get_ulong( &args );
317 struct object_attr64 attr;
318 HANDLE handle = 0;
319 NTSTATUS status;
321 *handle_ptr = 0;
322 status = NtCreateKeyedEvent( &handle, access, objattr_32to64( &attr, attr32 ), flags );
323 put_handle( handle_ptr, handle );
324 return status;
328 /**********************************************************************
329 * wow64_NtCreateMutant
331 NTSTATUS WINAPI wow64_NtCreateMutant( UINT *args )
333 ULONG *handle_ptr = get_ptr( &args );
334 ACCESS_MASK access = get_ulong( &args );
335 OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args );
336 BOOLEAN owned = get_ulong( &args );
338 struct object_attr64 attr;
339 HANDLE handle = 0;
340 NTSTATUS status;
342 *handle_ptr = 0;
343 status = NtCreateMutant( &handle, access, objattr_32to64( &attr, attr32 ), owned );
344 put_handle( handle_ptr, handle );
345 return status;
349 /**********************************************************************
350 * wow64_NtCreatePort
352 NTSTATUS WINAPI wow64_NtCreatePort( UINT *args )
354 ULONG *handle_ptr = get_ptr( &args );
355 OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args );
356 ULONG info_len = get_ulong( &args );
357 ULONG data_len = get_ulong( &args );
358 ULONG *reserved = get_ptr( &args );
360 struct object_attr64 attr;
361 HANDLE handle = 0;
362 NTSTATUS status;
364 *handle_ptr = 0;
365 status = NtCreatePort( &handle, objattr_32to64( &attr, attr32 ), info_len, data_len, reserved );
366 put_handle( handle_ptr, handle );
367 return status;
371 /**********************************************************************
372 * wow64_NtCreateSection
374 NTSTATUS WINAPI wow64_NtCreateSection( UINT *args )
376 ULONG *handle_ptr = get_ptr( &args );
377 ACCESS_MASK access = get_ulong( &args );
378 OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args );
379 const LARGE_INTEGER *size = get_ptr( &args );
380 ULONG protect = get_ulong( &args );
381 ULONG flags = get_ulong( &args );
382 HANDLE file = get_handle( &args );
384 struct object_attr64 attr;
385 HANDLE handle = 0;
386 NTSTATUS status;
388 *handle_ptr = 0;
389 status = NtCreateSection( &handle, access, objattr_32to64( &attr, attr32 ), size, protect, flags, file );
390 put_handle( handle_ptr, handle );
391 return status;
395 /**********************************************************************
396 * wow64_NtCreateSemaphore
398 NTSTATUS WINAPI wow64_NtCreateSemaphore( UINT *args )
400 ULONG *handle_ptr = get_ptr( &args );
401 ACCESS_MASK access = get_ulong( &args );
402 OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args );
403 LONG initial = get_ulong( &args );
404 LONG max = get_ulong( &args );
406 struct object_attr64 attr;
407 HANDLE handle = 0;
408 NTSTATUS status;
410 *handle_ptr = 0;
411 status = NtCreateSemaphore( &handle, access, objattr_32to64( &attr, attr32 ), initial, max );
412 put_handle( handle_ptr, handle );
413 return status;
417 /**********************************************************************
418 * wow64_NtCreateSymbolicLinkObject
420 NTSTATUS WINAPI wow64_NtCreateSymbolicLinkObject( UINT *args )
422 ULONG *handle_ptr = get_ptr( &args );
423 ACCESS_MASK access = get_ulong( &args );
424 OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args );
425 UNICODE_STRING32 *target32 = get_ptr( &args );
427 struct object_attr64 attr;
428 UNICODE_STRING target;
429 HANDLE handle = 0;
430 NTSTATUS status;
432 *handle_ptr = 0;
433 status = NtCreateSymbolicLinkObject( &handle, access, objattr_32to64( &attr, attr32 ),
434 unicode_str_32to64( &target, target32 ));
435 put_handle( handle_ptr, handle );
436 return status;
440 /**********************************************************************
441 * wow64_NtCreateTimer
443 NTSTATUS WINAPI wow64_NtCreateTimer( UINT *args )
445 ULONG *handle_ptr = get_ptr( &args );
446 ACCESS_MASK access = get_ulong( &args );
447 OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args );
448 TIMER_TYPE type = get_ulong( &args );
450 struct object_attr64 attr;
451 HANDLE handle = 0;
452 NTSTATUS status;
454 *handle_ptr = 0;
455 status = NtCreateTimer( &handle, access, objattr_32to64( &attr, attr32 ), type );
456 put_handle( handle_ptr, handle );
457 return status;
461 /**********************************************************************
462 * wow64_NtDebugContinue
464 NTSTATUS WINAPI wow64_NtDebugContinue( UINT *args )
466 HANDLE handle = get_handle( &args );
467 CLIENT_ID32 *id32 = get_ptr( &args );
468 NTSTATUS status = get_ulong( &args );
470 CLIENT_ID id;
472 return NtDebugContinue( handle, client_id_32to64( &id, id32 ), status );
476 /**********************************************************************
477 * wow64_NtDelayExecution
479 NTSTATUS WINAPI wow64_NtDelayExecution( UINT *args )
481 BOOLEAN alertable = get_ulong( &args );
482 const LARGE_INTEGER *timeout = get_ptr( &args );
484 return NtDelayExecution( alertable, timeout );
488 /**********************************************************************
489 * wow64_NtDuplicateObject
491 NTSTATUS WINAPI wow64_NtDuplicateObject( UINT *args )
493 HANDLE source_process = get_handle( &args );
494 HANDLE source_handle = get_handle( &args );
495 HANDLE dest_process = get_handle( &args );
496 ULONG *handle_ptr = get_ptr( &args );
497 ACCESS_MASK access = get_ulong( &args );
498 ULONG attributes = get_ulong( &args );
499 ULONG options = get_ulong( &args );
501 HANDLE handle = 0;
502 NTSTATUS status;
504 if (handle_ptr) *handle_ptr = 0;
505 status = NtDuplicateObject( source_process, source_handle, dest_process, &handle,
506 access, attributes, options );
507 if (handle_ptr) put_handle( handle_ptr, handle );
508 return status;
512 /**********************************************************************
513 * wow64_NtListenPort
515 NTSTATUS WINAPI wow64_NtListenPort( UINT *args )
517 HANDLE handle = get_handle( &args );
518 LPC_MESSAGE *msg = get_ptr( &args );
520 FIXME( "%p %p: stub\n", handle, msg );
521 return STATUS_NOT_IMPLEMENTED;
525 /**********************************************************************
526 * wow64_NtMakeTemporaryObject
528 NTSTATUS WINAPI wow64_NtMakeTemporaryObject( UINT *args )
530 HANDLE handle = get_handle( &args );
532 return NtMakeTemporaryObject( handle );
536 /**********************************************************************
537 * wow64_NtOpenDirectoryObject
539 NTSTATUS WINAPI wow64_NtOpenDirectoryObject( UINT *args )
541 ULONG *handle_ptr = get_ptr( &args );
542 ACCESS_MASK access = get_ulong( &args );
543 OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args );
545 struct object_attr64 attr;
546 HANDLE handle = 0;
547 NTSTATUS status;
549 *handle_ptr = 0;
550 status = NtOpenDirectoryObject( &handle, access, objattr_32to64( &attr, attr32 ));
551 put_handle( handle_ptr, handle );
552 return status;
556 /**********************************************************************
557 * wow64_NtOpenEvent
559 NTSTATUS WINAPI wow64_NtOpenEvent( UINT *args )
561 ULONG *handle_ptr = get_ptr( &args );
562 ACCESS_MASK access = get_ulong( &args );
563 OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args );
565 struct object_attr64 attr;
566 HANDLE handle = 0;
567 NTSTATUS status;
569 *handle_ptr = 0;
570 status = NtOpenEvent( &handle, access, objattr_32to64( &attr, attr32 ));
571 put_handle( handle_ptr, handle );
572 return status;
576 /**********************************************************************
577 * wow64_NtOpenIoCompletion
579 NTSTATUS WINAPI wow64_NtOpenIoCompletion( UINT *args )
581 ULONG *handle_ptr = get_ptr( &args );
582 ACCESS_MASK access = get_ulong( &args );
583 OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args );
585 struct object_attr64 attr;
586 HANDLE handle = 0;
587 NTSTATUS status;
589 *handle_ptr = 0;
590 status = NtOpenIoCompletion( &handle, access, objattr_32to64( &attr, attr32 ));
591 put_handle( handle_ptr, handle );
592 return status;
596 /**********************************************************************
597 * wow64_NtOpenJobObject
599 NTSTATUS WINAPI wow64_NtOpenJobObject( UINT *args )
601 ULONG *handle_ptr = get_ptr( &args );
602 ACCESS_MASK access = get_ulong( &args );
603 OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args );
605 struct object_attr64 attr;
606 HANDLE handle = 0;
607 NTSTATUS status;
609 *handle_ptr = 0;
610 status = NtOpenJobObject( &handle, access, objattr_32to64( &attr, attr32 ));
611 put_handle( handle_ptr, handle );
612 return status;
616 /**********************************************************************
617 * wow64_NtOpenKeyedEvent
619 NTSTATUS WINAPI wow64_NtOpenKeyedEvent( UINT *args )
621 ULONG *handle_ptr = get_ptr( &args );
622 ACCESS_MASK access = get_ulong( &args );
623 OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args );
625 struct object_attr64 attr;
626 HANDLE handle = 0;
627 NTSTATUS status;
629 *handle_ptr = 0;
630 status = NtOpenKeyedEvent( &handle, access, objattr_32to64( &attr, attr32 ));
631 put_handle( handle_ptr, handle );
632 return status;
636 /**********************************************************************
637 * wow64_NtOpenMutant
639 NTSTATUS WINAPI wow64_NtOpenMutant( UINT *args )
641 ULONG *handle_ptr = get_ptr( &args );
642 ACCESS_MASK access = get_ulong( &args );
643 OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args );
645 struct object_attr64 attr;
646 HANDLE handle = 0;
647 NTSTATUS status;
649 *handle_ptr = 0;
650 status = NtOpenMutant( &handle, access, objattr_32to64( &attr, attr32 ));
651 put_handle( handle_ptr, handle );
652 return status;
656 /**********************************************************************
657 * wow64_NtOpenSection
659 NTSTATUS WINAPI wow64_NtOpenSection( UINT *args )
661 ULONG *handle_ptr = get_ptr( &args );
662 ACCESS_MASK access = get_ulong( &args );
663 OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args );
665 struct object_attr64 attr;
666 HANDLE handle = 0;
667 NTSTATUS status;
669 *handle_ptr = 0;
670 status = NtOpenSection( &handle, access, objattr_32to64( &attr, attr32 ));
671 put_handle( handle_ptr, handle );
672 return status;
676 /**********************************************************************
677 * wow64_NtOpenSemaphore
679 NTSTATUS WINAPI wow64_NtOpenSemaphore( UINT *args )
681 ULONG *handle_ptr = get_ptr( &args );
682 ACCESS_MASK access = get_ulong( &args );
683 OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args );
685 struct object_attr64 attr;
686 HANDLE handle = 0;
687 NTSTATUS status;
689 *handle_ptr = 0;
690 status = NtOpenSemaphore( &handle, access, objattr_32to64( &attr, attr32 ));
691 put_handle( handle_ptr, handle );
692 return status;
696 /**********************************************************************
697 * wow64_NtOpenSymbolicLinkObject
699 NTSTATUS WINAPI wow64_NtOpenSymbolicLinkObject( UINT *args )
701 ULONG *handle_ptr = get_ptr( &args );
702 ACCESS_MASK access = get_ulong( &args );
703 OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args );
705 struct object_attr64 attr;
706 HANDLE handle = 0;
707 NTSTATUS status;
709 *handle_ptr = 0;
710 status = NtOpenSymbolicLinkObject( &handle, access, objattr_32to64( &attr, attr32 ));
711 put_handle( handle_ptr, handle );
712 return status;
716 /**********************************************************************
717 * wow64_NtOpenTimer
719 NTSTATUS WINAPI wow64_NtOpenTimer( UINT *args )
721 ULONG *handle_ptr = get_ptr( &args );
722 ACCESS_MASK access = get_ulong( &args );
723 OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args );
725 struct object_attr64 attr;
726 HANDLE handle = 0;
727 NTSTATUS status;
729 *handle_ptr = 0;
730 status = NtOpenTimer( &handle, access, objattr_32to64( &attr, attr32 ));
731 put_handle( handle_ptr, handle );
732 return status;
736 /**********************************************************************
737 * wow64_NtPulseEvent
739 NTSTATUS WINAPI wow64_NtPulseEvent( UINT *args )
741 HANDLE handle = get_handle( &args );
742 LONG *prev_state = get_ptr( &args );
744 return NtPulseEvent( handle, prev_state );
748 /**********************************************************************
749 * wow64_NtQueryDirectoryObject
751 NTSTATUS WINAPI wow64_NtQueryDirectoryObject( UINT *args )
753 HANDLE handle = get_handle( &args );
754 DIRECTORY_BASIC_INFORMATION32 *info32 = get_ptr( &args );
755 ULONG size32 = get_ulong( &args );
756 BOOLEAN single_entry = get_ulong( &args );
757 BOOLEAN restart = get_ulong( &args );
758 ULONG *context = get_ptr( &args );
759 ULONG *retlen = get_ptr( &args );
761 NTSTATUS status;
762 DIRECTORY_BASIC_INFORMATION *info;
763 ULONG size = size32 + sizeof(*info) - sizeof(*info32);
765 if (!single_entry) FIXME( "not implemented\n" );
766 info = Wow64AllocateTemp( size );
767 status = NtQueryDirectoryObject( handle, info, size, single_entry, restart, context, NULL );
768 if (!status)
770 info32->ObjectName.Buffer = PtrToUlong( info32 + 1 );
771 info32->ObjectName.Length = info->ObjectName.Length;
772 info32->ObjectName.MaximumLength = info->ObjectName.MaximumLength;
773 info32->ObjectTypeName.Buffer = info32->ObjectName.Buffer + info->ObjectName.MaximumLength;
774 info32->ObjectTypeName.Length = info->ObjectTypeName.Length;
775 info32->ObjectTypeName.MaximumLength = info->ObjectTypeName.MaximumLength;
776 size = info->ObjectName.MaximumLength + info->ObjectTypeName.MaximumLength;
777 memcpy( info32 + 1, info + 1, size );
778 if (retlen) *retlen = sizeof(*info32) + size;
780 return status;
784 /**********************************************************************
785 * wow64_NtQueryEvent
787 NTSTATUS WINAPI wow64_NtQueryEvent( UINT *args )
789 HANDLE handle = get_handle( &args );
790 EVENT_INFORMATION_CLASS class = get_ulong( &args );
791 void *info = get_ptr( &args );
792 ULONG len = get_ulong( &args );
793 ULONG *retlen = get_ptr( &args );
795 return NtQueryEvent( handle, class, info, len, retlen );
799 /**********************************************************************
800 * wow64_NtQueryInformationJobObject
802 NTSTATUS WINAPI wow64_NtQueryInformationJobObject( UINT *args )
804 HANDLE handle = get_handle( &args );
805 JOBOBJECTINFOCLASS class = get_ulong( &args );
806 void *ptr = get_ptr( &args );
807 ULONG len = get_ulong( &args );
808 ULONG *retlen = get_ptr( &args );
810 NTSTATUS status;
812 switch (class)
814 case JobObjectBasicAccountingInformation: /* JOBOBJECT_BASIC_ACCOUNTING_INFORMATION */
815 return NtQueryInformationJobObject( handle, class, ptr, len, retlen );
817 case JobObjectBasicLimitInformation: /* JOBOBJECT_BASIC_LIMIT_INFORMATION */
818 if (len >= sizeof(JOBOBJECT_BASIC_LIMIT_INFORMATION32))
820 JOBOBJECT_BASIC_LIMIT_INFORMATION32 *info32 = ptr;
821 JOBOBJECT_BASIC_LIMIT_INFORMATION info;
823 status = NtQueryInformationJobObject( handle, class, &info, sizeof(info), NULL );
824 if (!status) put_job_basic_limit_info( info32, &info );
825 if (retlen) *retlen = sizeof(*info32);
826 return status;
828 else return STATUS_INFO_LENGTH_MISMATCH;
830 case JobObjectBasicProcessIdList: /* JOBOBJECT_BASIC_PROCESS_ID_LIST */
831 if (len >= sizeof(JOBOBJECT_BASIC_PROCESS_ID_LIST32))
833 JOBOBJECT_BASIC_PROCESS_ID_LIST32 *info32 = ptr;
834 JOBOBJECT_BASIC_PROCESS_ID_LIST *info;
835 ULONG i, count, size;
837 count = (len - offsetof( JOBOBJECT_BASIC_PROCESS_ID_LIST32, ProcessIdList )) / sizeof(info32->ProcessIdList[0]);
838 size = offsetof( JOBOBJECT_BASIC_PROCESS_ID_LIST, ProcessIdList[count] );
839 info = Wow64AllocateTemp( size );
840 status = NtQueryInformationJobObject( handle, class, info, size, NULL );
841 if (!status)
843 info32->NumberOfAssignedProcesses = info->NumberOfAssignedProcesses;
844 info32->NumberOfProcessIdsInList = info->NumberOfProcessIdsInList;
845 for (i = 0; i < info->NumberOfProcessIdsInList; i++)
846 info32->ProcessIdList[i] = info->ProcessIdList[i];
847 if (retlen) *retlen = offsetof( JOBOBJECT_BASIC_PROCESS_ID_LIST32, ProcessIdList[i] );
849 return status;
851 else return STATUS_INFO_LENGTH_MISMATCH;
853 case JobObjectExtendedLimitInformation: /* JOBOBJECT_EXTENDED_LIMIT_INFORMATION */
854 if (len >= sizeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION32))
856 JOBOBJECT_EXTENDED_LIMIT_INFORMATION32 *info32 = ptr;
857 JOBOBJECT_EXTENDED_LIMIT_INFORMATION info;
859 status = NtQueryInformationJobObject( handle, class, &info, sizeof(info), NULL );
860 if (!status)
862 put_job_basic_limit_info( &info32->BasicLimitInformation, &info.BasicLimitInformation );
863 info32->IoInfo = info.IoInfo;
864 info32->ProcessMemoryLimit = info.ProcessMemoryLimit;
865 info32->JobMemoryLimit = info.JobMemoryLimit;
866 info32->PeakProcessMemoryUsed = info.PeakProcessMemoryUsed;
867 info32->PeakJobMemoryUsed = info.PeakJobMemoryUsed;
869 if (retlen) *retlen = sizeof(*info32);
870 return status;
872 else return STATUS_INFO_LENGTH_MISMATCH;
874 default:
875 if (class >= MaxJobObjectInfoClass) return STATUS_INVALID_PARAMETER;
876 FIXME( "unsupported class %u\n", class );
877 return STATUS_NOT_IMPLEMENTED;
882 /**********************************************************************
883 * wow64_NtQueryIoCompletion
885 NTSTATUS WINAPI wow64_NtQueryIoCompletion( UINT *args )
887 HANDLE handle = get_handle( &args );
888 IO_COMPLETION_INFORMATION_CLASS class = get_ulong( &args );
889 void *info = get_ptr( &args );
890 ULONG len = get_ulong( &args );
891 ULONG *retlen = get_ptr( &args );
893 return NtQueryIoCompletion( handle, class, info, len, retlen );
897 /**********************************************************************
898 * wow64_NtQueryMutant
900 NTSTATUS WINAPI wow64_NtQueryMutant( UINT *args )
902 HANDLE handle = get_handle( &args );
903 MUTANT_INFORMATION_CLASS class = get_ulong( &args );
904 void *info = get_ptr( &args );
905 ULONG len = get_ulong( &args );
906 ULONG *retlen = get_ptr( &args );
908 return NtQueryMutant( handle, class, info, len, retlen );
912 /**********************************************************************
913 * wow64_NtQueryObject
915 NTSTATUS WINAPI wow64_NtQueryObject( UINT *args )
917 HANDLE handle = get_handle( &args );
918 OBJECT_INFORMATION_CLASS class = get_ulong( &args );
919 void *ptr = get_ptr( &args );
920 ULONG len = get_ulong( &args );
921 ULONG *retlen = get_ptr( &args );
923 NTSTATUS status;
924 ULONG ret_size;
926 switch (class)
928 case ObjectBasicInformation: /* OBJECT_BASIC_INFORMATION */
929 case ObjectDataInformation: /* OBJECT_DATA_INFORMATION */
930 return NtQueryObject( handle, class, ptr, len, retlen );
932 case ObjectNameInformation: /* OBJECT_NAME_INFORMATION */
934 ULONG size = len + sizeof(OBJECT_NAME_INFORMATION) - sizeof(OBJECT_NAME_INFORMATION32);
935 OBJECT_NAME_INFORMATION32 *info32 = ptr;
936 OBJECT_NAME_INFORMATION *info = Wow64AllocateTemp( size );
938 if (!(status = NtQueryObject( handle, class, info, size, &ret_size )))
940 if (len >= sizeof(*info32) + info->Name.MaximumLength)
942 if (info->Name.Length)
944 memcpy( info32 + 1, info->Name.Buffer, info->Name.Length + sizeof(WCHAR) );
945 info32->Name.Length = info->Name.Length;
946 info32->Name.MaximumLength = info->Name.Length + sizeof(WCHAR);
947 info32->Name.Buffer = PtrToUlong( info32 + 1 );
949 else memset( &info32->Name, 0, sizeof(info32->Name) );
951 else status = STATUS_INFO_LENGTH_MISMATCH;
952 if (retlen) *retlen = sizeof(*info32) + info->Name.MaximumLength;
954 else if (status == STATUS_INFO_LENGTH_MISMATCH || status == STATUS_BUFFER_OVERFLOW)
956 if (retlen) *retlen = ret_size - sizeof(*info) + sizeof(*info32);
958 return status;
961 case ObjectTypeInformation: /* OBJECT_TYPE_INFORMATION */
963 ULONG_PTR buffer[(sizeof(OBJECT_TYPE_INFORMATION) + 64) / sizeof(ULONG_PTR)];
964 OBJECT_TYPE_INFORMATION *info = (OBJECT_TYPE_INFORMATION *)buffer;
965 OBJECT_TYPE_INFORMATION32 *info32 = ptr;
967 if (!(status = NtQueryObject( handle, class, info, sizeof(buffer), NULL )))
969 if (len >= sizeof(*info32) + info->TypeName.MaximumLength)
970 put_object_type_info( info32, info );
971 else
972 status = STATUS_INFO_LENGTH_MISMATCH;
973 if (retlen) *retlen = sizeof(*info32) + info->TypeName.Length + sizeof(WCHAR);
975 return status;
978 case ObjectTypesInformation: /* OBJECT_TYPES_INFORMATION */
980 OBJECT_TYPES_INFORMATION *info, *info32 = ptr;
981 /* assume at most 32 types, with an average 16-char name */
982 ULONG ret_size, size = 32 * (sizeof(OBJECT_TYPE_INFORMATION) + 16 * sizeof(WCHAR));
984 info = Wow64AllocateTemp( size );
985 if (!(status = NtQueryObject( handle, class, info, size, &ret_size )))
987 OBJECT_TYPE_INFORMATION *type;
988 OBJECT_TYPE_INFORMATION32 *type32;
989 ULONG align = TYPE_ALIGNMENT( OBJECT_TYPE_INFORMATION ) - 1;
990 ULONG align32 = TYPE_ALIGNMENT( OBJECT_TYPE_INFORMATION32 ) - 1;
991 ULONG i, pos = (sizeof(*info) + align) & ~align, pos32 = (sizeof(*info32) + align32) & ~align32;
993 if (pos32 <= len) info32->NumberOfTypes = info->NumberOfTypes;
994 for (i = 0; i < info->NumberOfTypes; i++)
996 type = (OBJECT_TYPE_INFORMATION *)((char *)info + pos);
997 type32 = (OBJECT_TYPE_INFORMATION32 *)((char *)ptr + pos32);
998 pos += sizeof(*type) + ((type->TypeName.MaximumLength + align) & ~align);
999 pos32 += sizeof(*type32) + ((type->TypeName.MaximumLength + align32) & ~align32);
1000 if (pos32 <= len) put_object_type_info( type32, type );
1002 if (pos32 > len) status = STATUS_INFO_LENGTH_MISMATCH;
1003 if (retlen) *retlen = pos32;
1005 return status;
1008 default:
1009 FIXME( "unsupported class %u\n", class );
1010 return STATUS_NOT_IMPLEMENTED;
1015 /**********************************************************************
1016 * wow64_NtQueryPerformanceCounter
1018 NTSTATUS WINAPI wow64_NtQueryPerformanceCounter( UINT *args )
1020 LARGE_INTEGER *counter = get_ptr( &args );
1021 LARGE_INTEGER *frequency = get_ptr( &args );
1023 return NtQueryPerformanceCounter( counter, frequency );
1027 /**********************************************************************
1028 * wow64_NtQuerySection
1030 NTSTATUS WINAPI wow64_NtQuerySection( UINT *args )
1032 HANDLE handle = get_handle( &args );
1033 SECTION_INFORMATION_CLASS class = get_ulong( &args );
1034 void *ptr = get_ptr( &args );
1035 SIZE_T size = get_ulong( &args );
1036 ULONG *ret_ptr = get_ptr( &args );
1038 NTSTATUS status;
1039 SIZE_T ret_size = 0;
1041 switch (class)
1043 case SectionBasicInformation:
1045 SECTION_BASIC_INFORMATION info;
1046 SECTION_BASIC_INFORMATION32 *info32 = ptr;
1048 if (size < sizeof(*info32)) return STATUS_INFO_LENGTH_MISMATCH;
1049 if (!(status = NtQuerySection( handle, class, &info, sizeof(info), &ret_size )))
1051 info32->BaseAddress = PtrToUlong( info.BaseAddress );
1052 info32->Attributes = info.Attributes;
1053 info32->Size = info.Size;
1054 ret_size = sizeof(*info32);
1056 break;
1058 case SectionImageInformation:
1060 SECTION_IMAGE_INFORMATION info;
1061 SECTION_IMAGE_INFORMATION32 *info32 = ptr;
1063 if (size < sizeof(*info32)) return STATUS_INFO_LENGTH_MISMATCH;
1064 if (!(status = NtQuerySection( handle, class, &info, sizeof(info), &ret_size )))
1066 put_section_image_info( info32, &info );
1067 ret_size = sizeof(*info32);
1069 break;
1071 default:
1072 FIXME( "class %u not implemented\n", class );
1073 return STATUS_NOT_IMPLEMENTED;
1075 put_size( ret_ptr, ret_size );
1076 return status;
1080 /**********************************************************************
1081 * wow64_NtQuerySemaphore
1083 NTSTATUS WINAPI wow64_NtQuerySemaphore( UINT *args )
1085 HANDLE handle = get_handle( &args );
1086 SEMAPHORE_INFORMATION_CLASS class = get_ulong( &args );
1087 void *info = get_ptr( &args );
1088 ULONG len = get_ulong( &args );
1089 ULONG *retlen = get_ptr( &args );
1091 return NtQuerySemaphore( handle, class, info, len, retlen );
1095 /**********************************************************************
1096 * wow64_NtQuerySymbolicLinkObject
1098 NTSTATUS WINAPI wow64_NtQuerySymbolicLinkObject( UINT *args )
1100 HANDLE handle = get_handle( &args );
1101 UNICODE_STRING32 *target32 = get_ptr( &args );
1102 ULONG *retlen = get_ptr( &args );
1104 UNICODE_STRING target;
1105 NTSTATUS status;
1107 status = NtQuerySymbolicLinkObject( handle, unicode_str_32to64( &target, target32 ), retlen );
1108 if (!status) target32->Length = target.Length;
1109 return status;
1113 /**********************************************************************
1114 * wow64_NtQueryTimer
1116 NTSTATUS WINAPI wow64_NtQueryTimer( UINT *args )
1118 HANDLE handle = get_handle( &args );
1119 TIMER_INFORMATION_CLASS class = get_ulong( &args );
1120 void *info = get_ptr( &args );
1121 ULONG len = get_ulong( &args );
1122 ULONG *retlen = get_ptr( &args );
1124 return NtQueryTimer( handle, class, info, len, retlen );
1128 /**********************************************************************
1129 * wow64_NtQueryTimerResolution
1131 NTSTATUS WINAPI wow64_NtQueryTimerResolution( UINT *args )
1133 ULONG *min_res = get_ptr( &args );
1134 ULONG *max_res = get_ptr( &args );
1135 ULONG *current_res = get_ptr( &args );
1137 return NtQueryTimerResolution( min_res, max_res, current_res );
1141 /**********************************************************************
1142 * wow64_NtRegisterThreadTerminatePort
1144 NTSTATUS WINAPI wow64_NtRegisterThreadTerminatePort( UINT *args )
1146 HANDLE handle = get_handle( &args );
1148 return NtRegisterThreadTerminatePort( handle );
1152 /**********************************************************************
1153 * wow64_NtReleaseKeyedEvent
1155 NTSTATUS WINAPI wow64_NtReleaseKeyedEvent( UINT *args )
1157 HANDLE handle = get_handle( &args );
1158 void *key = get_ptr( &args );
1159 BOOLEAN alertable = get_ulong( &args );
1160 const LARGE_INTEGER *timeout = get_ptr( &args );
1162 return NtReleaseKeyedEvent( handle, key, alertable, timeout );
1166 /**********************************************************************
1167 * wow64_NtReleaseMutant
1169 NTSTATUS WINAPI wow64_NtReleaseMutant( UINT *args )
1171 HANDLE handle = get_handle( &args );
1172 LONG *prev_count = get_ptr( &args );
1174 return NtReleaseMutant( handle, prev_count );
1178 /**********************************************************************
1179 * wow64_NtReleaseSemaphore
1181 NTSTATUS WINAPI wow64_NtReleaseSemaphore( UINT *args )
1183 HANDLE handle = get_handle( &args );
1184 ULONG count = get_ulong( &args );
1185 ULONG *previous = get_ptr( &args );
1187 return NtReleaseSemaphore( handle, count, previous );
1191 /**********************************************************************
1192 * wow64_NtReplyWaitReceivePort
1194 NTSTATUS WINAPI wow64_NtReplyWaitReceivePort( UINT *args )
1196 HANDLE handle = get_handle( &args );
1197 ULONG *id = get_ptr( &args );
1198 LPC_MESSAGE *reply = get_ptr( &args );
1199 LPC_MESSAGE *msg = get_ptr( &args );
1201 FIXME( "%p %p %p %p: stub\n", handle, id, reply, msg );
1202 return STATUS_NOT_IMPLEMENTED;
1206 /**********************************************************************
1207 * wow64_NtRequestWaitReplyPort
1209 NTSTATUS WINAPI wow64_NtRequestWaitReplyPort( UINT *args )
1211 HANDLE handle = get_handle( &args );
1212 LPC_MESSAGE *msg_in = get_ptr( &args );
1213 LPC_MESSAGE *msg_out = get_ptr( &args );
1215 FIXME( "%p %p %p: stub\n", handle, msg_in, msg_out );
1216 return STATUS_NOT_IMPLEMENTED;
1220 /**********************************************************************
1221 * wow64_NtResetEvent
1223 NTSTATUS WINAPI wow64_NtResetEvent( UINT *args )
1225 HANDLE handle = get_handle( &args );
1226 LONG *prev_state = get_ptr( &args );
1228 return NtResetEvent( handle, prev_state );
1232 /**********************************************************************
1233 * wow64_NtSecureConnectPort
1235 NTSTATUS WINAPI wow64_NtSecureConnectPort( UINT *args )
1237 ULONG *handle_ptr = get_ptr( &args );
1238 UNICODE_STRING32 *name32 = get_ptr( &args );
1239 SECURITY_QUALITY_OF_SERVICE *qos = get_ptr( &args );
1240 LPC_SECTION_WRITE *write = get_ptr( &args );
1241 SID *sid = get_ptr( &args );
1242 LPC_SECTION_READ *read = get_ptr( &args );
1243 ULONG *max_len = get_ptr( &args );
1244 void *info = get_ptr( &args );
1245 ULONG *info_len = get_ptr( &args );
1247 FIXME( "%p %p %p %p %p %p %p %p %p: stub\n",
1248 handle_ptr, name32, qos, write, sid, read, max_len, info, info_len );
1249 return STATUS_NOT_IMPLEMENTED;
1253 /**********************************************************************
1254 * wow64_NtSetEvent
1256 NTSTATUS WINAPI wow64_NtSetEvent( UINT *args )
1258 HANDLE handle = get_handle( &args );
1259 LONG *prev_state = get_ptr( &args );
1261 return NtSetEvent( handle, prev_state );
1265 /**********************************************************************
1266 * wow64_NtSetInformationDebugObject
1268 NTSTATUS WINAPI wow64_NtSetInformationDebugObject( UINT *args )
1270 HANDLE handle = get_handle( &args );
1271 DEBUGOBJECTINFOCLASS class = get_ulong( &args );
1272 void *ptr = get_ptr( &args );
1273 ULONG len = get_ulong( &args );
1274 ULONG *retlen = get_ptr( &args );
1276 return NtSetInformationDebugObject( handle, class, ptr, len, retlen );
1280 /**********************************************************************
1281 * wow64_NtSetInformationJobObject
1283 NTSTATUS WINAPI wow64_NtSetInformationJobObject( UINT *args )
1285 HANDLE handle = get_handle( &args );
1286 JOBOBJECTINFOCLASS class = get_ulong( &args );
1287 void *ptr = get_ptr( &args );
1288 ULONG len = get_ulong( &args );
1290 switch (class)
1292 case JobObjectBasicLimitInformation: /* JOBOBJECT_BASIC_LIMIT_INFORMATION */
1293 if (len == sizeof(JOBOBJECT_BASIC_LIMIT_INFORMATION32))
1295 JOBOBJECT_BASIC_LIMIT_INFORMATION info;
1297 return NtSetInformationJobObject( handle, class, job_basic_limit_info_32to64( &info, ptr ),
1298 sizeof(info) );
1300 else return STATUS_INVALID_PARAMETER;
1302 case JobObjectBasicUIRestrictions:
1303 FIXME( "unsupported class JobObjectBasicUIRestrictions\n" );
1304 return STATUS_SUCCESS;
1306 case JobObjectAssociateCompletionPortInformation: /* JOBOBJECT_ASSOCIATE_COMPLETION_PORT */
1307 if (len == sizeof(JOBOBJECT_ASSOCIATE_COMPLETION_PORT32))
1309 JOBOBJECT_ASSOCIATE_COMPLETION_PORT32 *info32 = ptr;
1310 JOBOBJECT_ASSOCIATE_COMPLETION_PORT info;
1312 info.CompletionKey = ULongToPtr( info32->CompletionKey );
1313 info.CompletionPort = LongToHandle( info32->CompletionPort );
1314 return NtSetInformationJobObject( handle, class, &info, sizeof(info) );
1316 else return STATUS_INVALID_PARAMETER;
1318 case JobObjectExtendedLimitInformation: /* JOBOBJECT_EXTENDED_LIMIT_INFORMATION */
1319 if (len == sizeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION32))
1321 JOBOBJECT_EXTENDED_LIMIT_INFORMATION32 *info32 = ptr;
1322 JOBOBJECT_EXTENDED_LIMIT_INFORMATION info;
1324 info.IoInfo = info32->IoInfo;
1325 info.ProcessMemoryLimit = info32->ProcessMemoryLimit;
1326 info.JobMemoryLimit = info32->JobMemoryLimit;
1327 info.PeakProcessMemoryUsed = info32->PeakProcessMemoryUsed;
1328 info.PeakJobMemoryUsed = info32->PeakJobMemoryUsed;
1329 return NtSetInformationJobObject( handle, class,
1330 job_basic_limit_info_32to64( &info.BasicLimitInformation,
1331 &info32->BasicLimitInformation ),
1332 sizeof(info) );
1334 else return STATUS_INVALID_PARAMETER;
1336 default:
1337 if (class >= MaxJobObjectInfoClass) return STATUS_INVALID_PARAMETER;
1338 FIXME( "unsupported class %u\n", class );
1339 return STATUS_NOT_IMPLEMENTED;
1344 /**********************************************************************
1345 * wow64_NtSetInformationObject
1347 NTSTATUS WINAPI wow64_NtSetInformationObject( UINT *args )
1349 HANDLE handle = get_handle( &args );
1350 OBJECT_INFORMATION_CLASS class = get_ulong( &args );
1351 void *ptr = get_ptr( &args );
1352 ULONG len = get_ulong( &args );
1354 switch (class)
1356 case ObjectDataInformation: /* OBJECT_DATA_INFORMATION */
1357 return NtSetInformationObject( handle, class, ptr, len );
1359 default:
1360 FIXME( "unsupported class %u\n", class );
1361 return STATUS_NOT_IMPLEMENTED;
1366 /**********************************************************************
1367 * wow64_NtSetIoCompletion
1369 NTSTATUS WINAPI wow64_NtSetIoCompletion( UINT *args )
1371 HANDLE handle = get_handle( &args );
1372 ULONG_PTR key = get_ulong( &args );
1373 ULONG_PTR value = get_ulong( &args );
1374 NTSTATUS status = get_ulong( &args );
1375 SIZE_T count = get_ulong( &args );
1377 return NtSetIoCompletion( handle, key, value, status, count );
1381 /**********************************************************************
1382 * wow64_NtSetTimer
1384 NTSTATUS WINAPI wow64_NtSetTimer( UINT *args )
1386 HANDLE handle = get_handle( &args );
1387 LARGE_INTEGER *when = get_ptr( &args );
1388 ULONG apc = get_ulong( &args );
1389 ULONG apc_param = get_ulong( &args );
1390 BOOLEAN resume = get_ulong( &args );
1391 ULONG period = get_ulong( &args );
1392 BOOLEAN *state = get_ptr( &args );
1394 return NtSetTimer( handle, when, apc_32to64( apc ), apc_param_32to64( apc, apc_param ),
1395 resume, period, state );
1399 /**********************************************************************
1400 * wow64_NtSetTimerResolution
1402 NTSTATUS WINAPI wow64_NtSetTimerResolution( UINT *args )
1404 ULONG res = get_ulong( &args );
1405 BOOLEAN set = get_ulong( &args );
1406 ULONG *current_res = get_ptr( &args );
1408 return NtSetTimerResolution( res, set, current_res );
1412 /**********************************************************************
1413 * wow64_NtSignalAndWaitForSingleObject
1415 NTSTATUS WINAPI wow64_NtSignalAndWaitForSingleObject( UINT *args )
1417 HANDLE signal = get_handle( &args );
1418 HANDLE wait = get_handle( &args );
1419 BOOLEAN alertable = get_ulong( &args );
1420 const LARGE_INTEGER *timeout = get_ptr( &args );
1422 return NtSignalAndWaitForSingleObject( signal, wait, alertable, timeout );
1426 /**********************************************************************
1427 * wow64_NtTerminateJobObject
1429 NTSTATUS WINAPI wow64_NtTerminateJobObject( UINT *args )
1431 HANDLE handle = get_handle( &args );
1432 NTSTATUS status = get_ulong( &args );
1434 return NtTerminateJobObject( handle, status );
1438 /**********************************************************************
1439 * wow64_NtTestAlert
1441 NTSTATUS WINAPI wow64_NtTestAlert( UINT *args )
1443 return NtTestAlert();
1447 /**********************************************************************
1448 * wow64_NtTraceControl
1450 NTSTATUS WINAPI wow64_NtTraceControl( UINT *args )
1452 ULONG code = get_ulong( &args );
1453 void *inbuf = get_ptr( &args );
1454 ULONG inbuf_len = get_ulong( &args );
1455 void *outbuf = get_ptr( &args );
1456 ULONG outbuf_len = get_ulong( &args );
1457 ULONG *size = get_ptr( &args );
1459 return NtTraceControl( code, inbuf, inbuf_len, outbuf, outbuf_len, size );
1463 /**********************************************************************
1464 * wow64_NtWaitForDebugEvent
1466 NTSTATUS WINAPI wow64_NtWaitForDebugEvent( UINT *args )
1468 HANDLE handle = get_handle( &args );
1469 BOOLEAN alertable = get_ulong( &args );
1470 LARGE_INTEGER *timeout = get_ptr( &args );
1471 DBGUI_WAIT_STATE_CHANGE32 *state32 = get_ptr( &args );
1473 ULONG i;
1474 DBGUI_WAIT_STATE_CHANGE state;
1475 NTSTATUS status = NtWaitForDebugEvent( handle, alertable, timeout, &state );
1477 if (!status)
1479 state32->NewState = state.NewState;
1480 state32->AppClientId.UniqueProcess = HandleToULong( state.AppClientId.UniqueProcess );
1481 state32->AppClientId.UniqueThread = HandleToULong( state.AppClientId.UniqueThread );
1482 switch (state.NewState)
1484 #define COPY_ULONG(field) state32->StateInfo.field = state.StateInfo.field
1485 #define COPY_PTR(field) state32->StateInfo.field = PtrToUlong( state.StateInfo.field )
1486 case DbgCreateThreadStateChange:
1487 COPY_PTR( CreateThread.HandleToThread );
1488 COPY_PTR( CreateThread.NewThread.StartAddress );
1489 COPY_ULONG( CreateThread.NewThread.SubSystemKey );
1490 break;
1491 case DbgCreateProcessStateChange:
1492 COPY_PTR( CreateProcessInfo.HandleToProcess );
1493 COPY_PTR( CreateProcessInfo.HandleToThread );
1494 COPY_PTR( CreateProcessInfo.NewProcess.FileHandle );
1495 COPY_PTR( CreateProcessInfo.NewProcess.BaseOfImage );
1496 COPY_PTR( CreateProcessInfo.NewProcess.InitialThread.StartAddress );
1497 COPY_ULONG( CreateProcessInfo.NewProcess.InitialThread.SubSystemKey );
1498 COPY_ULONG( CreateProcessInfo.NewProcess.DebugInfoFileOffset );
1499 COPY_ULONG( CreateProcessInfo.NewProcess.DebugInfoSize );
1500 break;
1501 case DbgExitThreadStateChange:
1502 case DbgExitProcessStateChange:
1503 COPY_ULONG( ExitThread.ExitStatus );
1504 break;
1505 case DbgExceptionStateChange:
1506 case DbgBreakpointStateChange:
1507 case DbgSingleStepStateChange:
1508 COPY_ULONG( Exception.FirstChance );
1509 COPY_ULONG( Exception.ExceptionRecord.ExceptionCode );
1510 COPY_ULONG( Exception.ExceptionRecord.ExceptionFlags );
1511 COPY_ULONG( Exception.ExceptionRecord.NumberParameters );
1512 COPY_PTR( Exception.ExceptionRecord.ExceptionRecord );
1513 COPY_PTR( Exception.ExceptionRecord.ExceptionAddress );
1514 for (i = 0; i < state.StateInfo.Exception.ExceptionRecord.NumberParameters; i++)
1515 COPY_ULONG( Exception.ExceptionRecord.ExceptionInformation[i] );
1516 break;
1517 case DbgLoadDllStateChange:
1518 COPY_PTR( LoadDll.FileHandle );
1519 COPY_PTR( LoadDll.BaseOfDll );
1520 COPY_ULONG( LoadDll.DebugInfoFileOffset );
1521 COPY_ULONG( LoadDll.DebugInfoSize );
1522 COPY_PTR( LoadDll.NamePointer );
1523 break;
1524 case DbgUnloadDllStateChange:
1525 COPY_PTR( UnloadDll.BaseAddress );
1526 break;
1527 default:
1528 break;
1530 #undef COPY_ULONG
1531 #undef COPY_PTR
1533 return status;
1537 /**********************************************************************
1538 * wow64_NtWaitForKeyedEvent
1540 NTSTATUS WINAPI wow64_NtWaitForKeyedEvent( UINT *args )
1542 HANDLE handle = get_handle( &args );
1543 const void *key = get_ptr( &args );
1544 BOOLEAN alertable = get_ulong( &args );
1545 const LARGE_INTEGER *timeout = get_ptr( &args );
1547 return NtWaitForKeyedEvent( handle, key, alertable, timeout );
1551 /**********************************************************************
1552 * wow64_NtWaitForMultipleObjects
1554 NTSTATUS WINAPI wow64_NtWaitForMultipleObjects( UINT *args )
1556 DWORD count = get_ulong( &args );
1557 LONG *handles_ptr = get_ptr( &args );
1558 BOOLEAN wait_any = get_ulong( &args );
1559 BOOLEAN alertable = get_ulong( &args );
1560 const LARGE_INTEGER *timeout = get_ptr( &args );
1562 HANDLE handles[MAXIMUM_WAIT_OBJECTS];
1563 DWORD i;
1565 for (i = 0; i < count && i < MAXIMUM_WAIT_OBJECTS; i++) handles[i] = LongToHandle( handles_ptr[i] );
1566 return NtWaitForMultipleObjects( count, handles, wait_any, alertable, timeout );
1570 /**********************************************************************
1571 * wow64_NtWaitForSingleObject
1573 NTSTATUS WINAPI wow64_NtWaitForSingleObject( UINT *args )
1575 HANDLE handle = get_handle( &args );
1576 BOOLEAN alertable = get_ulong( &args );
1577 const LARGE_INTEGER *timeout = get_ptr( &args );
1579 return NtWaitForSingleObject( handle, alertable, timeout );
1583 /**********************************************************************
1584 * wow64_NtYieldExecution
1586 NTSTATUS WINAPI wow64_NtYieldExecution( UINT *args )
1588 return NtYieldExecution();