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
)
399 FIXME( "stub: %p, %u, %i, %i, %p\n", VirtualAddress
, Length
, SecondaryBuffer
, ChargeQuota
, Irp
);
404 /***********************************************************************
405 * IoAllocateWorkItem (NTOSKRNL.EXE.@)
407 PIO_WORKITEM WINAPI
IoAllocateWorkItem( PDEVICE_OBJECT DeviceObject
)
409 FIXME( "stub: %p\n", DeviceObject
);
414 /***********************************************************************
415 * IoAttachDeviceToDeviceStack (NTOSKRNL.EXE.@)
417 PDEVICE_OBJECT WINAPI
IoAttachDeviceToDeviceStack( DEVICE_OBJECT
*source
,
418 DEVICE_OBJECT
*target
)
420 TRACE( "%p, %p\n", source
, target
);
421 target
->AttachedDevice
= source
;
422 source
->StackSize
= target
->StackSize
+ 1;
427 /***********************************************************************
428 * IoBuildDeviceIoControlRequest (NTOSKRNL.EXE.@)
430 PIRP WINAPI
IoBuildDeviceIoControlRequest( ULONG IoControlCode
,
431 PDEVICE_OBJECT DeviceObject
,
433 ULONG InputBufferLength
,
435 ULONG OutputBufferLength
,
436 BOOLEAN InternalDeviceIoControl
,
438 PIO_STATUS_BLOCK IoStatusBlock
)
441 PIO_STACK_LOCATION irpsp
;
442 struct IrpInstance
*instance
;
444 TRACE( "%x, %p, %p, %u, %p, %u, %u, %p, %p\n",
445 IoControlCode
, DeviceObject
, InputBuffer
, InputBufferLength
,
446 OutputBuffer
, OutputBufferLength
, InternalDeviceIoControl
,
447 Event
, IoStatusBlock
);
449 if (DeviceObject
== NULL
)
452 irp
= IoAllocateIrp( DeviceObject
->StackSize
, FALSE
);
456 instance
= HeapAlloc( GetProcessHeap(), 0, sizeof(struct IrpInstance
) );
457 if (instance
== NULL
)
463 list_add_tail( &Irps
, &instance
->entry
);
465 irpsp
= IoGetNextIrpStackLocation( irp
);
466 irpsp
->MajorFunction
= InternalDeviceIoControl
?
467 IRP_MJ_INTERNAL_DEVICE_CONTROL
: IRP_MJ_DEVICE_CONTROL
;
468 irpsp
->Parameters
.DeviceIoControl
.IoControlCode
= IoControlCode
;
469 irp
->UserIosb
= IoStatusBlock
;
470 irp
->UserEvent
= Event
;
476 /***********************************************************************
477 * IoCreateDriver (NTOSKRNL.EXE.@)
479 NTSTATUS WINAPI
IoCreateDriver( UNICODE_STRING
*name
, PDRIVER_INITIALIZE init
)
481 DRIVER_OBJECT
*driver
;
482 DRIVER_EXTENSION
*extension
;
485 if (!(driver
= RtlAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY
,
486 sizeof(*driver
) + sizeof(*extension
) )))
487 return STATUS_NO_MEMORY
;
489 if ((status
= RtlDuplicateUnicodeString( 1, name
, &driver
->DriverName
)))
491 RtlFreeHeap( GetProcessHeap(), 0, driver
);
495 extension
= (DRIVER_EXTENSION
*)(driver
+ 1);
496 driver
->Size
= sizeof(*driver
);
497 driver
->DriverInit
= init
;
498 driver
->DriverExtension
= extension
;
499 extension
->DriverObject
= driver
;
500 extension
->ServiceKeyName
= driver
->DriverName
;
502 status
= driver
->DriverInit( driver
, name
);
506 RtlFreeUnicodeString( &driver
->DriverName
);
507 RtlFreeHeap( GetProcessHeap(), 0, driver
);
513 /***********************************************************************
514 * IoDeleteDriver (NTOSKRNL.EXE.@)
516 void WINAPI
IoDeleteDriver( DRIVER_OBJECT
*driver
)
518 RtlFreeUnicodeString( &driver
->DriverName
);
519 RtlFreeHeap( GetProcessHeap(), 0, driver
);
523 /***********************************************************************
524 * IoCreateDevice (NTOSKRNL.EXE.@)
526 NTSTATUS WINAPI
IoCreateDevice( DRIVER_OBJECT
*driver
, ULONG ext_size
,
527 UNICODE_STRING
*name
, DEVICE_TYPE type
,
528 ULONG characteristics
, BOOLEAN exclusive
,
529 DEVICE_OBJECT
**ret_device
)
532 DEVICE_OBJECT
*device
;
534 HANDLE manager
= get_device_manager();
536 TRACE( "(%p, %u, %s, %u, %x, %u, %p)\n",
537 driver
, ext_size
, debugstr_us(name
), type
, characteristics
, exclusive
, ret_device
);
539 if (!(device
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*device
) + ext_size
)))
540 return STATUS_NO_MEMORY
;
542 SERVER_START_REQ( create_device
)
547 req
->manager
= wine_server_obj_handle( manager
);
548 req
->user_ptr
= wine_server_client_ptr( device
);
549 if (name
) wine_server_add_data( req
, name
->Buffer
, name
->Length
);
550 if (!(status
= wine_server_call( req
))) handle
= wine_server_ptr_handle( reply
->handle
);
554 if (status
== STATUS_SUCCESS
)
556 device
->DriverObject
= driver
;
557 device
->DeviceExtension
= device
+ 1;
558 device
->DeviceType
= type
;
559 device
->StackSize
= 1;
560 device
->Reserved
= handle
;
562 device
->NextDevice
= driver
->DeviceObject
;
563 driver
->DeviceObject
= device
;
565 *ret_device
= device
;
567 else HeapFree( GetProcessHeap(), 0, device
);
573 /***********************************************************************
574 * IoDeleteDevice (NTOSKRNL.EXE.@)
576 void WINAPI
IoDeleteDevice( DEVICE_OBJECT
*device
)
580 TRACE( "%p\n", device
);
582 SERVER_START_REQ( delete_device
)
584 req
->handle
= wine_server_obj_handle( device
->Reserved
);
585 status
= wine_server_call( req
);
589 if (status
== STATUS_SUCCESS
)
591 DEVICE_OBJECT
**prev
= &device
->DriverObject
->DeviceObject
;
592 while (*prev
&& *prev
!= device
) prev
= &(*prev
)->NextDevice
;
593 if (*prev
) *prev
= (*prev
)->NextDevice
;
594 NtClose( device
->Reserved
);
595 HeapFree( GetProcessHeap(), 0, device
);
600 /***********************************************************************
601 * IoCreateSymbolicLink (NTOSKRNL.EXE.@)
603 NTSTATUS WINAPI
IoCreateSymbolicLink( UNICODE_STRING
*name
, UNICODE_STRING
*target
)
606 OBJECT_ATTRIBUTES attr
;
608 attr
.Length
= sizeof(attr
);
609 attr
.RootDirectory
= 0;
610 attr
.ObjectName
= name
;
611 attr
.Attributes
= OBJ_CASE_INSENSITIVE
| OBJ_OPENIF
;
612 attr
.SecurityDescriptor
= NULL
;
613 attr
.SecurityQualityOfService
= NULL
;
615 TRACE( "%s -> %s\n", debugstr_us(name
), debugstr_us(target
) );
616 /* FIXME: store handle somewhere */
617 return NtCreateSymbolicLinkObject( &handle
, SYMBOLIC_LINK_ALL_ACCESS
, &attr
, target
);
621 /***********************************************************************
622 * IoDeleteSymbolicLink (NTOSKRNL.EXE.@)
624 NTSTATUS WINAPI
IoDeleteSymbolicLink( UNICODE_STRING
*name
)
627 OBJECT_ATTRIBUTES attr
;
630 attr
.Length
= sizeof(attr
);
631 attr
.RootDirectory
= 0;
632 attr
.ObjectName
= name
;
633 attr
.Attributes
= OBJ_CASE_INSENSITIVE
;
634 attr
.SecurityDescriptor
= NULL
;
635 attr
.SecurityQualityOfService
= NULL
;
637 if (!(status
= NtOpenSymbolicLinkObject( &handle
, 0, &attr
)))
639 SERVER_START_REQ( unlink_object
)
641 req
->handle
= wine_server_obj_handle( handle
);
642 status
= wine_server_call( req
);
651 /***********************************************************************
652 * IoGetDeviceInterfaces (NTOSKRNL.EXE.@)
654 NTSTATUS WINAPI
IoGetDeviceInterfaces( CONST GUID
*InterfaceClassGuid
,
655 PDEVICE_OBJECT PhysicalDeviceObject
,
656 ULONG Flags
, PWSTR
*SymbolicLinkList
)
658 FIXME( "stub: %s %p %x %p\n", debugstr_guid(InterfaceClassGuid
),
659 PhysicalDeviceObject
, Flags
, SymbolicLinkList
);
660 return STATUS_NOT_IMPLEMENTED
;
664 /***********************************************************************
665 * IoGetDeviceObjectPointer (NTOSKRNL.EXE.@)
667 NTSTATUS WINAPI
IoGetDeviceObjectPointer( UNICODE_STRING
*name
, ACCESS_MASK access
, PFILE_OBJECT
*file
, PDEVICE_OBJECT
*device
)
669 FIXME( "stub: %s %x %p %p\n", debugstr_us(name
), access
, file
, device
);
670 return STATUS_NOT_IMPLEMENTED
;
674 /***********************************************************************
675 * IoGetDeviceProperty (NTOSKRNL.EXE.@)
677 NTSTATUS WINAPI
IoGetDeviceProperty( DEVICE_OBJECT
*device
, DEVICE_REGISTRY_PROPERTY device_property
,
678 ULONG buffer_length
, PVOID property_buffer
, PULONG result_length
)
680 FIXME( "%p %d %u %p %p: stub\n", device
, device_property
, buffer_length
,
681 property_buffer
, result_length
);
682 return STATUS_NOT_IMPLEMENTED
;
686 /***********************************************************************
687 * IoCallDriver (NTOSKRNL.EXE.@)
689 NTSTATUS WINAPI
IoCallDriver( DEVICE_OBJECT
*device
, IRP
*irp
)
691 PDRIVER_DISPATCH dispatch
;
692 IO_STACK_LOCATION
*irpsp
;
695 TRACE( "%p %p\n", device
, irp
);
697 --irp
->CurrentLocation
;
698 irpsp
= --irp
->Tail
.Overlay
.s
.u2
.CurrentStackLocation
;
699 dispatch
= device
->DriverObject
->MajorFunction
[irpsp
->MajorFunction
];
700 status
= dispatch( device
, irp
);
706 /***********************************************************************
707 * IofCallDriver (NTOSKRNL.EXE.@)
709 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
710 DEFINE_FASTCALL2_ENTRYPOINT( IofCallDriver
)
711 NTSTATUS WINAPI
__regs_IofCallDriver( DEVICE_OBJECT
*device
, IRP
*irp
)
713 NTSTATUS WINAPI
IofCallDriver( DEVICE_OBJECT
*device
, IRP
*irp
)
716 TRACE( "%p %p\n", device
, irp
);
717 return IoCallDriver( device
, irp
);
721 /***********************************************************************
722 * IoGetRelatedDeviceObject (NTOSKRNL.EXE.@)
724 PDEVICE_OBJECT WINAPI
IoGetRelatedDeviceObject( PFILE_OBJECT obj
)
726 FIXME( "stub: %p\n", obj
);
730 static CONFIGURATION_INFORMATION configuration_information
;
732 /***********************************************************************
733 * IoGetConfigurationInformation (NTOSKRNL.EXE.@)
735 PCONFIGURATION_INFORMATION WINAPI
IoGetConfigurationInformation(void)
737 FIXME( "partial stub\n" );
738 /* FIXME: return actual devices on system */
739 return &configuration_information
;
743 /***********************************************************************
744 * IoIsWdmVersionAvailable (NTOSKRNL.EXE.@)
746 NTSTATUS WINAPI
IoIsWdmVersionAvailable(UCHAR MajorVersion
, UCHAR MinorVersion
)
752 TRACE( "%d, 0x%X\n", MajorVersion
, MinorVersion
);
754 version
= GetVersion();
755 major
= LOBYTE(version
);
756 minor
= HIBYTE(LOWORD(version
));
758 if (MajorVersion
== 6 && MinorVersion
== 0)
760 /* Windows Vista, Windows Server 2008, Windows 7 */
762 else if (MajorVersion
== 1)
764 if (MinorVersion
== 0x30)
766 /* Windows server 2003 */
770 else if (MinorVersion
== 0x20)
776 else if (MinorVersion
== 0x10)
782 else if (MinorVersion
== 0x05)
788 else if (MinorVersion
== 0x00)
796 FIXME( "unknown major %d minor 0x%X\n", MajorVersion
, MinorVersion
);
802 FIXME( "unknown major %d minor 0x%X\n", MajorVersion
, MinorVersion
);
805 return major
> MajorVersion
|| (major
== MajorVersion
&& minor
>= MinorVersion
);
809 /***********************************************************************
810 * IoQueryDeviceDescription (NTOSKRNL.EXE.@)
812 NTSTATUS WINAPI
IoQueryDeviceDescription(PINTERFACE_TYPE itype
, PULONG bus
, PCONFIGURATION_TYPE ctype
,
813 PULONG cnum
, PCONFIGURATION_TYPE ptype
, PULONG pnum
,
814 PIO_QUERY_DEVICE_ROUTINE callout
, PVOID context
)
816 FIXME( "(%p %p %p %p %p %p %p %p)\n", itype
, bus
, ctype
, cnum
, ptype
, pnum
, callout
, context
);
817 return STATUS_NOT_IMPLEMENTED
;
821 /***********************************************************************
822 * IoRegisterDriverReinitialization (NTOSKRNL.EXE.@)
824 void WINAPI
IoRegisterDriverReinitialization( PDRIVER_OBJECT obj
, PDRIVER_REINITIALIZE reinit
, PVOID context
)
826 FIXME( "stub: %p %p %p\n", obj
, reinit
, context
);
830 /***********************************************************************
831 * IoRegisterShutdownNotification (NTOSKRNL.EXE.@)
833 NTSTATUS WINAPI
IoRegisterShutdownNotification( PDEVICE_OBJECT obj
)
835 FIXME( "stub: %p\n", obj
);
836 return STATUS_SUCCESS
;
840 /***********************************************************************
841 * IoUnregisterShutdownNotification (NTOSKRNL.EXE.@)
843 VOID WINAPI
IoUnregisterShutdownNotification( PDEVICE_OBJECT obj
)
845 FIXME( "stub: %p\n", obj
);
849 /***********************************************************************
850 * IoReportResourceUsage (NTOSKRNL.EXE.@)
852 NTSTATUS WINAPI
IoReportResourceUsage(PUNICODE_STRING name
, PDRIVER_OBJECT drv_obj
, PCM_RESOURCE_LIST drv_list
,
853 ULONG drv_size
, PDRIVER_OBJECT dev_obj
, PCM_RESOURCE_LIST dev_list
,
854 ULONG dev_size
, BOOLEAN overwrite
, PBOOLEAN detected
)
856 FIXME("(%s %p %p %u %p %p %u %d %p) stub\n", debugstr_w(name
? name
->Buffer
: NULL
),
857 drv_obj
, drv_list
, drv_size
, dev_obj
, dev_list
, dev_size
, overwrite
, detected
);
858 return STATUS_NOT_IMPLEMENTED
;
862 /***********************************************************************
863 * IoCompleteRequest (NTOSKRNL.EXE.@)
865 VOID WINAPI
IoCompleteRequest( IRP
*irp
, UCHAR priority_boost
)
867 IO_STACK_LOCATION
*irpsp
;
868 PIO_COMPLETION_ROUTINE routine
;
869 IO_STATUS_BLOCK
*iosb
;
870 struct IrpInstance
*instance
;
871 NTSTATUS status
, stat
;
874 TRACE( "%p %u\n", irp
, priority_boost
);
876 iosb
= irp
->UserIosb
;
877 status
= irp
->IoStatus
.u
.Status
;
878 while (irp
->CurrentLocation
<= irp
->StackCount
)
880 irpsp
= irp
->Tail
.Overlay
.s
.u2
.CurrentStackLocation
;
881 routine
= irpsp
->CompletionRoutine
;
883 /* FIXME: add SL_INVOKE_ON_CANCEL support */
886 if ((irpsp
->Control
& SL_INVOKE_ON_SUCCESS
) && STATUS_SUCCESS
== status
)
888 if ((irpsp
->Control
& SL_INVOKE_ON_ERROR
) && STATUS_SUCCESS
!= status
)
891 ++irp
->CurrentLocation
;
892 ++irp
->Tail
.Overlay
.s
.u2
.CurrentStackLocation
;
895 TRACE( "calling %p( %p, %p, %p )\n", routine
,
896 irpsp
->DeviceObject
, irp
, irpsp
->Context
);
897 stat
= routine( irpsp
->DeviceObject
, irp
, irpsp
->Context
);
898 TRACE( "CompletionRoutine returned %x\n", stat
);
899 if (STATUS_MORE_PROCESSING_REQUIRED
== stat
)
903 if (iosb
&& STATUS_SUCCESS
== status
)
905 iosb
->u
.Status
= irp
->IoStatus
.u
.Status
;
906 iosb
->Information
= irp
->IoStatus
.Information
;
908 LIST_FOR_EACH_ENTRY( instance
, &Irps
, struct IrpInstance
, entry
)
910 if (instance
->irp
== irp
)
912 list_remove( &instance
->entry
);
913 HeapFree( GetProcessHeap(), 0, instance
);
921 /***********************************************************************
922 * IofCompleteRequest (NTOSKRNL.EXE.@)
924 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
925 DEFINE_FASTCALL2_ENTRYPOINT( IofCompleteRequest
)
926 void WINAPI
__regs_IofCompleteRequest( IRP
*irp
, UCHAR priority_boost
)
928 void WINAPI
IofCompleteRequest( IRP
*irp
, UCHAR priority_boost
)
931 TRACE( "%p %u\n", irp
, priority_boost
);
932 IoCompleteRequest( irp
, priority_boost
);
936 /***********************************************************************
937 * InterlockedCompareExchange (NTOSKRNL.EXE.@)
939 #ifdef DEFINE_FASTCALL3_ENTRYPOINT
940 DEFINE_FASTCALL3_ENTRYPOINT( NTOSKRNL_InterlockedCompareExchange
)
941 LONG WINAPI
__regs_NTOSKRNL_InterlockedCompareExchange( LONG
volatile *dest
, LONG xchg
, LONG compare
)
943 LONG WINAPI
NTOSKRNL_InterlockedCompareExchange( LONG
volatile *dest
, LONG xchg
, LONG compare
)
946 return InterlockedCompareExchange( dest
, xchg
, compare
);
950 /***********************************************************************
951 * InterlockedDecrement (NTOSKRNL.EXE.@)
953 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
954 DEFINE_FASTCALL1_ENTRYPOINT( NTOSKRNL_InterlockedDecrement
)
955 LONG WINAPI
__regs_NTOSKRNL_InterlockedDecrement( LONG
volatile *dest
)
957 LONG WINAPI
NTOSKRNL_InterlockedDecrement( LONG
volatile *dest
)
960 return InterlockedDecrement( dest
);
964 /***********************************************************************
965 * InterlockedExchange (NTOSKRNL.EXE.@)
967 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
968 DEFINE_FASTCALL2_ENTRYPOINT( NTOSKRNL_InterlockedExchange
)
969 LONG WINAPI
__regs_NTOSKRNL_InterlockedExchange( LONG
volatile *dest
, LONG val
)
971 LONG WINAPI
NTOSKRNL_InterlockedExchange( LONG
volatile *dest
, LONG val
)
974 return InterlockedExchange( dest
, val
);
978 /***********************************************************************
979 * InterlockedExchangeAdd (NTOSKRNL.EXE.@)
981 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
982 DEFINE_FASTCALL2_ENTRYPOINT( NTOSKRNL_InterlockedExchangeAdd
)
983 LONG WINAPI
__regs_NTOSKRNL_InterlockedExchangeAdd( LONG
volatile *dest
, LONG incr
)
985 LONG WINAPI
NTOSKRNL_InterlockedExchangeAdd( LONG
volatile *dest
, LONG incr
)
988 return InterlockedExchangeAdd( dest
, incr
);
992 /***********************************************************************
993 * InterlockedIncrement (NTOSKRNL.EXE.@)
995 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
996 DEFINE_FASTCALL1_ENTRYPOINT( NTOSKRNL_InterlockedIncrement
)
997 LONG WINAPI
__regs_NTOSKRNL_InterlockedIncrement( LONG
volatile *dest
)
999 LONG WINAPI
NTOSKRNL_InterlockedIncrement( LONG
volatile *dest
)
1002 return InterlockedIncrement( dest
);
1006 /***********************************************************************
1007 * ExAllocatePool (NTOSKRNL.EXE.@)
1009 PVOID WINAPI
ExAllocatePool( POOL_TYPE type
, SIZE_T size
)
1011 return ExAllocatePoolWithTag( type
, size
, 0 );
1015 /***********************************************************************
1016 * ExAllocatePoolWithQuota (NTOSKRNL.EXE.@)
1018 PVOID WINAPI
ExAllocatePoolWithQuota( POOL_TYPE type
, SIZE_T size
)
1020 return ExAllocatePoolWithTag( type
, size
, 0 );
1024 /***********************************************************************
1025 * ExAllocatePoolWithTag (NTOSKRNL.EXE.@)
1027 PVOID WINAPI
ExAllocatePoolWithTag( POOL_TYPE type
, SIZE_T size
, ULONG tag
)
1029 /* FIXME: handle page alignment constraints */
1030 void *ret
= HeapAlloc( GetProcessHeap(), 0, size
);
1031 TRACE( "%lu pool %u -> %p\n", size
, type
, ret
);
1036 /***********************************************************************
1037 * ExAllocatePoolWithQuotaTag (NTOSKRNL.EXE.@)
1039 PVOID WINAPI
ExAllocatePoolWithQuotaTag( POOL_TYPE type
, SIZE_T size
, ULONG tag
)
1041 return ExAllocatePoolWithTag( type
, size
, tag
);
1045 /***********************************************************************
1046 * ExFreePool (NTOSKRNL.EXE.@)
1048 void WINAPI
ExFreePool( void *ptr
)
1050 ExFreePoolWithTag( ptr
, 0 );
1054 /***********************************************************************
1055 * ExFreePoolWithTag (NTOSKRNL.EXE.@)
1057 void WINAPI
ExFreePoolWithTag( void *ptr
, ULONG tag
)
1059 TRACE( "%p\n", ptr
);
1060 HeapFree( GetProcessHeap(), 0, ptr
);
1064 /***********************************************************************
1065 * ExInitializeResourceLite (NTOSKRNL.EXE.@)
1067 NTSTATUS WINAPI
ExInitializeResourceLite(PERESOURCE Resource
)
1069 FIXME( "stub: %p\n", Resource
);
1070 return STATUS_NOT_IMPLEMENTED
;
1074 /***********************************************************************
1075 * ExInitializeNPagedLookasideList (NTOSKRNL.EXE.@)
1077 void WINAPI
ExInitializeNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside
,
1078 PALLOCATE_FUNCTION Allocate
,
1079 PFREE_FUNCTION Free
,
1085 FIXME( "stub: %p, %p, %p, %u, %lu, %u, %u\n", Lookaside
, Allocate
, Free
, Flags
, Size
, Tag
, Depth
);
1088 /***********************************************************************
1089 * ExInitializePagedLookasideList (NTOSKRNL.EXE.@)
1091 void WINAPI
ExInitializePagedLookasideList(PPAGED_LOOKASIDE_LIST Lookaside
,
1092 PALLOCATE_FUNCTION Allocate
,
1093 PFREE_FUNCTION Free
,
1099 FIXME( "stub: %p, %p, %p, %u, %lu, %u, %u\n", Lookaside
, Allocate
, Free
, Flags
, Size
, Tag
, Depth
);
1102 /***********************************************************************
1103 * ExInitializeZone (NTOSKRNL.EXE.@)
1105 NTSTATUS WINAPI
ExInitializeZone(PZONE_HEADER Zone
,
1107 PVOID InitialSegment
,
1108 ULONG InitialSegmentSize
)
1110 FIXME( "stub: %p, %u, %p, %u\n", Zone
, BlockSize
, InitialSegment
, InitialSegmentSize
);
1111 return STATUS_NOT_IMPLEMENTED
;
1114 /***********************************************************************
1115 * FsRtlRegisterUncProvider (NTOSKRNL.EXE.@)
1117 NTSTATUS WINAPI
FsRtlRegisterUncProvider(PHANDLE MupHandle
, PUNICODE_STRING RedirDevName
,
1118 BOOLEAN MailslotsSupported
)
1120 FIXME("(%p %p %d): stub\n", MupHandle
, RedirDevName
, MailslotsSupported
);
1121 return STATUS_NOT_IMPLEMENTED
;
1124 /***********************************************************************
1125 * IoGetCurrentProcess / PsGetCurrentProcess (NTOSKRNL.EXE.@)
1127 PEPROCESS WINAPI
IoGetCurrentProcess(void)
1133 /***********************************************************************
1134 * KeGetCurrentThread / PsGetCurrentThread (NTOSKRNL.EXE.@)
1136 PRKTHREAD WINAPI
KeGetCurrentThread(void)
1142 /***********************************************************************
1143 * KeInitializeEvent (NTOSKRNL.EXE.@)
1145 void WINAPI
KeInitializeEvent( PRKEVENT Event
, EVENT_TYPE Type
, BOOLEAN State
)
1147 FIXME( "stub: %p %d %d\n", Event
, Type
, State
);
1151 /***********************************************************************
1152 * KeInitializeMutex (NTOSKRNL.EXE.@)
1154 void WINAPI
KeInitializeMutex(PRKMUTEX Mutex
, ULONG Level
)
1156 FIXME( "stub: %p, %u\n", Mutex
, Level
);
1160 /***********************************************************************
1161 * KeWaitForMutexObject (NTOSKRNL.EXE.@)
1163 NTSTATUS WINAPI
KeWaitForMutexObject(PRKMUTEX Mutex
, KWAIT_REASON WaitReason
, KPROCESSOR_MODE WaitMode
,
1164 BOOLEAN Alertable
, PLARGE_INTEGER Timeout
)
1166 FIXME( "stub: %p, %d, %d, %d, %p\n", Mutex
, WaitReason
, WaitMode
, Alertable
, Timeout
);
1167 return STATUS_NOT_IMPLEMENTED
;
1171 /***********************************************************************
1172 * KeReleaseMutex (NTOSKRNL.EXE.@)
1174 LONG WINAPI
KeReleaseMutex(PRKMUTEX Mutex
, BOOLEAN Wait
)
1176 FIXME( "stub: %p, %d\n", Mutex
, Wait
);
1177 return STATUS_NOT_IMPLEMENTED
;
1181 /***********************************************************************
1182 * KeInitializeSemaphore (NTOSKRNL.EXE.@)
1184 void WINAPI
KeInitializeSemaphore( PRKSEMAPHORE Semaphore
, LONG Count
, LONG Limit
)
1186 FIXME( "(%p %d %d) stub\n", Semaphore
, Count
, Limit
);
1190 /***********************************************************************
1191 * KeInitializeSpinLock (NTOSKRNL.EXE.@)
1193 void WINAPI
KeInitializeSpinLock( PKSPIN_LOCK SpinLock
)
1195 FIXME( "stub: %p\n", SpinLock
);
1199 /***********************************************************************
1200 * KeInitializeTimerEx (NTOSKRNL.EXE.@)
1202 void WINAPI
KeInitializeTimerEx( PKTIMER Timer
, TIMER_TYPE Type
)
1204 FIXME( "stub: %p %d\n", Timer
, Type
);
1208 /***********************************************************************
1209 * KeInitializeTimer (NTOSKRNL.EXE.@)
1211 void WINAPI
KeInitializeTimer( PKTIMER Timer
)
1213 KeInitializeTimerEx(Timer
, NotificationTimer
);
1217 /**********************************************************************
1218 * KeQueryActiveProcessors (NTOSKRNL.EXE.@)
1220 * Return the active Processors as bitmask
1223 * active Processors as bitmask
1226 KAFFINITY WINAPI
KeQueryActiveProcessors( void )
1228 DWORD_PTR AffinityMask
;
1230 GetProcessAffinityMask( GetCurrentProcess(), &AffinityMask
, NULL
);
1231 return AffinityMask
;
1235 /**********************************************************************
1236 * KeQueryInterruptTime (NTOSKRNL.EXE.@)
1238 * Return the interrupt time count
1241 ULONGLONG WINAPI
KeQueryInterruptTime( void )
1243 LARGE_INTEGER totaltime
;
1245 KeQueryTickCount(&totaltime
);
1246 return totaltime
.QuadPart
;
1250 /***********************************************************************
1251 * KeQuerySystemTime (NTOSKRNL.EXE.@)
1253 void WINAPI
KeQuerySystemTime( LARGE_INTEGER
*time
)
1255 NtQuerySystemTime( time
);
1259 /***********************************************************************
1260 * KeQueryTickCount (NTOSKRNL.EXE.@)
1262 void WINAPI
KeQueryTickCount( LARGE_INTEGER
*count
)
1264 count
->QuadPart
= NtGetTickCount();
1265 /* update the global variable too */
1266 KeTickCount
.LowPart
= count
->u
.LowPart
;
1267 KeTickCount
.High1Time
= count
->u
.HighPart
;
1268 KeTickCount
.High2Time
= count
->u
.HighPart
;
1272 /***********************************************************************
1273 * KeReleaseSemaphore (NTOSKRNL.EXE.@)
1275 LONG WINAPI
KeReleaseSemaphore( PRKSEMAPHORE Semaphore
, KPRIORITY Increment
,
1276 LONG Adjustment
, BOOLEAN Wait
)
1278 FIXME("(%p %d %d %d) stub\n", Semaphore
, Increment
, Adjustment
, Wait
);
1283 /***********************************************************************
1284 * KeQueryTimeIncrement (NTOSKRNL.EXE.@)
1286 ULONG WINAPI
KeQueryTimeIncrement(void)
1292 /***********************************************************************
1293 * KeResetEvent (NTOSKRNL.EXE.@)
1295 LONG WINAPI
KeResetEvent( PRKEVENT Event
)
1297 FIXME("(%p): stub\n", Event
);
1302 /***********************************************************************
1303 * KeSetEvent (NTOSKRNL.EXE.@)
1305 LONG WINAPI
KeSetEvent( PRKEVENT Event
, KPRIORITY Increment
, BOOLEAN Wait
)
1307 FIXME("(%p, %d, %d): stub\n", Event
, Increment
, Wait
);
1312 /***********************************************************************
1313 * KeSetPriorityThread (NTOSKRNL.EXE.@)
1315 KPRIORITY WINAPI
KeSetPriorityThread( PKTHREAD Thread
, KPRIORITY Priority
)
1317 FIXME("(%p %d)\n", Thread
, Priority
);
1322 /***********************************************************************
1323 * KeWaitForSingleObject (NTOSKRNL.EXE.@)
1325 NTSTATUS WINAPI
KeWaitForSingleObject(PVOID Object
,
1326 KWAIT_REASON WaitReason
,
1327 KPROCESSOR_MODE WaitMode
,
1329 PLARGE_INTEGER Timeout
)
1331 FIXME( "stub: %p, %d, %d, %d, %p\n", Object
, WaitReason
, WaitMode
, Alertable
, Timeout
);
1332 return STATUS_NOT_IMPLEMENTED
;
1335 /***********************************************************************
1336 * IoRegisterFileSystem (NTOSKRNL.EXE.@)
1338 VOID WINAPI
IoRegisterFileSystem(PDEVICE_OBJECT DeviceObject
)
1340 FIXME("(%p): stub\n", DeviceObject
);
1343 /***********************************************************************
1344 * IoUnregisterFileSystem (NTOSKRNL.EXE.@)
1346 VOID WINAPI
IoUnregisterFileSystem(PDEVICE_OBJECT DeviceObject
)
1348 FIXME("(%p): stub\n", DeviceObject
);
1351 /***********************************************************************
1352 * MmAllocateNonCachedMemory (NTOSKRNL.EXE.@)
1354 PVOID WINAPI
MmAllocateNonCachedMemory( SIZE_T size
)
1356 TRACE( "%lu\n", size
);
1357 return VirtualAlloc( NULL
, size
, MEM_RESERVE
|MEM_COMMIT
, PAGE_READWRITE
|PAGE_NOCACHE
);
1360 /***********************************************************************
1361 * MmAllocateContiguousMemory (NTOSKRNL.EXE.@)
1363 PVOID WINAPI
MmAllocateContiguousMemory( SIZE_T size
, PHYSICAL_ADDRESS highest_valid_address
)
1365 FIXME( "%lu, %s stub\n", size
, wine_dbgstr_longlong(highest_valid_address
.QuadPart
) );
1369 /***********************************************************************
1370 * MmAllocateContiguousMemorySpecifyCache (NTOSKRNL.EXE.@)
1372 PVOID WINAPI
MmAllocateContiguousMemorySpecifyCache( SIZE_T size
,
1373 PHYSICAL_ADDRESS lowest_valid_address
,
1374 PHYSICAL_ADDRESS highest_valid_address
,
1375 PHYSICAL_ADDRESS BoundaryAddressMultiple
,
1376 MEMORY_CACHING_TYPE CacheType
)
1382 /***********************************************************************
1383 * MmAllocatePagesForMdl (NTOSKRNL.EXE.@)
1385 PMDL WINAPI
MmAllocatePagesForMdl(PHYSICAL_ADDRESS lowaddress
, PHYSICAL_ADDRESS highaddress
,
1386 PHYSICAL_ADDRESS skipbytes
, SIZE_T size
)
1388 FIXME("%s %s %s %lu: stub\n", wine_dbgstr_longlong(lowaddress
.QuadPart
), wine_dbgstr_longlong(highaddress
.QuadPart
),
1389 wine_dbgstr_longlong(skipbytes
.QuadPart
), size
);
1393 /***********************************************************************
1394 * MmFreeNonCachedMemory (NTOSKRNL.EXE.@)
1396 void WINAPI
MmFreeNonCachedMemory( void *addr
, SIZE_T size
)
1398 TRACE( "%p %lu\n", addr
, size
);
1399 VirtualFree( addr
, 0, MEM_RELEASE
);
1402 /***********************************************************************
1403 * MmIsAddressValid (NTOSKRNL.EXE.@)
1405 * Check if the process can access the virtual address without a pagefault
1408 * VirtualAddress [I] Address to check
1412 * Success: TRUE (Accessing the Address works without a Pagefault)
1415 BOOLEAN WINAPI
MmIsAddressValid(PVOID VirtualAddress
)
1417 TRACE("(%p)\n", VirtualAddress
);
1418 return !IsBadWritePtr(VirtualAddress
, 1);
1421 /***********************************************************************
1422 * MmMapIoSpace (NTOSKRNL.EXE.@)
1424 PVOID WINAPI
MmMapIoSpace( PHYSICAL_ADDRESS PhysicalAddress
, DWORD NumberOfBytes
, DWORD CacheType
)
1426 FIXME( "stub: 0x%08x%08x, %d, %d\n", PhysicalAddress
.u
.HighPart
, PhysicalAddress
.u
.LowPart
, NumberOfBytes
, CacheType
);
1430 /***********************************************************************
1431 * MmPageEntireDriver (NTOSKRNL.EXE.@)
1433 PVOID WINAPI
MmPageEntireDriver(PVOID AddrInSection
)
1435 TRACE("%p\n", AddrInSection
);
1436 return AddrInSection
;
1439 /***********************************************************************
1440 * MmResetDriverPaging (NTOSKRNL.EXE.@)
1442 void WINAPI
MmResetDriverPaging(PVOID AddrInSection
)
1444 TRACE("%p\n", AddrInSection
);
1447 /***********************************************************************
1448 * MmUnmapIoSpace (NTOSKRNL.EXE.@)
1450 VOID WINAPI
MmUnmapIoSpace( PVOID BaseAddress
, SIZE_T NumberOfBytes
)
1452 FIXME( "stub: %p, %lu\n", BaseAddress
, NumberOfBytes
);
1455 /***********************************************************************
1456 * ObfReferenceObject (NTOSKRNL.EXE.@)
1458 VOID WINAPI
ObfReferenceObject(PVOID Object
)
1460 FIXME("(%p): stub\n", Object
);
1463 /***********************************************************************
1464 * ObReferenceObjectByHandle (NTOSKRNL.EXE.@)
1466 NTSTATUS WINAPI
ObReferenceObjectByHandle( HANDLE obj
, ACCESS_MASK access
,
1468 KPROCESSOR_MODE mode
, PVOID
* ptr
,
1469 POBJECT_HANDLE_INFORMATION info
)
1471 FIXME( "stub: %p %x %p %d %p %p\n", obj
, access
, type
, mode
, ptr
, info
);
1472 return STATUS_NOT_IMPLEMENTED
;
1475 /***********************************************************************
1476 * ObReferenceObjectByName (NTOSKRNL.EXE.@)
1478 NTSTATUS WINAPI
ObReferenceObjectByName( UNICODE_STRING
*ObjectName
,
1480 ACCESS_STATE
*AccessState
,
1481 ACCESS_MASK DesiredAccess
,
1482 POBJECT_TYPE ObjectType
,
1483 KPROCESSOR_MODE AccessMode
,
1488 return STATUS_NOT_IMPLEMENTED
;
1491 /***********************************************************************
1492 * ObfDereferenceObject (NTOSKRNL.EXE.@)
1494 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
1495 DEFINE_FASTCALL1_ENTRYPOINT( ObfDereferenceObject
)
1496 void WINAPI
__regs_ObfDereferenceObject( VOID
*obj
)
1498 void WINAPI
ObfDereferenceObject( VOID
*obj
)
1501 FIXME( "stub: %p\n", obj
);
1505 /***********************************************************************
1506 * PsCreateSystemThread (NTOSKRNL.EXE.@)
1508 NTSTATUS WINAPI
PsCreateSystemThread(PHANDLE ThreadHandle
, ULONG DesiredAccess
,
1509 POBJECT_ATTRIBUTES ObjectAttributes
,
1510 HANDLE ProcessHandle
, PCLIENT_ID ClientId
,
1511 PKSTART_ROUTINE StartRoutine
, PVOID StartContext
)
1513 if (!ProcessHandle
) ProcessHandle
= GetCurrentProcess();
1514 return RtlCreateUserThread(ProcessHandle
, 0, FALSE
, 0, 0,
1515 0, StartRoutine
, StartContext
,
1516 ThreadHandle
, ClientId
);
1519 /***********************************************************************
1520 * PsGetCurrentProcessId (NTOSKRNL.EXE.@)
1522 HANDLE WINAPI
PsGetCurrentProcessId(void)
1524 if (GetCurrentThreadId() == request_thread
)
1525 return UlongToHandle(client_pid
);
1526 return UlongToHandle(GetCurrentProcessId());
1530 /***********************************************************************
1531 * PsGetCurrentThreadId (NTOSKRNL.EXE.@)
1533 HANDLE WINAPI
PsGetCurrentThreadId(void)
1535 if (GetCurrentThreadId() == request_thread
)
1536 return UlongToHandle(client_tid
);
1537 return UlongToHandle(GetCurrentThreadId());
1541 /***********************************************************************
1542 * PsGetVersion (NTOSKRNL.EXE.@)
1544 BOOLEAN WINAPI
PsGetVersion(ULONG
*major
, ULONG
*minor
, ULONG
*build
, UNICODE_STRING
*version
)
1546 RTL_OSVERSIONINFOEXW info
;
1548 info
.dwOSVersionInfoSize
= sizeof(info
);
1549 RtlGetVersion( &info
);
1550 if (major
) *major
= info
.dwMajorVersion
;
1551 if (minor
) *minor
= info
.dwMinorVersion
;
1552 if (build
) *build
= info
.dwBuildNumber
;
1556 #if 0 /* FIXME: GameGuard passes an uninitialized pointer in version->Buffer */
1557 size_t len
= min( strlenW(info
.szCSDVersion
)*sizeof(WCHAR
), version
->MaximumLength
);
1558 memcpy( version
->Buffer
, info
.szCSDVersion
, len
);
1559 if (len
< version
->MaximumLength
) version
->Buffer
[len
/ sizeof(WCHAR
)] = 0;
1560 version
->Length
= len
;
1567 /***********************************************************************
1568 * PsSetCreateProcessNotifyRoutine (NTOSKRNL.EXE.@)
1570 NTSTATUS WINAPI
PsSetCreateProcessNotifyRoutine( PCREATE_PROCESS_NOTIFY_ROUTINE callback
, BOOLEAN remove
)
1572 FIXME( "stub: %p %d\n", callback
, remove
);
1573 return STATUS_SUCCESS
;
1577 /***********************************************************************
1578 * PsSetCreateThreadNotifyRoutine (NTOSKRNL.EXE.@)
1580 NTSTATUS WINAPI
PsSetCreateThreadNotifyRoutine( PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine
)
1582 FIXME( "stub: %p\n", NotifyRoutine
);
1583 return STATUS_SUCCESS
;
1587 /***********************************************************************
1588 * PsTerminateSystemThread (NTOSKRNL.EXE.@)
1590 NTSTATUS WINAPI
PsTerminateSystemThread(NTSTATUS ExitStatus
)
1592 FIXME( "stub: %u\n", ExitStatus
);
1593 return STATUS_NOT_IMPLEMENTED
;
1597 /***********************************************************************
1598 * MmGetSystemRoutineAddress (NTOSKRNL.EXE.@)
1600 PVOID WINAPI
MmGetSystemRoutineAddress(PUNICODE_STRING SystemRoutineName
)
1603 STRING routineNameA
;
1606 static const WCHAR ntoskrnlW
[] = {'n','t','o','s','k','r','n','l','.','e','x','e',0};
1607 static const WCHAR halW
[] = {'h','a','l','.','d','l','l',0};
1609 if (!SystemRoutineName
) return NULL
;
1611 if (RtlUnicodeStringToAnsiString( &routineNameA
, SystemRoutineName
, TRUE
) == STATUS_SUCCESS
)
1613 /* We only support functions exported from ntoskrnl.exe or hal.dll */
1614 hMod
= GetModuleHandleW( ntoskrnlW
);
1615 pFunc
= GetProcAddress( hMod
, routineNameA
.Buffer
);
1618 hMod
= GetModuleHandleW( halW
);
1619 if (hMod
) pFunc
= GetProcAddress( hMod
, routineNameA
.Buffer
);
1621 RtlFreeAnsiString( &routineNameA
);
1625 TRACE( "%s -> %p\n", debugstr_us(SystemRoutineName
), pFunc
);
1627 FIXME( "%s not found\n", debugstr_us(SystemRoutineName
) );
1632 /***********************************************************************
1633 * MmQuerySystemSize (NTOSKRNL.EXE.@)
1635 MM_SYSTEMSIZE WINAPI
MmQuerySystemSize(void)
1638 return MmLargeSystem
;
1641 /***********************************************************************
1642 * KeInitializeDpc (NTOSKRNL.EXE.@)
1644 VOID WINAPI
KeInitializeDpc(PRKDPC Dpc
, PKDEFERRED_ROUTINE DeferredRoutine
, PVOID DeferredContext
)
1649 /***********************************************************************
1650 * READ_REGISTER_BUFFER_UCHAR (NTOSKRNL.EXE.@)
1652 VOID WINAPI
READ_REGISTER_BUFFER_UCHAR(PUCHAR Register
, PUCHAR Buffer
, ULONG Count
)
1657 /*****************************************************
1658 * PoSetPowerState (NTOSKRNL.EXE.@)
1660 POWER_STATE WINAPI
PoSetPowerState(PDEVICE_OBJECT DeviceObject
, POWER_STATE_TYPE Type
, POWER_STATE State
)
1662 FIXME("(%p %u %u) stub\n", DeviceObject
, Type
, State
.DeviceState
);
1666 /*****************************************************
1667 * IoWMIRegistrationControl (NTOSKRNL.EXE.@)
1669 NTSTATUS WINAPI
IoWMIRegistrationControl(PDEVICE_OBJECT DeviceObject
, ULONG Action
)
1671 FIXME("(%p %u ) stub\n", DeviceObject
, Action
);
1672 return STATUS_SUCCESS
;
1675 /*****************************************************
1676 * PsSetLoadImageNotifyRoutine (NTOSKRNL.EXE.@)
1678 NTSTATUS WINAPI
PsSetLoadImageNotifyRoutine(PLOAD_IMAGE_NOTIFY_ROUTINE routine
)
1680 FIXME("(%p) stub\n", routine
);
1681 return STATUS_SUCCESS
;
1684 /*****************************************************
1685 * PsLookupProcessByProcessId (NTOSKRNL.EXE.@)
1687 NTSTATUS WINAPI
PsLookupProcessByProcessId(HANDLE processid
, PEPROCESS
*process
)
1689 FIXME("(%p %p) stub\n", processid
, process
);
1690 return STATUS_NOT_IMPLEMENTED
;
1694 /*****************************************************
1695 * IoSetThreadHardErrorMode (NTOSKRNL.EXE.@)
1697 BOOLEAN WINAPI
IoSetThreadHardErrorMode(BOOLEAN EnableHardErrors
)
1704 /*****************************************************
1705 * IoInitializeRemoveLockEx (NTOSKRNL.EXE.@)
1707 VOID WINAPI
IoInitializeRemoveLockEx(PIO_REMOVE_LOCK lock
, ULONG tag
,
1708 ULONG maxmin
, ULONG high
, ULONG size
)
1710 FIXME("(%p %u %u %u %u) stub\n", lock
, tag
, maxmin
, high
, size
);
1713 /*****************************************************
1716 BOOL WINAPI
DllMain( HINSTANCE inst
, DWORD reason
, LPVOID reserved
)
1718 static void *handler
;
1719 LARGE_INTEGER count
;
1723 case DLL_PROCESS_ATTACH
:
1724 DisableThreadLibraryCalls( inst
);
1726 handler
= RtlAddVectoredExceptionHandler( TRUE
, vectored_handler
);
1728 KeQueryTickCount( &count
); /* initialize the global KeTickCount */
1730 case DLL_PROCESS_DETACH
:
1731 RtlRemoveVectoredExceptionHandler( handler
);
1737 /*****************************************************
1738 * Ke386IoSetAccessProcess (NTOSKRNL.EXE.@)
1740 BOOLEAN WINAPI
Ke386IoSetAccessProcess(PEPROCESS
*process
, ULONG flag
)
1742 FIXME("(%p %d) stub\n", process
, flag
);
1746 /*****************************************************
1747 * Ke386SetIoAccessMap (NTOSKRNL.EXE.@)
1749 BOOLEAN WINAPI
Ke386SetIoAccessMap(ULONG flag
, PVOID buffer
)
1751 FIXME("(%d %p) stub\n", flag
, buffer
);
1755 /*****************************************************
1756 * IoCreateSynchronizationEvent (NTOSKRNL.EXE.@)
1758 PKEVENT WINAPI
IoCreateSynchronizationEvent(PUNICODE_STRING name
, PHANDLE handle
)
1760 FIXME("(%p %p) stub\n", name
, handle
);
1764 /*****************************************************
1765 * IoStartNextPacket (NTOSKRNL.EXE.@)
1767 VOID WINAPI
IoStartNextPacket(PDEVICE_OBJECT deviceobject
, BOOLEAN cancelable
)
1769 FIXME("(%p %d) stub\n", deviceobject
, cancelable
);