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 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 * IoAllocateDriverObjectExtension (NTOSKRNL.EXE.@)
289 NTSTATUS WINAPI IoAllocateDriverObjectExtension( PDRIVER_OBJECT DriverObject,
290 PVOID ClientIdentificationAddress,
291 ULONG DriverObjectExtensionSize,
292 PVOID *DriverObjectExtension )
294 FIXME( "stub: %p, %p, %u, %p\n", DriverObject, ClientIdentificationAddress,
295 DriverObjectExtensionSize, DriverObjectExtension );
296 return STATUS_NOT_IMPLEMENTED;
300 /***********************************************************************
301 * IoGetDriverObjectExtension (NTOSKRNL.EXE.@)
303 PVOID WINAPI IoGetDriverObjectExtension( PDRIVER_OBJECT DriverObject,
304 PVOID ClientIdentificationAddress )
306 FIXME( "stub: %p, %p\n", DriverObject, ClientIdentificationAddress );
311 /***********************************************************************
312 * IoInitializeIrp (NTOSKRNL.EXE.@)
314 void WINAPI IoInitializeIrp( IRP *irp, USHORT size, CCHAR stack_size )
316 TRACE( "%p, %u, %d\n", irp, size, stack_size );
318 RtlZeroMemory( irp, size );
320 irp->Type = IO_TYPE_IRP;
322 InitializeListHead( &irp->ThreadListEntry );
323 irp->StackCount = stack_size;
324 irp->CurrentLocation = stack_size + 1;
325 irp->Tail.Overlay.s.u2.CurrentStackLocation =
326 (PIO_STACK_LOCATION)(irp + 1) + stack_size;
330 /***********************************************************************
331 * IoInitializeTimer (NTOSKRNL.EXE.@)
333 NTSTATUS WINAPI IoInitializeTimer(PDEVICE_OBJECT DeviceObject,
334 PIO_TIMER_ROUTINE TimerRoutine,
337 FIXME( "stub: %p, %p, %p\n", DeviceObject, TimerRoutine, Context );
338 return STATUS_NOT_IMPLEMENTED;
342 /***********************************************************************
343 * IoStartTimer (NTOSKRNL.EXE.@)
345 void WINAPI IoStartTimer(PDEVICE_OBJECT DeviceObject)
347 FIXME( "stub: %p\n", DeviceObject );
351 /***********************************************************************
352 * IoAllocateIrp (NTOSKRNL.EXE.@)
354 PIRP WINAPI IoAllocateIrp( CCHAR stack_size, BOOLEAN charge_quota )
359 TRACE( "%d, %d\n", stack_size, charge_quota );
361 size = sizeof(IRP) + stack_size * sizeof(IO_STACK_LOCATION);
362 irp = ExAllocatePool( NonPagedPool, size );
365 IoInitializeIrp( irp, size, stack_size );
366 irp->AllocationFlags = IRP_ALLOCATED_FIXED_SIZE;
368 irp->AllocationFlags |= IRP_LOOKASIDE_ALLOCATION;
373 /***********************************************************************
374 * IoFreeIrp (NTOSKRNL.EXE.@)
376 void WINAPI IoFreeIrp( IRP *irp )
378 TRACE( "%p\n", irp );
384 /***********************************************************************
385 * IoAllocateErrorLogEntry (NTOSKRNL.EXE.@)
387 PVOID WINAPI IoAllocateErrorLogEntry( PVOID IoObject, UCHAR EntrySize )
389 FIXME( "stub: %p, %u\n", IoObject, EntrySize );
394 /***********************************************************************
395 * IoAllocateMdl (NTOSKRNL.EXE.@)
397 PMDL WINAPI IoAllocateMdl( PVOID VirtualAddress, ULONG Length, BOOLEAN SecondaryBuffer, BOOLEAN ChargeQuota, PIRP Irp )
401 FIXME("partial stub: %p, %u, %i, %i, %p\n", VirtualAddress, Length, SecondaryBuffer, ChargeQuota, Irp);
403 mdl = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(MDL));
411 /***********************************************************************
412 * IoFreeMdl (NTOSKRNL.EXE.@)
414 VOID WINAPI IoFreeMdl(PMDL mdl)
416 FIXME("partial stub: %p\n", mdl);
418 HeapFree(GetProcessHeap(), 0, mdl);
422 /***********************************************************************
423 * IoAllocateWorkItem (NTOSKRNL.EXE.@)
425 PIO_WORKITEM WINAPI IoAllocateWorkItem( PDEVICE_OBJECT DeviceObject )
427 FIXME( "stub: %p\n", DeviceObject );
432 /***********************************************************************
433 * IoAttachDeviceToDeviceStack (NTOSKRNL.EXE.@)
435 PDEVICE_OBJECT WINAPI IoAttachDeviceToDeviceStack( DEVICE_OBJECT *source,
436 DEVICE_OBJECT *target )
438 TRACE( "%p, %p\n", source, target );
439 target->AttachedDevice = source;
440 source->StackSize = target->StackSize + 1;
445 /***********************************************************************
446 * IoBuildDeviceIoControlRequest (NTOSKRNL.EXE.@)
448 PIRP WINAPI IoBuildDeviceIoControlRequest( ULONG IoControlCode,
449 PDEVICE_OBJECT DeviceObject,
451 ULONG InputBufferLength,
453 ULONG OutputBufferLength,
454 BOOLEAN InternalDeviceIoControl,
456 PIO_STATUS_BLOCK IoStatusBlock )
459 PIO_STACK_LOCATION irpsp;
460 struct IrpInstance *instance;
462 TRACE( "%x, %p, %p, %u, %p, %u, %u, %p, %p\n",
463 IoControlCode, DeviceObject, InputBuffer, InputBufferLength,
464 OutputBuffer, OutputBufferLength, InternalDeviceIoControl,
465 Event, IoStatusBlock );
467 if (DeviceObject == NULL)
470 irp = IoAllocateIrp( DeviceObject->StackSize, FALSE );
474 instance = HeapAlloc( GetProcessHeap(), 0, sizeof(struct IrpInstance) );
475 if (instance == NULL)
481 list_add_tail( &Irps, &instance->entry );
483 irpsp = IoGetNextIrpStackLocation( irp );
484 irpsp->MajorFunction = InternalDeviceIoControl ?
485 IRP_MJ_INTERNAL_DEVICE_CONTROL : IRP_MJ_DEVICE_CONTROL;
486 irpsp->Parameters.DeviceIoControl.IoControlCode = IoControlCode;
487 irp->UserIosb = IoStatusBlock;
488 irp->UserEvent = Event;
494 /***********************************************************************
495 * IoCreateDriver (NTOSKRNL.EXE.@)
497 NTSTATUS WINAPI IoCreateDriver( UNICODE_STRING *name, PDRIVER_INITIALIZE init )
499 DRIVER_OBJECT *driver;
500 DRIVER_EXTENSION *extension;
503 if (!(driver = RtlAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY,
504 sizeof(*driver) + sizeof(*extension) )))
505 return STATUS_NO_MEMORY;
507 if ((status = RtlDuplicateUnicodeString( 1, name, &driver->DriverName )))
509 RtlFreeHeap( GetProcessHeap(), 0, driver );
513 extension = (DRIVER_EXTENSION *)(driver + 1);
514 driver->Size = sizeof(*driver);
515 driver->DriverInit = init;
516 driver->DriverExtension = extension;
517 extension->DriverObject = driver;
518 extension->ServiceKeyName = driver->DriverName;
520 status = driver->DriverInit( driver, name );
524 RtlFreeUnicodeString( &driver->DriverName );
525 RtlFreeHeap( GetProcessHeap(), 0, driver );
531 /***********************************************************************
532 * IoDeleteDriver (NTOSKRNL.EXE.@)
534 void WINAPI IoDeleteDriver( DRIVER_OBJECT *driver )
536 RtlFreeUnicodeString( &driver->DriverName );
537 RtlFreeHeap( GetProcessHeap(), 0, driver );
541 /***********************************************************************
542 * IoCreateDevice (NTOSKRNL.EXE.@)
544 NTSTATUS WINAPI IoCreateDevice( DRIVER_OBJECT *driver, ULONG ext_size,
545 UNICODE_STRING *name, DEVICE_TYPE type,
546 ULONG characteristics, BOOLEAN exclusive,
547 DEVICE_OBJECT **ret_device )
550 DEVICE_OBJECT *device;
552 HANDLE manager = get_device_manager();
554 TRACE( "(%p, %u, %s, %u, %x, %u, %p)\n",
555 driver, ext_size, debugstr_us(name), type, characteristics, exclusive, ret_device );
557 if (!(device = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*device) + ext_size )))
558 return STATUS_NO_MEMORY;
560 SERVER_START_REQ( create_device )
565 req->manager = wine_server_obj_handle( manager );
566 req->user_ptr = wine_server_client_ptr( device );
567 if (name) wine_server_add_data( req, name->Buffer, name->Length );
568 if (!(status = wine_server_call( req ))) handle = wine_server_ptr_handle( reply->handle );
572 if (status == STATUS_SUCCESS)
574 device->DriverObject = driver;
575 device->DeviceExtension = device + 1;
576 device->DeviceType = type;
577 device->StackSize = 1;
578 device->Reserved = handle;
580 device->NextDevice = driver->DeviceObject;
581 driver->DeviceObject = device;
583 *ret_device = device;
585 else HeapFree( GetProcessHeap(), 0, device );
591 /***********************************************************************
592 * IoDeleteDevice (NTOSKRNL.EXE.@)
594 void WINAPI IoDeleteDevice( DEVICE_OBJECT *device )
598 TRACE( "%p\n", device );
600 SERVER_START_REQ( delete_device )
602 req->handle = wine_server_obj_handle( device->Reserved );
603 status = wine_server_call( req );
607 if (status == STATUS_SUCCESS)
609 DEVICE_OBJECT **prev = &device->DriverObject->DeviceObject;
610 while (*prev && *prev != device) prev = &(*prev)->NextDevice;
611 if (*prev) *prev = (*prev)->NextDevice;
612 NtClose( device->Reserved );
613 HeapFree( GetProcessHeap(), 0, device );
618 /***********************************************************************
619 * IoCreateSymbolicLink (NTOSKRNL.EXE.@)
621 NTSTATUS WINAPI IoCreateSymbolicLink( UNICODE_STRING *name, UNICODE_STRING *target )
624 OBJECT_ATTRIBUTES attr;
626 attr.Length = sizeof(attr);
627 attr.RootDirectory = 0;
628 attr.ObjectName = name;
629 attr.Attributes = OBJ_CASE_INSENSITIVE | OBJ_OPENIF;
630 attr.SecurityDescriptor = NULL;
631 attr.SecurityQualityOfService = NULL;
633 TRACE( "%s -> %s\n", debugstr_us(name), debugstr_us(target) );
634 /* FIXME: store handle somewhere */
635 return NtCreateSymbolicLinkObject( &handle, SYMBOLIC_LINK_ALL_ACCESS, &attr, target );
639 /***********************************************************************
640 * IoDeleteSymbolicLink (NTOSKRNL.EXE.@)
642 NTSTATUS WINAPI IoDeleteSymbolicLink( UNICODE_STRING *name )
645 OBJECT_ATTRIBUTES attr;
648 attr.Length = sizeof(attr);
649 attr.RootDirectory = 0;
650 attr.ObjectName = name;
651 attr.Attributes = OBJ_CASE_INSENSITIVE;
652 attr.SecurityDescriptor = NULL;
653 attr.SecurityQualityOfService = NULL;
655 if (!(status = NtOpenSymbolicLinkObject( &handle, 0, &attr )))
657 SERVER_START_REQ( unlink_object )
659 req->handle = wine_server_obj_handle( handle );
660 status = wine_server_call( req );
669 /***********************************************************************
670 * IoGetDeviceInterfaces (NTOSKRNL.EXE.@)
672 NTSTATUS WINAPI IoGetDeviceInterfaces( CONST GUID *InterfaceClassGuid,
673 PDEVICE_OBJECT PhysicalDeviceObject,
674 ULONG Flags, PWSTR *SymbolicLinkList )
676 FIXME( "stub: %s %p %x %p\n", debugstr_guid(InterfaceClassGuid),
677 PhysicalDeviceObject, Flags, SymbolicLinkList );
678 return STATUS_NOT_IMPLEMENTED;
682 /***********************************************************************
683 * IoGetDeviceObjectPointer (NTOSKRNL.EXE.@)
685 NTSTATUS WINAPI IoGetDeviceObjectPointer( UNICODE_STRING *name, ACCESS_MASK access, PFILE_OBJECT *file, PDEVICE_OBJECT *device )
687 FIXME( "stub: %s %x %p %p\n", debugstr_us(name), access, file, device );
688 return STATUS_NOT_IMPLEMENTED;
692 /***********************************************************************
693 * IoGetDeviceProperty (NTOSKRNL.EXE.@)
695 NTSTATUS WINAPI IoGetDeviceProperty( DEVICE_OBJECT *device, DEVICE_REGISTRY_PROPERTY device_property,
696 ULONG buffer_length, PVOID property_buffer, PULONG result_length )
698 FIXME( "%p %d %u %p %p: stub\n", device, device_property, buffer_length,
699 property_buffer, result_length );
700 return STATUS_NOT_IMPLEMENTED;
704 /***********************************************************************
705 * IoCallDriver (NTOSKRNL.EXE.@)
707 NTSTATUS WINAPI IoCallDriver( DEVICE_OBJECT *device, IRP *irp )
709 PDRIVER_DISPATCH dispatch;
710 IO_STACK_LOCATION *irpsp;
713 TRACE( "%p %p\n", device, irp );
715 --irp->CurrentLocation;
716 irpsp = --irp->Tail.Overlay.s.u2.CurrentStackLocation;
717 dispatch = device->DriverObject->MajorFunction[irpsp->MajorFunction];
718 status = dispatch( device, irp );
724 /***********************************************************************
725 * IofCallDriver (NTOSKRNL.EXE.@)
727 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
728 DEFINE_FASTCALL2_ENTRYPOINT( IofCallDriver )
729 NTSTATUS WINAPI __regs_IofCallDriver( DEVICE_OBJECT *device, IRP *irp )
731 NTSTATUS WINAPI IofCallDriver( DEVICE_OBJECT *device, IRP *irp )
734 TRACE( "%p %p\n", device, irp );
735 return IoCallDriver( device, irp );
739 /***********************************************************************
740 * IoGetRelatedDeviceObject (NTOSKRNL.EXE.@)
742 PDEVICE_OBJECT WINAPI IoGetRelatedDeviceObject( PFILE_OBJECT obj )
744 FIXME( "stub: %p\n", obj );
748 static CONFIGURATION_INFORMATION configuration_information;
750 /***********************************************************************
751 * IoGetConfigurationInformation (NTOSKRNL.EXE.@)
753 PCONFIGURATION_INFORMATION WINAPI IoGetConfigurationInformation(void)
755 FIXME( "partial stub\n" );
756 /* FIXME: return actual devices on system */
757 return &configuration_information;
761 /***********************************************************************
762 * IoIsWdmVersionAvailable (NTOSKRNL.EXE.@)
764 NTSTATUS WINAPI IoIsWdmVersionAvailable(UCHAR MajorVersion, UCHAR MinorVersion)
770 TRACE( "%d, 0x%X\n", MajorVersion, MinorVersion );
772 version = GetVersion();
773 major = LOBYTE(version);
774 minor = HIBYTE(LOWORD(version));
776 if (MajorVersion == 6 && MinorVersion == 0)
778 /* Windows Vista, Windows Server 2008, Windows 7 */
780 else if (MajorVersion == 1)
782 if (MinorVersion == 0x30)
784 /* Windows server 2003 */
788 else if (MinorVersion == 0x20)
794 else if (MinorVersion == 0x10)
800 else if (MinorVersion == 0x05)
806 else if (MinorVersion == 0x00)
814 FIXME( "unknown major %d minor 0x%X\n", MajorVersion, MinorVersion );
820 FIXME( "unknown major %d minor 0x%X\n", MajorVersion, MinorVersion );
823 return major > MajorVersion || (major == MajorVersion && minor >= MinorVersion);
827 /***********************************************************************
828 * IoQueryDeviceDescription (NTOSKRNL.EXE.@)
830 NTSTATUS WINAPI IoQueryDeviceDescription(PINTERFACE_TYPE itype, PULONG bus, PCONFIGURATION_TYPE ctype,
831 PULONG cnum, PCONFIGURATION_TYPE ptype, PULONG pnum,
832 PIO_QUERY_DEVICE_ROUTINE callout, PVOID context)
834 FIXME( "(%p %p %p %p %p %p %p %p)\n", itype, bus, ctype, cnum, ptype, pnum, callout, context);
835 return STATUS_NOT_IMPLEMENTED;
839 /***********************************************************************
840 * IoRegisterDriverReinitialization (NTOSKRNL.EXE.@)
842 void WINAPI IoRegisterDriverReinitialization( PDRIVER_OBJECT obj, PDRIVER_REINITIALIZE reinit, PVOID context )
844 FIXME( "stub: %p %p %p\n", obj, reinit, context );
848 /***********************************************************************
849 * IoRegisterShutdownNotification (NTOSKRNL.EXE.@)
851 NTSTATUS WINAPI IoRegisterShutdownNotification( PDEVICE_OBJECT obj )
853 FIXME( "stub: %p\n", obj );
854 return STATUS_SUCCESS;
858 /***********************************************************************
859 * IoUnregisterShutdownNotification (NTOSKRNL.EXE.@)
861 VOID WINAPI IoUnregisterShutdownNotification( PDEVICE_OBJECT obj )
863 FIXME( "stub: %p\n", obj );
867 /***********************************************************************
868 * IoReportResourceUsage (NTOSKRNL.EXE.@)
870 NTSTATUS WINAPI IoReportResourceUsage(PUNICODE_STRING name, PDRIVER_OBJECT drv_obj, PCM_RESOURCE_LIST drv_list,
871 ULONG drv_size, PDRIVER_OBJECT dev_obj, PCM_RESOURCE_LIST dev_list,
872 ULONG dev_size, BOOLEAN overwrite, PBOOLEAN detected)
874 FIXME("(%s %p %p %u %p %p %u %d %p) stub\n", debugstr_w(name? name->Buffer : NULL),
875 drv_obj, drv_list, drv_size, dev_obj, dev_list, dev_size, overwrite, detected);
876 return STATUS_NOT_IMPLEMENTED;
880 /***********************************************************************
881 * IoCompleteRequest (NTOSKRNL.EXE.@)
883 VOID WINAPI IoCompleteRequest( IRP *irp, UCHAR priority_boost )
885 IO_STACK_LOCATION *irpsp;
886 PIO_COMPLETION_ROUTINE routine;
887 IO_STATUS_BLOCK *iosb;
888 struct IrpInstance *instance;
889 NTSTATUS status, stat;
892 TRACE( "%p %u\n", irp, priority_boost );
894 iosb = irp->UserIosb;
895 status = irp->IoStatus.u.Status;
896 while (irp->CurrentLocation <= irp->StackCount)
898 irpsp = irp->Tail.Overlay.s.u2.CurrentStackLocation;
899 routine = irpsp->CompletionRoutine;
901 /* FIXME: add SL_INVOKE_ON_CANCEL support */
904 if ((irpsp->Control & SL_INVOKE_ON_SUCCESS) && STATUS_SUCCESS == status)
906 if ((irpsp->Control & SL_INVOKE_ON_ERROR) && STATUS_SUCCESS != status)
909 ++irp->CurrentLocation;
910 ++irp->Tail.Overlay.s.u2.CurrentStackLocation;
913 TRACE( "calling %p( %p, %p, %p )\n", routine,
914 irpsp->DeviceObject, irp, irpsp->Context );
915 stat = routine( irpsp->DeviceObject, irp, irpsp->Context );
916 TRACE( "CompletionRoutine returned %x\n", stat );
917 if (STATUS_MORE_PROCESSING_REQUIRED == stat)
921 if (iosb && STATUS_SUCCESS == status)
923 iosb->u.Status = irp->IoStatus.u.Status;
924 iosb->Information = irp->IoStatus.Information;
926 LIST_FOR_EACH_ENTRY( instance, &Irps, struct IrpInstance, entry )
928 if (instance->irp == irp)
930 list_remove( &instance->entry );
931 HeapFree( GetProcessHeap(), 0, instance );
939 /***********************************************************************
940 * IofCompleteRequest (NTOSKRNL.EXE.@)
942 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
943 DEFINE_FASTCALL2_ENTRYPOINT( IofCompleteRequest )
944 void WINAPI __regs_IofCompleteRequest( IRP *irp, UCHAR priority_boost )
946 void WINAPI IofCompleteRequest( IRP *irp, UCHAR priority_boost )
949 TRACE( "%p %u\n", irp, priority_boost );
950 IoCompleteRequest( irp, priority_boost );
954 /***********************************************************************
955 * InterlockedCompareExchange (NTOSKRNL.EXE.@)
957 #ifdef DEFINE_FASTCALL3_ENTRYPOINT
958 DEFINE_FASTCALL3_ENTRYPOINT( NTOSKRNL_InterlockedCompareExchange )
959 LONG WINAPI __regs_NTOSKRNL_InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare )
961 LONG WINAPI NTOSKRNL_InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare )
964 return InterlockedCompareExchange( dest, xchg, compare );
968 /***********************************************************************
969 * InterlockedDecrement (NTOSKRNL.EXE.@)
971 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
972 DEFINE_FASTCALL1_ENTRYPOINT( NTOSKRNL_InterlockedDecrement )
973 LONG WINAPI __regs_NTOSKRNL_InterlockedDecrement( LONG volatile *dest )
975 LONG WINAPI NTOSKRNL_InterlockedDecrement( LONG volatile *dest )
978 return InterlockedDecrement( dest );
982 /***********************************************************************
983 * InterlockedExchange (NTOSKRNL.EXE.@)
985 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
986 DEFINE_FASTCALL2_ENTRYPOINT( NTOSKRNL_InterlockedExchange )
987 LONG WINAPI __regs_NTOSKRNL_InterlockedExchange( LONG volatile *dest, LONG val )
989 LONG WINAPI NTOSKRNL_InterlockedExchange( LONG volatile *dest, LONG val )
992 return InterlockedExchange( dest, val );
996 /***********************************************************************
997 * InterlockedExchangeAdd (NTOSKRNL.EXE.@)
999 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
1000 DEFINE_FASTCALL2_ENTRYPOINT( NTOSKRNL_InterlockedExchangeAdd )
1001 LONG WINAPI __regs_NTOSKRNL_InterlockedExchangeAdd( LONG volatile *dest, LONG incr )
1003 LONG WINAPI NTOSKRNL_InterlockedExchangeAdd( LONG volatile *dest, LONG incr )
1006 return InterlockedExchangeAdd( dest, incr );
1010 /***********************************************************************
1011 * InterlockedIncrement (NTOSKRNL.EXE.@)
1013 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
1014 DEFINE_FASTCALL1_ENTRYPOINT( NTOSKRNL_InterlockedIncrement )
1015 LONG WINAPI __regs_NTOSKRNL_InterlockedIncrement( LONG volatile *dest )
1017 LONG WINAPI NTOSKRNL_InterlockedIncrement( LONG volatile *dest )
1020 return InterlockedIncrement( dest );
1024 /***********************************************************************
1025 * ExAllocatePool (NTOSKRNL.EXE.@)
1027 PVOID WINAPI ExAllocatePool( POOL_TYPE type, SIZE_T size )
1029 return ExAllocatePoolWithTag( type, size, 0 );
1033 /***********************************************************************
1034 * ExAllocatePoolWithQuota (NTOSKRNL.EXE.@)
1036 PVOID WINAPI ExAllocatePoolWithQuota( POOL_TYPE type, SIZE_T size )
1038 return ExAllocatePoolWithTag( type, size, 0 );
1042 /***********************************************************************
1043 * ExAllocatePoolWithTag (NTOSKRNL.EXE.@)
1045 PVOID WINAPI ExAllocatePoolWithTag( POOL_TYPE type, SIZE_T size, ULONG tag )
1047 /* FIXME: handle page alignment constraints */
1048 void *ret = HeapAlloc( GetProcessHeap(), 0, size );
1049 TRACE( "%lu pool %u -> %p\n", size, type, ret );
1054 /***********************************************************************
1055 * ExAllocatePoolWithQuotaTag (NTOSKRNL.EXE.@)
1057 PVOID WINAPI ExAllocatePoolWithQuotaTag( POOL_TYPE type, SIZE_T size, ULONG tag )
1059 return ExAllocatePoolWithTag( type, size, tag );
1063 /***********************************************************************
1064 * ExFreePool (NTOSKRNL.EXE.@)
1066 void WINAPI ExFreePool( void *ptr )
1068 ExFreePoolWithTag( ptr, 0 );
1072 /***********************************************************************
1073 * ExFreePoolWithTag (NTOSKRNL.EXE.@)
1075 void WINAPI ExFreePoolWithTag( void *ptr, ULONG tag )
1077 TRACE( "%p\n", ptr );
1078 HeapFree( GetProcessHeap(), 0, ptr );
1082 /***********************************************************************
1083 * ExInitializeResourceLite (NTOSKRNL.EXE.@)
1085 NTSTATUS WINAPI ExInitializeResourceLite(PERESOURCE Resource)
1087 FIXME( "stub: %p\n", Resource );
1088 return STATUS_NOT_IMPLEMENTED;
1092 /***********************************************************************
1093 * ExInitializeNPagedLookasideList (NTOSKRNL.EXE.@)
1095 void WINAPI ExInitializeNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside,
1096 PALLOCATE_FUNCTION Allocate,
1097 PFREE_FUNCTION Free,
1103 FIXME( "stub: %p, %p, %p, %u, %lu, %u, %u\n", Lookaside, Allocate, Free, Flags, Size, Tag, Depth );
1106 /***********************************************************************
1107 * ExInitializePagedLookasideList (NTOSKRNL.EXE.@)
1109 void WINAPI ExInitializePagedLookasideList(PPAGED_LOOKASIDE_LIST Lookaside,
1110 PALLOCATE_FUNCTION Allocate,
1111 PFREE_FUNCTION Free,
1117 FIXME( "stub: %p, %p, %p, %u, %lu, %u, %u\n", Lookaside, Allocate, Free, Flags, Size, Tag, Depth );
1120 /***********************************************************************
1121 * ExInitializeZone (NTOSKRNL.EXE.@)
1123 NTSTATUS WINAPI ExInitializeZone(PZONE_HEADER Zone,
1125 PVOID InitialSegment,
1126 ULONG InitialSegmentSize)
1128 FIXME( "stub: %p, %u, %p, %u\n", Zone, BlockSize, InitialSegment, InitialSegmentSize );
1129 return STATUS_NOT_IMPLEMENTED;
1132 /***********************************************************************
1133 * FsRtlRegisterUncProvider (NTOSKRNL.EXE.@)
1135 NTSTATUS WINAPI FsRtlRegisterUncProvider(PHANDLE MupHandle, PUNICODE_STRING RedirDevName,
1136 BOOLEAN MailslotsSupported)
1138 FIXME("(%p %p %d): stub\n", MupHandle, RedirDevName, MailslotsSupported);
1139 return STATUS_NOT_IMPLEMENTED;
1142 /***********************************************************************
1143 * IoGetCurrentProcess / PsGetCurrentProcess (NTOSKRNL.EXE.@)
1145 PEPROCESS WINAPI IoGetCurrentProcess(void)
1151 /***********************************************************************
1152 * KeGetCurrentThread / PsGetCurrentThread (NTOSKRNL.EXE.@)
1154 PRKTHREAD WINAPI KeGetCurrentThread(void)
1160 /***********************************************************************
1161 * KeInitializeEvent (NTOSKRNL.EXE.@)
1163 void WINAPI KeInitializeEvent( PRKEVENT Event, EVENT_TYPE Type, BOOLEAN State )
1165 FIXME( "stub: %p %d %d\n", Event, Type, State );
1169 /***********************************************************************
1170 * KeInitializeMutex (NTOSKRNL.EXE.@)
1172 void WINAPI KeInitializeMutex(PRKMUTEX Mutex, ULONG Level)
1174 FIXME( "stub: %p, %u\n", Mutex, Level );
1178 /***********************************************************************
1179 * KeWaitForMutexObject (NTOSKRNL.EXE.@)
1181 NTSTATUS WINAPI KeWaitForMutexObject(PRKMUTEX Mutex, KWAIT_REASON WaitReason, KPROCESSOR_MODE WaitMode,
1182 BOOLEAN Alertable, PLARGE_INTEGER Timeout)
1184 FIXME( "stub: %p, %d, %d, %d, %p\n", Mutex, WaitReason, WaitMode, Alertable, Timeout );
1185 return STATUS_NOT_IMPLEMENTED;
1189 /***********************************************************************
1190 * KeReleaseMutex (NTOSKRNL.EXE.@)
1192 LONG WINAPI KeReleaseMutex(PRKMUTEX Mutex, BOOLEAN Wait)
1194 FIXME( "stub: %p, %d\n", Mutex, Wait );
1195 return STATUS_NOT_IMPLEMENTED;
1199 /***********************************************************************
1200 * KeInitializeSemaphore (NTOSKRNL.EXE.@)
1202 void WINAPI KeInitializeSemaphore( PRKSEMAPHORE Semaphore, LONG Count, LONG Limit )
1204 FIXME( "(%p %d %d) stub\n", Semaphore , Count, Limit );
1208 /***********************************************************************
1209 * KeInitializeSpinLock (NTOSKRNL.EXE.@)
1211 void WINAPI KeInitializeSpinLock( PKSPIN_LOCK SpinLock )
1213 FIXME( "stub: %p\n", SpinLock );
1217 /***********************************************************************
1218 * KeInitializeTimerEx (NTOSKRNL.EXE.@)
1220 void WINAPI KeInitializeTimerEx( PKTIMER Timer, TIMER_TYPE Type )
1222 FIXME( "stub: %p %d\n", Timer, Type );
1226 /***********************************************************************
1227 * KeInitializeTimer (NTOSKRNL.EXE.@)
1229 void WINAPI KeInitializeTimer( PKTIMER Timer )
1231 KeInitializeTimerEx(Timer, NotificationTimer);
1235 /**********************************************************************
1236 * KeQueryActiveProcessors (NTOSKRNL.EXE.@)
1238 * Return the active Processors as bitmask
1241 * active Processors as bitmask
1244 KAFFINITY WINAPI KeQueryActiveProcessors( void )
1246 DWORD_PTR AffinityMask;
1248 GetProcessAffinityMask( GetCurrentProcess(), &AffinityMask, NULL);
1249 return AffinityMask;
1253 /**********************************************************************
1254 * KeQueryInterruptTime (NTOSKRNL.EXE.@)
1256 * Return the interrupt time count
1259 ULONGLONG WINAPI KeQueryInterruptTime( void )
1261 LARGE_INTEGER totaltime;
1263 KeQueryTickCount(&totaltime);
1264 return totaltime.QuadPart;
1268 /***********************************************************************
1269 * KeQuerySystemTime (NTOSKRNL.EXE.@)
1271 void WINAPI KeQuerySystemTime( LARGE_INTEGER *time )
1273 NtQuerySystemTime( time );
1277 /***********************************************************************
1278 * KeQueryTickCount (NTOSKRNL.EXE.@)
1280 void WINAPI KeQueryTickCount( LARGE_INTEGER *count )
1282 count->QuadPart = NtGetTickCount();
1283 /* update the global variable too */
1284 KeTickCount.LowPart = count->u.LowPart;
1285 KeTickCount.High1Time = count->u.HighPart;
1286 KeTickCount.High2Time = count->u.HighPart;
1290 /***********************************************************************
1291 * KeReleaseSemaphore (NTOSKRNL.EXE.@)
1293 LONG WINAPI KeReleaseSemaphore( PRKSEMAPHORE Semaphore, KPRIORITY Increment,
1294 LONG Adjustment, BOOLEAN Wait )
1296 FIXME("(%p %d %d %d) stub\n", Semaphore, Increment, Adjustment, Wait );
1301 /***********************************************************************
1302 * KeQueryTimeIncrement (NTOSKRNL.EXE.@)
1304 ULONG WINAPI KeQueryTimeIncrement(void)
1310 /***********************************************************************
1311 * KeResetEvent (NTOSKRNL.EXE.@)
1313 LONG WINAPI KeResetEvent( PRKEVENT Event )
1315 FIXME("(%p): stub\n", Event);
1320 /***********************************************************************
1321 * KeSetEvent (NTOSKRNL.EXE.@)
1323 LONG WINAPI KeSetEvent( PRKEVENT Event, KPRIORITY Increment, BOOLEAN Wait )
1325 FIXME("(%p, %d, %d): stub\n", Event, Increment, Wait);
1330 /***********************************************************************
1331 * KeSetPriorityThread (NTOSKRNL.EXE.@)
1333 KPRIORITY WINAPI KeSetPriorityThread( PKTHREAD Thread, KPRIORITY Priority )
1335 FIXME("(%p %d)\n", Thread, Priority);
1340 /***********************************************************************
1341 * KeWaitForSingleObject (NTOSKRNL.EXE.@)
1343 NTSTATUS WINAPI KeWaitForSingleObject(PVOID Object,
1344 KWAIT_REASON WaitReason,
1345 KPROCESSOR_MODE WaitMode,
1347 PLARGE_INTEGER Timeout)
1349 FIXME( "stub: %p, %d, %d, %d, %p\n", Object, WaitReason, WaitMode, Alertable, Timeout );
1350 return STATUS_NOT_IMPLEMENTED;
1353 /***********************************************************************
1354 * IoRegisterFileSystem (NTOSKRNL.EXE.@)
1356 VOID WINAPI IoRegisterFileSystem(PDEVICE_OBJECT DeviceObject)
1358 FIXME("(%p): stub\n", DeviceObject);
1361 /***********************************************************************
1362 * IoUnregisterFileSystem (NTOSKRNL.EXE.@)
1364 VOID WINAPI IoUnregisterFileSystem(PDEVICE_OBJECT DeviceObject)
1366 FIXME("(%p): stub\n", DeviceObject);
1369 /***********************************************************************
1370 * MmAllocateNonCachedMemory (NTOSKRNL.EXE.@)
1372 PVOID WINAPI MmAllocateNonCachedMemory( SIZE_T size )
1374 TRACE( "%lu\n", size );
1375 return VirtualAlloc( NULL, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE|PAGE_NOCACHE );
1378 /***********************************************************************
1379 * MmAllocateContiguousMemory (NTOSKRNL.EXE.@)
1381 PVOID WINAPI MmAllocateContiguousMemory( SIZE_T size, PHYSICAL_ADDRESS highest_valid_address )
1383 FIXME( "%lu, %s stub\n", size, wine_dbgstr_longlong(highest_valid_address.QuadPart) );
1387 /***********************************************************************
1388 * MmAllocateContiguousMemorySpecifyCache (NTOSKRNL.EXE.@)
1390 PVOID WINAPI MmAllocateContiguousMemorySpecifyCache( SIZE_T size,
1391 PHYSICAL_ADDRESS lowest_valid_address,
1392 PHYSICAL_ADDRESS highest_valid_address,
1393 PHYSICAL_ADDRESS BoundaryAddressMultiple,
1394 MEMORY_CACHING_TYPE CacheType )
1400 /***********************************************************************
1401 * MmAllocatePagesForMdl (NTOSKRNL.EXE.@)
1403 PMDL WINAPI MmAllocatePagesForMdl(PHYSICAL_ADDRESS lowaddress, PHYSICAL_ADDRESS highaddress,
1404 PHYSICAL_ADDRESS skipbytes, SIZE_T size)
1406 FIXME("%s %s %s %lu: stub\n", wine_dbgstr_longlong(lowaddress.QuadPart), wine_dbgstr_longlong(highaddress.QuadPart),
1407 wine_dbgstr_longlong(skipbytes.QuadPart), size);
1411 /***********************************************************************
1412 * MmFreeNonCachedMemory (NTOSKRNL.EXE.@)
1414 void WINAPI MmFreeNonCachedMemory( void *addr, SIZE_T size )
1416 TRACE( "%p %lu\n", addr, size );
1417 VirtualFree( addr, 0, MEM_RELEASE );
1420 /***********************************************************************
1421 * MmIsAddressValid (NTOSKRNL.EXE.@)
1423 * Check if the process can access the virtual address without a pagefault
1426 * VirtualAddress [I] Address to check
1430 * Success: TRUE (Accessing the Address works without a Pagefault)
1433 BOOLEAN WINAPI MmIsAddressValid(PVOID VirtualAddress)
1435 TRACE("(%p)\n", VirtualAddress);
1436 return !IsBadWritePtr(VirtualAddress, 1);
1439 /***********************************************************************
1440 * MmMapIoSpace (NTOSKRNL.EXE.@)
1442 PVOID WINAPI MmMapIoSpace( PHYSICAL_ADDRESS PhysicalAddress, DWORD NumberOfBytes, DWORD CacheType )
1444 FIXME( "stub: 0x%08x%08x, %d, %d\n", PhysicalAddress.u.HighPart, PhysicalAddress.u.LowPart, NumberOfBytes, CacheType );
1448 /***********************************************************************
1449 * MmPageEntireDriver (NTOSKRNL.EXE.@)
1451 PVOID WINAPI MmPageEntireDriver(PVOID AddrInSection)
1453 TRACE("%p\n", AddrInSection);
1454 return AddrInSection;
1458 /***********************************************************************
1459 * MmProbeAndLockPages (NTOSKRNL.EXE.@)
1461 void MmProbeAndLockPages(PMDLX MemoryDescriptorList, KPROCESSOR_MODE AccessMode, LOCK_OPERATION Operation)
1463 FIXME("(%p, %u, %u): stub\n", MemoryDescriptorList, AccessMode, Operation);
1467 /***********************************************************************
1468 * MmResetDriverPaging (NTOSKRNL.EXE.@)
1470 void WINAPI MmResetDriverPaging(PVOID AddrInSection)
1472 TRACE("%p\n", AddrInSection);
1476 /***********************************************************************
1477 * MmUnlockPages (NTOSKRNL.EXE.@)
1479 void MmUnlockPages(PMDLX MemoryDescriptorList)
1481 FIXME("(%p): stub\n", MemoryDescriptorList);
1485 /***********************************************************************
1486 * MmUnmapIoSpace (NTOSKRNL.EXE.@)
1488 VOID WINAPI MmUnmapIoSpace( PVOID BaseAddress, SIZE_T NumberOfBytes )
1490 FIXME( "stub: %p, %lu\n", BaseAddress, NumberOfBytes );
1493 /***********************************************************************
1494 * ObfReferenceObject (NTOSKRNL.EXE.@)
1496 VOID WINAPI ObfReferenceObject(PVOID Object)
1498 FIXME("(%p): stub\n", Object);
1501 /***********************************************************************
1502 * ObReferenceObjectByHandle (NTOSKRNL.EXE.@)
1504 NTSTATUS WINAPI ObReferenceObjectByHandle( HANDLE obj, ACCESS_MASK access,
1506 KPROCESSOR_MODE mode, PVOID* ptr,
1507 POBJECT_HANDLE_INFORMATION info)
1509 FIXME( "stub: %p %x %p %d %p %p\n", obj, access, type, mode, ptr, info);
1510 return STATUS_NOT_IMPLEMENTED;
1513 /***********************************************************************
1514 * ObReferenceObjectByName (NTOSKRNL.EXE.@)
1516 NTSTATUS WINAPI ObReferenceObjectByName( UNICODE_STRING *ObjectName,
1518 ACCESS_STATE *AccessState,
1519 ACCESS_MASK DesiredAccess,
1520 POBJECT_TYPE ObjectType,
1521 KPROCESSOR_MODE AccessMode,
1526 return STATUS_NOT_IMPLEMENTED;
1529 /***********************************************************************
1530 * ObfDereferenceObject (NTOSKRNL.EXE.@)
1532 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
1533 DEFINE_FASTCALL1_ENTRYPOINT( ObfDereferenceObject )
1534 void WINAPI __regs_ObfDereferenceObject( VOID *obj )
1536 void WINAPI ObfDereferenceObject( VOID *obj )
1539 FIXME( "stub: %p\n", obj );
1543 /***********************************************************************
1544 * PsCreateSystemThread (NTOSKRNL.EXE.@)
1546 NTSTATUS WINAPI PsCreateSystemThread(PHANDLE ThreadHandle, ULONG DesiredAccess,
1547 POBJECT_ATTRIBUTES ObjectAttributes,
1548 HANDLE ProcessHandle, PCLIENT_ID ClientId,
1549 PKSTART_ROUTINE StartRoutine, PVOID StartContext)
1551 if (!ProcessHandle) ProcessHandle = GetCurrentProcess();
1552 return RtlCreateUserThread(ProcessHandle, 0, FALSE, 0, 0,
1553 0, StartRoutine, StartContext,
1554 ThreadHandle, ClientId);
1557 /***********************************************************************
1558 * PsGetCurrentProcessId (NTOSKRNL.EXE.@)
1560 HANDLE WINAPI PsGetCurrentProcessId(void)
1562 if (GetCurrentThreadId() == request_thread)
1563 return UlongToHandle(client_pid);
1564 return UlongToHandle(GetCurrentProcessId());
1568 /***********************************************************************
1569 * PsGetCurrentThreadId (NTOSKRNL.EXE.@)
1571 HANDLE WINAPI PsGetCurrentThreadId(void)
1573 if (GetCurrentThreadId() == request_thread)
1574 return UlongToHandle(client_tid);
1575 return UlongToHandle(GetCurrentThreadId());
1579 /***********************************************************************
1580 * PsGetVersion (NTOSKRNL.EXE.@)
1582 BOOLEAN WINAPI PsGetVersion(ULONG *major, ULONG *minor, ULONG *build, UNICODE_STRING *version )
1584 RTL_OSVERSIONINFOEXW info;
1586 info.dwOSVersionInfoSize = sizeof(info);
1587 RtlGetVersion( &info );
1588 if (major) *major = info.dwMajorVersion;
1589 if (minor) *minor = info.dwMinorVersion;
1590 if (build) *build = info.dwBuildNumber;
1594 #if 0 /* FIXME: GameGuard passes an uninitialized pointer in version->Buffer */
1595 size_t len = min( strlenW(info.szCSDVersion)*sizeof(WCHAR), version->MaximumLength );
1596 memcpy( version->Buffer, info.szCSDVersion, len );
1597 if (len < version->MaximumLength) version->Buffer[len / sizeof(WCHAR)] = 0;
1598 version->Length = len;
1605 /***********************************************************************
1606 * PsSetCreateProcessNotifyRoutine (NTOSKRNL.EXE.@)
1608 NTSTATUS WINAPI PsSetCreateProcessNotifyRoutine( PCREATE_PROCESS_NOTIFY_ROUTINE callback, BOOLEAN remove )
1610 FIXME( "stub: %p %d\n", callback, remove );
1611 return STATUS_SUCCESS;
1615 /***********************************************************************
1616 * PsSetCreateThreadNotifyRoutine (NTOSKRNL.EXE.@)
1618 NTSTATUS WINAPI PsSetCreateThreadNotifyRoutine( PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine )
1620 FIXME( "stub: %p\n", NotifyRoutine );
1621 return STATUS_SUCCESS;
1625 /***********************************************************************
1626 * PsTerminateSystemThread (NTOSKRNL.EXE.@)
1628 NTSTATUS WINAPI PsTerminateSystemThread(NTSTATUS ExitStatus)
1630 FIXME( "stub: %u\n", ExitStatus );
1631 return STATUS_NOT_IMPLEMENTED;
1635 /***********************************************************************
1636 * MmGetSystemRoutineAddress (NTOSKRNL.EXE.@)
1638 PVOID WINAPI MmGetSystemRoutineAddress(PUNICODE_STRING SystemRoutineName)
1641 STRING routineNameA;
1644 static const WCHAR ntoskrnlW[] = {'n','t','o','s','k','r','n','l','.','e','x','e',0};
1645 static const WCHAR halW[] = {'h','a','l','.','d','l','l',0};
1647 if (!SystemRoutineName) return NULL;
1649 if (RtlUnicodeStringToAnsiString( &routineNameA, SystemRoutineName, TRUE ) == STATUS_SUCCESS)
1651 /* We only support functions exported from ntoskrnl.exe or hal.dll */
1652 hMod = GetModuleHandleW( ntoskrnlW );
1653 pFunc = GetProcAddress( hMod, routineNameA.Buffer );
1656 hMod = GetModuleHandleW( halW );
1657 if (hMod) pFunc = GetProcAddress( hMod, routineNameA.Buffer );
1659 RtlFreeAnsiString( &routineNameA );
1663 TRACE( "%s -> %p\n", debugstr_us(SystemRoutineName), pFunc );
1665 FIXME( "%s not found\n", debugstr_us(SystemRoutineName) );
1670 /***********************************************************************
1671 * MmQuerySystemSize (NTOSKRNL.EXE.@)
1673 MM_SYSTEMSIZE WINAPI MmQuerySystemSize(void)
1676 return MmLargeSystem;
1679 /***********************************************************************
1680 * KeInitializeDpc (NTOSKRNL.EXE.@)
1682 VOID WINAPI KeInitializeDpc(PRKDPC Dpc, PKDEFERRED_ROUTINE DeferredRoutine, PVOID DeferredContext)
1687 /***********************************************************************
1688 * READ_REGISTER_BUFFER_UCHAR (NTOSKRNL.EXE.@)
1690 VOID WINAPI READ_REGISTER_BUFFER_UCHAR(PUCHAR Register, PUCHAR Buffer, ULONG Count)
1695 /*****************************************************
1696 * PoSetPowerState (NTOSKRNL.EXE.@)
1698 POWER_STATE WINAPI PoSetPowerState(PDEVICE_OBJECT DeviceObject, POWER_STATE_TYPE Type, POWER_STATE State)
1700 FIXME("(%p %u %u) stub\n", DeviceObject, Type, State.DeviceState);
1704 /*****************************************************
1705 * IoWMIRegistrationControl (NTOSKRNL.EXE.@)
1707 NTSTATUS WINAPI IoWMIRegistrationControl(PDEVICE_OBJECT DeviceObject, ULONG Action)
1709 FIXME("(%p %u ) stub\n", DeviceObject, Action);
1710 return STATUS_SUCCESS;
1713 /*****************************************************
1714 * PsSetLoadImageNotifyRoutine (NTOSKRNL.EXE.@)
1716 NTSTATUS WINAPI PsSetLoadImageNotifyRoutine(PLOAD_IMAGE_NOTIFY_ROUTINE routine)
1718 FIXME("(%p) stub\n", routine);
1719 return STATUS_SUCCESS;
1722 /*****************************************************
1723 * PsLookupProcessByProcessId (NTOSKRNL.EXE.@)
1725 NTSTATUS WINAPI PsLookupProcessByProcessId(HANDLE processid, PEPROCESS *process)
1727 FIXME("(%p %p) stub\n", processid, process);
1728 return STATUS_NOT_IMPLEMENTED;
1732 /*****************************************************
1733 * IoSetThreadHardErrorMode (NTOSKRNL.EXE.@)
1735 BOOLEAN WINAPI IoSetThreadHardErrorMode(BOOLEAN EnableHardErrors)
1742 /*****************************************************
1743 * IoInitializeRemoveLockEx (NTOSKRNL.EXE.@)
1745 VOID WINAPI IoInitializeRemoveLockEx(PIO_REMOVE_LOCK lock, ULONG tag,
1746 ULONG maxmin, ULONG high, ULONG size)
1748 FIXME("(%p %u %u %u %u) stub\n", lock, tag, maxmin, high, size);
1751 /*****************************************************
1754 BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
1756 static void *handler;
1757 LARGE_INTEGER count;
1761 case DLL_PROCESS_ATTACH:
1762 DisableThreadLibraryCalls( inst );
1764 handler = RtlAddVectoredExceptionHandler( TRUE, vectored_handler );
1766 KeQueryTickCount( &count ); /* initialize the global KeTickCount */
1768 case DLL_PROCESS_DETACH:
1769 RtlRemoveVectoredExceptionHandler( handler );
1775 /*****************************************************
1776 * Ke386IoSetAccessProcess (NTOSKRNL.EXE.@)
1778 BOOLEAN WINAPI Ke386IoSetAccessProcess(PEPROCESS *process, ULONG flag)
1780 FIXME("(%p %d) stub\n", process, flag);
1784 /*****************************************************
1785 * Ke386SetIoAccessMap (NTOSKRNL.EXE.@)
1787 BOOLEAN WINAPI Ke386SetIoAccessMap(ULONG flag, PVOID buffer)
1789 FIXME("(%d %p) stub\n", flag, buffer);
1793 /*****************************************************
1794 * IoCreateSynchronizationEvent (NTOSKRNL.EXE.@)
1796 PKEVENT WINAPI IoCreateSynchronizationEvent(PUNICODE_STRING name, PHANDLE handle)
1798 FIXME("(%p %p) stub\n", name, handle);
1802 /*****************************************************
1803 * IoStartNextPacket (NTOSKRNL.EXE.@)
1805 VOID WINAPI IoStartNextPacket(PDEVICE_OBJECT deviceobject, BOOLEAN cancelable)
1807 FIXME("(%p %d) stub\n", deviceobject, cancelable);