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
35 #include "ddk/ntddk.h"
36 #include "wine/unicode.h"
37 #include "wine/server.h"
38 #include "wine/list.h"
39 #include "wine/debug.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(ntoskrnl
);
42 WINE_DECLARE_DEBUG_CHANNEL(relay
);
44 BOOLEAN KdDebuggerEnabled
= FALSE
;
46 extern LONG CALLBACK
vectored_handler( EXCEPTION_POINTERS
*ptrs
);
48 KSYSTEM_TIME KeTickCount
= { 0, 0, 0 };
50 typedef struct _KSERVICE_TABLE_DESCRIPTOR
56 } KSERVICE_TABLE_DESCRIPTOR
, *PKSERVICE_TABLE_DESCRIPTOR
;
58 KSERVICE_TABLE_DESCRIPTOR KeServiceDescriptorTable
[4] = { { 0 } };
60 typedef void (WINAPI
*PCREATE_PROCESS_NOTIFY_ROUTINE
)(HANDLE
,HANDLE
,BOOLEAN
);
61 typedef void (WINAPI
*PCREATE_THREAD_NOTIFY_ROUTINE
)(HANDLE
,HANDLE
,BOOLEAN
);
63 static struct list Irps
= LIST_INIT(Irps
);
72 #define DEFINE_FASTCALL1_ENTRYPOINT( name ) \
73 __ASM_STDCALL_FUNC( name, 4, \
77 "jmp " __ASM_NAME("__regs_") #name __ASM_STDCALL(4))
78 #define DEFINE_FASTCALL2_ENTRYPOINT( name ) \
79 __ASM_STDCALL_FUNC( name, 8, \
84 "jmp " __ASM_NAME("__regs_") #name __ASM_STDCALL(8))
85 #define DEFINE_FASTCALL3_ENTRYPOINT( name ) \
86 __ASM_STDCALL_FUNC( name, 12, \
91 "jmp " __ASM_NAME("__regs_") #name __ASM_STDCALL(12))
94 static inline LPCSTR
debugstr_us( const UNICODE_STRING
*us
)
96 if (!us
) return "<null>";
97 return debugstr_wn( us
->Buffer
, us
->Length
/ sizeof(WCHAR
) );
100 static HANDLE
get_device_manager(void)
102 static HANDLE device_manager
;
103 HANDLE handle
= 0, ret
= device_manager
;
107 SERVER_START_REQ( create_device_manager
)
109 req
->access
= SYNCHRONIZE
;
111 if (!wine_server_call( req
)) handle
= wine_server_ptr_handle( reply
->handle
);
117 ERR( "failed to create the device manager\n" );
120 if (!(ret
= InterlockedCompareExchangePointer( &device_manager
, handle
, 0 )))
123 NtClose( handle
); /* somebody beat us to it */
128 /* process an ioctl request for a given device */
129 static NTSTATUS
process_ioctl( DEVICE_OBJECT
*device
, ULONG code
, void *in_buff
, ULONG in_size
,
130 void *out_buff
, ULONG
*out_size
)
134 IO_STACK_LOCATION irpsp
;
135 PDRIVER_DISPATCH dispatch
= device
->DriverObject
->MajorFunction
[IRP_MJ_DEVICE_CONTROL
];
139 TRACE( "ioctl %x device %p in_size %u out_size %u\n", code
, device
, in_size
, *out_size
);
141 /* so we can spot things that we should initialize */
142 memset( &irp
, 0x55, sizeof(irp
) );
143 memset( &irpsp
, 0x66, sizeof(irpsp
) );
144 memset( &mdl
, 0x77, sizeof(mdl
) );
146 irp
.RequestorMode
= UserMode
;
147 irp
.AssociatedIrp
.SystemBuffer
= in_buff
;
148 irp
.UserBuffer
= out_buff
;
149 irp
.MdlAddress
= &mdl
;
150 irp
.Tail
.Overlay
.s
.u2
.CurrentStackLocation
= &irpsp
;
153 irpsp
.MajorFunction
= IRP_MJ_DEVICE_CONTROL
;
154 irpsp
.Parameters
.DeviceIoControl
.OutputBufferLength
= *out_size
;
155 irpsp
.Parameters
.DeviceIoControl
.InputBufferLength
= in_size
;
156 irpsp
.Parameters
.DeviceIoControl
.IoControlCode
= code
;
157 irpsp
.Parameters
.DeviceIoControl
.Type3InputBuffer
= in_buff
;
158 irpsp
.DeviceObject
= device
;
159 irpsp
.CompletionRoutine
= NULL
;
163 mdl
.StartVa
= out_buff
;
164 mdl
.ByteCount
= *out_size
;
167 device
->CurrentIrp
= &irp
;
169 KeQueryTickCount( &count
); /* update the global KeTickCount */
172 DPRINTF( "%04x:Call driver dispatch %p (device=%p,irp=%p)\n",
173 GetCurrentThreadId(), dispatch
, device
, &irp
);
175 status
= dispatch( device
, &irp
);
178 DPRINTF( "%04x:Ret driver dispatch %p (device=%p,irp=%p) retval=%08x\n",
179 GetCurrentThreadId(), dispatch
, device
, &irp
, status
);
181 *out_size
= (irp
.IoStatus
.u
.Status
>= 0) ? irp
.IoStatus
.Information
: 0;
182 return irp
.IoStatus
.u
.Status
;
186 /***********************************************************************
187 * wine_ntoskrnl_main_loop (Not a Windows API)
189 NTSTATUS CDECL
wine_ntoskrnl_main_loop( HANDLE stop_event
)
191 HANDLE manager
= get_device_manager();
192 obj_handle_t ioctl
= 0;
193 NTSTATUS status
= STATUS_SUCCESS
;
195 void *in_buff
, *out_buff
= NULL
;
196 DEVICE_OBJECT
*device
= NULL
;
197 ULONG in_size
= 4096, out_size
= 0;
200 if (!(in_buff
= HeapAlloc( GetProcessHeap(), 0, in_size
)))
202 ERR( "failed to allocate buffer\n" );
203 return STATUS_NO_MEMORY
;
206 handles
[0] = stop_event
;
207 handles
[1] = manager
;
211 SERVER_START_REQ( get_next_device_request
)
213 req
->manager
= wine_server_obj_handle( manager
);
215 req
->status
= status
;
216 wine_server_add_data( req
, out_buff
, out_size
);
217 wine_server_set_reply( req
, in_buff
, in_size
);
218 if (!(status
= wine_server_call( req
)))
222 device
= wine_server_get_ptr( reply
->user_ptr
);
223 in_size
= reply
->in_size
;
224 out_size
= reply
->out_size
;
228 ioctl
= 0; /* no previous ioctl */
230 in_size
= reply
->in_size
;
238 HeapFree( GetProcessHeap(), 0, out_buff
);
239 if (out_size
) out_buff
= HeapAlloc( GetProcessHeap(), 0, out_size
);
240 else out_buff
= NULL
;
241 status
= process_ioctl( device
, code
, in_buff
, in_size
, out_buff
, &out_size
);
243 case STATUS_BUFFER_OVERFLOW
:
244 HeapFree( GetProcessHeap(), 0, in_buff
);
245 in_buff
= HeapAlloc( GetProcessHeap(), 0, in_size
);
246 /* restart with larger buffer */
249 if (WaitForMultipleObjects( 2, handles
, FALSE
, INFINITE
) == WAIT_OBJECT_0
)
251 HeapFree( GetProcessHeap(), 0, in_buff
);
252 HeapFree( GetProcessHeap(), 0, out_buff
);
253 return STATUS_SUCCESS
;
261 /***********************************************************************
262 * IoAllocateDriverObjectExtension (NTOSKRNL.EXE.@)
264 NTSTATUS WINAPI
IoAllocateDriverObjectExtension( PDRIVER_OBJECT DriverObject
,
265 PVOID ClientIdentificationAddress
,
266 ULONG DriverObjectExtensionSize
,
267 PVOID
*DriverObjectExtension
)
269 FIXME( "stub: %p, %p, %u, %p\n", DriverObject
, ClientIdentificationAddress
,
270 DriverObjectExtensionSize
, DriverObjectExtension
);
271 return STATUS_NOT_IMPLEMENTED
;
275 /***********************************************************************
276 * IoGetDriverObjectExtension (NTOSKRNL.EXE.@)
278 PVOID WINAPI
IoGetDriverObjectExtension( PDRIVER_OBJECT DriverObject
,
279 PVOID ClientIdentificationAddress
)
281 FIXME( "stub: %p, %p\n", DriverObject
, ClientIdentificationAddress
);
286 /***********************************************************************
287 * IoInitializeIrp (NTOSKRNL.EXE.@)
289 void WINAPI
IoInitializeIrp( IRP
*irp
, USHORT size
, CCHAR stack_size
)
291 TRACE( "%p, %u, %d\n", irp
, size
, stack_size
);
293 RtlZeroMemory( irp
, size
);
295 irp
->Type
= IO_TYPE_IRP
;
297 InitializeListHead( &irp
->ThreadListEntry
);
298 irp
->StackCount
= stack_size
;
299 irp
->CurrentLocation
= stack_size
+ 1;
300 irp
->Tail
.Overlay
.s
.u2
.CurrentStackLocation
=
301 (PIO_STACK_LOCATION
)(irp
+ 1) + stack_size
;
305 /***********************************************************************
306 * IoInitializeTimer (NTOSKRNL.EXE.@)
308 NTSTATUS WINAPI
IoInitializeTimer(PDEVICE_OBJECT DeviceObject
,
309 PIO_TIMER_ROUTINE TimerRoutine
,
312 FIXME( "stub: %p, %p, %p\n", DeviceObject
, TimerRoutine
, Context
);
313 return STATUS_NOT_IMPLEMENTED
;
317 /***********************************************************************
318 * IoStartTimer (NTOSKRNL.EXE.@)
320 void WINAPI
IoStartTimer(PDEVICE_OBJECT DeviceObject
)
322 FIXME( "stub: %p\n", DeviceObject
);
326 /***********************************************************************
327 * IoAllocateIrp (NTOSKRNL.EXE.@)
329 PIRP WINAPI
IoAllocateIrp( CCHAR stack_size
, BOOLEAN charge_quota
)
334 TRACE( "%d, %d\n", stack_size
, charge_quota
);
336 size
= sizeof(IRP
) + stack_size
* sizeof(IO_STACK_LOCATION
);
337 irp
= ExAllocatePool( NonPagedPool
, size
);
340 IoInitializeIrp( irp
, size
, stack_size
);
341 irp
->AllocationFlags
= IRP_ALLOCATED_FIXED_SIZE
;
343 irp
->AllocationFlags
|= IRP_LOOKASIDE_ALLOCATION
;
348 /***********************************************************************
349 * IoFreeIrp (NTOSKRNL.EXE.@)
351 void WINAPI
IoFreeIrp( IRP
*irp
)
353 TRACE( "%p\n", irp
);
359 /***********************************************************************
360 * IoAllocateErrorLogEntry (NTOSKRNL.EXE.@)
362 PVOID WINAPI
IoAllocateErrorLogEntry( PVOID IoObject
, UCHAR EntrySize
)
364 FIXME( "stub: %p, %u\n", IoObject
, EntrySize
);
369 /***********************************************************************
370 * IoAllocateMdl (NTOSKRNL.EXE.@)
372 PMDL WINAPI
IoAllocateMdl( PVOID VirtualAddress
, ULONG Length
, BOOLEAN SecondaryBuffer
, BOOLEAN ChargeQuota
, PIRP Irp
)
374 FIXME( "stub: %p, %u, %i, %i, %p\n", VirtualAddress
, Length
, SecondaryBuffer
, ChargeQuota
, Irp
);
379 /***********************************************************************
380 * IoAllocateWorkItem (NTOSKRNL.EXE.@)
382 PIO_WORKITEM WINAPI
IoAllocateWorkItem( PDEVICE_OBJECT DeviceObject
)
384 FIXME( "stub: %p\n", DeviceObject
);
389 /***********************************************************************
390 * IoAttachDeviceToDeviceStack (NTOSKRNL.EXE.@)
392 PDEVICE_OBJECT WINAPI
IoAttachDeviceToDeviceStack( DEVICE_OBJECT
*source
,
393 DEVICE_OBJECT
*target
)
395 TRACE( "%p, %p\n", source
, target
);
396 target
->AttachedDevice
= source
;
397 source
->StackSize
= target
->StackSize
+ 1;
402 /***********************************************************************
403 * IoBuildDeviceIoControlRequest (NTOSKRNL.EXE.@)
405 PIRP WINAPI
IoBuildDeviceIoControlRequest( ULONG IoControlCode
,
406 PDEVICE_OBJECT DeviceObject
,
408 ULONG InputBufferLength
,
410 ULONG OutputBufferLength
,
411 BOOLEAN InternalDeviceIoControl
,
413 PIO_STATUS_BLOCK IoStatusBlock
)
416 PIO_STACK_LOCATION irpsp
;
417 struct IrpInstance
*instance
;
419 TRACE( "%x, %p, %p, %u, %p, %u, %u, %p, %p\n",
420 IoControlCode
, DeviceObject
, InputBuffer
, InputBufferLength
,
421 OutputBuffer
, OutputBufferLength
, InternalDeviceIoControl
,
422 Event
, IoStatusBlock
);
424 if (DeviceObject
== NULL
)
427 irp
= IoAllocateIrp( DeviceObject
->StackSize
, FALSE
);
431 instance
= HeapAlloc( GetProcessHeap(), 0, sizeof(struct IrpInstance
) );
432 if (instance
== NULL
)
438 list_add_tail( &Irps
, &instance
->entry
);
440 irpsp
= IoGetNextIrpStackLocation( irp
);
441 irpsp
->MajorFunction
= InternalDeviceIoControl
?
442 IRP_MJ_INTERNAL_DEVICE_CONTROL
: IRP_MJ_DEVICE_CONTROL
;
443 irpsp
->Parameters
.DeviceIoControl
.IoControlCode
= IoControlCode
;
444 irp
->UserIosb
= IoStatusBlock
;
445 irp
->UserEvent
= Event
;
451 /***********************************************************************
452 * IoCreateDriver (NTOSKRNL.EXE.@)
454 NTSTATUS WINAPI
IoCreateDriver( UNICODE_STRING
*name
, PDRIVER_INITIALIZE init
)
456 DRIVER_OBJECT
*driver
;
457 DRIVER_EXTENSION
*extension
;
460 if (!(driver
= RtlAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY
,
461 sizeof(*driver
) + sizeof(*extension
) )))
462 return STATUS_NO_MEMORY
;
464 if ((status
= RtlDuplicateUnicodeString( 1, name
, &driver
->DriverName
)))
466 RtlFreeHeap( GetProcessHeap(), 0, driver
);
470 extension
= (DRIVER_EXTENSION
*)(driver
+ 1);
471 driver
->Size
= sizeof(*driver
);
472 driver
->DriverInit
= init
;
473 driver
->DriverExtension
= extension
;
474 extension
->DriverObject
= driver
;
475 extension
->ServiceKeyName
= driver
->DriverName
;
477 status
= driver
->DriverInit( driver
, name
);
481 RtlFreeUnicodeString( &driver
->DriverName
);
482 RtlFreeHeap( GetProcessHeap(), 0, driver
);
488 /***********************************************************************
489 * IoDeleteDriver (NTOSKRNL.EXE.@)
491 void WINAPI
IoDeleteDriver( DRIVER_OBJECT
*driver
)
493 RtlFreeUnicodeString( &driver
->DriverName
);
494 RtlFreeHeap( GetProcessHeap(), 0, driver
);
498 /***********************************************************************
499 * IoCreateDevice (NTOSKRNL.EXE.@)
501 NTSTATUS WINAPI
IoCreateDevice( DRIVER_OBJECT
*driver
, ULONG ext_size
,
502 UNICODE_STRING
*name
, DEVICE_TYPE type
,
503 ULONG characteristics
, BOOLEAN exclusive
,
504 DEVICE_OBJECT
**ret_device
)
507 DEVICE_OBJECT
*device
;
509 HANDLE manager
= get_device_manager();
511 TRACE( "(%p, %u, %s, %u, %x, %u, %p)\n",
512 driver
, ext_size
, debugstr_us(name
), type
, characteristics
, exclusive
, ret_device
);
514 if (!(device
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*device
) + ext_size
)))
515 return STATUS_NO_MEMORY
;
517 SERVER_START_REQ( create_device
)
522 req
->manager
= wine_server_obj_handle( manager
);
523 req
->user_ptr
= wine_server_client_ptr( device
);
524 if (name
) wine_server_add_data( req
, name
->Buffer
, name
->Length
);
525 if (!(status
= wine_server_call( req
))) handle
= wine_server_ptr_handle( reply
->handle
);
529 if (status
== STATUS_SUCCESS
)
531 device
->DriverObject
= driver
;
532 device
->DeviceExtension
= device
+ 1;
533 device
->DeviceType
= type
;
534 device
->StackSize
= 1;
535 device
->Reserved
= handle
;
537 device
->NextDevice
= driver
->DeviceObject
;
538 driver
->DeviceObject
= device
;
540 *ret_device
= device
;
542 else HeapFree( GetProcessHeap(), 0, device
);
548 /***********************************************************************
549 * IoDeleteDevice (NTOSKRNL.EXE.@)
551 void WINAPI
IoDeleteDevice( DEVICE_OBJECT
*device
)
555 TRACE( "%p\n", device
);
557 SERVER_START_REQ( delete_device
)
559 req
->handle
= wine_server_obj_handle( device
->Reserved
);
560 status
= wine_server_call( req
);
564 if (status
== STATUS_SUCCESS
)
566 DEVICE_OBJECT
**prev
= &device
->DriverObject
->DeviceObject
;
567 while (*prev
&& *prev
!= device
) prev
= &(*prev
)->NextDevice
;
568 if (*prev
) *prev
= (*prev
)->NextDevice
;
569 NtClose( device
->Reserved
);
570 HeapFree( GetProcessHeap(), 0, device
);
575 /***********************************************************************
576 * IoCreateSymbolicLink (NTOSKRNL.EXE.@)
578 NTSTATUS WINAPI
IoCreateSymbolicLink( UNICODE_STRING
*name
, UNICODE_STRING
*target
)
581 OBJECT_ATTRIBUTES attr
;
583 attr
.Length
= sizeof(attr
);
584 attr
.RootDirectory
= 0;
585 attr
.ObjectName
= name
;
586 attr
.Attributes
= OBJ_CASE_INSENSITIVE
| OBJ_OPENIF
;
587 attr
.SecurityDescriptor
= NULL
;
588 attr
.SecurityQualityOfService
= NULL
;
590 TRACE( "%s -> %s\n", debugstr_us(name
), debugstr_us(target
) );
591 /* FIXME: store handle somewhere */
592 return NtCreateSymbolicLinkObject( &handle
, SYMBOLIC_LINK_ALL_ACCESS
, &attr
, target
);
596 /***********************************************************************
597 * IoDeleteSymbolicLink (NTOSKRNL.EXE.@)
599 NTSTATUS WINAPI
IoDeleteSymbolicLink( UNICODE_STRING
*name
)
602 OBJECT_ATTRIBUTES attr
;
605 attr
.Length
= sizeof(attr
);
606 attr
.RootDirectory
= 0;
607 attr
.ObjectName
= name
;
608 attr
.Attributes
= OBJ_CASE_INSENSITIVE
;
609 attr
.SecurityDescriptor
= NULL
;
610 attr
.SecurityQualityOfService
= NULL
;
612 if (!(status
= NtOpenSymbolicLinkObject( &handle
, 0, &attr
)))
614 SERVER_START_REQ( unlink_object
)
616 req
->handle
= wine_server_obj_handle( handle
);
617 status
= wine_server_call( req
);
626 /***********************************************************************
627 * IoGetDeviceInterfaces (NTOSKRNL.EXE.@)
629 NTSTATUS WINAPI
IoGetDeviceInterfaces( CONST GUID
*InterfaceClassGuid
,
630 PDEVICE_OBJECT PhysicalDeviceObject
,
631 ULONG Flags
, PWSTR
*SymbolicLinkList
)
633 FIXME( "stub: %s %p %x %p\n", debugstr_guid(InterfaceClassGuid
),
634 PhysicalDeviceObject
, Flags
, SymbolicLinkList
);
635 return STATUS_NOT_IMPLEMENTED
;
639 /***********************************************************************
640 * IoGetDeviceObjectPointer (NTOSKRNL.EXE.@)
642 NTSTATUS WINAPI
IoGetDeviceObjectPointer( UNICODE_STRING
*name
, ACCESS_MASK access
, PFILE_OBJECT
*file
, PDEVICE_OBJECT
*device
)
644 FIXME( "stub: %s %x %p %p\n", debugstr_us(name
), access
, file
, device
);
645 return STATUS_NOT_IMPLEMENTED
;
649 /***********************************************************************
650 * IoGetDeviceProperty (NTOSKRNL.EXE.@)
652 NTSTATUS WINAPI
IoGetDeviceProperty( DEVICE_OBJECT
*device
, DEVICE_REGISTRY_PROPERTY device_property
,
653 ULONG buffer_length
, PVOID property_buffer
, PULONG result_length
)
655 FIXME( "%p %d %u %p %p: stub\n", device
, device_property
, buffer_length
,
656 property_buffer
, result_length
);
657 return STATUS_NOT_IMPLEMENTED
;
661 /***********************************************************************
662 * IoCallDriver (NTOSKRNL.EXE.@)
664 NTSTATUS WINAPI
IoCallDriver( DEVICE_OBJECT
*device
, IRP
*irp
)
666 PDRIVER_DISPATCH dispatch
;
667 IO_STACK_LOCATION
*irpsp
;
670 TRACE( "%p %p\n", device
, irp
);
672 --irp
->CurrentLocation
;
673 irpsp
= --irp
->Tail
.Overlay
.s
.u2
.CurrentStackLocation
;
674 dispatch
= device
->DriverObject
->MajorFunction
[irpsp
->MajorFunction
];
675 status
= dispatch( device
, irp
);
681 /***********************************************************************
682 * IofCallDriver (NTOSKRNL.EXE.@)
684 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
685 DEFINE_FASTCALL2_ENTRYPOINT( IofCallDriver
)
686 NTSTATUS WINAPI
__regs_IofCallDriver( DEVICE_OBJECT
*device
, IRP
*irp
)
688 NTSTATUS WINAPI
IofCallDriver( DEVICE_OBJECT
*device
, IRP
*irp
)
691 TRACE( "%p %p\n", device
, irp
);
692 return IoCallDriver( device
, irp
);
696 /***********************************************************************
697 * IoGetRelatedDeviceObject (NTOSKRNL.EXE.@)
699 PDEVICE_OBJECT WINAPI
IoGetRelatedDeviceObject( PFILE_OBJECT obj
)
701 FIXME( "stub: %p\n", obj
);
705 static CONFIGURATION_INFORMATION configuration_information
;
707 /***********************************************************************
708 * IoGetConfigurationInformation (NTOSKRNL.EXE.@)
710 PCONFIGURATION_INFORMATION WINAPI
IoGetConfigurationInformation(void)
712 FIXME( "partial stub\n" );
713 /* FIXME: return actual devices on system */
714 return &configuration_information
;
718 /***********************************************************************
719 * IoIsWdmVersionAvailable (NTOSKRNL.EXE.@)
721 NTSTATUS WINAPI
IoIsWdmVersionAvailable(UCHAR MajorVersion
, UCHAR MinorVersion
)
727 TRACE( "%d, 0x%X\n", MajorVersion
, MinorVersion
);
729 version
= GetVersion();
730 major
= LOBYTE(version
);
731 minor
= HIBYTE(LOWORD(version
));
733 if (MajorVersion
== 6 && MinorVersion
== 0)
735 /* Windows Vista, Windows Server 2008, Windows 7 */
737 else if (MajorVersion
== 1)
739 if (MinorVersion
== 0x30)
741 /* Windows server 2003 */
745 else if (MinorVersion
== 0x20)
751 else if (MinorVersion
== 0x10)
757 else if (MinorVersion
== 0x05)
763 else if (MinorVersion
== 0x00)
771 FIXME( "unknown major %d minor 0x%X\n", MajorVersion
, MinorVersion
);
777 FIXME( "unknown major %d minor 0x%X\n", MajorVersion
, MinorVersion
);
780 return major
> MajorVersion
|| (major
== MajorVersion
&& minor
>= MinorVersion
);
784 /***********************************************************************
785 * IoQueryDeviceDescription (NTOSKRNL.EXE.@)
787 NTSTATUS WINAPI
IoQueryDeviceDescription(PINTERFACE_TYPE itype
, PULONG bus
, PCONFIGURATION_TYPE ctype
,
788 PULONG cnum
, PCONFIGURATION_TYPE ptype
, PULONG pnum
,
789 PIO_QUERY_DEVICE_ROUTINE callout
, PVOID context
)
791 FIXME( "(%p %p %p %p %p %p %p %p)\n", itype
, bus
, ctype
, cnum
, ptype
, pnum
, callout
, context
);
792 return STATUS_NOT_IMPLEMENTED
;
796 /***********************************************************************
797 * IoRegisterDriverReinitialization (NTOSKRNL.EXE.@)
799 void WINAPI
IoRegisterDriverReinitialization( PDRIVER_OBJECT obj
, PDRIVER_REINITIALIZE reinit
, PVOID context
)
801 FIXME( "stub: %p %p %p\n", obj
, reinit
, context
);
805 /***********************************************************************
806 * IoRegisterShutdownNotification (NTOSKRNL.EXE.@)
808 NTSTATUS WINAPI
IoRegisterShutdownNotification( PDEVICE_OBJECT obj
)
810 FIXME( "stub: %p\n", obj
);
811 return STATUS_SUCCESS
;
815 /***********************************************************************
816 * IoReportResourceUsage (NTOSKRNL.EXE.@)
818 NTSTATUS WINAPI
IoReportResourceUsage(PUNICODE_STRING name
, PDRIVER_OBJECT drv_obj
, PCM_RESOURCE_LIST drv_list
,
819 ULONG drv_size
, PDRIVER_OBJECT dev_obj
, PCM_RESOURCE_LIST dev_list
,
820 ULONG dev_size
, BOOLEAN overwrite
, PBOOLEAN detected
)
822 FIXME("(%s %p %p %u %p %p %u %d %p) stub\n", debugstr_w(name
? name
->Buffer
: NULL
),
823 drv_obj
, drv_list
, drv_size
, dev_obj
, dev_list
, dev_size
, overwrite
, detected
);
824 return STATUS_NOT_IMPLEMENTED
;
828 /***********************************************************************
829 * IoCompleteRequest (NTOSKRNL.EXE.@)
831 VOID WINAPI
IoCompleteRequest( IRP
*irp
, UCHAR priority_boost
)
833 IO_STACK_LOCATION
*irpsp
;
834 PIO_COMPLETION_ROUTINE routine
;
835 IO_STATUS_BLOCK
*iosb
;
836 struct IrpInstance
*instance
;
837 NTSTATUS status
, stat
;
840 TRACE( "%p %u\n", irp
, priority_boost
);
842 iosb
= irp
->UserIosb
;
843 status
= irp
->IoStatus
.u
.Status
;
844 while (irp
->CurrentLocation
<= irp
->StackCount
)
846 irpsp
= irp
->Tail
.Overlay
.s
.u2
.CurrentStackLocation
;
847 routine
= irpsp
->CompletionRoutine
;
849 /* FIXME: add SL_INVOKE_ON_CANCEL support */
852 if ((irpsp
->Control
& SL_INVOKE_ON_SUCCESS
) && STATUS_SUCCESS
== status
)
854 if ((irpsp
->Control
& SL_INVOKE_ON_ERROR
) && STATUS_SUCCESS
!= status
)
857 ++irp
->CurrentLocation
;
858 ++irp
->Tail
.Overlay
.s
.u2
.CurrentStackLocation
;
861 TRACE( "calling %p( %p, %p, %p )\n", routine
,
862 irpsp
->DeviceObject
, irp
, irpsp
->Context
);
863 stat
= routine( irpsp
->DeviceObject
, irp
, irpsp
->Context
);
864 TRACE( "CompletionRoutine returned %x\n", stat
);
865 if (STATUS_MORE_PROCESSING_REQUIRED
== stat
)
869 if (iosb
&& STATUS_SUCCESS
== status
)
871 iosb
->u
.Status
= irp
->IoStatus
.u
.Status
;
872 iosb
->Information
= irp
->IoStatus
.Information
;
874 LIST_FOR_EACH_ENTRY( instance
, &Irps
, struct IrpInstance
, entry
)
876 if (instance
->irp
== irp
)
878 list_remove( &instance
->entry
);
879 HeapFree( GetProcessHeap(), 0, instance
);
887 /***********************************************************************
888 * IofCompleteRequest (NTOSKRNL.EXE.@)
890 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
891 DEFINE_FASTCALL2_ENTRYPOINT( IofCompleteRequest
)
892 void WINAPI
__regs_IofCompleteRequest( IRP
*irp
, UCHAR priority_boost
)
894 void WINAPI
IofCompleteRequest( IRP
*irp
, UCHAR priority_boost
)
897 TRACE( "%p %u\n", irp
, priority_boost
);
898 IoCompleteRequest( irp
, priority_boost
);
902 /***********************************************************************
903 * InterlockedCompareExchange (NTOSKRNL.EXE.@)
905 #ifdef DEFINE_FASTCALL3_ENTRYPOINT
906 DEFINE_FASTCALL3_ENTRYPOINT( NTOSKRNL_InterlockedCompareExchange
)
907 LONG WINAPI
__regs_NTOSKRNL_InterlockedCompareExchange( LONG
volatile *dest
, LONG xchg
, LONG compare
)
909 LONG WINAPI
NTOSKRNL_InterlockedCompareExchange( LONG
volatile *dest
, LONG xchg
, LONG compare
)
912 return InterlockedCompareExchange( dest
, xchg
, compare
);
916 /***********************************************************************
917 * InterlockedDecrement (NTOSKRNL.EXE.@)
919 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
920 DEFINE_FASTCALL1_ENTRYPOINT( NTOSKRNL_InterlockedDecrement
)
921 LONG WINAPI
__regs_NTOSKRNL_InterlockedDecrement( LONG
volatile *dest
)
923 LONG WINAPI
NTOSKRNL_InterlockedDecrement( LONG
volatile *dest
)
926 return InterlockedDecrement( dest
);
930 /***********************************************************************
931 * InterlockedExchange (NTOSKRNL.EXE.@)
933 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
934 DEFINE_FASTCALL2_ENTRYPOINT( NTOSKRNL_InterlockedExchange
)
935 LONG WINAPI
__regs_NTOSKRNL_InterlockedExchange( LONG
volatile *dest
, LONG val
)
937 LONG WINAPI
NTOSKRNL_InterlockedExchange( LONG
volatile *dest
, LONG val
)
940 return InterlockedExchange( dest
, val
);
944 /***********************************************************************
945 * InterlockedExchangeAdd (NTOSKRNL.EXE.@)
947 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
948 DEFINE_FASTCALL2_ENTRYPOINT( NTOSKRNL_InterlockedExchangeAdd
)
949 LONG WINAPI
__regs_NTOSKRNL_InterlockedExchangeAdd( LONG
volatile *dest
, LONG incr
)
951 LONG WINAPI
NTOSKRNL_InterlockedExchangeAdd( LONG
volatile *dest
, LONG incr
)
954 return InterlockedExchangeAdd( dest
, incr
);
958 /***********************************************************************
959 * InterlockedIncrement (NTOSKRNL.EXE.@)
961 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
962 DEFINE_FASTCALL1_ENTRYPOINT( NTOSKRNL_InterlockedIncrement
)
963 LONG WINAPI
__regs_NTOSKRNL_InterlockedIncrement( LONG
volatile *dest
)
965 LONG WINAPI
NTOSKRNL_InterlockedIncrement( LONG
volatile *dest
)
968 return InterlockedIncrement( dest
);
972 /***********************************************************************
973 * ExAllocatePool (NTOSKRNL.EXE.@)
975 PVOID WINAPI
ExAllocatePool( POOL_TYPE type
, SIZE_T size
)
977 return ExAllocatePoolWithTag( type
, size
, 0 );
981 /***********************************************************************
982 * ExAllocatePoolWithQuota (NTOSKRNL.EXE.@)
984 PVOID WINAPI
ExAllocatePoolWithQuota( POOL_TYPE type
, SIZE_T size
)
986 return ExAllocatePoolWithTag( type
, size
, 0 );
990 /***********************************************************************
991 * ExAllocatePoolWithTag (NTOSKRNL.EXE.@)
993 PVOID WINAPI
ExAllocatePoolWithTag( POOL_TYPE type
, SIZE_T size
, ULONG tag
)
995 /* FIXME: handle page alignment constraints */
996 void *ret
= HeapAlloc( GetProcessHeap(), 0, size
);
997 TRACE( "%lu pool %u -> %p\n", size
, type
, ret
);
1002 /***********************************************************************
1003 * ExAllocatePoolWithQuotaTag (NTOSKRNL.EXE.@)
1005 PVOID WINAPI
ExAllocatePoolWithQuotaTag( POOL_TYPE type
, SIZE_T size
, ULONG tag
)
1007 return ExAllocatePoolWithTag( type
, size
, tag
);
1011 /***********************************************************************
1012 * ExFreePool (NTOSKRNL.EXE.@)
1014 void WINAPI
ExFreePool( void *ptr
)
1016 ExFreePoolWithTag( ptr
, 0 );
1020 /***********************************************************************
1021 * ExFreePoolWithTag (NTOSKRNL.EXE.@)
1023 void WINAPI
ExFreePoolWithTag( void *ptr
, ULONG tag
)
1025 TRACE( "%p\n", ptr
);
1026 HeapFree( GetProcessHeap(), 0, ptr
);
1030 /***********************************************************************
1031 * ExInitializeResourceLite (NTOSKRNL.EXE.@)
1033 NTSTATUS WINAPI
ExInitializeResourceLite(PERESOURCE Resource
)
1035 FIXME( "stub: %p\n", Resource
);
1036 return STATUS_NOT_IMPLEMENTED
;
1040 /***********************************************************************
1041 * ExInitializeNPagedLookasideList (NTOSKRNL.EXE.@)
1043 void WINAPI
ExInitializeNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside
,
1044 PALLOCATE_FUNCTION Allocate
,
1045 PFREE_FUNCTION Free
,
1051 FIXME( "stub: %p, %p, %p, %u, %lu, %u, %u\n", Lookaside
, Allocate
, Free
, Flags
, Size
, Tag
, Depth
);
1055 /***********************************************************************
1056 * ExInitializeZone (NTOSKRNL.EXE.@)
1058 NTSTATUS WINAPI
ExInitializeZone(PZONE_HEADER Zone
,
1060 PVOID InitialSegment
,
1061 ULONG InitialSegmentSize
)
1063 FIXME( "stub: %p, %u, %p, %u\n", Zone
, BlockSize
, InitialSegment
, InitialSegmentSize
);
1064 return STATUS_NOT_IMPLEMENTED
;
1067 /***********************************************************************
1068 * FsRtlRegisterUncProvider (NTOSKRNL.EXE.@)
1070 NTSTATUS WINAPI
FsRtlRegisterUncProvider(PHANDLE MupHandle
, PUNICODE_STRING RedirDevName
,
1071 BOOLEAN MailslotsSupported
)
1073 FIXME("(%p %p %d): stub\n", MupHandle
, RedirDevName
, MailslotsSupported
);
1074 return STATUS_NOT_IMPLEMENTED
;
1077 /***********************************************************************
1078 * KeGetCurrentThread / PsGetCurrentThread (NTOSKRNL.EXE.@)
1080 PRKTHREAD WINAPI
KeGetCurrentThread(void)
1086 /***********************************************************************
1087 * KeInitializeEvent (NTOSKRNL.EXE.@)
1089 void WINAPI
KeInitializeEvent( PRKEVENT Event
, EVENT_TYPE Type
, BOOLEAN State
)
1091 FIXME( "stub: %p %d %d\n", Event
, Type
, State
);
1095 /***********************************************************************
1096 * KeInitializeMutex (NTOSKRNL.EXE.@)
1098 void WINAPI
KeInitializeMutex(PRKMUTEX Mutex
, ULONG Level
)
1100 FIXME( "stub: %p, %u\n", Mutex
, Level
);
1104 /***********************************************************************
1105 * KeWaitForMutexObject (NTOSKRNL.EXE.@)
1107 NTSTATUS WINAPI
KeWaitForMutexObject(PRKMUTEX Mutex
, KWAIT_REASON WaitReason
, KPROCESSOR_MODE WaitMode
,
1108 BOOLEAN Alertable
, PLARGE_INTEGER Timeout
)
1110 FIXME( "stub: %p, %d, %d, %d, %p\n", Mutex
, WaitReason
, WaitMode
, Alertable
, Timeout
);
1111 return STATUS_NOT_IMPLEMENTED
;
1115 /***********************************************************************
1116 * KeReleaseMutex (NTOSKRNL.EXE.@)
1118 LONG WINAPI
KeReleaseMutex(PRKMUTEX Mutex
, BOOLEAN Wait
)
1120 FIXME( "stub: %p, %d\n", Mutex
, Wait
);
1121 return STATUS_NOT_IMPLEMENTED
;
1125 /***********************************************************************
1126 * KeInitializeSemaphore (NTOSKRNL.EXE.@)
1128 void WINAPI
KeInitializeSemaphore( PRKSEMAPHORE Semaphore
, LONG Count
, LONG Limit
)
1130 FIXME( "(%p %d %d) stub\n", Semaphore
, Count
, Limit
);
1134 /***********************************************************************
1135 * KeInitializeSpinLock (NTOSKRNL.EXE.@)
1137 void WINAPI
KeInitializeSpinLock( PKSPIN_LOCK SpinLock
)
1139 FIXME( "stub: %p\n", SpinLock
);
1143 /***********************************************************************
1144 * KeInitializeTimerEx (NTOSKRNL.EXE.@)
1146 void WINAPI
KeInitializeTimerEx( PKTIMER Timer
, TIMER_TYPE Type
)
1148 FIXME( "stub: %p %d\n", Timer
, Type
);
1152 /***********************************************************************
1153 * KeInitializeTimer (NTOSKRNL.EXE.@)
1155 void WINAPI
KeInitializeTimer( PKTIMER Timer
)
1157 KeInitializeTimerEx(Timer
, NotificationTimer
);
1161 /**********************************************************************
1162 * KeQueryActiveProcessors (NTOSKRNL.EXE.@)
1164 * Return the active Processors as bitmask
1167 * active Processors as bitmask
1170 KAFFINITY WINAPI
KeQueryActiveProcessors( void )
1172 DWORD_PTR AffinityMask
;
1174 GetProcessAffinityMask( GetCurrentProcess(), &AffinityMask
, NULL
);
1175 return AffinityMask
;
1179 /**********************************************************************
1180 * KeQueryInterruptTime (NTOSKRNL.EXE.@)
1182 * Return the interrupt time count
1185 ULONGLONG WINAPI
KeQueryInterruptTime( void )
1187 LARGE_INTEGER totaltime
;
1189 KeQueryTickCount(&totaltime
);
1190 return totaltime
.QuadPart
;
1194 /***********************************************************************
1195 * KeQuerySystemTime (NTOSKRNL.EXE.@)
1197 void WINAPI
KeQuerySystemTime( LARGE_INTEGER
*time
)
1199 NtQuerySystemTime( time
);
1203 /***********************************************************************
1204 * KeQueryTickCount (NTOSKRNL.EXE.@)
1206 void WINAPI
KeQueryTickCount( LARGE_INTEGER
*count
)
1208 count
->QuadPart
= NtGetTickCount();
1209 /* update the global variable too */
1210 KeTickCount
.LowPart
= count
->u
.LowPart
;
1211 KeTickCount
.High1Time
= count
->u
.HighPart
;
1212 KeTickCount
.High2Time
= count
->u
.HighPart
;
1216 /***********************************************************************
1217 * KeReleaseSemaphore (NTOSKRNL.EXE.@)
1219 LONG WINAPI
KeReleaseSemaphore( PRKSEMAPHORE Semaphore
, KPRIORITY Increment
,
1220 LONG Adjustment
, BOOLEAN Wait
)
1222 FIXME("(%p %d %d %d) stub\n", Semaphore
, Increment
, Adjustment
, Wait
);
1227 /***********************************************************************
1228 * KeQueryTimeIncrement (NTOSKRNL.EXE.@)
1230 ULONG WINAPI
KeQueryTimeIncrement(void)
1236 /***********************************************************************
1237 * KeResetEvent (NTOSKRNL.EXE.@)
1239 LONG WINAPI
KeResetEvent( PRKEVENT Event
)
1241 FIXME("(%p): stub\n", Event
);
1246 /***********************************************************************
1247 * KeSetEvent (NTOSKRNL.EXE.@)
1249 LONG WINAPI
KeSetEvent( PRKEVENT Event
, KPRIORITY Increment
, BOOLEAN Wait
)
1251 FIXME("(%p, %d, %d): stub\n", Event
, Increment
, Wait
);
1256 /***********************************************************************
1257 * KeSetPriorityThread (NTOSKRNL.EXE.@)
1259 KPRIORITY WINAPI
KeSetPriorityThread( PKTHREAD Thread
, KPRIORITY Priority
)
1261 FIXME("(%p %d)\n", Thread
, Priority
);
1266 /***********************************************************************
1267 * KeWaitForSingleObject (NTOSKRNL.EXE.@)
1269 NTSTATUS WINAPI
KeWaitForSingleObject(PVOID Object
,
1270 KWAIT_REASON WaitReason
,
1271 KPROCESSOR_MODE WaitMode
,
1273 PLARGE_INTEGER Timeout
)
1275 FIXME( "stub: %p, %d, %d, %d, %p\n", Object
, WaitReason
, WaitMode
, Alertable
, Timeout
);
1276 return STATUS_NOT_IMPLEMENTED
;
1279 /***********************************************************************
1280 * IoRegisterFileSystem (NTOSKRNL.EXE.@)
1282 VOID WINAPI
IoRegisterFileSystem(PDEVICE_OBJECT DeviceObject
)
1284 FIXME("(%p): stub\n", DeviceObject
);
1287 /***********************************************************************
1288 * IoUnregisterFileSystem (NTOSKRNL.EXE.@)
1290 VOID WINAPI
IoUnregisterFileSystem(PDEVICE_OBJECT DeviceObject
)
1292 FIXME("(%p): stub\n", DeviceObject
);
1295 /***********************************************************************
1296 * MmAllocateNonCachedMemory (NTOSKRNL.EXE.@)
1298 PVOID WINAPI
MmAllocateNonCachedMemory( SIZE_T size
)
1300 TRACE( "%lu\n", size
);
1301 return VirtualAlloc( NULL
, size
, MEM_RESERVE
|MEM_COMMIT
, PAGE_READWRITE
|PAGE_NOCACHE
);
1304 /***********************************************************************
1305 * MmAllocateContiguousMemory (NTOSKRNL.EXE.@)
1307 PVOID WINAPI
MmAllocateContiguousMemory( SIZE_T size
, PHYSICAL_ADDRESS highest_valid_address
)
1309 FIXME( "%lu, %s stub\n", size
, wine_dbgstr_longlong(highest_valid_address
.QuadPart
) );
1313 /***********************************************************************
1314 * MmAllocateContiguousMemorySpecifyCache (NTOSKRNL.EXE.@)
1316 PVOID WINAPI
MmAllocateContiguousMemorySpecifyCache( SIZE_T size
,
1317 PHYSICAL_ADDRESS lowest_valid_address
,
1318 PHYSICAL_ADDRESS highest_valid_address
,
1319 PHYSICAL_ADDRESS BoundaryAddressMultiple
,
1320 MEMORY_CACHING_TYPE CacheType
)
1326 /***********************************************************************
1327 * MmAllocatePagesForMdl (NTOSKRNL.EXE.@)
1329 PMDL WINAPI
MmAllocatePagesForMdl(PHYSICAL_ADDRESS lowaddress
, PHYSICAL_ADDRESS highaddress
,
1330 PHYSICAL_ADDRESS skipbytes
, SIZE_T size
)
1332 FIXME("%s %s %s %lu: stub\n", wine_dbgstr_longlong(lowaddress
.QuadPart
), wine_dbgstr_longlong(highaddress
.QuadPart
),
1333 wine_dbgstr_longlong(skipbytes
.QuadPart
), size
);
1337 /***********************************************************************
1338 * MmFreeNonCachedMemory (NTOSKRNL.EXE.@)
1340 void WINAPI
MmFreeNonCachedMemory( void *addr
, SIZE_T size
)
1342 TRACE( "%p %lu\n", addr
, size
);
1343 VirtualFree( addr
, 0, MEM_RELEASE
);
1346 /***********************************************************************
1347 * MmIsAddressValid (NTOSKRNL.EXE.@)
1349 * Check if the process can access the virtual address without a pagefault
1352 * VirtualAddress [I] Address to check
1356 * Success: TRUE (Accessing the Address works without a Pagefault)
1359 BOOLEAN WINAPI
MmIsAddressValid(PVOID VirtualAddress
)
1361 TRACE("(%p)\n", VirtualAddress
);
1362 return !IsBadWritePtr(VirtualAddress
, 1);
1365 /***********************************************************************
1366 * MmMapIoSpace (NTOSKRNL.EXE.@)
1368 PVOID WINAPI
MmMapIoSpace( PHYSICAL_ADDRESS PhysicalAddress
, DWORD NumberOfBytes
, DWORD CacheType
)
1370 FIXME( "stub: 0x%08x%08x, %d, %d\n", PhysicalAddress
.u
.HighPart
, PhysicalAddress
.u
.LowPart
, NumberOfBytes
, CacheType
);
1374 /***********************************************************************
1375 * MmPageEntireDriver (NTOSKRNL.EXE.@)
1377 PVOID WINAPI
MmPageEntireDriver(PVOID AddrInSection
)
1379 TRACE("%p\n", AddrInSection
);
1380 return AddrInSection
;
1383 /***********************************************************************
1384 * MmResetDriverPaging (NTOSKRNL.EXE.@)
1386 void WINAPI
MmResetDriverPaging(PVOID AddrInSection
)
1388 TRACE("%p\n", AddrInSection
);
1391 /***********************************************************************
1392 * MmUnmapIoSpace (NTOSKRNL.EXE.@)
1394 VOID WINAPI
MmUnmapIoSpace( PVOID BaseAddress
, SIZE_T NumberOfBytes
)
1396 FIXME( "stub: %p, %lu\n", BaseAddress
, NumberOfBytes
);
1399 /***********************************************************************
1400 * ObfReferenceObject (NTOSKRNL.EXE.@)
1402 VOID WINAPI
ObfReferenceObject(PVOID Object
)
1404 FIXME("(%p): stub\n", Object
);
1407 /***********************************************************************
1408 * ObReferenceObjectByHandle (NTOSKRNL.EXE.@)
1410 NTSTATUS WINAPI
ObReferenceObjectByHandle( HANDLE obj
, ACCESS_MASK access
,
1412 KPROCESSOR_MODE mode
, PVOID
* ptr
,
1413 POBJECT_HANDLE_INFORMATION info
)
1415 FIXME( "stub: %p %x %p %d %p %p\n", obj
, access
, type
, mode
, ptr
, info
);
1416 return STATUS_NOT_IMPLEMENTED
;
1419 /***********************************************************************
1420 * ObReferenceObjectByName (NTOSKRNL.EXE.@)
1422 NTSTATUS WINAPI
ObReferenceObjectByName( UNICODE_STRING
*ObjectName
,
1424 ACCESS_STATE
*AccessState
,
1425 ACCESS_MASK DesiredAccess
,
1426 POBJECT_TYPE ObjectType
,
1427 KPROCESSOR_MODE AccessMode
,
1432 return STATUS_NOT_IMPLEMENTED
;
1435 /***********************************************************************
1436 * ObfDereferenceObject (NTOSKRNL.EXE.@)
1438 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
1439 DEFINE_FASTCALL1_ENTRYPOINT( ObfDereferenceObject
)
1440 void WINAPI
__regs_ObfDereferenceObject( VOID
*obj
)
1442 void WINAPI
ObfDereferenceObject( VOID
*obj
)
1445 FIXME( "stub: %p\n", obj
);
1449 /***********************************************************************
1450 * PsCreateSystemThread (NTOSKRNL.EXE.@)
1452 NTSTATUS WINAPI
PsCreateSystemThread(PHANDLE ThreadHandle
, ULONG DesiredAccess
,
1453 POBJECT_ATTRIBUTES ObjectAttributes
,
1454 HANDLE ProcessHandle
, PCLIENT_ID ClientId
,
1455 PKSTART_ROUTINE StartRoutine
, PVOID StartContext
)
1457 if (!ProcessHandle
) ProcessHandle
= GetCurrentProcess();
1458 return RtlCreateUserThread(ProcessHandle
, 0, FALSE
, 0, 0,
1459 0, StartRoutine
, StartContext
,
1460 ThreadHandle
, ClientId
);
1463 /***********************************************************************
1464 * PsGetCurrentProcessId (NTOSKRNL.EXE.@)
1466 HANDLE WINAPI
PsGetCurrentProcessId(void)
1468 return UlongToHandle(GetCurrentProcessId()); /* FIXME: not quite right... */
1472 /***********************************************************************
1473 * PsGetCurrentThreadId (NTOSKRNL.EXE.@)
1475 HANDLE WINAPI
PsGetCurrentThreadId(void)
1477 return UlongToHandle(GetCurrentThreadId()); /* FIXME: not quite right... */
1481 /***********************************************************************
1482 * PsGetVersion (NTOSKRNL.EXE.@)
1484 BOOLEAN WINAPI
PsGetVersion(ULONG
*major
, ULONG
*minor
, ULONG
*build
, UNICODE_STRING
*version
)
1486 RTL_OSVERSIONINFOEXW info
;
1488 info
.dwOSVersionInfoSize
= sizeof(info
);
1489 RtlGetVersion( &info
);
1490 if (major
) *major
= info
.dwMajorVersion
;
1491 if (minor
) *minor
= info
.dwMinorVersion
;
1492 if (build
) *build
= info
.dwBuildNumber
;
1496 #if 0 /* FIXME: GameGuard passes an uninitialized pointer in version->Buffer */
1497 size_t len
= min( strlenW(info
.szCSDVersion
)*sizeof(WCHAR
), version
->MaximumLength
);
1498 memcpy( version
->Buffer
, info
.szCSDVersion
, len
);
1499 if (len
< version
->MaximumLength
) version
->Buffer
[len
/ sizeof(WCHAR
)] = 0;
1500 version
->Length
= len
;
1507 /***********************************************************************
1508 * PsSetCreateProcessNotifyRoutine (NTOSKRNL.EXE.@)
1510 NTSTATUS WINAPI
PsSetCreateProcessNotifyRoutine( PCREATE_PROCESS_NOTIFY_ROUTINE callback
, BOOLEAN remove
)
1512 FIXME( "stub: %p %d\n", callback
, remove
);
1513 return STATUS_SUCCESS
;
1517 /***********************************************************************
1518 * PsSetCreateThreadNotifyRoutine (NTOSKRNL.EXE.@)
1520 NTSTATUS WINAPI
PsSetCreateThreadNotifyRoutine( PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine
)
1522 FIXME( "stub: %p\n", NotifyRoutine
);
1523 return STATUS_SUCCESS
;
1527 /***********************************************************************
1528 * PsTerminateSystemThread (NTOSKRNL.EXE.@)
1530 NTSTATUS WINAPI
PsTerminateSystemThread(NTSTATUS ExitStatus
)
1532 FIXME( "stub: %u\n", ExitStatus
);
1533 return STATUS_NOT_IMPLEMENTED
;
1537 /***********************************************************************
1538 * MmGetSystemRoutineAddress (NTOSKRNL.EXE.@)
1540 PVOID WINAPI
MmGetSystemRoutineAddress(PUNICODE_STRING SystemRoutineName
)
1543 STRING routineNameA
;
1546 static const WCHAR ntoskrnlW
[] = {'n','t','o','s','k','r','n','l','.','e','x','e',0};
1547 static const WCHAR halW
[] = {'h','a','l','.','d','l','l',0};
1549 if (!SystemRoutineName
) return NULL
;
1551 if (RtlUnicodeStringToAnsiString( &routineNameA
, SystemRoutineName
, TRUE
) == STATUS_SUCCESS
)
1553 /* We only support functions exported from ntoskrnl.exe or hal.dll */
1554 hMod
= GetModuleHandleW( ntoskrnlW
);
1555 pFunc
= GetProcAddress( hMod
, routineNameA
.Buffer
);
1558 hMod
= GetModuleHandleW( halW
);
1559 if (hMod
) pFunc
= GetProcAddress( hMod
, routineNameA
.Buffer
);
1561 RtlFreeAnsiString( &routineNameA
);
1565 TRACE( "%s -> %p\n", debugstr_us(SystemRoutineName
), pFunc
);
1567 FIXME( "%s not found\n", debugstr_us(SystemRoutineName
) );
1572 /***********************************************************************
1573 * MmQuerySystemSize (NTOSKRNL.EXE.@)
1575 MM_SYSTEMSIZE WINAPI
MmQuerySystemSize(void)
1578 return MmLargeSystem
;
1581 /***********************************************************************
1582 * KeInitializeDpc (NTOSKRNL.EXE.@)
1584 VOID WINAPI
KeInitializeDpc(PRKDPC Dpc
, PKDEFERRED_ROUTINE DeferredRoutine
, PVOID DeferredContext
)
1589 /***********************************************************************
1590 * READ_REGISTER_BUFFER_UCHAR (NTOSKRNL.EXE.@)
1592 VOID WINAPI
READ_REGISTER_BUFFER_UCHAR(PUCHAR Register
, PUCHAR Buffer
, ULONG Count
)
1597 /*****************************************************
1598 * PoSetPowerState (NTOSKRNL.EXE.@)
1600 POWER_STATE WINAPI
PoSetPowerState(PDEVICE_OBJECT DeviceObject
, POWER_STATE_TYPE Type
, POWER_STATE State
)
1602 FIXME("(%p %u %u) stub\n", DeviceObject
, Type
, State
.DeviceState
);
1606 /*****************************************************
1607 * IoWMIRegistrationControl (NTOSKRNL.EXE.@)
1609 NTSTATUS WINAPI
IoWMIRegistrationControl(PDEVICE_OBJECT DeviceObject
, ULONG Action
)
1611 FIXME("(%p %u ) stub\n", DeviceObject
, Action
);
1612 return STATUS_SUCCESS
;
1615 /*****************************************************
1616 * PsSetLoadImageNotifyRoutine (NTOSKRNL.EXE.@)
1618 NTSTATUS WINAPI
PsSetLoadImageNotifyRoutine(PLOAD_IMAGE_NOTIFY_ROUTINE routine
)
1620 FIXME("(%p) stub\n", routine
);
1621 return STATUS_SUCCESS
;
1624 /*****************************************************
1625 * PsLookupProcessByProcessId (NTOSKRNL.EXE.@)
1627 NTSTATUS WINAPI
PsLookupProcessByProcessId(HANDLE processid
, PEPROCESS
*process
)
1629 FIXME("(%p %p) stub\n", processid
, process
);
1630 return STATUS_NOT_IMPLEMENTED
;
1634 /*****************************************************
1635 * IoSetThreadHardErrorMode (NTOSKRNL.EXE.@)
1637 BOOLEAN WINAPI
IoSetThreadHardErrorMode(BOOLEAN EnableHardErrors
)
1643 /*****************************************************
1646 BOOL WINAPI
DllMain( HINSTANCE inst
, DWORD reason
, LPVOID reserved
)
1648 static void *handler
;
1649 LARGE_INTEGER count
;
1653 case DLL_PROCESS_ATTACH
:
1654 DisableThreadLibraryCalls( inst
);
1656 handler
= RtlAddVectoredExceptionHandler( TRUE
, vectored_handler
);
1658 KeQueryTickCount( &count
); /* initialize the global KeTickCount */
1660 case DLL_PROCESS_DETACH
:
1661 RtlRemoveVectoredExceptionHandler( handler
);