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_pid
;
247 client_pid
= reply
->client_tid
;
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 * IoReportResourceUsage (NTOSKRNL.EXE.@)
843 NTSTATUS WINAPI
IoReportResourceUsage(PUNICODE_STRING name
, PDRIVER_OBJECT drv_obj
, PCM_RESOURCE_LIST drv_list
,
844 ULONG drv_size
, PDRIVER_OBJECT dev_obj
, PCM_RESOURCE_LIST dev_list
,
845 ULONG dev_size
, BOOLEAN overwrite
, PBOOLEAN detected
)
847 FIXME("(%s %p %p %u %p %p %u %d %p) stub\n", debugstr_w(name
? name
->Buffer
: NULL
),
848 drv_obj
, drv_list
, drv_size
, dev_obj
, dev_list
, dev_size
, overwrite
, detected
);
849 return STATUS_NOT_IMPLEMENTED
;
853 /***********************************************************************
854 * IoCompleteRequest (NTOSKRNL.EXE.@)
856 VOID WINAPI
IoCompleteRequest( IRP
*irp
, UCHAR priority_boost
)
858 IO_STACK_LOCATION
*irpsp
;
859 PIO_COMPLETION_ROUTINE routine
;
860 IO_STATUS_BLOCK
*iosb
;
861 struct IrpInstance
*instance
;
862 NTSTATUS status
, stat
;
865 TRACE( "%p %u\n", irp
, priority_boost
);
867 iosb
= irp
->UserIosb
;
868 status
= irp
->IoStatus
.u
.Status
;
869 while (irp
->CurrentLocation
<= irp
->StackCount
)
871 irpsp
= irp
->Tail
.Overlay
.s
.u2
.CurrentStackLocation
;
872 routine
= irpsp
->CompletionRoutine
;
874 /* FIXME: add SL_INVOKE_ON_CANCEL support */
877 if ((irpsp
->Control
& SL_INVOKE_ON_SUCCESS
) && STATUS_SUCCESS
== status
)
879 if ((irpsp
->Control
& SL_INVOKE_ON_ERROR
) && STATUS_SUCCESS
!= status
)
882 ++irp
->CurrentLocation
;
883 ++irp
->Tail
.Overlay
.s
.u2
.CurrentStackLocation
;
886 TRACE( "calling %p( %p, %p, %p )\n", routine
,
887 irpsp
->DeviceObject
, irp
, irpsp
->Context
);
888 stat
= routine( irpsp
->DeviceObject
, irp
, irpsp
->Context
);
889 TRACE( "CompletionRoutine returned %x\n", stat
);
890 if (STATUS_MORE_PROCESSING_REQUIRED
== stat
)
894 if (iosb
&& STATUS_SUCCESS
== status
)
896 iosb
->u
.Status
= irp
->IoStatus
.u
.Status
;
897 iosb
->Information
= irp
->IoStatus
.Information
;
899 LIST_FOR_EACH_ENTRY( instance
, &Irps
, struct IrpInstance
, entry
)
901 if (instance
->irp
== irp
)
903 list_remove( &instance
->entry
);
904 HeapFree( GetProcessHeap(), 0, instance
);
912 /***********************************************************************
913 * IofCompleteRequest (NTOSKRNL.EXE.@)
915 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
916 DEFINE_FASTCALL2_ENTRYPOINT( IofCompleteRequest
)
917 void WINAPI
__regs_IofCompleteRequest( IRP
*irp
, UCHAR priority_boost
)
919 void WINAPI
IofCompleteRequest( IRP
*irp
, UCHAR priority_boost
)
922 TRACE( "%p %u\n", irp
, priority_boost
);
923 IoCompleteRequest( irp
, priority_boost
);
927 /***********************************************************************
928 * InterlockedCompareExchange (NTOSKRNL.EXE.@)
930 #ifdef DEFINE_FASTCALL3_ENTRYPOINT
931 DEFINE_FASTCALL3_ENTRYPOINT( NTOSKRNL_InterlockedCompareExchange
)
932 LONG WINAPI
__regs_NTOSKRNL_InterlockedCompareExchange( LONG
volatile *dest
, LONG xchg
, LONG compare
)
934 LONG WINAPI
NTOSKRNL_InterlockedCompareExchange( LONG
volatile *dest
, LONG xchg
, LONG compare
)
937 return InterlockedCompareExchange( dest
, xchg
, compare
);
941 /***********************************************************************
942 * InterlockedDecrement (NTOSKRNL.EXE.@)
944 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
945 DEFINE_FASTCALL1_ENTRYPOINT( NTOSKRNL_InterlockedDecrement
)
946 LONG WINAPI
__regs_NTOSKRNL_InterlockedDecrement( LONG
volatile *dest
)
948 LONG WINAPI
NTOSKRNL_InterlockedDecrement( LONG
volatile *dest
)
951 return InterlockedDecrement( dest
);
955 /***********************************************************************
956 * InterlockedExchange (NTOSKRNL.EXE.@)
958 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
959 DEFINE_FASTCALL2_ENTRYPOINT( NTOSKRNL_InterlockedExchange
)
960 LONG WINAPI
__regs_NTOSKRNL_InterlockedExchange( LONG
volatile *dest
, LONG val
)
962 LONG WINAPI
NTOSKRNL_InterlockedExchange( LONG
volatile *dest
, LONG val
)
965 return InterlockedExchange( dest
, val
);
969 /***********************************************************************
970 * InterlockedExchangeAdd (NTOSKRNL.EXE.@)
972 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
973 DEFINE_FASTCALL2_ENTRYPOINT( NTOSKRNL_InterlockedExchangeAdd
)
974 LONG WINAPI
__regs_NTOSKRNL_InterlockedExchangeAdd( LONG
volatile *dest
, LONG incr
)
976 LONG WINAPI
NTOSKRNL_InterlockedExchangeAdd( LONG
volatile *dest
, LONG incr
)
979 return InterlockedExchangeAdd( dest
, incr
);
983 /***********************************************************************
984 * InterlockedIncrement (NTOSKRNL.EXE.@)
986 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
987 DEFINE_FASTCALL1_ENTRYPOINT( NTOSKRNL_InterlockedIncrement
)
988 LONG WINAPI
__regs_NTOSKRNL_InterlockedIncrement( LONG
volatile *dest
)
990 LONG WINAPI
NTOSKRNL_InterlockedIncrement( LONG
volatile *dest
)
993 return InterlockedIncrement( dest
);
997 /***********************************************************************
998 * ExAllocatePool (NTOSKRNL.EXE.@)
1000 PVOID WINAPI
ExAllocatePool( POOL_TYPE type
, SIZE_T size
)
1002 return ExAllocatePoolWithTag( type
, size
, 0 );
1006 /***********************************************************************
1007 * ExAllocatePoolWithQuota (NTOSKRNL.EXE.@)
1009 PVOID WINAPI
ExAllocatePoolWithQuota( POOL_TYPE type
, SIZE_T size
)
1011 return ExAllocatePoolWithTag( type
, size
, 0 );
1015 /***********************************************************************
1016 * ExAllocatePoolWithTag (NTOSKRNL.EXE.@)
1018 PVOID WINAPI
ExAllocatePoolWithTag( POOL_TYPE type
, SIZE_T size
, ULONG tag
)
1020 /* FIXME: handle page alignment constraints */
1021 void *ret
= HeapAlloc( GetProcessHeap(), 0, size
);
1022 TRACE( "%lu pool %u -> %p\n", size
, type
, ret
);
1027 /***********************************************************************
1028 * ExAllocatePoolWithQuotaTag (NTOSKRNL.EXE.@)
1030 PVOID WINAPI
ExAllocatePoolWithQuotaTag( POOL_TYPE type
, SIZE_T size
, ULONG tag
)
1032 return ExAllocatePoolWithTag( type
, size
, tag
);
1036 /***********************************************************************
1037 * ExFreePool (NTOSKRNL.EXE.@)
1039 void WINAPI
ExFreePool( void *ptr
)
1041 ExFreePoolWithTag( ptr
, 0 );
1045 /***********************************************************************
1046 * ExFreePoolWithTag (NTOSKRNL.EXE.@)
1048 void WINAPI
ExFreePoolWithTag( void *ptr
, ULONG tag
)
1050 TRACE( "%p\n", ptr
);
1051 HeapFree( GetProcessHeap(), 0, ptr
);
1055 /***********************************************************************
1056 * ExInitializeResourceLite (NTOSKRNL.EXE.@)
1058 NTSTATUS WINAPI
ExInitializeResourceLite(PERESOURCE Resource
)
1060 FIXME( "stub: %p\n", Resource
);
1061 return STATUS_NOT_IMPLEMENTED
;
1065 /***********************************************************************
1066 * ExInitializeNPagedLookasideList (NTOSKRNL.EXE.@)
1068 void WINAPI
ExInitializeNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside
,
1069 PALLOCATE_FUNCTION Allocate
,
1070 PFREE_FUNCTION Free
,
1076 FIXME( "stub: %p, %p, %p, %u, %lu, %u, %u\n", Lookaside
, Allocate
, Free
, Flags
, Size
, Tag
, Depth
);
1080 /***********************************************************************
1081 * ExInitializeZone (NTOSKRNL.EXE.@)
1083 NTSTATUS WINAPI
ExInitializeZone(PZONE_HEADER Zone
,
1085 PVOID InitialSegment
,
1086 ULONG InitialSegmentSize
)
1088 FIXME( "stub: %p, %u, %p, %u\n", Zone
, BlockSize
, InitialSegment
, InitialSegmentSize
);
1089 return STATUS_NOT_IMPLEMENTED
;
1092 /***********************************************************************
1093 * FsRtlRegisterUncProvider (NTOSKRNL.EXE.@)
1095 NTSTATUS WINAPI
FsRtlRegisterUncProvider(PHANDLE MupHandle
, PUNICODE_STRING RedirDevName
,
1096 BOOLEAN MailslotsSupported
)
1098 FIXME("(%p %p %d): stub\n", MupHandle
, RedirDevName
, MailslotsSupported
);
1099 return STATUS_NOT_IMPLEMENTED
;
1102 /***********************************************************************
1103 * KeGetCurrentThread / PsGetCurrentThread (NTOSKRNL.EXE.@)
1105 PRKTHREAD WINAPI
KeGetCurrentThread(void)
1111 /***********************************************************************
1112 * KeInitializeEvent (NTOSKRNL.EXE.@)
1114 void WINAPI
KeInitializeEvent( PRKEVENT Event
, EVENT_TYPE Type
, BOOLEAN State
)
1116 FIXME( "stub: %p %d %d\n", Event
, Type
, State
);
1120 /***********************************************************************
1121 * KeInitializeMutex (NTOSKRNL.EXE.@)
1123 void WINAPI
KeInitializeMutex(PRKMUTEX Mutex
, ULONG Level
)
1125 FIXME( "stub: %p, %u\n", Mutex
, Level
);
1129 /***********************************************************************
1130 * KeWaitForMutexObject (NTOSKRNL.EXE.@)
1132 NTSTATUS WINAPI
KeWaitForMutexObject(PRKMUTEX Mutex
, KWAIT_REASON WaitReason
, KPROCESSOR_MODE WaitMode
,
1133 BOOLEAN Alertable
, PLARGE_INTEGER Timeout
)
1135 FIXME( "stub: %p, %d, %d, %d, %p\n", Mutex
, WaitReason
, WaitMode
, Alertable
, Timeout
);
1136 return STATUS_NOT_IMPLEMENTED
;
1140 /***********************************************************************
1141 * KeReleaseMutex (NTOSKRNL.EXE.@)
1143 LONG WINAPI
KeReleaseMutex(PRKMUTEX Mutex
, BOOLEAN Wait
)
1145 FIXME( "stub: %p, %d\n", Mutex
, Wait
);
1146 return STATUS_NOT_IMPLEMENTED
;
1150 /***********************************************************************
1151 * KeInitializeSemaphore (NTOSKRNL.EXE.@)
1153 void WINAPI
KeInitializeSemaphore( PRKSEMAPHORE Semaphore
, LONG Count
, LONG Limit
)
1155 FIXME( "(%p %d %d) stub\n", Semaphore
, Count
, Limit
);
1159 /***********************************************************************
1160 * KeInitializeSpinLock (NTOSKRNL.EXE.@)
1162 void WINAPI
KeInitializeSpinLock( PKSPIN_LOCK SpinLock
)
1164 FIXME( "stub: %p\n", SpinLock
);
1168 /***********************************************************************
1169 * KeInitializeTimerEx (NTOSKRNL.EXE.@)
1171 void WINAPI
KeInitializeTimerEx( PKTIMER Timer
, TIMER_TYPE Type
)
1173 FIXME( "stub: %p %d\n", Timer
, Type
);
1177 /***********************************************************************
1178 * KeInitializeTimer (NTOSKRNL.EXE.@)
1180 void WINAPI
KeInitializeTimer( PKTIMER Timer
)
1182 KeInitializeTimerEx(Timer
, NotificationTimer
);
1186 /**********************************************************************
1187 * KeQueryActiveProcessors (NTOSKRNL.EXE.@)
1189 * Return the active Processors as bitmask
1192 * active Processors as bitmask
1195 KAFFINITY WINAPI
KeQueryActiveProcessors( void )
1197 DWORD_PTR AffinityMask
;
1199 GetProcessAffinityMask( GetCurrentProcess(), &AffinityMask
, NULL
);
1200 return AffinityMask
;
1204 /**********************************************************************
1205 * KeQueryInterruptTime (NTOSKRNL.EXE.@)
1207 * Return the interrupt time count
1210 ULONGLONG WINAPI
KeQueryInterruptTime( void )
1212 LARGE_INTEGER totaltime
;
1214 KeQueryTickCount(&totaltime
);
1215 return totaltime
.QuadPart
;
1219 /***********************************************************************
1220 * KeQuerySystemTime (NTOSKRNL.EXE.@)
1222 void WINAPI
KeQuerySystemTime( LARGE_INTEGER
*time
)
1224 NtQuerySystemTime( time
);
1228 /***********************************************************************
1229 * KeQueryTickCount (NTOSKRNL.EXE.@)
1231 void WINAPI
KeQueryTickCount( LARGE_INTEGER
*count
)
1233 count
->QuadPart
= NtGetTickCount();
1234 /* update the global variable too */
1235 KeTickCount
.LowPart
= count
->u
.LowPart
;
1236 KeTickCount
.High1Time
= count
->u
.HighPart
;
1237 KeTickCount
.High2Time
= count
->u
.HighPart
;
1241 /***********************************************************************
1242 * KeReleaseSemaphore (NTOSKRNL.EXE.@)
1244 LONG WINAPI
KeReleaseSemaphore( PRKSEMAPHORE Semaphore
, KPRIORITY Increment
,
1245 LONG Adjustment
, BOOLEAN Wait
)
1247 FIXME("(%p %d %d %d) stub\n", Semaphore
, Increment
, Adjustment
, Wait
);
1252 /***********************************************************************
1253 * KeQueryTimeIncrement (NTOSKRNL.EXE.@)
1255 ULONG WINAPI
KeQueryTimeIncrement(void)
1261 /***********************************************************************
1262 * KeResetEvent (NTOSKRNL.EXE.@)
1264 LONG WINAPI
KeResetEvent( PRKEVENT Event
)
1266 FIXME("(%p): stub\n", Event
);
1271 /***********************************************************************
1272 * KeSetEvent (NTOSKRNL.EXE.@)
1274 LONG WINAPI
KeSetEvent( PRKEVENT Event
, KPRIORITY Increment
, BOOLEAN Wait
)
1276 FIXME("(%p, %d, %d): stub\n", Event
, Increment
, Wait
);
1281 /***********************************************************************
1282 * KeSetPriorityThread (NTOSKRNL.EXE.@)
1284 KPRIORITY WINAPI
KeSetPriorityThread( PKTHREAD Thread
, KPRIORITY Priority
)
1286 FIXME("(%p %d)\n", Thread
, Priority
);
1291 /***********************************************************************
1292 * KeWaitForSingleObject (NTOSKRNL.EXE.@)
1294 NTSTATUS WINAPI
KeWaitForSingleObject(PVOID Object
,
1295 KWAIT_REASON WaitReason
,
1296 KPROCESSOR_MODE WaitMode
,
1298 PLARGE_INTEGER Timeout
)
1300 FIXME( "stub: %p, %d, %d, %d, %p\n", Object
, WaitReason
, WaitMode
, Alertable
, Timeout
);
1301 return STATUS_NOT_IMPLEMENTED
;
1304 /***********************************************************************
1305 * IoRegisterFileSystem (NTOSKRNL.EXE.@)
1307 VOID WINAPI
IoRegisterFileSystem(PDEVICE_OBJECT DeviceObject
)
1309 FIXME("(%p): stub\n", DeviceObject
);
1312 /***********************************************************************
1313 * IoUnregisterFileSystem (NTOSKRNL.EXE.@)
1315 VOID WINAPI
IoUnregisterFileSystem(PDEVICE_OBJECT DeviceObject
)
1317 FIXME("(%p): stub\n", DeviceObject
);
1320 /***********************************************************************
1321 * MmAllocateNonCachedMemory (NTOSKRNL.EXE.@)
1323 PVOID WINAPI
MmAllocateNonCachedMemory( SIZE_T size
)
1325 TRACE( "%lu\n", size
);
1326 return VirtualAlloc( NULL
, size
, MEM_RESERVE
|MEM_COMMIT
, PAGE_READWRITE
|PAGE_NOCACHE
);
1329 /***********************************************************************
1330 * MmAllocateContiguousMemory (NTOSKRNL.EXE.@)
1332 PVOID WINAPI
MmAllocateContiguousMemory( SIZE_T size
, PHYSICAL_ADDRESS highest_valid_address
)
1334 FIXME( "%lu, %s stub\n", size
, wine_dbgstr_longlong(highest_valid_address
.QuadPart
) );
1338 /***********************************************************************
1339 * MmAllocateContiguousMemorySpecifyCache (NTOSKRNL.EXE.@)
1341 PVOID WINAPI
MmAllocateContiguousMemorySpecifyCache( SIZE_T size
,
1342 PHYSICAL_ADDRESS lowest_valid_address
,
1343 PHYSICAL_ADDRESS highest_valid_address
,
1344 PHYSICAL_ADDRESS BoundaryAddressMultiple
,
1345 MEMORY_CACHING_TYPE CacheType
)
1351 /***********************************************************************
1352 * MmAllocatePagesForMdl (NTOSKRNL.EXE.@)
1354 PMDL WINAPI
MmAllocatePagesForMdl(PHYSICAL_ADDRESS lowaddress
, PHYSICAL_ADDRESS highaddress
,
1355 PHYSICAL_ADDRESS skipbytes
, SIZE_T size
)
1357 FIXME("%s %s %s %lu: stub\n", wine_dbgstr_longlong(lowaddress
.QuadPart
), wine_dbgstr_longlong(highaddress
.QuadPart
),
1358 wine_dbgstr_longlong(skipbytes
.QuadPart
), size
);
1362 /***********************************************************************
1363 * MmFreeNonCachedMemory (NTOSKRNL.EXE.@)
1365 void WINAPI
MmFreeNonCachedMemory( void *addr
, SIZE_T size
)
1367 TRACE( "%p %lu\n", addr
, size
);
1368 VirtualFree( addr
, 0, MEM_RELEASE
);
1371 /***********************************************************************
1372 * MmIsAddressValid (NTOSKRNL.EXE.@)
1374 * Check if the process can access the virtual address without a pagefault
1377 * VirtualAddress [I] Address to check
1381 * Success: TRUE (Accessing the Address works without a Pagefault)
1384 BOOLEAN WINAPI
MmIsAddressValid(PVOID VirtualAddress
)
1386 TRACE("(%p)\n", VirtualAddress
);
1387 return !IsBadWritePtr(VirtualAddress
, 1);
1390 /***********************************************************************
1391 * MmMapIoSpace (NTOSKRNL.EXE.@)
1393 PVOID WINAPI
MmMapIoSpace( PHYSICAL_ADDRESS PhysicalAddress
, DWORD NumberOfBytes
, DWORD CacheType
)
1395 FIXME( "stub: 0x%08x%08x, %d, %d\n", PhysicalAddress
.u
.HighPart
, PhysicalAddress
.u
.LowPart
, NumberOfBytes
, CacheType
);
1399 /***********************************************************************
1400 * MmPageEntireDriver (NTOSKRNL.EXE.@)
1402 PVOID WINAPI
MmPageEntireDriver(PVOID AddrInSection
)
1404 TRACE("%p\n", AddrInSection
);
1405 return AddrInSection
;
1408 /***********************************************************************
1409 * MmResetDriverPaging (NTOSKRNL.EXE.@)
1411 void WINAPI
MmResetDriverPaging(PVOID AddrInSection
)
1413 TRACE("%p\n", AddrInSection
);
1416 /***********************************************************************
1417 * MmUnmapIoSpace (NTOSKRNL.EXE.@)
1419 VOID WINAPI
MmUnmapIoSpace( PVOID BaseAddress
, SIZE_T NumberOfBytes
)
1421 FIXME( "stub: %p, %lu\n", BaseAddress
, NumberOfBytes
);
1424 /***********************************************************************
1425 * ObfReferenceObject (NTOSKRNL.EXE.@)
1427 VOID WINAPI
ObfReferenceObject(PVOID Object
)
1429 FIXME("(%p): stub\n", Object
);
1432 /***********************************************************************
1433 * ObReferenceObjectByHandle (NTOSKRNL.EXE.@)
1435 NTSTATUS WINAPI
ObReferenceObjectByHandle( HANDLE obj
, ACCESS_MASK access
,
1437 KPROCESSOR_MODE mode
, PVOID
* ptr
,
1438 POBJECT_HANDLE_INFORMATION info
)
1440 FIXME( "stub: %p %x %p %d %p %p\n", obj
, access
, type
, mode
, ptr
, info
);
1441 return STATUS_NOT_IMPLEMENTED
;
1444 /***********************************************************************
1445 * ObReferenceObjectByName (NTOSKRNL.EXE.@)
1447 NTSTATUS WINAPI
ObReferenceObjectByName( UNICODE_STRING
*ObjectName
,
1449 ACCESS_STATE
*AccessState
,
1450 ACCESS_MASK DesiredAccess
,
1451 POBJECT_TYPE ObjectType
,
1452 KPROCESSOR_MODE AccessMode
,
1457 return STATUS_NOT_IMPLEMENTED
;
1460 /***********************************************************************
1461 * ObfDereferenceObject (NTOSKRNL.EXE.@)
1463 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
1464 DEFINE_FASTCALL1_ENTRYPOINT( ObfDereferenceObject
)
1465 void WINAPI
__regs_ObfDereferenceObject( VOID
*obj
)
1467 void WINAPI
ObfDereferenceObject( VOID
*obj
)
1470 FIXME( "stub: %p\n", obj
);
1474 /***********************************************************************
1475 * PsCreateSystemThread (NTOSKRNL.EXE.@)
1477 NTSTATUS WINAPI
PsCreateSystemThread(PHANDLE ThreadHandle
, ULONG DesiredAccess
,
1478 POBJECT_ATTRIBUTES ObjectAttributes
,
1479 HANDLE ProcessHandle
, PCLIENT_ID ClientId
,
1480 PKSTART_ROUTINE StartRoutine
, PVOID StartContext
)
1482 if (!ProcessHandle
) ProcessHandle
= GetCurrentProcess();
1483 return RtlCreateUserThread(ProcessHandle
, 0, FALSE
, 0, 0,
1484 0, StartRoutine
, StartContext
,
1485 ThreadHandle
, ClientId
);
1488 /***********************************************************************
1489 * PsGetCurrentProcessId (NTOSKRNL.EXE.@)
1491 HANDLE WINAPI
PsGetCurrentProcessId(void)
1493 if (GetCurrentThreadId() == request_thread
)
1494 return UlongToHandle(client_pid
);
1495 return UlongToHandle(GetCurrentProcessId());
1499 /***********************************************************************
1500 * PsGetCurrentThreadId (NTOSKRNL.EXE.@)
1502 HANDLE WINAPI
PsGetCurrentThreadId(void)
1504 if (GetCurrentThreadId() == request_thread
)
1505 return UlongToHandle(client_tid
);
1506 return UlongToHandle(GetCurrentThreadId());
1510 /***********************************************************************
1511 * PsGetVersion (NTOSKRNL.EXE.@)
1513 BOOLEAN WINAPI
PsGetVersion(ULONG
*major
, ULONG
*minor
, ULONG
*build
, UNICODE_STRING
*version
)
1515 RTL_OSVERSIONINFOEXW info
;
1517 info
.dwOSVersionInfoSize
= sizeof(info
);
1518 RtlGetVersion( &info
);
1519 if (major
) *major
= info
.dwMajorVersion
;
1520 if (minor
) *minor
= info
.dwMinorVersion
;
1521 if (build
) *build
= info
.dwBuildNumber
;
1525 #if 0 /* FIXME: GameGuard passes an uninitialized pointer in version->Buffer */
1526 size_t len
= min( strlenW(info
.szCSDVersion
)*sizeof(WCHAR
), version
->MaximumLength
);
1527 memcpy( version
->Buffer
, info
.szCSDVersion
, len
);
1528 if (len
< version
->MaximumLength
) version
->Buffer
[len
/ sizeof(WCHAR
)] = 0;
1529 version
->Length
= len
;
1536 /***********************************************************************
1537 * PsSetCreateProcessNotifyRoutine (NTOSKRNL.EXE.@)
1539 NTSTATUS WINAPI
PsSetCreateProcessNotifyRoutine( PCREATE_PROCESS_NOTIFY_ROUTINE callback
, BOOLEAN remove
)
1541 FIXME( "stub: %p %d\n", callback
, remove
);
1542 return STATUS_SUCCESS
;
1546 /***********************************************************************
1547 * PsSetCreateThreadNotifyRoutine (NTOSKRNL.EXE.@)
1549 NTSTATUS WINAPI
PsSetCreateThreadNotifyRoutine( PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine
)
1551 FIXME( "stub: %p\n", NotifyRoutine
);
1552 return STATUS_SUCCESS
;
1556 /***********************************************************************
1557 * PsTerminateSystemThread (NTOSKRNL.EXE.@)
1559 NTSTATUS WINAPI
PsTerminateSystemThread(NTSTATUS ExitStatus
)
1561 FIXME( "stub: %u\n", ExitStatus
);
1562 return STATUS_NOT_IMPLEMENTED
;
1566 /***********************************************************************
1567 * MmGetSystemRoutineAddress (NTOSKRNL.EXE.@)
1569 PVOID WINAPI
MmGetSystemRoutineAddress(PUNICODE_STRING SystemRoutineName
)
1572 STRING routineNameA
;
1575 static const WCHAR ntoskrnlW
[] = {'n','t','o','s','k','r','n','l','.','e','x','e',0};
1576 static const WCHAR halW
[] = {'h','a','l','.','d','l','l',0};
1578 if (!SystemRoutineName
) return NULL
;
1580 if (RtlUnicodeStringToAnsiString( &routineNameA
, SystemRoutineName
, TRUE
) == STATUS_SUCCESS
)
1582 /* We only support functions exported from ntoskrnl.exe or hal.dll */
1583 hMod
= GetModuleHandleW( ntoskrnlW
);
1584 pFunc
= GetProcAddress( hMod
, routineNameA
.Buffer
);
1587 hMod
= GetModuleHandleW( halW
);
1588 if (hMod
) pFunc
= GetProcAddress( hMod
, routineNameA
.Buffer
);
1590 RtlFreeAnsiString( &routineNameA
);
1594 TRACE( "%s -> %p\n", debugstr_us(SystemRoutineName
), pFunc
);
1596 FIXME( "%s not found\n", debugstr_us(SystemRoutineName
) );
1601 /***********************************************************************
1602 * MmQuerySystemSize (NTOSKRNL.EXE.@)
1604 MM_SYSTEMSIZE WINAPI
MmQuerySystemSize(void)
1607 return MmLargeSystem
;
1610 /***********************************************************************
1611 * KeInitializeDpc (NTOSKRNL.EXE.@)
1613 VOID WINAPI
KeInitializeDpc(PRKDPC Dpc
, PKDEFERRED_ROUTINE DeferredRoutine
, PVOID DeferredContext
)
1618 /***********************************************************************
1619 * READ_REGISTER_BUFFER_UCHAR (NTOSKRNL.EXE.@)
1621 VOID WINAPI
READ_REGISTER_BUFFER_UCHAR(PUCHAR Register
, PUCHAR Buffer
, ULONG Count
)
1626 /*****************************************************
1627 * PoSetPowerState (NTOSKRNL.EXE.@)
1629 POWER_STATE WINAPI
PoSetPowerState(PDEVICE_OBJECT DeviceObject
, POWER_STATE_TYPE Type
, POWER_STATE State
)
1631 FIXME("(%p %u %u) stub\n", DeviceObject
, Type
, State
.DeviceState
);
1635 /*****************************************************
1636 * IoWMIRegistrationControl (NTOSKRNL.EXE.@)
1638 NTSTATUS WINAPI
IoWMIRegistrationControl(PDEVICE_OBJECT DeviceObject
, ULONG Action
)
1640 FIXME("(%p %u ) stub\n", DeviceObject
, Action
);
1641 return STATUS_SUCCESS
;
1644 /*****************************************************
1645 * PsSetLoadImageNotifyRoutine (NTOSKRNL.EXE.@)
1647 NTSTATUS WINAPI
PsSetLoadImageNotifyRoutine(PLOAD_IMAGE_NOTIFY_ROUTINE routine
)
1649 FIXME("(%p) stub\n", routine
);
1650 return STATUS_SUCCESS
;
1653 /*****************************************************
1654 * PsLookupProcessByProcessId (NTOSKRNL.EXE.@)
1656 NTSTATUS WINAPI
PsLookupProcessByProcessId(HANDLE processid
, PEPROCESS
*process
)
1658 FIXME("(%p %p) stub\n", processid
, process
);
1659 return STATUS_NOT_IMPLEMENTED
;
1663 /*****************************************************
1664 * IoSetThreadHardErrorMode (NTOSKRNL.EXE.@)
1666 BOOLEAN WINAPI
IoSetThreadHardErrorMode(BOOLEAN EnableHardErrors
)
1672 /*****************************************************
1675 BOOL WINAPI
DllMain( HINSTANCE inst
, DWORD reason
, LPVOID reserved
)
1677 static void *handler
;
1678 LARGE_INTEGER count
;
1682 case DLL_PROCESS_ATTACH
:
1683 DisableThreadLibraryCalls( inst
);
1685 handler
= RtlAddVectoredExceptionHandler( TRUE
, vectored_handler
);
1687 KeQueryTickCount( &count
); /* initialize the global KeTickCount */
1689 case DLL_PROCESS_DETACH
:
1690 RtlRemoveVectoredExceptionHandler( handler
);