2 * ntoskrnl.exe implementation
4 * Copyright (C) 2007 Alexandre Julliard
5 * Copyright (C) 2010 Damjan Jovanovic
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/port.h"
27 #define NONAMELESSUNION
28 #define NONAMELESSSTRUCT
31 #define WIN32_NO_STATUS
36 #include "ddk/ntddk.h"
37 #include "wine/unicode.h"
38 #include "wine/server.h"
39 #include "wine/list.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(ntoskrnl);
43 WINE_DECLARE_DEBUG_CHANNEL(relay);
45 BOOLEAN KdDebuggerEnabled = FALSE;
47 extern LONG CALLBACK vectored_handler( EXCEPTION_POINTERS *ptrs );
49 KSYSTEM_TIME KeTickCount = { 0, 0, 0 };
51 typedef struct _KSERVICE_TABLE_DESCRIPTOR
57 } KSERVICE_TABLE_DESCRIPTOR, *PKSERVICE_TABLE_DESCRIPTOR;
59 KSERVICE_TABLE_DESCRIPTOR KeServiceDescriptorTable[4] = { { 0 } };
61 typedef void (WINAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)(HANDLE,HANDLE,BOOLEAN);
62 typedef void (WINAPI *PCREATE_THREAD_NOTIFY_ROUTINE)(HANDLE,HANDLE,BOOLEAN);
64 static struct list Irps = LIST_INIT(Irps);
72 /* tid of the thread running client request */
73 static DWORD request_thread;
75 /* pid/tid of the client thread */
76 static DWORD client_tid;
77 static DWORD client_pid;
80 #define DEFINE_FASTCALL1_ENTRYPOINT( name ) \
81 __ASM_STDCALL_FUNC( name, 4, \
85 "jmp " __ASM_NAME("__regs_") #name __ASM_STDCALL(4))
86 #define DEFINE_FASTCALL2_ENTRYPOINT( name ) \
87 __ASM_STDCALL_FUNC( name, 8, \
92 "jmp " __ASM_NAME("__regs_") #name __ASM_STDCALL(8))
93 #define DEFINE_FASTCALL3_ENTRYPOINT( name ) \
94 __ASM_STDCALL_FUNC( name, 12, \
99 "jmp " __ASM_NAME("__regs_") #name __ASM_STDCALL(12))
102 static inline LPCSTR debugstr_us( const UNICODE_STRING *us )
104 if (!us) return "<null>";
105 return debugstr_wn( us->Buffer, us->Length / sizeof(WCHAR) );
108 static HANDLE get_device_manager(void)
110 static HANDLE device_manager;
111 HANDLE handle = 0, ret = device_manager;
115 SERVER_START_REQ( create_device_manager )
117 req->access = SYNCHRONIZE;
119 if (!wine_server_call( req )) handle = wine_server_ptr_handle( reply->handle );
125 ERR( "failed to create the device manager\n" );
128 if (!(ret = InterlockedCompareExchangePointer( &device_manager, handle, 0 )))
131 NtClose( handle ); /* somebody beat us to it */
136 /* process an ioctl request for a given device */
137 static NTSTATUS process_ioctl( DEVICE_OBJECT *device, ULONG code, void *in_buff, ULONG in_size,
138 void *out_buff, ULONG *out_size )
142 IO_STACK_LOCATION irpsp;
143 PDRIVER_DISPATCH dispatch = device->DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL];
147 TRACE( "ioctl %x device %p in_size %u out_size %u\n", code, device, in_size, *out_size );
149 /* so we can spot things that we should initialize */
150 memset( &irp, 0x55, sizeof(irp) );
151 memset( &irpsp, 0x66, sizeof(irpsp) );
152 memset( &mdl, 0x77, sizeof(mdl) );
154 irp.RequestorMode = UserMode;
155 if ((code & 3) == METHOD_BUFFERED)
157 irp.AssociatedIrp.SystemBuffer = HeapAlloc( GetProcessHeap(), 0, max( in_size, *out_size ) );
158 if (!irp.AssociatedIrp.SystemBuffer)
159 return STATUS_NO_MEMORY;
160 memcpy( irp.AssociatedIrp.SystemBuffer, in_buff, in_size );
163 irp.AssociatedIrp.SystemBuffer = in_buff;
164 irp.UserBuffer = out_buff;
165 irp.MdlAddress = &mdl;
166 irp.Tail.Overlay.s.u2.CurrentStackLocation = &irpsp;
169 irpsp.MajorFunction = IRP_MJ_DEVICE_CONTROL;
170 irpsp.Parameters.DeviceIoControl.OutputBufferLength = *out_size;
171 irpsp.Parameters.DeviceIoControl.InputBufferLength = in_size;
172 irpsp.Parameters.DeviceIoControl.IoControlCode = code;
173 irpsp.Parameters.DeviceIoControl.Type3InputBuffer = in_buff;
174 irpsp.DeviceObject = device;
175 irpsp.CompletionRoutine = NULL;
179 mdl.StartVa = out_buff;
180 mdl.ByteCount = *out_size;
183 device->CurrentIrp = &irp;
185 KeQueryTickCount( &count ); /* update the global KeTickCount */
188 DPRINTF( "%04x:Call driver dispatch %p (device=%p,irp=%p)\n",
189 GetCurrentThreadId(), dispatch, device, &irp );
191 status = dispatch( device, &irp );
194 DPRINTF( "%04x:Ret driver dispatch %p (device=%p,irp=%p) retval=%08x\n",
195 GetCurrentThreadId(), dispatch, device, &irp, status );
197 *out_size = (irp.IoStatus.u.Status >= 0) ? irp.IoStatus.Information : 0;
198 if ((code & 3) == METHOD_BUFFERED)
200 if (out_buff) memcpy( out_buff, irp.AssociatedIrp.SystemBuffer, *out_size );
201 HeapFree( GetProcessHeap(), 0, irp.AssociatedIrp.SystemBuffer );
203 return irp.IoStatus.u.Status;
207 /***********************************************************************
208 * wine_ntoskrnl_main_loop (Not a Windows API)
210 NTSTATUS CDECL wine_ntoskrnl_main_loop( HANDLE stop_event )
212 HANDLE manager = get_device_manager();
213 obj_handle_t ioctl = 0;
214 NTSTATUS status = STATUS_SUCCESS;
216 void *in_buff, *out_buff = NULL;
217 DEVICE_OBJECT *device = NULL;
218 ULONG in_size = 4096, out_size = 0;
221 request_thread = GetCurrentThreadId();
223 if (!(in_buff = HeapAlloc( GetProcessHeap(), 0, in_size )))
225 ERR( "failed to allocate buffer\n" );
226 return STATUS_NO_MEMORY;
229 handles[0] = stop_event;
230 handles[1] = manager;
234 SERVER_START_REQ( get_next_device_request )
236 req->manager = wine_server_obj_handle( manager );
238 req->status = status;
239 wine_server_add_data( req, out_buff, out_size );
240 wine_server_set_reply( req, in_buff, in_size );
241 if (!(status = wine_server_call( req )))
245 device = wine_server_get_ptr( reply->user_ptr );
246 client_tid = reply->client_tid;
247 client_pid = reply->client_pid;
248 in_size = reply->in_size;
249 out_size = reply->out_size;
253 ioctl = 0; /* no previous ioctl */
255 in_size = reply->in_size;
263 HeapFree( GetProcessHeap(), 0, out_buff );
264 if (out_size) out_buff = HeapAlloc( GetProcessHeap(), 0, out_size );
265 else out_buff = NULL;
266 status = process_ioctl( device, code, in_buff, in_size, out_buff, &out_size );
268 case STATUS_BUFFER_OVERFLOW:
269 HeapFree( GetProcessHeap(), 0, in_buff );
270 in_buff = HeapAlloc( GetProcessHeap(), 0, in_size );
271 /* restart with larger buffer */
274 if (WaitForMultipleObjects( 2, handles, FALSE, INFINITE ) == WAIT_OBJECT_0)
276 HeapFree( GetProcessHeap(), 0, in_buff );
277 HeapFree( GetProcessHeap(), 0, out_buff );
278 return STATUS_SUCCESS;
286 /***********************************************************************
287 * IoAcquireCancelSpinLock (NTOSKRNL.EXE.@)
289 void WINAPI IoAcquireCancelSpinLock(PKIRQL irql)
291 FIXME("(%p): stub\n", irql);
295 /***********************************************************************
296 * IoReleaseCancelSpinLock (NTOSKRNL.EXE.@)
298 void WINAPI IoReleaseCancelSpinLock(PKIRQL irql)
300 FIXME("(%p): stub\n", irql);
304 /***********************************************************************
305 * IoAllocateDriverObjectExtension (NTOSKRNL.EXE.@)
307 NTSTATUS WINAPI IoAllocateDriverObjectExtension( PDRIVER_OBJECT DriverObject,
308 PVOID ClientIdentificationAddress,
309 ULONG DriverObjectExtensionSize,
310 PVOID *DriverObjectExtension )
312 FIXME( "stub: %p, %p, %u, %p\n", DriverObject, ClientIdentificationAddress,
313 DriverObjectExtensionSize, DriverObjectExtension );
314 return STATUS_NOT_IMPLEMENTED;
318 /***********************************************************************
319 * IoGetDriverObjectExtension (NTOSKRNL.EXE.@)
321 PVOID WINAPI IoGetDriverObjectExtension( PDRIVER_OBJECT DriverObject,
322 PVOID ClientIdentificationAddress )
324 FIXME( "stub: %p, %p\n", DriverObject, ClientIdentificationAddress );
329 /***********************************************************************
330 * IoInitializeIrp (NTOSKRNL.EXE.@)
332 void WINAPI IoInitializeIrp( IRP *irp, USHORT size, CCHAR stack_size )
334 TRACE( "%p, %u, %d\n", irp, size, stack_size );
336 RtlZeroMemory( irp, size );
338 irp->Type = IO_TYPE_IRP;
340 InitializeListHead( &irp->ThreadListEntry );
341 irp->StackCount = stack_size;
342 irp->CurrentLocation = stack_size + 1;
343 irp->Tail.Overlay.s.u2.CurrentStackLocation =
344 (PIO_STACK_LOCATION)(irp + 1) + stack_size;
348 /***********************************************************************
349 * IoInitializeTimer (NTOSKRNL.EXE.@)
351 NTSTATUS WINAPI IoInitializeTimer(PDEVICE_OBJECT DeviceObject,
352 PIO_TIMER_ROUTINE TimerRoutine,
355 FIXME( "stub: %p, %p, %p\n", DeviceObject, TimerRoutine, Context );
356 return STATUS_NOT_IMPLEMENTED;
360 /***********************************************************************
361 * IoStartTimer (NTOSKRNL.EXE.@)
363 void WINAPI IoStartTimer(PDEVICE_OBJECT DeviceObject)
365 FIXME( "stub: %p\n", DeviceObject );
369 /***********************************************************************
370 * IoAllocateIrp (NTOSKRNL.EXE.@)
372 PIRP WINAPI IoAllocateIrp( CCHAR stack_size, BOOLEAN charge_quota )
377 TRACE( "%d, %d\n", stack_size, charge_quota );
379 size = sizeof(IRP) + stack_size * sizeof(IO_STACK_LOCATION);
380 irp = ExAllocatePool( NonPagedPool, size );
383 IoInitializeIrp( irp, size, stack_size );
384 irp->AllocationFlags = IRP_ALLOCATED_FIXED_SIZE;
386 irp->AllocationFlags |= IRP_LOOKASIDE_ALLOCATION;
391 /***********************************************************************
392 * IoFreeIrp (NTOSKRNL.EXE.@)
394 void WINAPI IoFreeIrp( IRP *irp )
396 TRACE( "%p\n", irp );
402 /***********************************************************************
403 * IoAllocateErrorLogEntry (NTOSKRNL.EXE.@)
405 PVOID WINAPI IoAllocateErrorLogEntry( PVOID IoObject, UCHAR EntrySize )
407 FIXME( "stub: %p, %u\n", IoObject, EntrySize );
412 /***********************************************************************
413 * IoAllocateMdl (NTOSKRNL.EXE.@)
415 PMDL WINAPI IoAllocateMdl( PVOID VirtualAddress, ULONG Length, BOOLEAN SecondaryBuffer, BOOLEAN ChargeQuota, PIRP Irp )
418 ULONG_PTR address = (ULONG_PTR)VirtualAddress;
419 ULONG_PTR page_address;
420 SIZE_T nb_pages, mdl_size;
422 TRACE("(%p, %u, %i, %i, %p)\n", VirtualAddress, Length, SecondaryBuffer, ChargeQuota, Irp);
425 FIXME("Attaching the MDL to an IRP is not yet supported\n");
428 FIXME("Charge quota is not yet supported\n");
430 /* FIXME: We suppose that page size is 4096 */
431 page_address = address & ~(4096 - 1);
432 nb_pages = (((address + Length - 1) & ~(4096 - 1)) - page_address) / 4096 + 1;
434 mdl_size = sizeof(MDL) + nb_pages * sizeof(PVOID);
436 mdl = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mdl_size);
440 mdl->Size = mdl_size;
441 mdl->Process = IoGetCurrentProcess();
442 mdl->StartVa = (PVOID)page_address;
443 mdl->ByteCount = Length;
444 mdl->ByteOffset = address - page_address;
450 /***********************************************************************
451 * IoFreeMdl (NTOSKRNL.EXE.@)
453 VOID WINAPI IoFreeMdl(PMDL mdl)
455 FIXME("partial stub: %p\n", mdl);
457 HeapFree(GetProcessHeap(), 0, mdl);
461 /***********************************************************************
462 * IoAllocateWorkItem (NTOSKRNL.EXE.@)
464 PIO_WORKITEM WINAPI IoAllocateWorkItem( PDEVICE_OBJECT DeviceObject )
466 FIXME( "stub: %p\n", DeviceObject );
471 /***********************************************************************
472 * IoAttachDeviceToDeviceStack (NTOSKRNL.EXE.@)
474 PDEVICE_OBJECT WINAPI IoAttachDeviceToDeviceStack( DEVICE_OBJECT *source,
475 DEVICE_OBJECT *target )
477 TRACE( "%p, %p\n", source, target );
478 target->AttachedDevice = source;
479 source->StackSize = target->StackSize + 1;
484 /***********************************************************************
485 * IoBuildDeviceIoControlRequest (NTOSKRNL.EXE.@)
487 PIRP WINAPI IoBuildDeviceIoControlRequest( ULONG IoControlCode,
488 PDEVICE_OBJECT DeviceObject,
490 ULONG InputBufferLength,
492 ULONG OutputBufferLength,
493 BOOLEAN InternalDeviceIoControl,
495 PIO_STATUS_BLOCK IoStatusBlock )
498 PIO_STACK_LOCATION irpsp;
499 struct IrpInstance *instance;
501 TRACE( "%x, %p, %p, %u, %p, %u, %u, %p, %p\n",
502 IoControlCode, DeviceObject, InputBuffer, InputBufferLength,
503 OutputBuffer, OutputBufferLength, InternalDeviceIoControl,
504 Event, IoStatusBlock );
506 if (DeviceObject == NULL)
509 irp = IoAllocateIrp( DeviceObject->StackSize, FALSE );
513 instance = HeapAlloc( GetProcessHeap(), 0, sizeof(struct IrpInstance) );
514 if (instance == NULL)
520 list_add_tail( &Irps, &instance->entry );
522 irpsp = IoGetNextIrpStackLocation( irp );
523 irpsp->MajorFunction = InternalDeviceIoControl ?
524 IRP_MJ_INTERNAL_DEVICE_CONTROL : IRP_MJ_DEVICE_CONTROL;
525 irpsp->Parameters.DeviceIoControl.IoControlCode = IoControlCode;
526 irp->UserIosb = IoStatusBlock;
527 irp->UserEvent = Event;
533 /***********************************************************************
534 * IoCreateDriver (NTOSKRNL.EXE.@)
536 NTSTATUS WINAPI IoCreateDriver( UNICODE_STRING *name, PDRIVER_INITIALIZE init )
538 DRIVER_OBJECT *driver;
539 DRIVER_EXTENSION *extension;
542 TRACE("(%s, %p)\n", debugstr_us(name), init);
544 if (!(driver = RtlAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY,
545 sizeof(*driver) + sizeof(*extension) )))
546 return STATUS_NO_MEMORY;
548 if ((status = RtlDuplicateUnicodeString( 1, name, &driver->DriverName )))
550 RtlFreeHeap( GetProcessHeap(), 0, driver );
554 extension = (DRIVER_EXTENSION *)(driver + 1);
555 driver->Size = sizeof(*driver);
556 driver->DriverInit = init;
557 driver->DriverExtension = extension;
558 extension->DriverObject = driver;
559 extension->ServiceKeyName = driver->DriverName;
561 status = driver->DriverInit( driver, name );
565 RtlFreeUnicodeString( &driver->DriverName );
566 RtlFreeHeap( GetProcessHeap(), 0, driver );
572 /***********************************************************************
573 * IoDeleteDriver (NTOSKRNL.EXE.@)
575 void WINAPI IoDeleteDriver( DRIVER_OBJECT *driver )
577 TRACE("(%p)\n", driver);
579 RtlFreeUnicodeString( &driver->DriverName );
580 RtlFreeHeap( GetProcessHeap(), 0, driver );
584 /***********************************************************************
585 * IoCreateDevice (NTOSKRNL.EXE.@)
587 NTSTATUS WINAPI IoCreateDevice( DRIVER_OBJECT *driver, ULONG ext_size,
588 UNICODE_STRING *name, DEVICE_TYPE type,
589 ULONG characteristics, BOOLEAN exclusive,
590 DEVICE_OBJECT **ret_device )
593 DEVICE_OBJECT *device;
595 HANDLE manager = get_device_manager();
597 TRACE( "(%p, %u, %s, %u, %x, %u, %p)\n",
598 driver, ext_size, debugstr_us(name), type, characteristics, exclusive, ret_device );
600 if (!(device = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*device) + ext_size )))
601 return STATUS_NO_MEMORY;
603 SERVER_START_REQ( create_device )
608 req->manager = wine_server_obj_handle( manager );
609 req->user_ptr = wine_server_client_ptr( device );
610 if (name) wine_server_add_data( req, name->Buffer, name->Length );
611 if (!(status = wine_server_call( req ))) handle = wine_server_ptr_handle( reply->handle );
615 if (status == STATUS_SUCCESS)
617 device->DriverObject = driver;
618 device->DeviceExtension = device + 1;
619 device->DeviceType = type;
620 device->StackSize = 1;
621 device->Reserved = handle;
623 device->NextDevice = driver->DeviceObject;
624 driver->DeviceObject = device;
626 *ret_device = device;
628 else HeapFree( GetProcessHeap(), 0, device );
634 /***********************************************************************
635 * IoDeleteDevice (NTOSKRNL.EXE.@)
637 void WINAPI IoDeleteDevice( DEVICE_OBJECT *device )
641 TRACE( "%p\n", device );
643 SERVER_START_REQ( delete_device )
645 req->handle = wine_server_obj_handle( device->Reserved );
646 status = wine_server_call( req );
650 if (status == STATUS_SUCCESS)
652 DEVICE_OBJECT **prev = &device->DriverObject->DeviceObject;
653 while (*prev && *prev != device) prev = &(*prev)->NextDevice;
654 if (*prev) *prev = (*prev)->NextDevice;
655 NtClose( device->Reserved );
656 HeapFree( GetProcessHeap(), 0, device );
661 /***********************************************************************
662 * IoCreateSymbolicLink (NTOSKRNL.EXE.@)
664 NTSTATUS WINAPI IoCreateSymbolicLink( UNICODE_STRING *name, UNICODE_STRING *target )
667 OBJECT_ATTRIBUTES attr;
669 attr.Length = sizeof(attr);
670 attr.RootDirectory = 0;
671 attr.ObjectName = name;
672 attr.Attributes = OBJ_CASE_INSENSITIVE | OBJ_OPENIF;
673 attr.SecurityDescriptor = NULL;
674 attr.SecurityQualityOfService = NULL;
676 TRACE( "%s -> %s\n", debugstr_us(name), debugstr_us(target) );
677 /* FIXME: store handle somewhere */
678 return NtCreateSymbolicLinkObject( &handle, SYMBOLIC_LINK_ALL_ACCESS, &attr, target );
682 /***********************************************************************
683 * IoDeleteSymbolicLink (NTOSKRNL.EXE.@)
685 NTSTATUS WINAPI IoDeleteSymbolicLink( UNICODE_STRING *name )
688 OBJECT_ATTRIBUTES attr;
691 attr.Length = sizeof(attr);
692 attr.RootDirectory = 0;
693 attr.ObjectName = name;
694 attr.Attributes = OBJ_CASE_INSENSITIVE;
695 attr.SecurityDescriptor = NULL;
696 attr.SecurityQualityOfService = NULL;
698 if (!(status = NtOpenSymbolicLinkObject( &handle, 0, &attr )))
700 SERVER_START_REQ( unlink_object )
702 req->handle = wine_server_obj_handle( handle );
703 status = wine_server_call( req );
712 /***********************************************************************
713 * IoGetDeviceInterfaces (NTOSKRNL.EXE.@)
715 NTSTATUS WINAPI IoGetDeviceInterfaces( CONST GUID *InterfaceClassGuid,
716 PDEVICE_OBJECT PhysicalDeviceObject,
717 ULONG Flags, PWSTR *SymbolicLinkList )
719 FIXME( "stub: %s %p %x %p\n", debugstr_guid(InterfaceClassGuid),
720 PhysicalDeviceObject, Flags, SymbolicLinkList );
721 return STATUS_NOT_IMPLEMENTED;
725 /***********************************************************************
726 * IoGetDeviceObjectPointer (NTOSKRNL.EXE.@)
728 NTSTATUS WINAPI IoGetDeviceObjectPointer( UNICODE_STRING *name, ACCESS_MASK access, PFILE_OBJECT *file, PDEVICE_OBJECT *device )
730 FIXME( "stub: %s %x %p %p\n", debugstr_us(name), access, file, device );
732 return STATUS_NOT_IMPLEMENTED;
736 /***********************************************************************
737 * IoGetDeviceProperty (NTOSKRNL.EXE.@)
739 NTSTATUS WINAPI IoGetDeviceProperty( DEVICE_OBJECT *device, DEVICE_REGISTRY_PROPERTY device_property,
740 ULONG buffer_length, PVOID property_buffer, PULONG result_length )
742 FIXME( "%p %d %u %p %p: stub\n", device, device_property, buffer_length,
743 property_buffer, result_length );
744 return STATUS_NOT_IMPLEMENTED;
748 /***********************************************************************
749 * IoCallDriver (NTOSKRNL.EXE.@)
751 NTSTATUS WINAPI IoCallDriver( DEVICE_OBJECT *device, IRP *irp )
753 PDRIVER_DISPATCH dispatch;
754 IO_STACK_LOCATION *irpsp;
757 TRACE( "%p %p\n", device, irp );
759 --irp->CurrentLocation;
760 irpsp = --irp->Tail.Overlay.s.u2.CurrentStackLocation;
761 dispatch = device->DriverObject->MajorFunction[irpsp->MajorFunction];
762 status = dispatch( device, irp );
768 /***********************************************************************
769 * IofCallDriver (NTOSKRNL.EXE.@)
771 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
772 DEFINE_FASTCALL2_ENTRYPOINT( IofCallDriver )
773 NTSTATUS WINAPI __regs_IofCallDriver( DEVICE_OBJECT *device, IRP *irp )
775 NTSTATUS WINAPI IofCallDriver( DEVICE_OBJECT *device, IRP *irp )
778 TRACE( "%p %p\n", device, irp );
779 return IoCallDriver( device, irp );
783 /***********************************************************************
784 * IoGetRelatedDeviceObject (NTOSKRNL.EXE.@)
786 PDEVICE_OBJECT WINAPI IoGetRelatedDeviceObject( PFILE_OBJECT obj )
788 FIXME( "stub: %p\n", obj );
792 static CONFIGURATION_INFORMATION configuration_information;
794 /***********************************************************************
795 * IoGetConfigurationInformation (NTOSKRNL.EXE.@)
797 PCONFIGURATION_INFORMATION WINAPI IoGetConfigurationInformation(void)
799 FIXME( "partial stub\n" );
800 /* FIXME: return actual devices on system */
801 return &configuration_information;
805 /***********************************************************************
806 * IoIsWdmVersionAvailable (NTOSKRNL.EXE.@)
808 NTSTATUS WINAPI IoIsWdmVersionAvailable(UCHAR MajorVersion, UCHAR MinorVersion)
814 TRACE( "%d, 0x%X\n", MajorVersion, MinorVersion );
816 version = GetVersion();
817 major = LOBYTE(version);
818 minor = HIBYTE(LOWORD(version));
820 if (MajorVersion == 6 && MinorVersion == 0)
822 /* Windows Vista, Windows Server 2008, Windows 7 */
824 else if (MajorVersion == 1)
826 if (MinorVersion == 0x30)
828 /* Windows server 2003 */
832 else if (MinorVersion == 0x20)
838 else if (MinorVersion == 0x10)
844 else if (MinorVersion == 0x05)
850 else if (MinorVersion == 0x00)
858 FIXME( "unknown major %d minor 0x%X\n", MajorVersion, MinorVersion );
864 FIXME( "unknown major %d minor 0x%X\n", MajorVersion, MinorVersion );
867 return major > MajorVersion || (major == MajorVersion && minor >= MinorVersion);
871 /***********************************************************************
872 * IoQueryDeviceDescription (NTOSKRNL.EXE.@)
874 NTSTATUS WINAPI IoQueryDeviceDescription(PINTERFACE_TYPE itype, PULONG bus, PCONFIGURATION_TYPE ctype,
875 PULONG cnum, PCONFIGURATION_TYPE ptype, PULONG pnum,
876 PIO_QUERY_DEVICE_ROUTINE callout, PVOID context)
878 FIXME( "(%p %p %p %p %p %p %p %p)\n", itype, bus, ctype, cnum, ptype, pnum, callout, context);
879 return STATUS_NOT_IMPLEMENTED;
883 /***********************************************************************
884 * IoRegisterDriverReinitialization (NTOSKRNL.EXE.@)
886 void WINAPI IoRegisterDriverReinitialization( PDRIVER_OBJECT obj, PDRIVER_REINITIALIZE reinit, PVOID context )
888 FIXME( "stub: %p %p %p\n", obj, reinit, context );
892 /***********************************************************************
893 * IoRegisterShutdownNotification (NTOSKRNL.EXE.@)
895 NTSTATUS WINAPI IoRegisterShutdownNotification( PDEVICE_OBJECT obj )
897 FIXME( "stub: %p\n", obj );
898 return STATUS_SUCCESS;
902 /***********************************************************************
903 * IoUnregisterShutdownNotification (NTOSKRNL.EXE.@)
905 VOID WINAPI IoUnregisterShutdownNotification( PDEVICE_OBJECT obj )
907 FIXME( "stub: %p\n", obj );
911 /***********************************************************************
912 * IoReportResourceUsage (NTOSKRNL.EXE.@)
914 NTSTATUS WINAPI IoReportResourceUsage(PUNICODE_STRING name, PDRIVER_OBJECT drv_obj, PCM_RESOURCE_LIST drv_list,
915 ULONG drv_size, PDRIVER_OBJECT dev_obj, PCM_RESOURCE_LIST dev_list,
916 ULONG dev_size, BOOLEAN overwrite, PBOOLEAN detected)
918 FIXME("(%s %p %p %u %p %p %u %d %p) stub\n", debugstr_w(name? name->Buffer : NULL),
919 drv_obj, drv_list, drv_size, dev_obj, dev_list, dev_size, overwrite, detected);
920 return STATUS_NOT_IMPLEMENTED;
924 /***********************************************************************
925 * IoCompleteRequest (NTOSKRNL.EXE.@)
927 VOID WINAPI IoCompleteRequest( IRP *irp, UCHAR priority_boost )
929 IO_STACK_LOCATION *irpsp;
930 PIO_COMPLETION_ROUTINE routine;
931 IO_STATUS_BLOCK *iosb;
932 struct IrpInstance *instance;
933 NTSTATUS status, stat;
936 TRACE( "%p %u\n", irp, priority_boost );
938 iosb = irp->UserIosb;
939 status = irp->IoStatus.u.Status;
940 while (irp->CurrentLocation <= irp->StackCount)
942 irpsp = irp->Tail.Overlay.s.u2.CurrentStackLocation;
943 routine = irpsp->CompletionRoutine;
945 /* FIXME: add SL_INVOKE_ON_CANCEL support */
948 if ((irpsp->Control & SL_INVOKE_ON_SUCCESS) && STATUS_SUCCESS == status)
950 if ((irpsp->Control & SL_INVOKE_ON_ERROR) && STATUS_SUCCESS != status)
953 ++irp->CurrentLocation;
954 ++irp->Tail.Overlay.s.u2.CurrentStackLocation;
957 TRACE( "calling %p( %p, %p, %p )\n", routine,
958 irpsp->DeviceObject, irp, irpsp->Context );
959 stat = routine( irpsp->DeviceObject, irp, irpsp->Context );
960 TRACE( "CompletionRoutine returned %x\n", stat );
961 if (STATUS_MORE_PROCESSING_REQUIRED == stat)
965 if (iosb && STATUS_SUCCESS == status)
967 iosb->u.Status = irp->IoStatus.u.Status;
968 iosb->Information = irp->IoStatus.Information;
970 LIST_FOR_EACH_ENTRY( instance, &Irps, struct IrpInstance, entry )
972 if (instance->irp == irp)
974 list_remove( &instance->entry );
975 HeapFree( GetProcessHeap(), 0, instance );
983 /***********************************************************************
984 * IofCompleteRequest (NTOSKRNL.EXE.@)
986 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
987 DEFINE_FASTCALL2_ENTRYPOINT( IofCompleteRequest )
988 void WINAPI __regs_IofCompleteRequest( IRP *irp, UCHAR priority_boost )
990 void WINAPI IofCompleteRequest( IRP *irp, UCHAR priority_boost )
993 TRACE( "%p %u\n", irp, priority_boost );
994 IoCompleteRequest( irp, priority_boost );
998 /***********************************************************************
999 * InterlockedCompareExchange (NTOSKRNL.EXE.@)
1001 #ifdef DEFINE_FASTCALL3_ENTRYPOINT
1002 DEFINE_FASTCALL3_ENTRYPOINT( NTOSKRNL_InterlockedCompareExchange )
1003 LONG WINAPI __regs_NTOSKRNL_InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare )
1005 LONG WINAPI NTOSKRNL_InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare )
1008 return InterlockedCompareExchange( dest, xchg, compare );
1012 /***********************************************************************
1013 * InterlockedDecrement (NTOSKRNL.EXE.@)
1015 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
1016 DEFINE_FASTCALL1_ENTRYPOINT( NTOSKRNL_InterlockedDecrement )
1017 LONG WINAPI __regs_NTOSKRNL_InterlockedDecrement( LONG volatile *dest )
1019 LONG WINAPI NTOSKRNL_InterlockedDecrement( LONG volatile *dest )
1022 return InterlockedDecrement( dest );
1026 /***********************************************************************
1027 * InterlockedExchange (NTOSKRNL.EXE.@)
1029 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
1030 DEFINE_FASTCALL2_ENTRYPOINT( NTOSKRNL_InterlockedExchange )
1031 LONG WINAPI __regs_NTOSKRNL_InterlockedExchange( LONG volatile *dest, LONG val )
1033 LONG WINAPI NTOSKRNL_InterlockedExchange( LONG volatile *dest, LONG val )
1036 return InterlockedExchange( dest, val );
1040 /***********************************************************************
1041 * InterlockedExchangeAdd (NTOSKRNL.EXE.@)
1043 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
1044 DEFINE_FASTCALL2_ENTRYPOINT( NTOSKRNL_InterlockedExchangeAdd )
1045 LONG WINAPI __regs_NTOSKRNL_InterlockedExchangeAdd( LONG volatile *dest, LONG incr )
1047 LONG WINAPI NTOSKRNL_InterlockedExchangeAdd( LONG volatile *dest, LONG incr )
1050 return InterlockedExchangeAdd( dest, incr );
1054 /***********************************************************************
1055 * InterlockedIncrement (NTOSKRNL.EXE.@)
1057 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
1058 DEFINE_FASTCALL1_ENTRYPOINT( NTOSKRNL_InterlockedIncrement )
1059 LONG WINAPI __regs_NTOSKRNL_InterlockedIncrement( LONG volatile *dest )
1061 LONG WINAPI NTOSKRNL_InterlockedIncrement( LONG volatile *dest )
1064 return InterlockedIncrement( dest );
1068 /***********************************************************************
1069 * ExAllocatePool (NTOSKRNL.EXE.@)
1071 PVOID WINAPI ExAllocatePool( POOL_TYPE type, SIZE_T size )
1073 return ExAllocatePoolWithTag( type, size, 0 );
1077 /***********************************************************************
1078 * ExAllocatePoolWithQuota (NTOSKRNL.EXE.@)
1080 PVOID WINAPI ExAllocatePoolWithQuota( POOL_TYPE type, SIZE_T size )
1082 return ExAllocatePoolWithTag( type, size, 0 );
1086 /***********************************************************************
1087 * ExAllocatePoolWithTag (NTOSKRNL.EXE.@)
1089 PVOID WINAPI ExAllocatePoolWithTag( POOL_TYPE type, SIZE_T size, ULONG tag )
1091 /* FIXME: handle page alignment constraints */
1092 void *ret = HeapAlloc( GetProcessHeap(), 0, size );
1093 TRACE( "%lu pool %u -> %p\n", size, type, ret );
1098 /***********************************************************************
1099 * ExAllocatePoolWithQuotaTag (NTOSKRNL.EXE.@)
1101 PVOID WINAPI ExAllocatePoolWithQuotaTag( POOL_TYPE type, SIZE_T size, ULONG tag )
1103 return ExAllocatePoolWithTag( type, size, tag );
1107 /***********************************************************************
1108 * ExCreateCallback (NTOSKRNL.EXE.@)
1110 NTSTATUS WINAPI ExCreateCallback(PCALLBACK_OBJECT *obj, POBJECT_ATTRIBUTES attr,
1111 BOOLEAN create, BOOLEAN allow_multiple)
1113 FIXME("(%p, %p, %u, %u): stub\n", obj, attr, create, allow_multiple);
1115 return STATUS_NOT_IMPLEMENTED;
1119 /***********************************************************************
1120 * ExFreePool (NTOSKRNL.EXE.@)
1122 void WINAPI ExFreePool( void *ptr )
1124 ExFreePoolWithTag( ptr, 0 );
1128 /***********************************************************************
1129 * ExFreePoolWithTag (NTOSKRNL.EXE.@)
1131 void WINAPI ExFreePoolWithTag( void *ptr, ULONG tag )
1133 TRACE( "%p\n", ptr );
1134 HeapFree( GetProcessHeap(), 0, ptr );
1138 /***********************************************************************
1139 * ExInitializeResourceLite (NTOSKRNL.EXE.@)
1141 NTSTATUS WINAPI ExInitializeResourceLite(PERESOURCE Resource)
1143 FIXME( "stub: %p\n", Resource );
1144 return STATUS_NOT_IMPLEMENTED;
1148 /***********************************************************************
1149 * ExInitializeNPagedLookasideList (NTOSKRNL.EXE.@)
1151 void WINAPI ExInitializeNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside,
1152 PALLOCATE_FUNCTION Allocate,
1153 PFREE_FUNCTION Free,
1159 FIXME( "stub: %p, %p, %p, %u, %lu, %u, %u\n", Lookaside, Allocate, Free, Flags, Size, Tag, Depth );
1162 /***********************************************************************
1163 * ExInitializePagedLookasideList (NTOSKRNL.EXE.@)
1165 void WINAPI ExInitializePagedLookasideList(PPAGED_LOOKASIDE_LIST Lookaside,
1166 PALLOCATE_FUNCTION Allocate,
1167 PFREE_FUNCTION Free,
1173 FIXME( "stub: %p, %p, %p, %u, %lu, %u, %u\n", Lookaside, Allocate, Free, Flags, Size, Tag, Depth );
1176 /***********************************************************************
1177 * ExInitializeZone (NTOSKRNL.EXE.@)
1179 NTSTATUS WINAPI ExInitializeZone(PZONE_HEADER Zone,
1181 PVOID InitialSegment,
1182 ULONG InitialSegmentSize)
1184 FIXME( "stub: %p, %u, %p, %u\n", Zone, BlockSize, InitialSegment, InitialSegmentSize );
1185 return STATUS_NOT_IMPLEMENTED;
1188 /***********************************************************************
1189 * FsRtlRegisterUncProvider (NTOSKRNL.EXE.@)
1191 NTSTATUS WINAPI FsRtlRegisterUncProvider(PHANDLE MupHandle, PUNICODE_STRING RedirDevName,
1192 BOOLEAN MailslotsSupported)
1194 FIXME("(%p %p %d): stub\n", MupHandle, RedirDevName, MailslotsSupported);
1195 return STATUS_NOT_IMPLEMENTED;
1198 /***********************************************************************
1199 * IoGetCurrentProcess / PsGetCurrentProcess (NTOSKRNL.EXE.@)
1201 PEPROCESS WINAPI IoGetCurrentProcess(void)
1207 /***********************************************************************
1208 * KeGetCurrentThread / PsGetCurrentThread (NTOSKRNL.EXE.@)
1210 PRKTHREAD WINAPI KeGetCurrentThread(void)
1216 /***********************************************************************
1217 * KeInitializeEvent (NTOSKRNL.EXE.@)
1219 void WINAPI KeInitializeEvent( PRKEVENT Event, EVENT_TYPE Type, BOOLEAN State )
1221 FIXME( "stub: %p %d %d\n", Event, Type, State );
1225 /***********************************************************************
1226 * KeInitializeMutex (NTOSKRNL.EXE.@)
1228 void WINAPI KeInitializeMutex(PRKMUTEX Mutex, ULONG Level)
1230 FIXME( "stub: %p, %u\n", Mutex, Level );
1234 /***********************************************************************
1235 * KeWaitForMutexObject (NTOSKRNL.EXE.@)
1237 NTSTATUS WINAPI KeWaitForMutexObject(PRKMUTEX Mutex, KWAIT_REASON WaitReason, KPROCESSOR_MODE WaitMode,
1238 BOOLEAN Alertable, PLARGE_INTEGER Timeout)
1240 FIXME( "stub: %p, %d, %d, %d, %p\n", Mutex, WaitReason, WaitMode, Alertable, Timeout );
1241 return STATUS_NOT_IMPLEMENTED;
1245 /***********************************************************************
1246 * KeReleaseMutex (NTOSKRNL.EXE.@)
1248 LONG WINAPI KeReleaseMutex(PRKMUTEX Mutex, BOOLEAN Wait)
1250 FIXME( "stub: %p, %d\n", Mutex, Wait );
1251 return STATUS_NOT_IMPLEMENTED;
1255 /***********************************************************************
1256 * KeInitializeSemaphore (NTOSKRNL.EXE.@)
1258 void WINAPI KeInitializeSemaphore( PRKSEMAPHORE Semaphore, LONG Count, LONG Limit )
1260 FIXME( "(%p %d %d) stub\n", Semaphore , Count, Limit );
1264 /***********************************************************************
1265 * KeInitializeSpinLock (NTOSKRNL.EXE.@)
1267 void WINAPI KeInitializeSpinLock( PKSPIN_LOCK SpinLock )
1269 FIXME( "stub: %p\n", SpinLock );
1273 /***********************************************************************
1274 * KeInitializeTimerEx (NTOSKRNL.EXE.@)
1276 void WINAPI KeInitializeTimerEx( PKTIMER Timer, TIMER_TYPE Type )
1278 FIXME( "stub: %p %d\n", Timer, Type );
1282 /***********************************************************************
1283 * KeInitializeTimer (NTOSKRNL.EXE.@)
1285 void WINAPI KeInitializeTimer( PKTIMER Timer )
1287 KeInitializeTimerEx(Timer, NotificationTimer);
1291 /**********************************************************************
1292 * KeQueryActiveProcessors (NTOSKRNL.EXE.@)
1294 * Return the active Processors as bitmask
1297 * active Processors as bitmask
1300 KAFFINITY WINAPI KeQueryActiveProcessors( void )
1302 DWORD_PTR AffinityMask;
1304 GetProcessAffinityMask( GetCurrentProcess(), &AffinityMask, NULL);
1305 return AffinityMask;
1309 /**********************************************************************
1310 * KeQueryInterruptTime (NTOSKRNL.EXE.@)
1312 * Return the interrupt time count
1315 ULONGLONG WINAPI KeQueryInterruptTime( void )
1317 LARGE_INTEGER totaltime;
1319 KeQueryTickCount(&totaltime);
1320 return totaltime.QuadPart;
1324 /***********************************************************************
1325 * KeQuerySystemTime (NTOSKRNL.EXE.@)
1327 void WINAPI KeQuerySystemTime( LARGE_INTEGER *time )
1329 NtQuerySystemTime( time );
1333 /***********************************************************************
1334 * KeQueryTickCount (NTOSKRNL.EXE.@)
1336 void WINAPI KeQueryTickCount( LARGE_INTEGER *count )
1338 count->QuadPart = NtGetTickCount();
1339 /* update the global variable too */
1340 KeTickCount.LowPart = count->u.LowPart;
1341 KeTickCount.High1Time = count->u.HighPart;
1342 KeTickCount.High2Time = count->u.HighPart;
1346 /***********************************************************************
1347 * KeReleaseSemaphore (NTOSKRNL.EXE.@)
1349 LONG WINAPI KeReleaseSemaphore( PRKSEMAPHORE Semaphore, KPRIORITY Increment,
1350 LONG Adjustment, BOOLEAN Wait )
1352 FIXME("(%p %d %d %d) stub\n", Semaphore, Increment, Adjustment, Wait );
1357 /***********************************************************************
1358 * KeQueryTimeIncrement (NTOSKRNL.EXE.@)
1360 ULONG WINAPI KeQueryTimeIncrement(void)
1366 /***********************************************************************
1367 * KeResetEvent (NTOSKRNL.EXE.@)
1369 LONG WINAPI KeResetEvent( PRKEVENT Event )
1371 FIXME("(%p): stub\n", Event);
1376 /***********************************************************************
1377 * KeSetEvent (NTOSKRNL.EXE.@)
1379 LONG WINAPI KeSetEvent( PRKEVENT Event, KPRIORITY Increment, BOOLEAN Wait )
1381 FIXME("(%p, %d, %d): stub\n", Event, Increment, Wait);
1386 /***********************************************************************
1387 * KeSetPriorityThread (NTOSKRNL.EXE.@)
1389 KPRIORITY WINAPI KeSetPriorityThread( PKTHREAD Thread, KPRIORITY Priority )
1391 FIXME("(%p %d)\n", Thread, Priority);
1396 /***********************************************************************
1397 * KeWaitForSingleObject (NTOSKRNL.EXE.@)
1399 NTSTATUS WINAPI KeWaitForSingleObject(PVOID Object,
1400 KWAIT_REASON WaitReason,
1401 KPROCESSOR_MODE WaitMode,
1403 PLARGE_INTEGER Timeout)
1405 FIXME( "stub: %p, %d, %d, %d, %p\n", Object, WaitReason, WaitMode, Alertable, Timeout );
1406 return STATUS_NOT_IMPLEMENTED;
1409 /***********************************************************************
1410 * IoRegisterFileSystem (NTOSKRNL.EXE.@)
1412 VOID WINAPI IoRegisterFileSystem(PDEVICE_OBJECT DeviceObject)
1414 FIXME("(%p): stub\n", DeviceObject);
1417 /***********************************************************************
1418 * IoUnregisterFileSystem (NTOSKRNL.EXE.@)
1420 VOID WINAPI IoUnregisterFileSystem(PDEVICE_OBJECT DeviceObject)
1422 FIXME("(%p): stub\n", DeviceObject);
1425 /***********************************************************************
1426 * MmAllocateNonCachedMemory (NTOSKRNL.EXE.@)
1428 PVOID WINAPI MmAllocateNonCachedMemory( SIZE_T size )
1430 TRACE( "%lu\n", size );
1431 return VirtualAlloc( NULL, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE|PAGE_NOCACHE );
1434 /***********************************************************************
1435 * MmAllocateContiguousMemory (NTOSKRNL.EXE.@)
1437 PVOID WINAPI MmAllocateContiguousMemory( SIZE_T size, PHYSICAL_ADDRESS highest_valid_address )
1439 FIXME( "%lu, %s stub\n", size, wine_dbgstr_longlong(highest_valid_address.QuadPart) );
1443 /***********************************************************************
1444 * MmAllocateContiguousMemorySpecifyCache (NTOSKRNL.EXE.@)
1446 PVOID WINAPI MmAllocateContiguousMemorySpecifyCache( SIZE_T size,
1447 PHYSICAL_ADDRESS lowest_valid_address,
1448 PHYSICAL_ADDRESS highest_valid_address,
1449 PHYSICAL_ADDRESS BoundaryAddressMultiple,
1450 MEMORY_CACHING_TYPE CacheType )
1456 /***********************************************************************
1457 * MmAllocatePagesForMdl (NTOSKRNL.EXE.@)
1459 PMDL WINAPI MmAllocatePagesForMdl(PHYSICAL_ADDRESS lowaddress, PHYSICAL_ADDRESS highaddress,
1460 PHYSICAL_ADDRESS skipbytes, SIZE_T size)
1462 FIXME("%s %s %s %lu: stub\n", wine_dbgstr_longlong(lowaddress.QuadPart), wine_dbgstr_longlong(highaddress.QuadPart),
1463 wine_dbgstr_longlong(skipbytes.QuadPart), size);
1467 /***********************************************************************
1468 * MmFreeNonCachedMemory (NTOSKRNL.EXE.@)
1470 void WINAPI MmFreeNonCachedMemory( void *addr, SIZE_T size )
1472 TRACE( "%p %lu\n", addr, size );
1473 VirtualFree( addr, 0, MEM_RELEASE );
1476 /***********************************************************************
1477 * MmIsAddressValid (NTOSKRNL.EXE.@)
1479 * Check if the process can access the virtual address without a pagefault
1482 * VirtualAddress [I] Address to check
1486 * Success: TRUE (Accessing the Address works without a Pagefault)
1489 BOOLEAN WINAPI MmIsAddressValid(PVOID VirtualAddress)
1491 TRACE("(%p)\n", VirtualAddress);
1492 return !IsBadWritePtr(VirtualAddress, 1);
1495 /***********************************************************************
1496 * MmMapIoSpace (NTOSKRNL.EXE.@)
1498 PVOID WINAPI MmMapIoSpace( PHYSICAL_ADDRESS PhysicalAddress, DWORD NumberOfBytes, DWORD CacheType )
1500 FIXME( "stub: 0x%08x%08x, %d, %d\n", PhysicalAddress.u.HighPart, PhysicalAddress.u.LowPart, NumberOfBytes, CacheType );
1505 /***********************************************************************
1506 * MmMapLockedPagesSpecifyCache (NTOSKRNL.EXE.@)
1508 PVOID WINAPI MmMapLockedPagesSpecifyCache(PMDLX MemoryDescriptorList, KPROCESSOR_MODE AccessMode, MEMORY_CACHING_TYPE CacheType,
1509 PVOID BaseAddress, ULONG BugCheckOnFailure, MM_PAGE_PRIORITY Priority)
1511 FIXME("(%p, %u, %u, %p, %u, %u): stub\n", MemoryDescriptorList, AccessMode, CacheType, BaseAddress, BugCheckOnFailure, Priority);
1517 /***********************************************************************
1518 * MmPageEntireDriver (NTOSKRNL.EXE.@)
1520 PVOID WINAPI MmPageEntireDriver(PVOID AddrInSection)
1522 TRACE("%p\n", AddrInSection);
1523 return AddrInSection;
1527 /***********************************************************************
1528 * MmProbeAndLockPages (NTOSKRNL.EXE.@)
1530 void WINAPI MmProbeAndLockPages(PMDLX MemoryDescriptorList, KPROCESSOR_MODE AccessMode, LOCK_OPERATION Operation)
1532 FIXME("(%p, %u, %u): stub\n", MemoryDescriptorList, AccessMode, Operation);
1536 /***********************************************************************
1537 * MmResetDriverPaging (NTOSKRNL.EXE.@)
1539 void WINAPI MmResetDriverPaging(PVOID AddrInSection)
1541 TRACE("%p\n", AddrInSection);
1545 /***********************************************************************
1546 * MmUnlockPages (NTOSKRNL.EXE.@)
1548 void WINAPI MmUnlockPages(PMDLX MemoryDescriptorList)
1550 FIXME("(%p): stub\n", MemoryDescriptorList);
1554 /***********************************************************************
1555 * MmUnmapIoSpace (NTOSKRNL.EXE.@)
1557 VOID WINAPI MmUnmapIoSpace( PVOID BaseAddress, SIZE_T NumberOfBytes )
1559 FIXME( "stub: %p, %lu\n", BaseAddress, NumberOfBytes );
1562 /***********************************************************************
1563 * ObfReferenceObject (NTOSKRNL.EXE.@)
1565 VOID WINAPI ObfReferenceObject(PVOID Object)
1567 FIXME("(%p): stub\n", Object);
1570 /***********************************************************************
1571 * ObReferenceObjectByHandle (NTOSKRNL.EXE.@)
1573 NTSTATUS WINAPI ObReferenceObjectByHandle( HANDLE obj, ACCESS_MASK access,
1575 KPROCESSOR_MODE mode, PVOID* ptr,
1576 POBJECT_HANDLE_INFORMATION info)
1578 FIXME( "stub: %p %x %p %d %p %p\n", obj, access, type, mode, ptr, info);
1579 return STATUS_NOT_IMPLEMENTED;
1582 /***********************************************************************
1583 * ObReferenceObjectByName (NTOSKRNL.EXE.@)
1585 NTSTATUS WINAPI ObReferenceObjectByName( UNICODE_STRING *ObjectName,
1587 ACCESS_STATE *AccessState,
1588 ACCESS_MASK DesiredAccess,
1589 POBJECT_TYPE ObjectType,
1590 KPROCESSOR_MODE AccessMode,
1595 return STATUS_NOT_IMPLEMENTED;
1598 /***********************************************************************
1599 * ObfDereferenceObject (NTOSKRNL.EXE.@)
1601 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
1602 DEFINE_FASTCALL1_ENTRYPOINT( ObfDereferenceObject )
1603 void WINAPI __regs_ObfDereferenceObject( VOID *obj )
1605 void WINAPI ObfDereferenceObject( VOID *obj )
1608 FIXME( "stub: %p\n", obj );
1612 /***********************************************************************
1613 * PsCreateSystemThread (NTOSKRNL.EXE.@)
1615 NTSTATUS WINAPI PsCreateSystemThread(PHANDLE ThreadHandle, ULONG DesiredAccess,
1616 POBJECT_ATTRIBUTES ObjectAttributes,
1617 HANDLE ProcessHandle, PCLIENT_ID ClientId,
1618 PKSTART_ROUTINE StartRoutine, PVOID StartContext)
1620 if (!ProcessHandle) ProcessHandle = GetCurrentProcess();
1621 return RtlCreateUserThread(ProcessHandle, 0, FALSE, 0, 0,
1622 0, StartRoutine, StartContext,
1623 ThreadHandle, ClientId);
1626 /***********************************************************************
1627 * PsGetCurrentProcessId (NTOSKRNL.EXE.@)
1629 HANDLE WINAPI PsGetCurrentProcessId(void)
1631 if (GetCurrentThreadId() == request_thread)
1632 return UlongToHandle(client_pid);
1633 return UlongToHandle(GetCurrentProcessId());
1637 /***********************************************************************
1638 * PsGetCurrentThreadId (NTOSKRNL.EXE.@)
1640 HANDLE WINAPI PsGetCurrentThreadId(void)
1642 if (GetCurrentThreadId() == request_thread)
1643 return UlongToHandle(client_tid);
1644 return UlongToHandle(GetCurrentThreadId());
1648 /***********************************************************************
1649 * PsGetVersion (NTOSKRNL.EXE.@)
1651 BOOLEAN WINAPI PsGetVersion(ULONG *major, ULONG *minor, ULONG *build, UNICODE_STRING *version )
1653 RTL_OSVERSIONINFOEXW info;
1655 info.dwOSVersionInfoSize = sizeof(info);
1656 RtlGetVersion( &info );
1657 if (major) *major = info.dwMajorVersion;
1658 if (minor) *minor = info.dwMinorVersion;
1659 if (build) *build = info.dwBuildNumber;
1663 #if 0 /* FIXME: GameGuard passes an uninitialized pointer in version->Buffer */
1664 size_t len = min( strlenW(info.szCSDVersion)*sizeof(WCHAR), version->MaximumLength );
1665 memcpy( version->Buffer, info.szCSDVersion, len );
1666 if (len < version->MaximumLength) version->Buffer[len / sizeof(WCHAR)] = 0;
1667 version->Length = len;
1674 /***********************************************************************
1675 * PsImpersonateClient (NTOSKRNL.EXE.@)
1677 NTSTATUS WINAPI PsImpersonateClient(PETHREAD Thread, PACCESS_TOKEN Token, BOOLEAN CopyOnOpen,
1678 BOOLEAN EffectiveOnly, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
1680 FIXME("(%p, %p, %u, %u, %u): stub\n", Thread, Token, CopyOnOpen, EffectiveOnly, ImpersonationLevel);
1682 return STATUS_NOT_IMPLEMENTED;
1686 /***********************************************************************
1687 * PsSetCreateProcessNotifyRoutine (NTOSKRNL.EXE.@)
1689 NTSTATUS WINAPI PsSetCreateProcessNotifyRoutine( PCREATE_PROCESS_NOTIFY_ROUTINE callback, BOOLEAN remove )
1691 FIXME( "stub: %p %d\n", callback, remove );
1692 return STATUS_SUCCESS;
1696 /***********************************************************************
1697 * PsSetCreateThreadNotifyRoutine (NTOSKRNL.EXE.@)
1699 NTSTATUS WINAPI PsSetCreateThreadNotifyRoutine( PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine )
1701 FIXME( "stub: %p\n", NotifyRoutine );
1702 return STATUS_SUCCESS;
1706 /***********************************************************************
1707 * PsTerminateSystemThread (NTOSKRNL.EXE.@)
1709 NTSTATUS WINAPI PsTerminateSystemThread(NTSTATUS ExitStatus)
1711 FIXME( "stub: %u\n", ExitStatus );
1712 return STATUS_NOT_IMPLEMENTED;
1716 /***********************************************************************
1717 * MmGetSystemRoutineAddress (NTOSKRNL.EXE.@)
1719 PVOID WINAPI MmGetSystemRoutineAddress(PUNICODE_STRING SystemRoutineName)
1722 STRING routineNameA;
1725 static const WCHAR ntoskrnlW[] = {'n','t','o','s','k','r','n','l','.','e','x','e',0};
1726 static const WCHAR halW[] = {'h','a','l','.','d','l','l',0};
1728 if (!SystemRoutineName) return NULL;
1730 if (RtlUnicodeStringToAnsiString( &routineNameA, SystemRoutineName, TRUE ) == STATUS_SUCCESS)
1732 /* We only support functions exported from ntoskrnl.exe or hal.dll */
1733 hMod = GetModuleHandleW( ntoskrnlW );
1734 pFunc = GetProcAddress( hMod, routineNameA.Buffer );
1737 hMod = GetModuleHandleW( halW );
1738 if (hMod) pFunc = GetProcAddress( hMod, routineNameA.Buffer );
1740 RtlFreeAnsiString( &routineNameA );
1744 TRACE( "%s -> %p\n", debugstr_us(SystemRoutineName), pFunc );
1746 FIXME( "%s not found\n", debugstr_us(SystemRoutineName) );
1751 /***********************************************************************
1752 * MmQuerySystemSize (NTOSKRNL.EXE.@)
1754 MM_SYSTEMSIZE WINAPI MmQuerySystemSize(void)
1757 return MmLargeSystem;
1760 /***********************************************************************
1761 * KeInitializeDpc (NTOSKRNL.EXE.@)
1763 VOID WINAPI KeInitializeDpc(PRKDPC Dpc, PKDEFERRED_ROUTINE DeferredRoutine, PVOID DeferredContext)
1768 /***********************************************************************
1769 * READ_REGISTER_BUFFER_UCHAR (NTOSKRNL.EXE.@)
1771 VOID WINAPI READ_REGISTER_BUFFER_UCHAR(PUCHAR Register, PUCHAR Buffer, ULONG Count)
1776 /*****************************************************
1777 * PoSetPowerState (NTOSKRNL.EXE.@)
1779 POWER_STATE WINAPI PoSetPowerState(PDEVICE_OBJECT DeviceObject, POWER_STATE_TYPE Type, POWER_STATE State)
1781 FIXME("(%p %u %u) stub\n", DeviceObject, Type, State.DeviceState);
1785 /*****************************************************
1786 * IoWMIRegistrationControl (NTOSKRNL.EXE.@)
1788 NTSTATUS WINAPI IoWMIRegistrationControl(PDEVICE_OBJECT DeviceObject, ULONG Action)
1790 FIXME("(%p %u) stub\n", DeviceObject, Action);
1791 return STATUS_SUCCESS;
1794 /*****************************************************
1795 * PsSetLoadImageNotifyRoutine (NTOSKRNL.EXE.@)
1797 NTSTATUS WINAPI PsSetLoadImageNotifyRoutine(PLOAD_IMAGE_NOTIFY_ROUTINE routine)
1799 FIXME("(%p) stub\n", routine);
1800 return STATUS_SUCCESS;
1803 /*****************************************************
1804 * PsLookupProcessByProcessId (NTOSKRNL.EXE.@)
1806 NTSTATUS WINAPI PsLookupProcessByProcessId(HANDLE processid, PEPROCESS *process)
1808 FIXME("(%p %p) stub\n", processid, process);
1809 return STATUS_NOT_IMPLEMENTED;
1813 /*****************************************************
1814 * IoSetThreadHardErrorMode (NTOSKRNL.EXE.@)
1816 BOOLEAN WINAPI IoSetThreadHardErrorMode(BOOLEAN EnableHardErrors)
1823 /*****************************************************
1824 * IoInitializeRemoveLockEx (NTOSKRNL.EXE.@)
1826 VOID WINAPI IoInitializeRemoveLockEx(PIO_REMOVE_LOCK lock, ULONG tag,
1827 ULONG maxmin, ULONG high, ULONG size)
1829 FIXME("(%p %u %u %u %u) stub\n", lock, tag, maxmin, high, size);
1833 /*****************************************************
1834 * IoAcquireRemoveLockEx (NTOSKRNL.EXE.@)
1837 NTSTATUS WINAPI IoAcquireRemoveLockEx(PIO_REMOVE_LOCK lock, PVOID tag,
1838 LPCSTR file, ULONG line, ULONG lock_size)
1840 FIXME("(%p, %p, %s, %u, %u): stub\n", lock, tag, debugstr_a(file), line, lock_size);
1842 return STATUS_NOT_IMPLEMENTED;
1846 /*****************************************************
1849 BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
1851 static void *handler;
1852 LARGE_INTEGER count;
1856 case DLL_PROCESS_ATTACH:
1857 DisableThreadLibraryCalls( inst );
1859 handler = RtlAddVectoredExceptionHandler( TRUE, vectored_handler );
1861 KeQueryTickCount( &count ); /* initialize the global KeTickCount */
1863 case DLL_PROCESS_DETACH:
1864 RtlRemoveVectoredExceptionHandler( handler );
1870 /*****************************************************
1871 * Ke386IoSetAccessProcess (NTOSKRNL.EXE.@)
1873 BOOLEAN WINAPI Ke386IoSetAccessProcess(PEPROCESS *process, ULONG flag)
1875 FIXME("(%p %d) stub\n", process, flag);
1879 /*****************************************************
1880 * Ke386SetIoAccessMap (NTOSKRNL.EXE.@)
1882 BOOLEAN WINAPI Ke386SetIoAccessMap(ULONG flag, PVOID buffer)
1884 FIXME("(%d %p) stub\n", flag, buffer);
1888 /*****************************************************
1889 * IoCreateSynchronizationEvent (NTOSKRNL.EXE.@)
1891 PKEVENT WINAPI IoCreateSynchronizationEvent(PUNICODE_STRING name, PHANDLE handle)
1893 FIXME("(%p %p) stub\n", name, handle);
1897 /*****************************************************
1898 * IoStartNextPacket (NTOSKRNL.EXE.@)
1900 VOID WINAPI IoStartNextPacket(PDEVICE_OBJECT deviceobject, BOOLEAN cancelable)
1902 FIXME("(%p %d) stub\n", deviceobject, cancelable);