wineps: Fix a couple of typos in the path painting function.
[wine/testsucceed.git] / dlls / ntoskrnl.exe / ntoskrnl.c
blob9c7916e63debb67eab2ea8c80bc17f901f4fca32
1 /*
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
22 #include "config.h"
23 #include "wine/port.h"
25 #include <stdarg.h>
27 #define NONAMELESSUNION
28 #define NONAMELESSSTRUCT
30 #include "ntstatus.h"
31 #define WIN32_NO_STATUS
32 #include "windef.h"
33 #include "winternl.h"
34 #include "excpt.h"
35 #include "ddk/ntddk.h"
36 #include "wine/unicode.h"
37 #include "wine/server.h"
38 #include "wine/list.h"
39 #include "wine/debug.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(ntoskrnl);
42 WINE_DECLARE_DEBUG_CHANNEL(relay);
44 BOOLEAN KdDebuggerEnabled = FALSE;
46 extern LONG CALLBACK vectored_handler( EXCEPTION_POINTERS *ptrs );
48 KSYSTEM_TIME KeTickCount = { 0, 0, 0 };
50 typedef struct _KSERVICE_TABLE_DESCRIPTOR
52 PULONG_PTR Base;
53 PULONG Count;
54 ULONG Limit;
55 PUCHAR Number;
56 } KSERVICE_TABLE_DESCRIPTOR, *PKSERVICE_TABLE_DESCRIPTOR;
58 KSERVICE_TABLE_DESCRIPTOR KeServiceDescriptorTable[4] = { { 0 } };
60 typedef void (WINAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)(HANDLE,HANDLE,BOOLEAN);
61 typedef void (WINAPI *PCREATE_THREAD_NOTIFY_ROUTINE)(HANDLE,HANDLE,BOOLEAN);
63 static struct list Irps = LIST_INIT(Irps);
65 struct IrpInstance
67 struct list entry;
68 IRP *irp;
71 /* tid of the thread running client request */
72 static DWORD request_thread;
74 /* pid/tid of the client thread */
75 static DWORD client_tid;
76 static DWORD client_pid;
78 #ifdef __i386__
79 #define DEFINE_FASTCALL1_ENTRYPOINT( name ) \
80 __ASM_STDCALL_FUNC( name, 4, \
81 "popl %eax\n\t" \
82 "pushl %ecx\n\t" \
83 "pushl %eax\n\t" \
84 "jmp " __ASM_NAME("__regs_") #name __ASM_STDCALL(4))
85 #define DEFINE_FASTCALL2_ENTRYPOINT( name ) \
86 __ASM_STDCALL_FUNC( name, 8, \
87 "popl %eax\n\t" \
88 "pushl %edx\n\t" \
89 "pushl %ecx\n\t" \
90 "pushl %eax\n\t" \
91 "jmp " __ASM_NAME("__regs_") #name __ASM_STDCALL(8))
92 #define DEFINE_FASTCALL3_ENTRYPOINT( name ) \
93 __ASM_STDCALL_FUNC( name, 12, \
94 "popl %eax\n\t" \
95 "pushl %edx\n\t" \
96 "pushl %ecx\n\t" \
97 "pushl %eax\n\t" \
98 "jmp " __ASM_NAME("__regs_") #name __ASM_STDCALL(12))
99 #endif
101 static inline LPCSTR debugstr_us( const UNICODE_STRING *us )
103 if (!us) return "<null>";
104 return debugstr_wn( us->Buffer, us->Length / sizeof(WCHAR) );
107 static HANDLE get_device_manager(void)
109 static HANDLE device_manager;
110 HANDLE handle = 0, ret = device_manager;
112 if (!ret)
114 SERVER_START_REQ( create_device_manager )
116 req->access = SYNCHRONIZE;
117 req->attributes = 0;
118 if (!wine_server_call( req )) handle = wine_server_ptr_handle( reply->handle );
120 SERVER_END_REQ;
122 if (!handle)
124 ERR( "failed to create the device manager\n" );
125 return 0;
127 if (!(ret = InterlockedCompareExchangePointer( &device_manager, handle, 0 )))
128 ret = handle;
129 else
130 NtClose( handle ); /* somebody beat us to it */
132 return ret;
135 /* process an ioctl request for a given device */
136 static NTSTATUS process_ioctl( DEVICE_OBJECT *device, ULONG code, void *in_buff, ULONG in_size,
137 void *out_buff, ULONG *out_size )
139 IRP irp;
140 MDL mdl;
141 IO_STACK_LOCATION irpsp;
142 PDRIVER_DISPATCH dispatch = device->DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL];
143 NTSTATUS status;
144 LARGE_INTEGER count;
146 TRACE( "ioctl %x device %p in_size %u out_size %u\n", code, device, in_size, *out_size );
148 /* so we can spot things that we should initialize */
149 memset( &irp, 0x55, sizeof(irp) );
150 memset( &irpsp, 0x66, sizeof(irpsp) );
151 memset( &mdl, 0x77, sizeof(mdl) );
153 irp.RequestorMode = UserMode;
154 irp.AssociatedIrp.SystemBuffer = in_buff;
155 irp.UserBuffer = out_buff;
156 irp.MdlAddress = &mdl;
157 irp.Tail.Overlay.s.u2.CurrentStackLocation = &irpsp;
158 irp.UserIosb = NULL;
160 irpsp.MajorFunction = IRP_MJ_DEVICE_CONTROL;
161 irpsp.Parameters.DeviceIoControl.OutputBufferLength = *out_size;
162 irpsp.Parameters.DeviceIoControl.InputBufferLength = in_size;
163 irpsp.Parameters.DeviceIoControl.IoControlCode = code;
164 irpsp.Parameters.DeviceIoControl.Type3InputBuffer = in_buff;
165 irpsp.DeviceObject = device;
166 irpsp.CompletionRoutine = NULL;
168 mdl.Next = NULL;
169 mdl.Size = 0;
170 mdl.StartVa = out_buff;
171 mdl.ByteCount = *out_size;
172 mdl.ByteOffset = 0;
174 device->CurrentIrp = &irp;
176 KeQueryTickCount( &count ); /* update the global KeTickCount */
178 if (TRACE_ON(relay))
179 DPRINTF( "%04x:Call driver dispatch %p (device=%p,irp=%p)\n",
180 GetCurrentThreadId(), dispatch, device, &irp );
182 status = dispatch( device, &irp );
184 if (TRACE_ON(relay))
185 DPRINTF( "%04x:Ret driver dispatch %p (device=%p,irp=%p) retval=%08x\n",
186 GetCurrentThreadId(), dispatch, device, &irp, status );
188 *out_size = (irp.IoStatus.u.Status >= 0) ? irp.IoStatus.Information : 0;
189 return irp.IoStatus.u.Status;
193 /***********************************************************************
194 * wine_ntoskrnl_main_loop (Not a Windows API)
196 NTSTATUS CDECL wine_ntoskrnl_main_loop( HANDLE stop_event )
198 HANDLE manager = get_device_manager();
199 obj_handle_t ioctl = 0;
200 NTSTATUS status = STATUS_SUCCESS;
201 ULONG code = 0;
202 void *in_buff, *out_buff = NULL;
203 DEVICE_OBJECT *device = NULL;
204 ULONG in_size = 4096, out_size = 0;
205 HANDLE handles[2];
207 request_thread = GetCurrentThreadId();
209 if (!(in_buff = HeapAlloc( GetProcessHeap(), 0, in_size )))
211 ERR( "failed to allocate buffer\n" );
212 return STATUS_NO_MEMORY;
215 handles[0] = stop_event;
216 handles[1] = manager;
218 for (;;)
220 SERVER_START_REQ( get_next_device_request )
222 req->manager = wine_server_obj_handle( manager );
223 req->prev = ioctl;
224 req->status = status;
225 wine_server_add_data( req, out_buff, out_size );
226 wine_server_set_reply( req, in_buff, in_size );
227 if (!(status = wine_server_call( req )))
229 code = reply->code;
230 ioctl = reply->next;
231 device = wine_server_get_ptr( reply->user_ptr );
232 client_tid = reply->client_pid;
233 client_pid = reply->client_tid;
234 in_size = reply->in_size;
235 out_size = reply->out_size;
237 else
239 ioctl = 0; /* no previous ioctl */
240 out_size = 0;
241 in_size = reply->in_size;
244 SERVER_END_REQ;
246 switch(status)
248 case STATUS_SUCCESS:
249 HeapFree( GetProcessHeap(), 0, out_buff );
250 if (out_size) out_buff = HeapAlloc( GetProcessHeap(), 0, out_size );
251 else out_buff = NULL;
252 status = process_ioctl( device, code, in_buff, in_size, out_buff, &out_size );
253 break;
254 case STATUS_BUFFER_OVERFLOW:
255 HeapFree( GetProcessHeap(), 0, in_buff );
256 in_buff = HeapAlloc( GetProcessHeap(), 0, in_size );
257 /* restart with larger buffer */
258 break;
259 case STATUS_PENDING:
260 if (WaitForMultipleObjects( 2, handles, FALSE, INFINITE ) == WAIT_OBJECT_0)
262 HeapFree( GetProcessHeap(), 0, in_buff );
263 HeapFree( GetProcessHeap(), 0, out_buff );
264 return STATUS_SUCCESS;
266 break;
272 /***********************************************************************
273 * IoAllocateDriverObjectExtension (NTOSKRNL.EXE.@)
275 NTSTATUS WINAPI IoAllocateDriverObjectExtension( PDRIVER_OBJECT DriverObject,
276 PVOID ClientIdentificationAddress,
277 ULONG DriverObjectExtensionSize,
278 PVOID *DriverObjectExtension )
280 FIXME( "stub: %p, %p, %u, %p\n", DriverObject, ClientIdentificationAddress,
281 DriverObjectExtensionSize, DriverObjectExtension );
282 return STATUS_NOT_IMPLEMENTED;
286 /***********************************************************************
287 * IoGetDriverObjectExtension (NTOSKRNL.EXE.@)
289 PVOID WINAPI IoGetDriverObjectExtension( PDRIVER_OBJECT DriverObject,
290 PVOID ClientIdentificationAddress )
292 FIXME( "stub: %p, %p\n", DriverObject, ClientIdentificationAddress );
293 return NULL;
297 /***********************************************************************
298 * IoInitializeIrp (NTOSKRNL.EXE.@)
300 void WINAPI IoInitializeIrp( IRP *irp, USHORT size, CCHAR stack_size )
302 TRACE( "%p, %u, %d\n", irp, size, stack_size );
304 RtlZeroMemory( irp, size );
306 irp->Type = IO_TYPE_IRP;
307 irp->Size = size;
308 InitializeListHead( &irp->ThreadListEntry );
309 irp->StackCount = stack_size;
310 irp->CurrentLocation = stack_size + 1;
311 irp->Tail.Overlay.s.u2.CurrentStackLocation =
312 (PIO_STACK_LOCATION)(irp + 1) + stack_size;
316 /***********************************************************************
317 * IoInitializeTimer (NTOSKRNL.EXE.@)
319 NTSTATUS WINAPI IoInitializeTimer(PDEVICE_OBJECT DeviceObject,
320 PIO_TIMER_ROUTINE TimerRoutine,
321 PVOID Context)
323 FIXME( "stub: %p, %p, %p\n", DeviceObject, TimerRoutine, Context );
324 return STATUS_NOT_IMPLEMENTED;
328 /***********************************************************************
329 * IoStartTimer (NTOSKRNL.EXE.@)
331 void WINAPI IoStartTimer(PDEVICE_OBJECT DeviceObject)
333 FIXME( "stub: %p\n", DeviceObject );
337 /***********************************************************************
338 * IoAllocateIrp (NTOSKRNL.EXE.@)
340 PIRP WINAPI IoAllocateIrp( CCHAR stack_size, BOOLEAN charge_quota )
342 SIZE_T size;
343 PIRP irp;
345 TRACE( "%d, %d\n", stack_size, charge_quota );
347 size = sizeof(IRP) + stack_size * sizeof(IO_STACK_LOCATION);
348 irp = ExAllocatePool( NonPagedPool, size );
349 if (irp == NULL)
350 return NULL;
351 IoInitializeIrp( irp, size, stack_size );
352 irp->AllocationFlags = IRP_ALLOCATED_FIXED_SIZE;
353 if (charge_quota)
354 irp->AllocationFlags |= IRP_LOOKASIDE_ALLOCATION;
355 return irp;
359 /***********************************************************************
360 * IoFreeIrp (NTOSKRNL.EXE.@)
362 void WINAPI IoFreeIrp( IRP *irp )
364 TRACE( "%p\n", irp );
366 ExFreePool( irp );
370 /***********************************************************************
371 * IoAllocateErrorLogEntry (NTOSKRNL.EXE.@)
373 PVOID WINAPI IoAllocateErrorLogEntry( PVOID IoObject, UCHAR EntrySize )
375 FIXME( "stub: %p, %u\n", IoObject, EntrySize );
376 return NULL;
380 /***********************************************************************
381 * IoAllocateMdl (NTOSKRNL.EXE.@)
383 PMDL WINAPI IoAllocateMdl( PVOID VirtualAddress, ULONG Length, BOOLEAN SecondaryBuffer, BOOLEAN ChargeQuota, PIRP Irp )
385 FIXME( "stub: %p, %u, %i, %i, %p\n", VirtualAddress, Length, SecondaryBuffer, ChargeQuota, Irp );
386 return NULL;
390 /***********************************************************************
391 * IoAllocateWorkItem (NTOSKRNL.EXE.@)
393 PIO_WORKITEM WINAPI IoAllocateWorkItem( PDEVICE_OBJECT DeviceObject )
395 FIXME( "stub: %p\n", DeviceObject );
396 return NULL;
400 /***********************************************************************
401 * IoAttachDeviceToDeviceStack (NTOSKRNL.EXE.@)
403 PDEVICE_OBJECT WINAPI IoAttachDeviceToDeviceStack( DEVICE_OBJECT *source,
404 DEVICE_OBJECT *target )
406 TRACE( "%p, %p\n", source, target );
407 target->AttachedDevice = source;
408 source->StackSize = target->StackSize + 1;
409 return target;
413 /***********************************************************************
414 * IoBuildDeviceIoControlRequest (NTOSKRNL.EXE.@)
416 PIRP WINAPI IoBuildDeviceIoControlRequest( ULONG IoControlCode,
417 PDEVICE_OBJECT DeviceObject,
418 PVOID InputBuffer,
419 ULONG InputBufferLength,
420 PVOID OutputBuffer,
421 ULONG OutputBufferLength,
422 BOOLEAN InternalDeviceIoControl,
423 PKEVENT Event,
424 PIO_STATUS_BLOCK IoStatusBlock )
426 PIRP irp;
427 PIO_STACK_LOCATION irpsp;
428 struct IrpInstance *instance;
430 TRACE( "%x, %p, %p, %u, %p, %u, %u, %p, %p\n",
431 IoControlCode, DeviceObject, InputBuffer, InputBufferLength,
432 OutputBuffer, OutputBufferLength, InternalDeviceIoControl,
433 Event, IoStatusBlock );
435 if (DeviceObject == NULL)
436 return NULL;
438 irp = IoAllocateIrp( DeviceObject->StackSize, FALSE );
439 if (irp == NULL)
440 return NULL;
442 instance = HeapAlloc( GetProcessHeap(), 0, sizeof(struct IrpInstance) );
443 if (instance == NULL)
445 IoFreeIrp( irp );
446 return NULL;
448 instance->irp = irp;
449 list_add_tail( &Irps, &instance->entry );
451 irpsp = IoGetNextIrpStackLocation( irp );
452 irpsp->MajorFunction = InternalDeviceIoControl ?
453 IRP_MJ_INTERNAL_DEVICE_CONTROL : IRP_MJ_DEVICE_CONTROL;
454 irpsp->Parameters.DeviceIoControl.IoControlCode = IoControlCode;
455 irp->UserIosb = IoStatusBlock;
456 irp->UserEvent = Event;
458 return irp;
462 /***********************************************************************
463 * IoCreateDriver (NTOSKRNL.EXE.@)
465 NTSTATUS WINAPI IoCreateDriver( UNICODE_STRING *name, PDRIVER_INITIALIZE init )
467 DRIVER_OBJECT *driver;
468 DRIVER_EXTENSION *extension;
469 NTSTATUS status;
471 if (!(driver = RtlAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY,
472 sizeof(*driver) + sizeof(*extension) )))
473 return STATUS_NO_MEMORY;
475 if ((status = RtlDuplicateUnicodeString( 1, name, &driver->DriverName )))
477 RtlFreeHeap( GetProcessHeap(), 0, driver );
478 return status;
481 extension = (DRIVER_EXTENSION *)(driver + 1);
482 driver->Size = sizeof(*driver);
483 driver->DriverInit = init;
484 driver->DriverExtension = extension;
485 extension->DriverObject = driver;
486 extension->ServiceKeyName = driver->DriverName;
488 status = driver->DriverInit( driver, name );
490 if (status)
492 RtlFreeUnicodeString( &driver->DriverName );
493 RtlFreeHeap( GetProcessHeap(), 0, driver );
495 return status;
499 /***********************************************************************
500 * IoDeleteDriver (NTOSKRNL.EXE.@)
502 void WINAPI IoDeleteDriver( DRIVER_OBJECT *driver )
504 RtlFreeUnicodeString( &driver->DriverName );
505 RtlFreeHeap( GetProcessHeap(), 0, driver );
509 /***********************************************************************
510 * IoCreateDevice (NTOSKRNL.EXE.@)
512 NTSTATUS WINAPI IoCreateDevice( DRIVER_OBJECT *driver, ULONG ext_size,
513 UNICODE_STRING *name, DEVICE_TYPE type,
514 ULONG characteristics, BOOLEAN exclusive,
515 DEVICE_OBJECT **ret_device )
517 NTSTATUS status;
518 DEVICE_OBJECT *device;
519 HANDLE handle = 0;
520 HANDLE manager = get_device_manager();
522 TRACE( "(%p, %u, %s, %u, %x, %u, %p)\n",
523 driver, ext_size, debugstr_us(name), type, characteristics, exclusive, ret_device );
525 if (!(device = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*device) + ext_size )))
526 return STATUS_NO_MEMORY;
528 SERVER_START_REQ( create_device )
530 req->access = 0;
531 req->attributes = 0;
532 req->rootdir = 0;
533 req->manager = wine_server_obj_handle( manager );
534 req->user_ptr = wine_server_client_ptr( device );
535 if (name) wine_server_add_data( req, name->Buffer, name->Length );
536 if (!(status = wine_server_call( req ))) handle = wine_server_ptr_handle( reply->handle );
538 SERVER_END_REQ;
540 if (status == STATUS_SUCCESS)
542 device->DriverObject = driver;
543 device->DeviceExtension = device + 1;
544 device->DeviceType = type;
545 device->StackSize = 1;
546 device->Reserved = handle;
548 device->NextDevice = driver->DeviceObject;
549 driver->DeviceObject = device;
551 *ret_device = device;
553 else HeapFree( GetProcessHeap(), 0, device );
555 return status;
559 /***********************************************************************
560 * IoDeleteDevice (NTOSKRNL.EXE.@)
562 void WINAPI IoDeleteDevice( DEVICE_OBJECT *device )
564 NTSTATUS status;
566 TRACE( "%p\n", device );
568 SERVER_START_REQ( delete_device )
570 req->handle = wine_server_obj_handle( device->Reserved );
571 status = wine_server_call( req );
573 SERVER_END_REQ;
575 if (status == STATUS_SUCCESS)
577 DEVICE_OBJECT **prev = &device->DriverObject->DeviceObject;
578 while (*prev && *prev != device) prev = &(*prev)->NextDevice;
579 if (*prev) *prev = (*prev)->NextDevice;
580 NtClose( device->Reserved );
581 HeapFree( GetProcessHeap(), 0, device );
586 /***********************************************************************
587 * IoCreateSymbolicLink (NTOSKRNL.EXE.@)
589 NTSTATUS WINAPI IoCreateSymbolicLink( UNICODE_STRING *name, UNICODE_STRING *target )
591 HANDLE handle;
592 OBJECT_ATTRIBUTES attr;
594 attr.Length = sizeof(attr);
595 attr.RootDirectory = 0;
596 attr.ObjectName = name;
597 attr.Attributes = OBJ_CASE_INSENSITIVE | OBJ_OPENIF;
598 attr.SecurityDescriptor = NULL;
599 attr.SecurityQualityOfService = NULL;
601 TRACE( "%s -> %s\n", debugstr_us(name), debugstr_us(target) );
602 /* FIXME: store handle somewhere */
603 return NtCreateSymbolicLinkObject( &handle, SYMBOLIC_LINK_ALL_ACCESS, &attr, target );
607 /***********************************************************************
608 * IoDeleteSymbolicLink (NTOSKRNL.EXE.@)
610 NTSTATUS WINAPI IoDeleteSymbolicLink( UNICODE_STRING *name )
612 HANDLE handle;
613 OBJECT_ATTRIBUTES attr;
614 NTSTATUS status;
616 attr.Length = sizeof(attr);
617 attr.RootDirectory = 0;
618 attr.ObjectName = name;
619 attr.Attributes = OBJ_CASE_INSENSITIVE;
620 attr.SecurityDescriptor = NULL;
621 attr.SecurityQualityOfService = NULL;
623 if (!(status = NtOpenSymbolicLinkObject( &handle, 0, &attr )))
625 SERVER_START_REQ( unlink_object )
627 req->handle = wine_server_obj_handle( handle );
628 status = wine_server_call( req );
630 SERVER_END_REQ;
631 NtClose( handle );
633 return status;
637 /***********************************************************************
638 * IoGetDeviceInterfaces (NTOSKRNL.EXE.@)
640 NTSTATUS WINAPI IoGetDeviceInterfaces( CONST GUID *InterfaceClassGuid,
641 PDEVICE_OBJECT PhysicalDeviceObject,
642 ULONG Flags, PWSTR *SymbolicLinkList )
644 FIXME( "stub: %s %p %x %p\n", debugstr_guid(InterfaceClassGuid),
645 PhysicalDeviceObject, Flags, SymbolicLinkList );
646 return STATUS_NOT_IMPLEMENTED;
650 /***********************************************************************
651 * IoGetDeviceObjectPointer (NTOSKRNL.EXE.@)
653 NTSTATUS WINAPI IoGetDeviceObjectPointer( UNICODE_STRING *name, ACCESS_MASK access, PFILE_OBJECT *file, PDEVICE_OBJECT *device )
655 FIXME( "stub: %s %x %p %p\n", debugstr_us(name), access, file, device );
656 return STATUS_NOT_IMPLEMENTED;
660 /***********************************************************************
661 * IoGetDeviceProperty (NTOSKRNL.EXE.@)
663 NTSTATUS WINAPI IoGetDeviceProperty( DEVICE_OBJECT *device, DEVICE_REGISTRY_PROPERTY device_property,
664 ULONG buffer_length, PVOID property_buffer, PULONG result_length )
666 FIXME( "%p %d %u %p %p: stub\n", device, device_property, buffer_length,
667 property_buffer, result_length );
668 return STATUS_NOT_IMPLEMENTED;
672 /***********************************************************************
673 * IoCallDriver (NTOSKRNL.EXE.@)
675 NTSTATUS WINAPI IoCallDriver( DEVICE_OBJECT *device, IRP *irp )
677 PDRIVER_DISPATCH dispatch;
678 IO_STACK_LOCATION *irpsp;
679 NTSTATUS status;
681 TRACE( "%p %p\n", device, irp );
683 --irp->CurrentLocation;
684 irpsp = --irp->Tail.Overlay.s.u2.CurrentStackLocation;
685 dispatch = device->DriverObject->MajorFunction[irpsp->MajorFunction];
686 status = dispatch( device, irp );
688 return status;
692 /***********************************************************************
693 * IofCallDriver (NTOSKRNL.EXE.@)
695 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
696 DEFINE_FASTCALL2_ENTRYPOINT( IofCallDriver )
697 NTSTATUS WINAPI __regs_IofCallDriver( DEVICE_OBJECT *device, IRP *irp )
698 #else
699 NTSTATUS WINAPI IofCallDriver( DEVICE_OBJECT *device, IRP *irp )
700 #endif
702 TRACE( "%p %p\n", device, irp );
703 return IoCallDriver( device, irp );
707 /***********************************************************************
708 * IoGetRelatedDeviceObject (NTOSKRNL.EXE.@)
710 PDEVICE_OBJECT WINAPI IoGetRelatedDeviceObject( PFILE_OBJECT obj )
712 FIXME( "stub: %p\n", obj );
713 return NULL;
716 static CONFIGURATION_INFORMATION configuration_information;
718 /***********************************************************************
719 * IoGetConfigurationInformation (NTOSKRNL.EXE.@)
721 PCONFIGURATION_INFORMATION WINAPI IoGetConfigurationInformation(void)
723 FIXME( "partial stub\n" );
724 /* FIXME: return actual devices on system */
725 return &configuration_information;
729 /***********************************************************************
730 * IoIsWdmVersionAvailable (NTOSKRNL.EXE.@)
732 NTSTATUS WINAPI IoIsWdmVersionAvailable(UCHAR MajorVersion, UCHAR MinorVersion)
734 DWORD version;
735 DWORD major;
736 DWORD minor;
738 TRACE( "%d, 0x%X\n", MajorVersion, MinorVersion );
740 version = GetVersion();
741 major = LOBYTE(version);
742 minor = HIBYTE(LOWORD(version));
744 if (MajorVersion == 6 && MinorVersion == 0)
746 /* Windows Vista, Windows Server 2008, Windows 7 */
748 else if (MajorVersion == 1)
750 if (MinorVersion == 0x30)
752 /* Windows server 2003 */
753 MajorVersion = 6;
754 MinorVersion = 0;
756 else if (MinorVersion == 0x20)
758 /* Windows XP */
759 MajorVersion = 5;
760 MinorVersion = 1;
762 else if (MinorVersion == 0x10)
764 /* Windows 2000 */
765 MajorVersion = 5;
766 MinorVersion = 0;
768 else if (MinorVersion == 0x05)
770 /* Windows ME */
771 MajorVersion = 4;
772 MinorVersion = 0x5a;
774 else if (MinorVersion == 0x00)
776 /* Windows 98 */
777 MajorVersion = 4;
778 MinorVersion = 0x0a;
780 else
782 FIXME( "unknown major %d minor 0x%X\n", MajorVersion, MinorVersion );
783 return FALSE;
786 else
788 FIXME( "unknown major %d minor 0x%X\n", MajorVersion, MinorVersion );
789 return FALSE;
791 return major > MajorVersion || (major == MajorVersion && minor >= MinorVersion);
795 /***********************************************************************
796 * IoQueryDeviceDescription (NTOSKRNL.EXE.@)
798 NTSTATUS WINAPI IoQueryDeviceDescription(PINTERFACE_TYPE itype, PULONG bus, PCONFIGURATION_TYPE ctype,
799 PULONG cnum, PCONFIGURATION_TYPE ptype, PULONG pnum,
800 PIO_QUERY_DEVICE_ROUTINE callout, PVOID context)
802 FIXME( "(%p %p %p %p %p %p %p %p)\n", itype, bus, ctype, cnum, ptype, pnum, callout, context);
803 return STATUS_NOT_IMPLEMENTED;
807 /***********************************************************************
808 * IoRegisterDriverReinitialization (NTOSKRNL.EXE.@)
810 void WINAPI IoRegisterDriverReinitialization( PDRIVER_OBJECT obj, PDRIVER_REINITIALIZE reinit, PVOID context )
812 FIXME( "stub: %p %p %p\n", obj, reinit, context );
816 /***********************************************************************
817 * IoRegisterShutdownNotification (NTOSKRNL.EXE.@)
819 NTSTATUS WINAPI IoRegisterShutdownNotification( PDEVICE_OBJECT obj )
821 FIXME( "stub: %p\n", obj );
822 return STATUS_SUCCESS;
826 /***********************************************************************
827 * IoReportResourceUsage (NTOSKRNL.EXE.@)
829 NTSTATUS WINAPI IoReportResourceUsage(PUNICODE_STRING name, PDRIVER_OBJECT drv_obj, PCM_RESOURCE_LIST drv_list,
830 ULONG drv_size, PDRIVER_OBJECT dev_obj, PCM_RESOURCE_LIST dev_list,
831 ULONG dev_size, BOOLEAN overwrite, PBOOLEAN detected)
833 FIXME("(%s %p %p %u %p %p %u %d %p) stub\n", debugstr_w(name? name->Buffer : NULL),
834 drv_obj, drv_list, drv_size, dev_obj, dev_list, dev_size, overwrite, detected);
835 return STATUS_NOT_IMPLEMENTED;
839 /***********************************************************************
840 * IoCompleteRequest (NTOSKRNL.EXE.@)
842 VOID WINAPI IoCompleteRequest( IRP *irp, UCHAR priority_boost )
844 IO_STACK_LOCATION *irpsp;
845 PIO_COMPLETION_ROUTINE routine;
846 IO_STATUS_BLOCK *iosb;
847 struct IrpInstance *instance;
848 NTSTATUS status, stat;
849 int call_flag = 0;
851 TRACE( "%p %u\n", irp, priority_boost );
853 iosb = irp->UserIosb;
854 status = irp->IoStatus.u.Status;
855 while (irp->CurrentLocation <= irp->StackCount)
857 irpsp = irp->Tail.Overlay.s.u2.CurrentStackLocation;
858 routine = irpsp->CompletionRoutine;
859 call_flag = 0;
860 /* FIXME: add SL_INVOKE_ON_CANCEL support */
861 if (routine)
863 if ((irpsp->Control & SL_INVOKE_ON_SUCCESS) && STATUS_SUCCESS == status)
864 call_flag = 1;
865 if ((irpsp->Control & SL_INVOKE_ON_ERROR) && STATUS_SUCCESS != status)
866 call_flag = 1;
868 ++irp->CurrentLocation;
869 ++irp->Tail.Overlay.s.u2.CurrentStackLocation;
870 if (call_flag)
872 TRACE( "calling %p( %p, %p, %p )\n", routine,
873 irpsp->DeviceObject, irp, irpsp->Context );
874 stat = routine( irpsp->DeviceObject, irp, irpsp->Context );
875 TRACE( "CompletionRoutine returned %x\n", stat );
876 if (STATUS_MORE_PROCESSING_REQUIRED == stat)
877 return;
880 if (iosb && STATUS_SUCCESS == status)
882 iosb->u.Status = irp->IoStatus.u.Status;
883 iosb->Information = irp->IoStatus.Information;
885 LIST_FOR_EACH_ENTRY( instance, &Irps, struct IrpInstance, entry )
887 if (instance->irp == irp)
889 list_remove( &instance->entry );
890 HeapFree( GetProcessHeap(), 0, instance );
891 IoFreeIrp( irp );
892 break;
898 /***********************************************************************
899 * IofCompleteRequest (NTOSKRNL.EXE.@)
901 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
902 DEFINE_FASTCALL2_ENTRYPOINT( IofCompleteRequest )
903 void WINAPI __regs_IofCompleteRequest( IRP *irp, UCHAR priority_boost )
904 #else
905 void WINAPI IofCompleteRequest( IRP *irp, UCHAR priority_boost )
906 #endif
908 TRACE( "%p %u\n", irp, priority_boost );
909 IoCompleteRequest( irp, priority_boost );
913 /***********************************************************************
914 * InterlockedCompareExchange (NTOSKRNL.EXE.@)
916 #ifdef DEFINE_FASTCALL3_ENTRYPOINT
917 DEFINE_FASTCALL3_ENTRYPOINT( NTOSKRNL_InterlockedCompareExchange )
918 LONG WINAPI __regs_NTOSKRNL_InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare )
919 #else
920 LONG WINAPI NTOSKRNL_InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare )
921 #endif
923 return InterlockedCompareExchange( dest, xchg, compare );
927 /***********************************************************************
928 * InterlockedDecrement (NTOSKRNL.EXE.@)
930 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
931 DEFINE_FASTCALL1_ENTRYPOINT( NTOSKRNL_InterlockedDecrement )
932 LONG WINAPI __regs_NTOSKRNL_InterlockedDecrement( LONG volatile *dest )
933 #else
934 LONG WINAPI NTOSKRNL_InterlockedDecrement( LONG volatile *dest )
935 #endif
937 return InterlockedDecrement( dest );
941 /***********************************************************************
942 * InterlockedExchange (NTOSKRNL.EXE.@)
944 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
945 DEFINE_FASTCALL2_ENTRYPOINT( NTOSKRNL_InterlockedExchange )
946 LONG WINAPI __regs_NTOSKRNL_InterlockedExchange( LONG volatile *dest, LONG val )
947 #else
948 LONG WINAPI NTOSKRNL_InterlockedExchange( LONG volatile *dest, LONG val )
949 #endif
951 return InterlockedExchange( dest, val );
955 /***********************************************************************
956 * InterlockedExchangeAdd (NTOSKRNL.EXE.@)
958 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
959 DEFINE_FASTCALL2_ENTRYPOINT( NTOSKRNL_InterlockedExchangeAdd )
960 LONG WINAPI __regs_NTOSKRNL_InterlockedExchangeAdd( LONG volatile *dest, LONG incr )
961 #else
962 LONG WINAPI NTOSKRNL_InterlockedExchangeAdd( LONG volatile *dest, LONG incr )
963 #endif
965 return InterlockedExchangeAdd( dest, incr );
969 /***********************************************************************
970 * InterlockedIncrement (NTOSKRNL.EXE.@)
972 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
973 DEFINE_FASTCALL1_ENTRYPOINT( NTOSKRNL_InterlockedIncrement )
974 LONG WINAPI __regs_NTOSKRNL_InterlockedIncrement( LONG volatile *dest )
975 #else
976 LONG WINAPI NTOSKRNL_InterlockedIncrement( LONG volatile *dest )
977 #endif
979 return InterlockedIncrement( dest );
983 /***********************************************************************
984 * ExAllocatePool (NTOSKRNL.EXE.@)
986 PVOID WINAPI ExAllocatePool( POOL_TYPE type, SIZE_T size )
988 return ExAllocatePoolWithTag( type, size, 0 );
992 /***********************************************************************
993 * ExAllocatePoolWithQuota (NTOSKRNL.EXE.@)
995 PVOID WINAPI ExAllocatePoolWithQuota( POOL_TYPE type, SIZE_T size )
997 return ExAllocatePoolWithTag( type, size, 0 );
1001 /***********************************************************************
1002 * ExAllocatePoolWithTag (NTOSKRNL.EXE.@)
1004 PVOID WINAPI ExAllocatePoolWithTag( POOL_TYPE type, SIZE_T size, ULONG tag )
1006 /* FIXME: handle page alignment constraints */
1007 void *ret = HeapAlloc( GetProcessHeap(), 0, size );
1008 TRACE( "%lu pool %u -> %p\n", size, type, ret );
1009 return ret;
1013 /***********************************************************************
1014 * ExAllocatePoolWithQuotaTag (NTOSKRNL.EXE.@)
1016 PVOID WINAPI ExAllocatePoolWithQuotaTag( POOL_TYPE type, SIZE_T size, ULONG tag )
1018 return ExAllocatePoolWithTag( type, size, tag );
1022 /***********************************************************************
1023 * ExFreePool (NTOSKRNL.EXE.@)
1025 void WINAPI ExFreePool( void *ptr )
1027 ExFreePoolWithTag( ptr, 0 );
1031 /***********************************************************************
1032 * ExFreePoolWithTag (NTOSKRNL.EXE.@)
1034 void WINAPI ExFreePoolWithTag( void *ptr, ULONG tag )
1036 TRACE( "%p\n", ptr );
1037 HeapFree( GetProcessHeap(), 0, ptr );
1041 /***********************************************************************
1042 * ExInitializeResourceLite (NTOSKRNL.EXE.@)
1044 NTSTATUS WINAPI ExInitializeResourceLite(PERESOURCE Resource)
1046 FIXME( "stub: %p\n", Resource );
1047 return STATUS_NOT_IMPLEMENTED;
1051 /***********************************************************************
1052 * ExInitializeNPagedLookasideList (NTOSKRNL.EXE.@)
1054 void WINAPI ExInitializeNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside,
1055 PALLOCATE_FUNCTION Allocate,
1056 PFREE_FUNCTION Free,
1057 ULONG Flags,
1058 SIZE_T Size,
1059 ULONG Tag,
1060 USHORT Depth)
1062 FIXME( "stub: %p, %p, %p, %u, %lu, %u, %u\n", Lookaside, Allocate, Free, Flags, Size, Tag, Depth );
1066 /***********************************************************************
1067 * ExInitializeZone (NTOSKRNL.EXE.@)
1069 NTSTATUS WINAPI ExInitializeZone(PZONE_HEADER Zone,
1070 ULONG BlockSize,
1071 PVOID InitialSegment,
1072 ULONG InitialSegmentSize)
1074 FIXME( "stub: %p, %u, %p, %u\n", Zone, BlockSize, InitialSegment, InitialSegmentSize );
1075 return STATUS_NOT_IMPLEMENTED;
1078 /***********************************************************************
1079 * FsRtlRegisterUncProvider (NTOSKRNL.EXE.@)
1081 NTSTATUS WINAPI FsRtlRegisterUncProvider(PHANDLE MupHandle, PUNICODE_STRING RedirDevName,
1082 BOOLEAN MailslotsSupported)
1084 FIXME("(%p %p %d): stub\n", MupHandle, RedirDevName, MailslotsSupported);
1085 return STATUS_NOT_IMPLEMENTED;
1088 /***********************************************************************
1089 * KeGetCurrentThread / PsGetCurrentThread (NTOSKRNL.EXE.@)
1091 PRKTHREAD WINAPI KeGetCurrentThread(void)
1093 FIXME("() stub\n");
1094 return NULL;
1097 /***********************************************************************
1098 * KeInitializeEvent (NTOSKRNL.EXE.@)
1100 void WINAPI KeInitializeEvent( PRKEVENT Event, EVENT_TYPE Type, BOOLEAN State )
1102 FIXME( "stub: %p %d %d\n", Event, Type, State );
1106 /***********************************************************************
1107 * KeInitializeMutex (NTOSKRNL.EXE.@)
1109 void WINAPI KeInitializeMutex(PRKMUTEX Mutex, ULONG Level)
1111 FIXME( "stub: %p, %u\n", Mutex, Level );
1115 /***********************************************************************
1116 * KeWaitForMutexObject (NTOSKRNL.EXE.@)
1118 NTSTATUS WINAPI KeWaitForMutexObject(PRKMUTEX Mutex, KWAIT_REASON WaitReason, KPROCESSOR_MODE WaitMode,
1119 BOOLEAN Alertable, PLARGE_INTEGER Timeout)
1121 FIXME( "stub: %p, %d, %d, %d, %p\n", Mutex, WaitReason, WaitMode, Alertable, Timeout );
1122 return STATUS_NOT_IMPLEMENTED;
1126 /***********************************************************************
1127 * KeReleaseMutex (NTOSKRNL.EXE.@)
1129 LONG WINAPI KeReleaseMutex(PRKMUTEX Mutex, BOOLEAN Wait)
1131 FIXME( "stub: %p, %d\n", Mutex, Wait );
1132 return STATUS_NOT_IMPLEMENTED;
1136 /***********************************************************************
1137 * KeInitializeSemaphore (NTOSKRNL.EXE.@)
1139 void WINAPI KeInitializeSemaphore( PRKSEMAPHORE Semaphore, LONG Count, LONG Limit )
1141 FIXME( "(%p %d %d) stub\n", Semaphore , Count, Limit );
1145 /***********************************************************************
1146 * KeInitializeSpinLock (NTOSKRNL.EXE.@)
1148 void WINAPI KeInitializeSpinLock( PKSPIN_LOCK SpinLock )
1150 FIXME( "stub: %p\n", SpinLock );
1154 /***********************************************************************
1155 * KeInitializeTimerEx (NTOSKRNL.EXE.@)
1157 void WINAPI KeInitializeTimerEx( PKTIMER Timer, TIMER_TYPE Type )
1159 FIXME( "stub: %p %d\n", Timer, Type );
1163 /***********************************************************************
1164 * KeInitializeTimer (NTOSKRNL.EXE.@)
1166 void WINAPI KeInitializeTimer( PKTIMER Timer )
1168 KeInitializeTimerEx(Timer, NotificationTimer);
1172 /**********************************************************************
1173 * KeQueryActiveProcessors (NTOSKRNL.EXE.@)
1175 * Return the active Processors as bitmask
1177 * RETURNS
1178 * active Processors as bitmask
1181 KAFFINITY WINAPI KeQueryActiveProcessors( void )
1183 DWORD_PTR AffinityMask;
1185 GetProcessAffinityMask( GetCurrentProcess(), &AffinityMask, NULL);
1186 return AffinityMask;
1190 /**********************************************************************
1191 * KeQueryInterruptTime (NTOSKRNL.EXE.@)
1193 * Return the interrupt time count
1196 ULONGLONG WINAPI KeQueryInterruptTime( void )
1198 LARGE_INTEGER totaltime;
1200 KeQueryTickCount(&totaltime);
1201 return totaltime.QuadPart;
1205 /***********************************************************************
1206 * KeQuerySystemTime (NTOSKRNL.EXE.@)
1208 void WINAPI KeQuerySystemTime( LARGE_INTEGER *time )
1210 NtQuerySystemTime( time );
1214 /***********************************************************************
1215 * KeQueryTickCount (NTOSKRNL.EXE.@)
1217 void WINAPI KeQueryTickCount( LARGE_INTEGER *count )
1219 count->QuadPart = NtGetTickCount();
1220 /* update the global variable too */
1221 KeTickCount.LowPart = count->u.LowPart;
1222 KeTickCount.High1Time = count->u.HighPart;
1223 KeTickCount.High2Time = count->u.HighPart;
1227 /***********************************************************************
1228 * KeReleaseSemaphore (NTOSKRNL.EXE.@)
1230 LONG WINAPI KeReleaseSemaphore( PRKSEMAPHORE Semaphore, KPRIORITY Increment,
1231 LONG Adjustment, BOOLEAN Wait )
1233 FIXME("(%p %d %d %d) stub\n", Semaphore, Increment, Adjustment, Wait );
1234 return 0;
1238 /***********************************************************************
1239 * KeQueryTimeIncrement (NTOSKRNL.EXE.@)
1241 ULONG WINAPI KeQueryTimeIncrement(void)
1243 return 10000;
1247 /***********************************************************************
1248 * KeResetEvent (NTOSKRNL.EXE.@)
1250 LONG WINAPI KeResetEvent( PRKEVENT Event )
1252 FIXME("(%p): stub\n", Event);
1253 return 0;
1257 /***********************************************************************
1258 * KeSetEvent (NTOSKRNL.EXE.@)
1260 LONG WINAPI KeSetEvent( PRKEVENT Event, KPRIORITY Increment, BOOLEAN Wait )
1262 FIXME("(%p, %d, %d): stub\n", Event, Increment, Wait);
1263 return 0;
1267 /***********************************************************************
1268 * KeSetPriorityThread (NTOSKRNL.EXE.@)
1270 KPRIORITY WINAPI KeSetPriorityThread( PKTHREAD Thread, KPRIORITY Priority )
1272 FIXME("(%p %d)\n", Thread, Priority);
1273 return Priority;
1277 /***********************************************************************
1278 * KeWaitForSingleObject (NTOSKRNL.EXE.@)
1280 NTSTATUS WINAPI KeWaitForSingleObject(PVOID Object,
1281 KWAIT_REASON WaitReason,
1282 KPROCESSOR_MODE WaitMode,
1283 BOOLEAN Alertable,
1284 PLARGE_INTEGER Timeout)
1286 FIXME( "stub: %p, %d, %d, %d, %p\n", Object, WaitReason, WaitMode, Alertable, Timeout );
1287 return STATUS_NOT_IMPLEMENTED;
1290 /***********************************************************************
1291 * IoRegisterFileSystem (NTOSKRNL.EXE.@)
1293 VOID WINAPI IoRegisterFileSystem(PDEVICE_OBJECT DeviceObject)
1295 FIXME("(%p): stub\n", DeviceObject);
1298 /***********************************************************************
1299 * IoUnregisterFileSystem (NTOSKRNL.EXE.@)
1301 VOID WINAPI IoUnregisterFileSystem(PDEVICE_OBJECT DeviceObject)
1303 FIXME("(%p): stub\n", DeviceObject);
1306 /***********************************************************************
1307 * MmAllocateNonCachedMemory (NTOSKRNL.EXE.@)
1309 PVOID WINAPI MmAllocateNonCachedMemory( SIZE_T size )
1311 TRACE( "%lu\n", size );
1312 return VirtualAlloc( NULL, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE|PAGE_NOCACHE );
1315 /***********************************************************************
1316 * MmAllocateContiguousMemory (NTOSKRNL.EXE.@)
1318 PVOID WINAPI MmAllocateContiguousMemory( SIZE_T size, PHYSICAL_ADDRESS highest_valid_address )
1320 FIXME( "%lu, %s stub\n", size, wine_dbgstr_longlong(highest_valid_address.QuadPart) );
1321 return NULL;
1324 /***********************************************************************
1325 * MmAllocateContiguousMemorySpecifyCache (NTOSKRNL.EXE.@)
1327 PVOID WINAPI MmAllocateContiguousMemorySpecifyCache( SIZE_T size,
1328 PHYSICAL_ADDRESS lowest_valid_address,
1329 PHYSICAL_ADDRESS highest_valid_address,
1330 PHYSICAL_ADDRESS BoundaryAddressMultiple,
1331 MEMORY_CACHING_TYPE CacheType )
1333 FIXME(": stub\n");
1334 return NULL;
1337 /***********************************************************************
1338 * MmAllocatePagesForMdl (NTOSKRNL.EXE.@)
1340 PMDL WINAPI MmAllocatePagesForMdl(PHYSICAL_ADDRESS lowaddress, PHYSICAL_ADDRESS highaddress,
1341 PHYSICAL_ADDRESS skipbytes, SIZE_T size)
1343 FIXME("%s %s %s %lu: stub\n", wine_dbgstr_longlong(lowaddress.QuadPart), wine_dbgstr_longlong(highaddress.QuadPart),
1344 wine_dbgstr_longlong(skipbytes.QuadPart), size);
1345 return NULL;
1348 /***********************************************************************
1349 * MmFreeNonCachedMemory (NTOSKRNL.EXE.@)
1351 void WINAPI MmFreeNonCachedMemory( void *addr, SIZE_T size )
1353 TRACE( "%p %lu\n", addr, size );
1354 VirtualFree( addr, 0, MEM_RELEASE );
1357 /***********************************************************************
1358 * MmIsAddressValid (NTOSKRNL.EXE.@)
1360 * Check if the process can access the virtual address without a pagefault
1362 * PARAMS
1363 * VirtualAddress [I] Address to check
1365 * RETURNS
1366 * Failure: FALSE
1367 * Success: TRUE (Accessing the Address works without a Pagefault)
1370 BOOLEAN WINAPI MmIsAddressValid(PVOID VirtualAddress)
1372 TRACE("(%p)\n", VirtualAddress);
1373 return !IsBadWritePtr(VirtualAddress, 1);
1376 /***********************************************************************
1377 * MmMapIoSpace (NTOSKRNL.EXE.@)
1379 PVOID WINAPI MmMapIoSpace( PHYSICAL_ADDRESS PhysicalAddress, DWORD NumberOfBytes, DWORD CacheType )
1381 FIXME( "stub: 0x%08x%08x, %d, %d\n", PhysicalAddress.u.HighPart, PhysicalAddress.u.LowPart, NumberOfBytes, CacheType );
1382 return NULL;
1385 /***********************************************************************
1386 * MmPageEntireDriver (NTOSKRNL.EXE.@)
1388 PVOID WINAPI MmPageEntireDriver(PVOID AddrInSection)
1390 TRACE("%p\n", AddrInSection);
1391 return AddrInSection;
1394 /***********************************************************************
1395 * MmResetDriverPaging (NTOSKRNL.EXE.@)
1397 void WINAPI MmResetDriverPaging(PVOID AddrInSection)
1399 TRACE("%p\n", AddrInSection);
1402 /***********************************************************************
1403 * MmUnmapIoSpace (NTOSKRNL.EXE.@)
1405 VOID WINAPI MmUnmapIoSpace( PVOID BaseAddress, SIZE_T NumberOfBytes )
1407 FIXME( "stub: %p, %lu\n", BaseAddress, NumberOfBytes );
1410 /***********************************************************************
1411 * ObfReferenceObject (NTOSKRNL.EXE.@)
1413 VOID WINAPI ObfReferenceObject(PVOID Object)
1415 FIXME("(%p): stub\n", Object);
1418 /***********************************************************************
1419 * ObReferenceObjectByHandle (NTOSKRNL.EXE.@)
1421 NTSTATUS WINAPI ObReferenceObjectByHandle( HANDLE obj, ACCESS_MASK access,
1422 POBJECT_TYPE type,
1423 KPROCESSOR_MODE mode, PVOID* ptr,
1424 POBJECT_HANDLE_INFORMATION info)
1426 FIXME( "stub: %p %x %p %d %p %p\n", obj, access, type, mode, ptr, info);
1427 return STATUS_NOT_IMPLEMENTED;
1430 /***********************************************************************
1431 * ObReferenceObjectByName (NTOSKRNL.EXE.@)
1433 NTSTATUS WINAPI ObReferenceObjectByName( UNICODE_STRING *ObjectName,
1434 ULONG Attributes,
1435 ACCESS_STATE *AccessState,
1436 ACCESS_MASK DesiredAccess,
1437 POBJECT_TYPE ObjectType,
1438 KPROCESSOR_MODE AccessMode,
1439 void *ParseContext,
1440 void **Object)
1442 FIXME("stub\n");
1443 return STATUS_NOT_IMPLEMENTED;
1446 /***********************************************************************
1447 * ObfDereferenceObject (NTOSKRNL.EXE.@)
1449 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
1450 DEFINE_FASTCALL1_ENTRYPOINT( ObfDereferenceObject )
1451 void WINAPI __regs_ObfDereferenceObject( VOID *obj )
1452 #else
1453 void WINAPI ObfDereferenceObject( VOID *obj )
1454 #endif
1456 FIXME( "stub: %p\n", obj );
1460 /***********************************************************************
1461 * PsCreateSystemThread (NTOSKRNL.EXE.@)
1463 NTSTATUS WINAPI PsCreateSystemThread(PHANDLE ThreadHandle, ULONG DesiredAccess,
1464 POBJECT_ATTRIBUTES ObjectAttributes,
1465 HANDLE ProcessHandle, PCLIENT_ID ClientId,
1466 PKSTART_ROUTINE StartRoutine, PVOID StartContext)
1468 if (!ProcessHandle) ProcessHandle = GetCurrentProcess();
1469 return RtlCreateUserThread(ProcessHandle, 0, FALSE, 0, 0,
1470 0, StartRoutine, StartContext,
1471 ThreadHandle, ClientId);
1474 /***********************************************************************
1475 * PsGetCurrentProcessId (NTOSKRNL.EXE.@)
1477 HANDLE WINAPI PsGetCurrentProcessId(void)
1479 if (GetCurrentThreadId() == request_thread)
1480 return UlongToHandle(client_pid);
1481 return UlongToHandle(GetCurrentProcessId());
1485 /***********************************************************************
1486 * PsGetCurrentThreadId (NTOSKRNL.EXE.@)
1488 HANDLE WINAPI PsGetCurrentThreadId(void)
1490 if (GetCurrentThreadId() == request_thread)
1491 return UlongToHandle(client_tid);
1492 return UlongToHandle(GetCurrentThreadId());
1496 /***********************************************************************
1497 * PsGetVersion (NTOSKRNL.EXE.@)
1499 BOOLEAN WINAPI PsGetVersion(ULONG *major, ULONG *minor, ULONG *build, UNICODE_STRING *version )
1501 RTL_OSVERSIONINFOEXW info;
1503 info.dwOSVersionInfoSize = sizeof(info);
1504 RtlGetVersion( &info );
1505 if (major) *major = info.dwMajorVersion;
1506 if (minor) *minor = info.dwMinorVersion;
1507 if (build) *build = info.dwBuildNumber;
1509 if (version)
1511 #if 0 /* FIXME: GameGuard passes an uninitialized pointer in version->Buffer */
1512 size_t len = min( strlenW(info.szCSDVersion)*sizeof(WCHAR), version->MaximumLength );
1513 memcpy( version->Buffer, info.szCSDVersion, len );
1514 if (len < version->MaximumLength) version->Buffer[len / sizeof(WCHAR)] = 0;
1515 version->Length = len;
1516 #endif
1518 return TRUE;
1522 /***********************************************************************
1523 * PsSetCreateProcessNotifyRoutine (NTOSKRNL.EXE.@)
1525 NTSTATUS WINAPI PsSetCreateProcessNotifyRoutine( PCREATE_PROCESS_NOTIFY_ROUTINE callback, BOOLEAN remove )
1527 FIXME( "stub: %p %d\n", callback, remove );
1528 return STATUS_SUCCESS;
1532 /***********************************************************************
1533 * PsSetCreateThreadNotifyRoutine (NTOSKRNL.EXE.@)
1535 NTSTATUS WINAPI PsSetCreateThreadNotifyRoutine( PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine )
1537 FIXME( "stub: %p\n", NotifyRoutine );
1538 return STATUS_SUCCESS;
1542 /***********************************************************************
1543 * PsTerminateSystemThread (NTOSKRNL.EXE.@)
1545 NTSTATUS WINAPI PsTerminateSystemThread(NTSTATUS ExitStatus)
1547 FIXME( "stub: %u\n", ExitStatus );
1548 return STATUS_NOT_IMPLEMENTED;
1552 /***********************************************************************
1553 * MmGetSystemRoutineAddress (NTOSKRNL.EXE.@)
1555 PVOID WINAPI MmGetSystemRoutineAddress(PUNICODE_STRING SystemRoutineName)
1557 HMODULE hMod;
1558 STRING routineNameA;
1559 PVOID pFunc = NULL;
1561 static const WCHAR ntoskrnlW[] = {'n','t','o','s','k','r','n','l','.','e','x','e',0};
1562 static const WCHAR halW[] = {'h','a','l','.','d','l','l',0};
1564 if (!SystemRoutineName) return NULL;
1566 if (RtlUnicodeStringToAnsiString( &routineNameA, SystemRoutineName, TRUE ) == STATUS_SUCCESS)
1568 /* We only support functions exported from ntoskrnl.exe or hal.dll */
1569 hMod = GetModuleHandleW( ntoskrnlW );
1570 pFunc = GetProcAddress( hMod, routineNameA.Buffer );
1571 if (!pFunc)
1573 hMod = GetModuleHandleW( halW );
1574 if (hMod) pFunc = GetProcAddress( hMod, routineNameA.Buffer );
1576 RtlFreeAnsiString( &routineNameA );
1579 if (pFunc)
1580 TRACE( "%s -> %p\n", debugstr_us(SystemRoutineName), pFunc );
1581 else
1582 FIXME( "%s not found\n", debugstr_us(SystemRoutineName) );
1583 return pFunc;
1587 /***********************************************************************
1588 * MmQuerySystemSize (NTOSKRNL.EXE.@)
1590 MM_SYSTEMSIZE WINAPI MmQuerySystemSize(void)
1592 FIXME("stub\n");
1593 return MmLargeSystem;
1596 /***********************************************************************
1597 * KeInitializeDpc (NTOSKRNL.EXE.@)
1599 VOID WINAPI KeInitializeDpc(PRKDPC Dpc, PKDEFERRED_ROUTINE DeferredRoutine, PVOID DeferredContext)
1601 FIXME("stub\n");
1604 /***********************************************************************
1605 * READ_REGISTER_BUFFER_UCHAR (NTOSKRNL.EXE.@)
1607 VOID WINAPI READ_REGISTER_BUFFER_UCHAR(PUCHAR Register, PUCHAR Buffer, ULONG Count)
1609 FIXME("stub\n");
1612 /*****************************************************
1613 * PoSetPowerState (NTOSKRNL.EXE.@)
1615 POWER_STATE WINAPI PoSetPowerState(PDEVICE_OBJECT DeviceObject, POWER_STATE_TYPE Type, POWER_STATE State)
1617 FIXME("(%p %u %u) stub\n", DeviceObject, Type, State.DeviceState);
1618 return State;
1621 /*****************************************************
1622 * IoWMIRegistrationControl (NTOSKRNL.EXE.@)
1624 NTSTATUS WINAPI IoWMIRegistrationControl(PDEVICE_OBJECT DeviceObject, ULONG Action)
1626 FIXME("(%p %u ) stub\n", DeviceObject, Action);
1627 return STATUS_SUCCESS;
1630 /*****************************************************
1631 * PsSetLoadImageNotifyRoutine (NTOSKRNL.EXE.@)
1633 NTSTATUS WINAPI PsSetLoadImageNotifyRoutine(PLOAD_IMAGE_NOTIFY_ROUTINE routine)
1635 FIXME("(%p) stub\n", routine);
1636 return STATUS_SUCCESS;
1639 /*****************************************************
1640 * PsLookupProcessByProcessId (NTOSKRNL.EXE.@)
1642 NTSTATUS WINAPI PsLookupProcessByProcessId(HANDLE processid, PEPROCESS *process)
1644 FIXME("(%p %p) stub\n", processid, process);
1645 return STATUS_NOT_IMPLEMENTED;
1649 /*****************************************************
1650 * IoSetThreadHardErrorMode (NTOSKRNL.EXE.@)
1652 BOOLEAN WINAPI IoSetThreadHardErrorMode(BOOLEAN EnableHardErrors)
1654 FIXME("stub\n");
1655 return FALSE;
1658 /*****************************************************
1659 * DllMain
1661 BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
1663 static void *handler;
1664 LARGE_INTEGER count;
1666 switch(reason)
1668 case DLL_PROCESS_ATTACH:
1669 DisableThreadLibraryCalls( inst );
1670 #ifdef __i386__
1671 handler = RtlAddVectoredExceptionHandler( TRUE, vectored_handler );
1672 #endif
1673 KeQueryTickCount( &count ); /* initialize the global KeTickCount */
1674 break;
1675 case DLL_PROCESS_DETACH:
1676 RtlRemoveVectoredExceptionHandler( handler );
1677 break;
1679 return TRUE;