2 * ntoskrnl.exe implementation
4 * Copyright (C) 2007 Alexandre Julliard
5 * Copyright (C) 2010 Damjan Jovanovic
6 * Copyright (C) 2016 Sebastian Lackner
7 * Copyright (C) 2016 CodeWeavers, Aric Stewart
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include "wine/port.h"
29 #define NONAMELESSUNION
30 #define NONAMELESSSTRUCT
33 #define WIN32_NO_STATUS
40 #include "ddk/ntddk.h"
41 #include "ddk/ntifs.h"
43 #include "wine/unicode.h"
44 #include "wine/server.h"
45 #include "wine/debug.h"
47 #include "wine/rbtree.h"
49 WINE_DEFAULT_DEBUG_CHANNEL(ntoskrnl
);
50 WINE_DECLARE_DEBUG_CHANNEL(relay
);
51 WINE_DECLARE_DEBUG_CHANNEL(plugplay
);
53 BOOLEAN KdDebuggerEnabled
= FALSE
;
54 ULONG InitSafeBootMode
= 0;
56 extern LONG CALLBACK
vectored_handler( EXCEPTION_POINTERS
*ptrs
);
58 KSYSTEM_TIME KeTickCount
= { 0, 0, 0 };
60 typedef struct _KSERVICE_TABLE_DESCRIPTOR
66 } KSERVICE_TABLE_DESCRIPTOR
, *PKSERVICE_TABLE_DESCRIPTOR
;
68 KSERVICE_TABLE_DESCRIPTOR KeServiceDescriptorTable
[4] = { { 0 } };
70 typedef void (WINAPI
*PCREATE_PROCESS_NOTIFY_ROUTINE
)(HANDLE
,HANDLE
,BOOLEAN
);
71 typedef void (WINAPI
*PCREATE_THREAD_NOTIFY_ROUTINE
)(HANDLE
,HANDLE
,BOOLEAN
);
73 static const WCHAR servicesW
[] = {'\\','R','e','g','i','s','t','r','y',
74 '\\','M','a','c','h','i','n','e',
75 '\\','S','y','s','t','e','m',
76 '\\','C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t',
77 '\\','S','e','r','v','i','c','e','s',
80 #define MAX_SERVICE_NAME 260
82 /* tid of the thread running client request */
83 static DWORD request_thread
;
85 /* pid/tid of the client thread */
86 static DWORD client_tid
;
87 static DWORD client_pid
;
91 struct wine_rb_entry entry
;
93 DRIVER_OBJECT driver_obj
;
94 DRIVER_EXTENSION driver_extension
;
97 static NTSTATUS
get_device_id( DEVICE_OBJECT
*device
, BUS_QUERY_ID_TYPE type
, WCHAR
**id
);
99 static int wine_drivers_rb_compare( const void *key
, const struct wine_rb_entry
*entry
)
101 const struct wine_driver
*driver
= WINE_RB_ENTRY_VALUE( entry
, const struct wine_driver
, entry
);
102 const UNICODE_STRING
*k
= key
;
104 return RtlCompareUnicodeString( k
, &driver
->driver_obj
.DriverName
, FALSE
);
107 static struct wine_rb_tree wine_drivers
= { wine_drivers_rb_compare
};
109 static CRITICAL_SECTION drivers_cs
;
110 static CRITICAL_SECTION_DEBUG critsect_debug
=
113 { &critsect_debug
.ProcessLocksList
, &critsect_debug
.ProcessLocksList
},
114 0, 0, { (DWORD_PTR
)(__FILE__
": drivers_cs") }
116 static CRITICAL_SECTION drivers_cs
= { &critsect_debug
, -1, 0, 0, 0, 0 };
119 #define DEFINE_FASTCALL1_ENTRYPOINT( name ) \
120 __ASM_STDCALL_FUNC( name, 4, \
124 "jmp " __ASM_NAME("__regs_") #name __ASM_STDCALL(4))
125 #define DEFINE_FASTCALL2_ENTRYPOINT( name ) \
126 __ASM_STDCALL_FUNC( name, 8, \
131 "jmp " __ASM_NAME("__regs_") #name __ASM_STDCALL(8))
132 #define DEFINE_FASTCALL3_ENTRYPOINT( name ) \
133 __ASM_STDCALL_FUNC( name, 12, \
138 "jmp " __ASM_NAME("__regs_") #name __ASM_STDCALL(12))
141 static inline LPCSTR
debugstr_us( const UNICODE_STRING
*us
)
143 if (!us
) return "<null>";
144 return debugstr_wn( us
->Buffer
, us
->Length
/ sizeof(WCHAR
) );
147 static HANDLE
get_device_manager(void)
149 static HANDLE device_manager
;
150 HANDLE handle
= 0, ret
= device_manager
;
154 SERVER_START_REQ( create_device_manager
)
156 req
->access
= SYNCHRONIZE
;
158 if (!wine_server_call( req
)) handle
= wine_server_ptr_handle( reply
->handle
);
164 ERR( "failed to create the device manager\n" );
167 if (!(ret
= InterlockedCompareExchangePointer( &device_manager
, handle
, 0 )))
170 NtClose( handle
); /* somebody beat us to it */
175 /* transfer result of IRP back to wineserver */
176 static NTSTATUS WINAPI
dispatch_irp_completion( DEVICE_OBJECT
*device
, IRP
*irp
, void *context
)
178 FILE_OBJECT
*file
= irp
->Tail
.Overlay
.OriginalFileObject
;
179 HANDLE irp_handle
= context
;
180 void *out_buff
= irp
->UserBuffer
;
182 if (irp
->Flags
& IRP_WRITE_OPERATION
)
183 out_buff
= NULL
; /* do not transfer back input buffer */
185 SERVER_START_REQ( set_irp_result
)
187 req
->handle
= wine_server_obj_handle( irp_handle
);
188 req
->status
= irp
->IoStatus
.u
.Status
;
189 req
->file_ptr
= wine_server_client_ptr( file
);
190 if (irp
->IoStatus
.u
.Status
>= 0)
192 req
->size
= irp
->IoStatus
.Information
;
193 if (out_buff
) wine_server_add_data( req
, out_buff
, irp
->IoStatus
.Information
);
195 wine_server_call( req
);
199 if (irp
->Flags
& IRP_CLOSE_OPERATION
)
201 HeapFree( GetProcessHeap(), 0, file
);
202 irp
->Tail
.Overlay
.OriginalFileObject
= NULL
;
205 if (irp
->UserBuffer
!= irp
->AssociatedIrp
.SystemBuffer
)
207 HeapFree( GetProcessHeap(), 0, irp
->UserBuffer
);
208 irp
->UserBuffer
= NULL
;
210 return STATUS_SUCCESS
;
213 static void dispatch_irp( DEVICE_OBJECT
*device
, IRP
*irp
, HANDLE irp_handle
)
217 IoSetCompletionRoutine( irp
, dispatch_irp_completion
, irp_handle
, TRUE
, TRUE
, TRUE
);
218 KeQueryTickCount( &count
); /* update the global KeTickCount */
220 device
->CurrentIrp
= irp
;
221 IoCallDriver( device
, irp
);
222 device
->CurrentIrp
= NULL
;
225 /* process a create request for a given file */
226 static NTSTATUS
dispatch_create( const irp_params_t
*params
, void *in_buff
, ULONG in_size
,
227 ULONG out_size
, HANDLE irp_handle
)
230 IO_STACK_LOCATION
*irpsp
;
232 DEVICE_OBJECT
*device
= wine_server_get_ptr( params
->create
.device
);
234 if (!(file
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*file
) ))) return STATUS_NO_MEMORY
;
236 TRACE( "device %p -> file %p\n", device
, file
);
238 file
->Type
= 5; /* MSDN */
239 file
->Size
= sizeof(*file
);
240 file
->DeviceObject
= device
;
242 if (!(irp
= IoAllocateIrp( device
->StackSize
, FALSE
)))
244 HeapFree( GetProcessHeap(), 0, file
);
245 return STATUS_NO_MEMORY
;
248 irpsp
= IoGetNextIrpStackLocation( irp
);
249 irpsp
->MajorFunction
= IRP_MJ_CREATE
;
250 irpsp
->DeviceObject
= device
;
251 irpsp
->Parameters
.Create
.SecurityContext
= NULL
; /* FIXME */
252 irpsp
->Parameters
.Create
.Options
= params
->create
.options
;
253 irpsp
->Parameters
.Create
.ShareAccess
= params
->create
.sharing
;
254 irpsp
->Parameters
.Create
.FileAttributes
= 0;
255 irpsp
->Parameters
.Create
.EaLength
= 0;
257 irp
->Tail
.Overlay
.OriginalFileObject
= file
;
258 irp
->RequestorMode
= UserMode
;
259 irp
->AssociatedIrp
.SystemBuffer
= NULL
;
260 irp
->UserBuffer
= NULL
;
261 irp
->UserIosb
= NULL
;
262 irp
->UserEvent
= NULL
;
264 irp
->Flags
|= IRP_CREATE_OPERATION
;
265 dispatch_irp( device
, irp
, irp_handle
);
267 HeapFree( GetProcessHeap(), 0, in_buff
);
268 return STATUS_SUCCESS
;
271 /* process a close request for a given file */
272 static NTSTATUS
dispatch_close( const irp_params_t
*params
, void *in_buff
, ULONG in_size
,
273 ULONG out_size
, HANDLE irp_handle
)
276 IO_STACK_LOCATION
*irpsp
;
277 DEVICE_OBJECT
*device
;
278 FILE_OBJECT
*file
= wine_server_get_ptr( params
->close
.file
);
280 if (!file
) return STATUS_INVALID_HANDLE
;
282 device
= file
->DeviceObject
;
284 TRACE( "device %p file %p\n", device
, file
);
286 if (!(irp
= IoAllocateIrp( device
->StackSize
, FALSE
)))
288 HeapFree( GetProcessHeap(), 0, file
);
289 return STATUS_NO_MEMORY
;
292 irpsp
= IoGetNextIrpStackLocation( irp
);
293 irpsp
->MajorFunction
= IRP_MJ_CLOSE
;
294 irpsp
->DeviceObject
= device
;
296 irp
->Tail
.Overlay
.OriginalFileObject
= file
;
297 irp
->RequestorMode
= UserMode
;
298 irp
->AssociatedIrp
.SystemBuffer
= NULL
;
299 irp
->UserBuffer
= NULL
;
300 irp
->UserIosb
= NULL
;
301 irp
->UserEvent
= NULL
;
303 irp
->Flags
|= IRP_CLOSE_OPERATION
;
304 dispatch_irp( device
, irp
, irp_handle
);
306 HeapFree( GetProcessHeap(), 0, in_buff
);
307 return STATUS_SUCCESS
;
310 /* process a read request for a given device */
311 static NTSTATUS
dispatch_read( const irp_params_t
*params
, void *in_buff
, ULONG in_size
,
312 ULONG out_size
, HANDLE irp_handle
)
316 LARGE_INTEGER offset
;
317 IO_STACK_LOCATION
*irpsp
;
318 DEVICE_OBJECT
*device
;
319 FILE_OBJECT
*file
= wine_server_get_ptr( params
->read
.file
);
321 if (!file
) return STATUS_INVALID_HANDLE
;
323 device
= file
->DeviceObject
;
325 TRACE( "device %p file %p size %u\n", device
, file
, out_size
);
327 if (!(out_buff
= HeapAlloc( GetProcessHeap(), 0, out_size
))) return STATUS_NO_MEMORY
;
329 offset
.QuadPart
= params
->read
.pos
;
331 if (!(irp
= IoBuildSynchronousFsdRequest( IRP_MJ_READ
, device
, out_buff
, out_size
,
332 &offset
, NULL
, NULL
)))
334 HeapFree( GetProcessHeap(), 0, out_buff
);
335 return STATUS_NO_MEMORY
;
338 irp
->Tail
.Overlay
.OriginalFileObject
= file
;
339 irp
->RequestorMode
= UserMode
;
341 irpsp
= IoGetNextIrpStackLocation( irp
);
342 irpsp
->Parameters
.Read
.Key
= params
->read
.key
;
344 irp
->Flags
|= IRP_READ_OPERATION
;
345 irp
->Flags
|= IRP_DEALLOCATE_BUFFER
; /* deallocate out_buff */
346 dispatch_irp( device
, irp
, irp_handle
);
348 HeapFree( GetProcessHeap(), 0, in_buff
);
349 return STATUS_SUCCESS
;
352 /* process a write request for a given device */
353 static NTSTATUS
dispatch_write( const irp_params_t
*params
, void *in_buff
, ULONG in_size
,
354 ULONG out_size
, HANDLE irp_handle
)
357 LARGE_INTEGER offset
;
358 IO_STACK_LOCATION
*irpsp
;
359 DEVICE_OBJECT
*device
;
360 FILE_OBJECT
*file
= wine_server_get_ptr( params
->write
.file
);
362 if (!file
) return STATUS_INVALID_HANDLE
;
364 device
= file
->DeviceObject
;
366 TRACE( "device %p file %p size %u\n", device
, file
, in_size
);
368 offset
.QuadPart
= params
->write
.pos
;
370 if (!(irp
= IoBuildSynchronousFsdRequest( IRP_MJ_WRITE
, device
, in_buff
, in_size
,
371 &offset
, NULL
, NULL
)))
372 return STATUS_NO_MEMORY
;
374 irp
->Tail
.Overlay
.OriginalFileObject
= file
;
375 irp
->RequestorMode
= UserMode
;
377 irpsp
= IoGetNextIrpStackLocation( irp
);
378 irpsp
->Parameters
.Write
.Key
= params
->write
.key
;
380 irp
->Flags
|= IRP_WRITE_OPERATION
;
381 irp
->Flags
|= IRP_DEALLOCATE_BUFFER
; /* deallocate in_buff */
382 dispatch_irp( device
, irp
, irp_handle
);
384 return STATUS_SUCCESS
;
387 /* process a flush request for a given device */
388 static NTSTATUS
dispatch_flush( const irp_params_t
*params
, void *in_buff
, ULONG in_size
,
389 ULONG out_size
, HANDLE irp_handle
)
392 DEVICE_OBJECT
*device
;
393 FILE_OBJECT
*file
= wine_server_get_ptr( params
->flush
.file
);
395 if (!file
) return STATUS_INVALID_HANDLE
;
397 device
= file
->DeviceObject
;
399 TRACE( "device %p file %p\n", device
, file
);
401 if (!(irp
= IoBuildSynchronousFsdRequest( IRP_MJ_FLUSH_BUFFERS
, device
, NULL
, 0,
403 return STATUS_NO_MEMORY
;
405 irp
->Tail
.Overlay
.OriginalFileObject
= file
;
406 irp
->RequestorMode
= UserMode
;
408 dispatch_irp( device
, irp
, irp_handle
);
410 HeapFree( GetProcessHeap(), 0, in_buff
);
411 return STATUS_SUCCESS
;
414 /* process an ioctl request for a given device */
415 static NTSTATUS
dispatch_ioctl( const irp_params_t
*params
, void *in_buff
, ULONG in_size
,
416 ULONG out_size
, HANDLE irp_handle
)
419 void *out_buff
= NULL
;
420 void *to_free
= NULL
;
421 DEVICE_OBJECT
*device
;
422 FILE_OBJECT
*file
= wine_server_get_ptr( params
->ioctl
.file
);
424 if (!file
) return STATUS_INVALID_HANDLE
;
426 device
= file
->DeviceObject
;
428 TRACE( "ioctl %x device %p file %p in_size %u out_size %u\n",
429 params
->ioctl
.code
, device
, file
, in_size
, out_size
);
433 if ((params
->ioctl
.code
& 3) != METHOD_BUFFERED
)
435 if (in_size
< out_size
) return STATUS_INVALID_DEVICE_REQUEST
;
437 if (!(out_buff
= HeapAlloc( GetProcessHeap(), 0, out_size
))) return STATUS_NO_MEMORY
;
438 memcpy( out_buff
, (char *)in_buff
+ in_size
, out_size
);
440 else if (out_size
> in_size
)
442 if (!(out_buff
= HeapAlloc( GetProcessHeap(), 0, out_size
))) return STATUS_NO_MEMORY
;
443 memcpy( out_buff
, in_buff
, in_size
);
454 irp
= IoBuildDeviceIoControlRequest( params
->ioctl
.code
, device
, in_buff
, in_size
, out_buff
, out_size
,
458 HeapFree( GetProcessHeap(), 0, out_buff
);
459 return STATUS_NO_MEMORY
;
462 if (out_size
&& (params
->ioctl
.code
& 3) != METHOD_BUFFERED
)
463 HeapReAlloc( GetProcessHeap(), HEAP_REALLOC_IN_PLACE_ONLY
, in_buff
, in_size
);
465 irp
->Tail
.Overlay
.OriginalFileObject
= file
;
466 irp
->RequestorMode
= UserMode
;
467 irp
->AssociatedIrp
.SystemBuffer
= in_buff
;
469 irp
->Flags
|= IRP_DEALLOCATE_BUFFER
; /* deallocate in_buff */
470 dispatch_irp( device
, irp
, irp_handle
);
472 HeapFree( GetProcessHeap(), 0, to_free
);
473 return STATUS_SUCCESS
;
476 typedef NTSTATUS (*dispatch_func
)( const irp_params_t
*params
, void *in_buff
, ULONG in_size
,
477 ULONG out_size
, HANDLE irp_handle
);
479 static const dispatch_func dispatch_funcs
[IRP_MJ_MAXIMUM_FUNCTION
+ 1] =
481 dispatch_create
, /* IRP_MJ_CREATE */
482 NULL
, /* IRP_MJ_CREATE_NAMED_PIPE */
483 dispatch_close
, /* IRP_MJ_CLOSE */
484 dispatch_read
, /* IRP_MJ_READ */
485 dispatch_write
, /* IRP_MJ_WRITE */
486 NULL
, /* IRP_MJ_QUERY_INFORMATION */
487 NULL
, /* IRP_MJ_SET_INFORMATION */
488 NULL
, /* IRP_MJ_QUERY_EA */
489 NULL
, /* IRP_MJ_SET_EA */
490 dispatch_flush
, /* IRP_MJ_FLUSH_BUFFERS */
491 NULL
, /* IRP_MJ_QUERY_VOLUME_INFORMATION */
492 NULL
, /* IRP_MJ_SET_VOLUME_INFORMATION */
493 NULL
, /* IRP_MJ_DIRECTORY_CONTROL */
494 NULL
, /* IRP_MJ_FILE_SYSTEM_CONTROL */
495 dispatch_ioctl
, /* IRP_MJ_DEVICE_CONTROL */
496 NULL
, /* IRP_MJ_INTERNAL_DEVICE_CONTROL */
497 NULL
, /* IRP_MJ_SHUTDOWN */
498 NULL
, /* IRP_MJ_LOCK_CONTROL */
499 NULL
, /* IRP_MJ_CLEANUP */
500 NULL
, /* IRP_MJ_CREATE_MAILSLOT */
501 NULL
, /* IRP_MJ_QUERY_SECURITY */
502 NULL
, /* IRP_MJ_SET_SECURITY */
503 NULL
, /* IRP_MJ_POWER */
504 NULL
, /* IRP_MJ_SYSTEM_CONTROL */
505 NULL
, /* IRP_MJ_DEVICE_CHANGE */
506 NULL
, /* IRP_MJ_QUERY_QUOTA */
507 NULL
, /* IRP_MJ_SET_QUOTA */
508 NULL
, /* IRP_MJ_PNP */
512 /***********************************************************************
513 * wine_ntoskrnl_main_loop (Not a Windows API)
515 NTSTATUS CDECL
wine_ntoskrnl_main_loop( HANDLE stop_event
)
517 HANDLE manager
= get_device_manager();
519 NTSTATUS status
= STATUS_SUCCESS
;
520 irp_params_t irp_params
;
521 ULONG in_size
= 4096, out_size
= 0;
522 void *in_buff
= NULL
;
525 request_thread
= GetCurrentThreadId();
527 handles
[0] = stop_event
;
528 handles
[1] = manager
;
532 if (!in_buff
&& !(in_buff
= HeapAlloc( GetProcessHeap(), 0, in_size
)))
534 ERR( "failed to allocate buffer\n" );
535 return STATUS_NO_MEMORY
;
538 SERVER_START_REQ( get_next_device_request
)
540 req
->manager
= wine_server_obj_handle( manager
);
541 req
->prev
= wine_server_obj_handle( irp
);
542 req
->status
= status
;
543 wine_server_set_reply( req
, in_buff
, in_size
);
544 if (!(status
= wine_server_call( req
)))
546 irp
= wine_server_ptr_handle( reply
->next
);
547 irp_params
= reply
->params
;
548 client_tid
= reply
->client_tid
;
549 client_pid
= reply
->client_pid
;
550 in_size
= reply
->in_size
;
551 out_size
= reply
->out_size
;
555 irp
= 0; /* no previous irp */
556 if (status
== STATUS_BUFFER_OVERFLOW
)
557 in_size
= reply
->in_size
;
565 if (irp_params
.major
> IRP_MJ_MAXIMUM_FUNCTION
|| !dispatch_funcs
[irp_params
.major
])
567 WARN( "unsupported request %u\n", irp_params
.major
);
568 status
= STATUS_NOT_SUPPORTED
;
571 status
= dispatch_funcs
[irp_params
.major
]( &irp_params
, in_buff
, in_size
, out_size
, irp
);
572 if (status
== STATUS_SUCCESS
)
574 irp
= 0; /* status reported by IoCompleteRequest */
579 case STATUS_BUFFER_OVERFLOW
:
580 HeapFree( GetProcessHeap(), 0, in_buff
);
582 /* restart with larger buffer */
587 DWORD ret
= WaitForMultipleObjectsEx( 2, handles
, FALSE
, INFINITE
, TRUE
);
588 if (ret
== WAIT_OBJECT_0
)
590 HeapFree( GetProcessHeap(), 0, in_buff
);
591 return STATUS_SUCCESS
;
593 if (ret
!= WAIT_IO_COMPLETION
) break;
601 /***********************************************************************
602 * IoAcquireCancelSpinLock (NTOSKRNL.EXE.@)
604 void WINAPI
IoAcquireCancelSpinLock(PKIRQL irql
)
606 FIXME("(%p): stub\n", irql
);
610 /***********************************************************************
611 * IoReleaseCancelSpinLock (NTOSKRNL.EXE.@)
613 void WINAPI
IoReleaseCancelSpinLock(PKIRQL irql
)
615 FIXME("(%p): stub\n", irql
);
619 /***********************************************************************
620 * IoAllocateDriverObjectExtension (NTOSKRNL.EXE.@)
622 NTSTATUS WINAPI
IoAllocateDriverObjectExtension( PDRIVER_OBJECT DriverObject
,
623 PVOID ClientIdentificationAddress
,
624 ULONG DriverObjectExtensionSize
,
625 PVOID
*DriverObjectExtension
)
627 FIXME( "stub: %p, %p, %u, %p\n", DriverObject
, ClientIdentificationAddress
,
628 DriverObjectExtensionSize
, DriverObjectExtension
);
629 return STATUS_NOT_IMPLEMENTED
;
633 /***********************************************************************
634 * IoGetDriverObjectExtension (NTOSKRNL.EXE.@)
636 PVOID WINAPI
IoGetDriverObjectExtension( PDRIVER_OBJECT DriverObject
,
637 PVOID ClientIdentificationAddress
)
639 FIXME( "stub: %p, %p\n", DriverObject
, ClientIdentificationAddress
);
644 /***********************************************************************
645 * IoInitializeIrp (NTOSKRNL.EXE.@)
647 void WINAPI
IoInitializeIrp( IRP
*irp
, USHORT size
, CCHAR stack_size
)
649 TRACE( "%p, %u, %d\n", irp
, size
, stack_size
);
651 RtlZeroMemory( irp
, size
);
653 irp
->Type
= IO_TYPE_IRP
;
655 InitializeListHead( &irp
->ThreadListEntry
);
656 irp
->StackCount
= stack_size
;
657 irp
->CurrentLocation
= stack_size
+ 1;
658 irp
->Tail
.Overlay
.s
.u2
.CurrentStackLocation
=
659 (PIO_STACK_LOCATION
)(irp
+ 1) + stack_size
;
663 /***********************************************************************
664 * IoInitializeTimer (NTOSKRNL.EXE.@)
666 NTSTATUS WINAPI
IoInitializeTimer(PDEVICE_OBJECT DeviceObject
,
667 PIO_TIMER_ROUTINE TimerRoutine
,
670 FIXME( "stub: %p, %p, %p\n", DeviceObject
, TimerRoutine
, Context
);
671 return STATUS_NOT_IMPLEMENTED
;
675 /***********************************************************************
676 * IoStartTimer (NTOSKRNL.EXE.@)
678 void WINAPI
IoStartTimer(PDEVICE_OBJECT DeviceObject
)
680 FIXME( "stub: %p\n", DeviceObject
);
684 /***********************************************************************
685 * IoStopTimer (NTOSKRNL.EXE.@)
687 void WINAPI
IoStopTimer(PDEVICE_OBJECT DeviceObject
)
689 FIXME( "stub: %p\n", DeviceObject
);
693 /***********************************************************************
694 * IoAllocateIrp (NTOSKRNL.EXE.@)
696 PIRP WINAPI
IoAllocateIrp( CCHAR stack_size
, BOOLEAN charge_quota
)
700 CCHAR loc_count
= stack_size
;
702 TRACE( "%d, %d\n", stack_size
, charge_quota
);
704 if (loc_count
< 8 && loc_count
!= 1)
707 size
= sizeof(IRP
) + loc_count
* sizeof(IO_STACK_LOCATION
);
708 irp
= ExAllocatePool( NonPagedPool
, size
);
711 IoInitializeIrp( irp
, size
, stack_size
);
712 if (stack_size
>= 1 && stack_size
<= 8)
713 irp
->AllocationFlags
= IRP_ALLOCATED_FIXED_SIZE
;
715 irp
->AllocationFlags
|= IRP_LOOKASIDE_ALLOCATION
;
720 /***********************************************************************
721 * IoFreeIrp (NTOSKRNL.EXE.@)
723 void WINAPI
IoFreeIrp( IRP
*irp
)
727 TRACE( "%p\n", irp
);
729 mdl
= irp
->MdlAddress
;
732 MDL
*next
= mdl
->Next
;
741 /***********************************************************************
742 * IoAllocateErrorLogEntry (NTOSKRNL.EXE.@)
744 PVOID WINAPI
IoAllocateErrorLogEntry( PVOID IoObject
, UCHAR EntrySize
)
746 FIXME( "stub: %p, %u\n", IoObject
, EntrySize
);
751 /***********************************************************************
752 * IoAllocateMdl (NTOSKRNL.EXE.@)
754 PMDL WINAPI
IoAllocateMdl( PVOID va
, ULONG length
, BOOLEAN secondary
, BOOLEAN charge_quota
, IRP
*irp
)
759 TRACE("(%p, %u, %i, %i, %p)\n", va
, length
, secondary
, charge_quota
, irp
);
762 FIXME("Charge quota is not yet supported\n");
764 mdl_size
= sizeof(MDL
) + sizeof(PFN_NUMBER
) * ADDRESS_AND_SIZE_TO_SPAN_PAGES(va
, length
);
765 mdl
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, mdl_size
);
769 MmInitializeMdl( mdl
, va
, length
);
771 if (!irp
) return mdl
;
773 if (secondary
) /* add it at the end */
775 MDL
**pmdl
= &irp
->MdlAddress
;
776 while (*pmdl
) pmdl
= &(*pmdl
)->Next
;
781 mdl
->Next
= irp
->MdlAddress
;
782 irp
->MdlAddress
= mdl
;
788 /***********************************************************************
789 * IoFreeMdl (NTOSKRNL.EXE.@)
791 void WINAPI
IoFreeMdl(PMDL mdl
)
794 HeapFree(GetProcessHeap(), 0, mdl
);
798 /***********************************************************************
799 * IoAllocateWorkItem (NTOSKRNL.EXE.@)
801 PIO_WORKITEM WINAPI
IoAllocateWorkItem( PDEVICE_OBJECT DeviceObject
)
803 FIXME( "stub: %p\n", DeviceObject
);
808 /***********************************************************************
809 * IoAttachDeviceToDeviceStack (NTOSKRNL.EXE.@)
811 PDEVICE_OBJECT WINAPI
IoAttachDeviceToDeviceStack( DEVICE_OBJECT
*source
,
812 DEVICE_OBJECT
*target
)
814 TRACE( "%p, %p\n", source
, target
);
815 target
->AttachedDevice
= source
;
816 source
->StackSize
= target
->StackSize
+ 1;
821 /***********************************************************************
822 * IoBuildDeviceIoControlRequest (NTOSKRNL.EXE.@)
824 PIRP WINAPI
IoBuildDeviceIoControlRequest( ULONG code
, PDEVICE_OBJECT device
,
825 PVOID in_buff
, ULONG in_len
,
826 PVOID out_buff
, ULONG out_len
,
827 BOOLEAN internal
, PKEVENT event
,
828 PIO_STATUS_BLOCK iosb
)
831 PIO_STACK_LOCATION irpsp
;
834 TRACE( "%x, %p, %p, %u, %p, %u, %u, %p, %p\n",
835 code
, device
, in_buff
, in_len
, out_buff
, out_len
, internal
, event
, iosb
);
840 irp
= IoAllocateIrp( device
->StackSize
, FALSE
);
844 irpsp
= IoGetNextIrpStackLocation( irp
);
845 irpsp
->MajorFunction
= internal
? IRP_MJ_INTERNAL_DEVICE_CONTROL
: IRP_MJ_DEVICE_CONTROL
;
846 irpsp
->Parameters
.DeviceIoControl
.IoControlCode
= code
;
847 irpsp
->Parameters
.DeviceIoControl
.InputBufferLength
= in_len
;
848 irpsp
->Parameters
.DeviceIoControl
.OutputBufferLength
= out_len
;
849 irpsp
->DeviceObject
= device
;
850 irpsp
->CompletionRoutine
= NULL
;
854 case METHOD_BUFFERED
:
855 irp
->AssociatedIrp
.SystemBuffer
= in_buff
;
857 case METHOD_IN_DIRECT
:
858 case METHOD_OUT_DIRECT
:
859 irp
->AssociatedIrp
.SystemBuffer
= in_buff
;
861 mdl
= IoAllocateMdl( out_buff
, out_len
, FALSE
, FALSE
, irp
);
868 mdl
->MdlFlags
|= MDL_MAPPED_TO_SYSTEM_VA
;
869 mdl
->MappedSystemVa
= out_buff
;
872 irpsp
->Parameters
.DeviceIoControl
.Type3InputBuffer
= in_buff
;
876 irp
->RequestorMode
= KernelMode
;
877 irp
->UserBuffer
= out_buff
;
878 irp
->UserIosb
= iosb
;
879 irp
->UserEvent
= event
;
884 /**********************************************************
885 * IoBuildSynchronousFsdRequest (NTOSKRNL.EXE.@)
887 PIRP WINAPI
IoBuildSynchronousFsdRequest(ULONG majorfunc
, PDEVICE_OBJECT device
,
888 PVOID buffer
, ULONG length
, PLARGE_INTEGER startoffset
,
889 PKEVENT event
, PIO_STATUS_BLOCK iosb
)
892 PIO_STACK_LOCATION irpsp
;
894 TRACE("(%d %p %p %d %p %p %p)\n", majorfunc
, device
, buffer
, length
, startoffset
, event
, iosb
);
896 if (!(irp
= IoAllocateIrp( device
->StackSize
, FALSE
))) return NULL
;
898 irpsp
= IoGetNextIrpStackLocation( irp
);
899 irpsp
->MajorFunction
= majorfunc
;
900 irpsp
->DeviceObject
= device
;
901 irpsp
->CompletionRoutine
= NULL
;
903 irp
->AssociatedIrp
.SystemBuffer
= buffer
;
905 if (device
->Flags
& DO_DIRECT_IO
)
907 MDL
*mdl
= IoAllocateMdl( buffer
, length
, FALSE
, FALSE
, irp
);
914 mdl
->MdlFlags
|= MDL_MAPPED_TO_SYSTEM_VA
;
915 mdl
->MappedSystemVa
= buffer
;
921 irpsp
->Parameters
.Read
.Length
= length
;
922 irpsp
->Parameters
.Read
.ByteOffset
= *startoffset
;
925 irpsp
->Parameters
.Write
.Length
= length
;
926 irpsp
->Parameters
.Write
.ByteOffset
= *startoffset
;
929 irp
->RequestorMode
= KernelMode
;
930 irp
->UserIosb
= iosb
;
931 irp
->UserEvent
= event
;
932 irp
->UserBuffer
= buffer
;
936 static void build_driver_keypath( const WCHAR
*name
, UNICODE_STRING
*keypath
)
938 static const WCHAR driverW
[] = {'\\','D','r','i','v','e','r','\\',0};
941 /* Check what prefix is present */
942 if (strncmpW( name
, servicesW
, strlenW(servicesW
) ) == 0)
944 FIXME( "Driver name %s is malformed as the keypath\n", debugstr_w(name
) );
945 RtlCreateUnicodeString( keypath
, name
);
948 if (strncmpW( name
, driverW
, strlenW(driverW
) ) == 0)
949 name
+= strlenW(driverW
);
951 FIXME( "Driver name %s does not properly begin with \\Driver\\\n", debugstr_w(name
) );
953 str
= HeapAlloc( GetProcessHeap(), 0, sizeof(servicesW
) + strlenW(name
)*sizeof(WCHAR
));
954 lstrcpyW( str
, servicesW
);
955 lstrcatW( str
, name
);
956 RtlInitUnicodeString( keypath
, str
);
960 static NTSTATUS WINAPI
unhandled_irp( DEVICE_OBJECT
*device
, IRP
*irp
)
962 TRACE( "(%p, %p)\n", device
, irp
);
963 irp
->IoStatus
.u
.Status
= STATUS_INVALID_DEVICE_REQUEST
;
964 IoCompleteRequest( irp
, IO_NO_INCREMENT
);
965 return STATUS_INVALID_DEVICE_REQUEST
;
969 /***********************************************************************
970 * IoCreateDriver (NTOSKRNL.EXE.@)
972 NTSTATUS WINAPI
IoCreateDriver( UNICODE_STRING
*name
, PDRIVER_INITIALIZE init
)
974 struct wine_driver
*driver
;
978 TRACE("(%s, %p)\n", debugstr_us(name
), init
);
980 if (!(driver
= RtlAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY
,
982 return STATUS_NO_MEMORY
;
984 if ((status
= RtlDuplicateUnicodeString( 1, name
, &driver
->driver_obj
.DriverName
)))
986 RtlFreeHeap( GetProcessHeap(), 0, driver
);
990 driver
->driver_obj
.Size
= sizeof(driver
->driver_obj
);
991 driver
->driver_obj
.DriverInit
= init
;
992 driver
->driver_obj
.DriverExtension
= &driver
->driver_extension
;
993 driver
->driver_extension
.DriverObject
= &driver
->driver_obj
;
994 build_driver_keypath( driver
->driver_obj
.DriverName
.Buffer
, &driver
->driver_extension
.ServiceKeyName
);
995 for (i
= 0; i
<= IRP_MJ_MAXIMUM_FUNCTION
; i
++)
996 driver
->driver_obj
.MajorFunction
[i
] = unhandled_irp
;
998 status
= driver
->driver_obj
.DriverInit( &driver
->driver_obj
, &driver
->driver_extension
.ServiceKeyName
);
1001 RtlFreeUnicodeString( &driver
->driver_obj
.DriverName
);
1002 RtlFreeUnicodeString( &driver
->driver_extension
.ServiceKeyName
);
1003 RtlFreeHeap( GetProcessHeap(), 0, driver
);
1007 for (i
= 0; i
<= IRP_MJ_MAXIMUM_FUNCTION
; i
++)
1009 if (driver
->driver_obj
.MajorFunction
[i
]) continue;
1010 driver
->driver_obj
.MajorFunction
[i
] = unhandled_irp
;
1013 EnterCriticalSection( &drivers_cs
);
1014 if (wine_rb_put( &wine_drivers
, &driver
->driver_obj
.DriverName
, &driver
->entry
))
1015 ERR( "failed to insert driver %s in tree\n", debugstr_us(name
) );
1016 LeaveCriticalSection( &drivers_cs
);
1017 return STATUS_SUCCESS
;
1021 /***********************************************************************
1022 * IoDeleteDriver (NTOSKRNL.EXE.@)
1024 void WINAPI
IoDeleteDriver( DRIVER_OBJECT
*driver_object
)
1026 TRACE( "(%p)\n", driver_object
);
1028 EnterCriticalSection( &drivers_cs
);
1029 wine_rb_remove_key( &wine_drivers
, &driver_object
->DriverName
);
1030 LeaveCriticalSection( &drivers_cs
);
1032 RtlFreeUnicodeString( &driver_object
->DriverName
);
1033 RtlFreeUnicodeString( &driver_object
->DriverExtension
->ServiceKeyName
);
1034 RtlFreeHeap( GetProcessHeap(), 0, CONTAINING_RECORD( driver_object
, struct wine_driver
, driver_obj
) );
1038 /***********************************************************************
1039 * IoCreateDevice (NTOSKRNL.EXE.@)
1041 NTSTATUS WINAPI
IoCreateDevice( DRIVER_OBJECT
*driver
, ULONG ext_size
,
1042 UNICODE_STRING
*name
, DEVICE_TYPE type
,
1043 ULONG characteristics
, BOOLEAN exclusive
,
1044 DEVICE_OBJECT
**ret_device
)
1047 DEVICE_OBJECT
*device
;
1049 HANDLE manager
= get_device_manager();
1051 TRACE( "(%p, %u, %s, %u, %x, %u, %p)\n",
1052 driver
, ext_size
, debugstr_us(name
), type
, characteristics
, exclusive
, ret_device
);
1054 if (!(device
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*device
) + ext_size
)))
1055 return STATUS_NO_MEMORY
;
1057 SERVER_START_REQ( create_device
)
1060 req
->attributes
= 0;
1062 req
->manager
= wine_server_obj_handle( manager
);
1063 req
->user_ptr
= wine_server_client_ptr( device
);
1064 if (name
) wine_server_add_data( req
, name
->Buffer
, name
->Length
);
1065 if (!(status
= wine_server_call( req
))) handle
= wine_server_ptr_handle( reply
->handle
);
1069 if (status
== STATUS_SUCCESS
)
1071 device
->DriverObject
= driver
;
1072 device
->DeviceExtension
= device
+ 1;
1073 device
->DeviceType
= type
;
1074 device
->StackSize
= 1;
1075 device
->Reserved
= handle
;
1077 device
->NextDevice
= driver
->DeviceObject
;
1078 driver
->DeviceObject
= device
;
1080 *ret_device
= device
;
1082 else HeapFree( GetProcessHeap(), 0, device
);
1088 /***********************************************************************
1089 * IoDeleteDevice (NTOSKRNL.EXE.@)
1091 void WINAPI
IoDeleteDevice( DEVICE_OBJECT
*device
)
1095 TRACE( "%p\n", device
);
1097 SERVER_START_REQ( delete_device
)
1099 req
->handle
= wine_server_obj_handle( device
->Reserved
);
1100 status
= wine_server_call( req
);
1104 if (status
== STATUS_SUCCESS
)
1106 DEVICE_OBJECT
**prev
= &device
->DriverObject
->DeviceObject
;
1107 while (*prev
&& *prev
!= device
) prev
= &(*prev
)->NextDevice
;
1108 if (*prev
) *prev
= (*prev
)->NextDevice
;
1109 NtClose( device
->Reserved
);
1110 HeapFree( GetProcessHeap(), 0, device
);
1115 /***********************************************************************
1116 * IoCreateSymbolicLink (NTOSKRNL.EXE.@)
1118 NTSTATUS WINAPI
IoCreateSymbolicLink( UNICODE_STRING
*name
, UNICODE_STRING
*target
)
1121 OBJECT_ATTRIBUTES attr
;
1123 attr
.Length
= sizeof(attr
);
1124 attr
.RootDirectory
= 0;
1125 attr
.ObjectName
= name
;
1126 attr
.Attributes
= OBJ_CASE_INSENSITIVE
| OBJ_OPENIF
;
1127 attr
.SecurityDescriptor
= NULL
;
1128 attr
.SecurityQualityOfService
= NULL
;
1130 TRACE( "%s -> %s\n", debugstr_us(name
), debugstr_us(target
) );
1131 /* FIXME: store handle somewhere */
1132 return NtCreateSymbolicLinkObject( &handle
, SYMBOLIC_LINK_ALL_ACCESS
, &attr
, target
);
1136 /***********************************************************************
1137 * IoDeleteSymbolicLink (NTOSKRNL.EXE.@)
1139 NTSTATUS WINAPI
IoDeleteSymbolicLink( UNICODE_STRING
*name
)
1142 OBJECT_ATTRIBUTES attr
;
1145 attr
.Length
= sizeof(attr
);
1146 attr
.RootDirectory
= 0;
1147 attr
.ObjectName
= name
;
1148 attr
.Attributes
= OBJ_CASE_INSENSITIVE
;
1149 attr
.SecurityDescriptor
= NULL
;
1150 attr
.SecurityQualityOfService
= NULL
;
1152 if (!(status
= NtOpenSymbolicLinkObject( &handle
, 0, &attr
)))
1154 SERVER_START_REQ( unlink_object
)
1156 req
->handle
= wine_server_obj_handle( handle
);
1157 status
= wine_server_call( req
);
1166 /***********************************************************************
1167 * IoGetDeviceInterfaces (NTOSKRNL.EXE.@)
1169 NTSTATUS WINAPI
IoGetDeviceInterfaces( const GUID
*InterfaceClassGuid
,
1170 PDEVICE_OBJECT PhysicalDeviceObject
,
1171 ULONG Flags
, PWSTR
*SymbolicLinkList
)
1173 FIXME( "stub: %s %p %x %p\n", debugstr_guid(InterfaceClassGuid
),
1174 PhysicalDeviceObject
, Flags
, SymbolicLinkList
);
1175 return STATUS_NOT_IMPLEMENTED
;
1179 /***********************************************************************
1180 * IoGetDeviceObjectPointer (NTOSKRNL.EXE.@)
1182 NTSTATUS WINAPI
IoGetDeviceObjectPointer( UNICODE_STRING
*name
, ACCESS_MASK access
, PFILE_OBJECT
*file
, PDEVICE_OBJECT
*device
)
1184 static DEVICE_OBJECT stub_device
;
1185 static DRIVER_OBJECT stub_driver
;
1187 FIXME( "stub: %s %x %p %p\n", debugstr_us(name
), access
, file
, device
);
1189 stub_device
.StackSize
= 0x80; /* minimum value to appease SecuROM 5.x */
1190 stub_device
.DriverObject
= &stub_driver
;
1193 *device
= &stub_device
;
1195 return STATUS_SUCCESS
;
1198 /***********************************************************************
1199 * IoGetAttachedDevice (NTOSKRNL.EXE.@)
1201 DEVICE_OBJECT
* WINAPI
IoGetAttachedDevice( DEVICE_OBJECT
*device
)
1203 DEVICE_OBJECT
*result
= device
;
1205 TRACE( "(%p)\n", device
);
1207 while (result
->AttachedDevice
)
1208 result
= result
->AttachedDevice
;
1214 /***********************************************************************
1215 * IoGetDeviceProperty (NTOSKRNL.EXE.@)
1217 NTSTATUS WINAPI
IoGetDeviceProperty( DEVICE_OBJECT
*device
, DEVICE_REGISTRY_PROPERTY device_property
,
1218 ULONG buffer_length
, PVOID property_buffer
, PULONG result_length
)
1220 NTSTATUS status
= STATUS_NOT_IMPLEMENTED
;
1221 TRACE( "%p %d %u %p %p\n", device
, device_property
, buffer_length
,
1222 property_buffer
, result_length
);
1223 switch (device_property
)
1225 case DevicePropertyEnumeratorName
:
1229 status
= get_device_id( device
, BusQueryInstanceID
, &id
);
1230 if (status
!= STATUS_SUCCESS
)
1232 ERR( "Failed to get device id\n" );
1237 ptr
= strchrW( id
, '\\' );
1240 *result_length
= sizeof(WCHAR
) * (strlenW(id
) + 1);
1241 if (buffer_length
>= *result_length
)
1242 memcpy( property_buffer
, id
, *result_length
);
1244 status
= STATUS_BUFFER_TOO_SMALL
;
1246 HeapFree( GetProcessHeap(), 0, id
);
1249 case DevicePropertyPhysicalDeviceObjectName
:
1251 ULONG used_len
, len
= buffer_length
+ sizeof(OBJECT_NAME_INFORMATION
);
1252 OBJECT_NAME_INFORMATION
*name
= HeapAlloc(GetProcessHeap(), 0, len
);
1254 status
= NtQueryObject(device
->Reserved
, ObjectNameInformation
, name
, len
, &used_len
);
1255 if (status
== STATUS_SUCCESS
)
1257 /* Ensure room for NULL termination */
1258 if (buffer_length
>= name
->Name
.MaximumLength
)
1259 memcpy(property_buffer
, name
->Name
.Buffer
, name
->Name
.MaximumLength
);
1261 status
= STATUS_BUFFER_TOO_SMALL
;
1262 *result_length
= name
->Name
.MaximumLength
;
1266 if (status
== STATUS_INFO_LENGTH_MISMATCH
||
1267 status
== STATUS_BUFFER_OVERFLOW
)
1269 status
= STATUS_BUFFER_TOO_SMALL
;
1270 *result_length
= used_len
- sizeof(OBJECT_NAME_INFORMATION
);
1275 HeapFree(GetProcessHeap(), 0, name
);
1279 FIXME("unhandled property %d\n", device_property
);
1285 /***********************************************************************
1286 * IoCallDriver (NTOSKRNL.EXE.@)
1288 NTSTATUS WINAPI
IoCallDriver( DEVICE_OBJECT
*device
, IRP
*irp
)
1290 PDRIVER_DISPATCH dispatch
;
1291 IO_STACK_LOCATION
*irpsp
;
1294 --irp
->CurrentLocation
;
1295 irpsp
= --irp
->Tail
.Overlay
.s
.u2
.CurrentStackLocation
;
1296 dispatch
= device
->DriverObject
->MajorFunction
[irpsp
->MajorFunction
];
1298 if (TRACE_ON(relay
))
1299 DPRINTF( "%04x:Call driver dispatch %p (device=%p,irp=%p)\n",
1300 GetCurrentThreadId(), dispatch
, device
, irp
);
1302 status
= dispatch( device
, irp
);
1304 if (TRACE_ON(relay
))
1305 DPRINTF( "%04x:Ret driver dispatch %p (device=%p,irp=%p) retval=%08x\n",
1306 GetCurrentThreadId(), dispatch
, device
, irp
, status
);
1312 /***********************************************************************
1313 * IofCallDriver (NTOSKRNL.EXE.@)
1315 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
1316 DEFINE_FASTCALL2_ENTRYPOINT( IofCallDriver
)
1317 NTSTATUS WINAPI DECLSPEC_HIDDEN
__regs_IofCallDriver( DEVICE_OBJECT
*device
, IRP
*irp
)
1319 NTSTATUS WINAPI
IofCallDriver( DEVICE_OBJECT
*device
, IRP
*irp
)
1322 TRACE( "%p %p\n", device
, irp
);
1323 return IoCallDriver( device
, irp
);
1327 /***********************************************************************
1328 * IoGetRelatedDeviceObject (NTOSKRNL.EXE.@)
1330 PDEVICE_OBJECT WINAPI
IoGetRelatedDeviceObject( PFILE_OBJECT obj
)
1332 FIXME( "stub: %p\n", obj
);
1336 static CONFIGURATION_INFORMATION configuration_information
;
1338 /***********************************************************************
1339 * IoGetConfigurationInformation (NTOSKRNL.EXE.@)
1341 PCONFIGURATION_INFORMATION WINAPI
IoGetConfigurationInformation(void)
1343 FIXME( "partial stub\n" );
1344 /* FIXME: return actual devices on system */
1345 return &configuration_information
;
1349 /***********************************************************************
1350 * IoIsWdmVersionAvailable (NTOSKRNL.EXE.@)
1352 NTSTATUS WINAPI
IoIsWdmVersionAvailable(UCHAR MajorVersion
, UCHAR MinorVersion
)
1358 TRACE( "%d, 0x%X\n", MajorVersion
, MinorVersion
);
1360 version
= GetVersion();
1361 major
= LOBYTE(version
);
1362 minor
= HIBYTE(LOWORD(version
));
1364 if (MajorVersion
== 6 && MinorVersion
== 0)
1366 /* Windows Vista, Windows Server 2008, Windows 7 */
1368 else if (MajorVersion
== 1)
1370 if (MinorVersion
== 0x30)
1372 /* Windows server 2003 */
1376 else if (MinorVersion
== 0x20)
1382 else if (MinorVersion
== 0x10)
1388 else if (MinorVersion
== 0x05)
1392 MinorVersion
= 0x5a;
1394 else if (MinorVersion
== 0x00)
1398 MinorVersion
= 0x0a;
1402 FIXME( "unknown major %d minor 0x%X\n", MajorVersion
, MinorVersion
);
1408 FIXME( "unknown major %d minor 0x%X\n", MajorVersion
, MinorVersion
);
1411 return major
> MajorVersion
|| (major
== MajorVersion
&& minor
>= MinorVersion
);
1415 /***********************************************************************
1416 * IoQueryDeviceDescription (NTOSKRNL.EXE.@)
1418 NTSTATUS WINAPI
IoQueryDeviceDescription(PINTERFACE_TYPE itype
, PULONG bus
, PCONFIGURATION_TYPE ctype
,
1419 PULONG cnum
, PCONFIGURATION_TYPE ptype
, PULONG pnum
,
1420 PIO_QUERY_DEVICE_ROUTINE callout
, PVOID context
)
1422 FIXME( "(%p %p %p %p %p %p %p %p)\n", itype
, bus
, ctype
, cnum
, ptype
, pnum
, callout
, context
);
1423 return STATUS_NOT_IMPLEMENTED
;
1427 /***********************************************************************
1428 * IoRegisterDriverReinitialization (NTOSKRNL.EXE.@)
1430 void WINAPI
IoRegisterDriverReinitialization( PDRIVER_OBJECT obj
, PDRIVER_REINITIALIZE reinit
, PVOID context
)
1432 FIXME( "stub: %p %p %p\n", obj
, reinit
, context
);
1436 /***********************************************************************
1437 * IoRegisterShutdownNotification (NTOSKRNL.EXE.@)
1439 NTSTATUS WINAPI
IoRegisterShutdownNotification( PDEVICE_OBJECT obj
)
1441 FIXME( "stub: %p\n", obj
);
1442 return STATUS_SUCCESS
;
1446 /***********************************************************************
1447 * IoUnregisterShutdownNotification (NTOSKRNL.EXE.@)
1449 VOID WINAPI
IoUnregisterShutdownNotification( PDEVICE_OBJECT obj
)
1451 FIXME( "stub: %p\n", obj
);
1455 /***********************************************************************
1456 * IoReportResourceForDetection (NTOSKRNL.EXE.@)
1458 NTSTATUS WINAPI
IoReportResourceForDetection( DRIVER_OBJECT
*drv_obj
, CM_RESOURCE_LIST
*drv_list
, ULONG drv_size
,
1459 DEVICE_OBJECT
*dev_obj
, CM_RESOURCE_LIST
*dev_list
, ULONG dev_size
,
1462 FIXME( "(%p, %p, %u, %p, %p, %u, %p): stub\n", drv_obj
, drv_list
, drv_size
,
1463 dev_obj
, dev_list
, dev_size
, conflict
);
1465 return STATUS_NOT_IMPLEMENTED
;
1469 /***********************************************************************
1470 * IoReportResourceUsage (NTOSKRNL.EXE.@)
1472 NTSTATUS WINAPI
IoReportResourceUsage( UNICODE_STRING
*name
, DRIVER_OBJECT
*drv_obj
, CM_RESOURCE_LIST
*drv_list
,
1473 ULONG drv_size
, DRIVER_OBJECT
*dev_obj
, CM_RESOURCE_LIST
*dev_list
,
1474 ULONG dev_size
, BOOLEAN overwrite
, BOOLEAN
*conflict
)
1476 FIXME( "(%s, %p, %p, %u, %p, %p, %u, %d, %p): stub\n", debugstr_us(name
),
1477 drv_obj
, drv_list
, drv_size
, dev_obj
, dev_list
, dev_size
, overwrite
, conflict
);
1479 return STATUS_NOT_IMPLEMENTED
;
1483 /***********************************************************************
1484 * IoCompleteRequest (NTOSKRNL.EXE.@)
1486 VOID WINAPI
IoCompleteRequest( IRP
*irp
, UCHAR priority_boost
)
1488 IO_STACK_LOCATION
*irpsp
;
1489 PIO_COMPLETION_ROUTINE routine
;
1490 NTSTATUS status
, stat
;
1493 TRACE( "%p %u\n", irp
, priority_boost
);
1495 status
= irp
->IoStatus
.u
.Status
;
1496 while (irp
->CurrentLocation
<= irp
->StackCount
)
1498 irpsp
= irp
->Tail
.Overlay
.s
.u2
.CurrentStackLocation
;
1499 routine
= irpsp
->CompletionRoutine
;
1501 /* FIXME: add SL_INVOKE_ON_CANCEL support */
1504 if ((irpsp
->Control
& SL_INVOKE_ON_SUCCESS
) && STATUS_SUCCESS
== status
)
1506 if ((irpsp
->Control
& SL_INVOKE_ON_ERROR
) && STATUS_SUCCESS
!= status
)
1509 ++irp
->CurrentLocation
;
1510 ++irp
->Tail
.Overlay
.s
.u2
.CurrentStackLocation
;
1513 TRACE( "calling %p( %p, %p, %p )\n", routine
,
1514 irpsp
->DeviceObject
, irp
, irpsp
->Context
);
1515 stat
= routine( irpsp
->DeviceObject
, irp
, irpsp
->Context
);
1516 TRACE( "CompletionRoutine returned %x\n", stat
);
1517 if (STATUS_MORE_PROCESSING_REQUIRED
== stat
)
1522 if (irp
->Flags
& IRP_DEALLOCATE_BUFFER
)
1523 HeapFree( GetProcessHeap(), 0, irp
->AssociatedIrp
.SystemBuffer
);
1529 /***********************************************************************
1530 * IofCompleteRequest (NTOSKRNL.EXE.@)
1532 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
1533 DEFINE_FASTCALL2_ENTRYPOINT( IofCompleteRequest
)
1534 void WINAPI DECLSPEC_HIDDEN
__regs_IofCompleteRequest( IRP
*irp
, UCHAR priority_boost
)
1536 void WINAPI
IofCompleteRequest( IRP
*irp
, UCHAR priority_boost
)
1539 TRACE( "%p %u\n", irp
, priority_boost
);
1540 IoCompleteRequest( irp
, priority_boost
);
1544 /***********************************************************************
1545 * InterlockedCompareExchange (NTOSKRNL.EXE.@)
1547 #ifdef DEFINE_FASTCALL3_ENTRYPOINT
1548 DEFINE_FASTCALL3_ENTRYPOINT( NTOSKRNL_InterlockedCompareExchange
)
1549 LONG WINAPI DECLSPEC_HIDDEN
__regs_NTOSKRNL_InterlockedCompareExchange( LONG
volatile *dest
, LONG xchg
, LONG compare
)
1551 LONG WINAPI
NTOSKRNL_InterlockedCompareExchange( LONG
volatile *dest
, LONG xchg
, LONG compare
)
1554 return InterlockedCompareExchange( dest
, xchg
, compare
);
1558 /***********************************************************************
1559 * InterlockedDecrement (NTOSKRNL.EXE.@)
1561 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
1562 DEFINE_FASTCALL1_ENTRYPOINT( NTOSKRNL_InterlockedDecrement
)
1563 LONG WINAPI DECLSPEC_HIDDEN
__regs_NTOSKRNL_InterlockedDecrement( LONG
volatile *dest
)
1565 LONG WINAPI
NTOSKRNL_InterlockedDecrement( LONG
volatile *dest
)
1568 return InterlockedDecrement( dest
);
1572 /***********************************************************************
1573 * InterlockedExchange (NTOSKRNL.EXE.@)
1575 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
1576 DEFINE_FASTCALL2_ENTRYPOINT( NTOSKRNL_InterlockedExchange
)
1577 LONG WINAPI DECLSPEC_HIDDEN
__regs_NTOSKRNL_InterlockedExchange( LONG
volatile *dest
, LONG val
)
1579 LONG WINAPI
NTOSKRNL_InterlockedExchange( LONG
volatile *dest
, LONG val
)
1582 return InterlockedExchange( dest
, val
);
1586 /***********************************************************************
1587 * InterlockedExchangeAdd (NTOSKRNL.EXE.@)
1589 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
1590 DEFINE_FASTCALL2_ENTRYPOINT( NTOSKRNL_InterlockedExchangeAdd
)
1591 LONG WINAPI DECLSPEC_HIDDEN
__regs_NTOSKRNL_InterlockedExchangeAdd( LONG
volatile *dest
, LONG incr
)
1593 LONG WINAPI
NTOSKRNL_InterlockedExchangeAdd( LONG
volatile *dest
, LONG incr
)
1596 return InterlockedExchangeAdd( dest
, incr
);
1600 /***********************************************************************
1601 * InterlockedIncrement (NTOSKRNL.EXE.@)
1603 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
1604 DEFINE_FASTCALL1_ENTRYPOINT( NTOSKRNL_InterlockedIncrement
)
1605 LONG WINAPI DECLSPEC_HIDDEN
__regs_NTOSKRNL_InterlockedIncrement( LONG
volatile *dest
)
1607 LONG WINAPI
NTOSKRNL_InterlockedIncrement( LONG
volatile *dest
)
1610 return InterlockedIncrement( dest
);
1614 /***********************************************************************
1615 * InterlockedPopEntrySList (NTOSKRNL.EXE.@)
1617 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
1618 DEFINE_FASTCALL1_ENTRYPOINT( NTOSKRNL_InterlockedPopEntrySList
)
1619 PSLIST_ENTRY WINAPI DECLSPEC_HIDDEN
__regs_NTOSKRNL_InterlockedPopEntrySList( PSLIST_HEADER list
)
1621 PSLIST_ENTRY WINAPI
NTOSKRNL_InterlockedPopEntrySList( PSLIST_HEADER list
)
1624 return InterlockedPopEntrySList( list
);
1628 /***********************************************************************
1629 * InterlockedPushEntrySList (NTOSKRNL.EXE.@)
1631 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
1632 DEFINE_FASTCALL2_ENTRYPOINT( NTOSKRNL_InterlockedPushEntrySList
)
1633 PSLIST_ENTRY WINAPI DECLSPEC_HIDDEN
__regs_NTOSKRNL_InterlockedPushEntrySList( PSLIST_HEADER list
,
1634 PSLIST_ENTRY entry
)
1636 PSLIST_ENTRY WINAPI
NTOSKRNL_InterlockedPushEntrySList( PSLIST_HEADER list
, PSLIST_ENTRY entry
)
1639 return InterlockedPushEntrySList( list
, entry
);
1643 /***********************************************************************
1644 * ExAllocatePool (NTOSKRNL.EXE.@)
1646 PVOID WINAPI
ExAllocatePool( POOL_TYPE type
, SIZE_T size
)
1648 return ExAllocatePoolWithTag( type
, size
, 0 );
1652 /***********************************************************************
1653 * ExAllocatePoolWithQuota (NTOSKRNL.EXE.@)
1655 PVOID WINAPI
ExAllocatePoolWithQuota( POOL_TYPE type
, SIZE_T size
)
1657 return ExAllocatePoolWithTag( type
, size
, 0 );
1661 /***********************************************************************
1662 * ExAllocatePoolWithTag (NTOSKRNL.EXE.@)
1664 PVOID WINAPI
ExAllocatePoolWithTag( POOL_TYPE type
, SIZE_T size
, ULONG tag
)
1666 /* FIXME: handle page alignment constraints */
1667 void *ret
= HeapAlloc( GetProcessHeap(), 0, size
);
1668 TRACE( "%lu pool %u -> %p\n", size
, type
, ret
);
1673 /***********************************************************************
1674 * ExAllocatePoolWithQuotaTag (NTOSKRNL.EXE.@)
1676 PVOID WINAPI
ExAllocatePoolWithQuotaTag( POOL_TYPE type
, SIZE_T size
, ULONG tag
)
1678 return ExAllocatePoolWithTag( type
, size
, tag
);
1682 /***********************************************************************
1683 * ExCreateCallback (NTOSKRNL.EXE.@)
1685 NTSTATUS WINAPI
ExCreateCallback(PCALLBACK_OBJECT
*obj
, POBJECT_ATTRIBUTES attr
,
1686 BOOLEAN create
, BOOLEAN allow_multiple
)
1688 FIXME("(%p, %p, %u, %u): stub\n", obj
, attr
, create
, allow_multiple
);
1690 return STATUS_NOT_IMPLEMENTED
;
1694 /***********************************************************************
1695 * ExDeleteNPagedLookasideList (NTOSKRNL.EXE.@)
1697 void WINAPI
ExDeleteNPagedLookasideList( PNPAGED_LOOKASIDE_LIST lookaside
)
1699 FIXME("(%p) stub\n", lookaside
);
1703 /***********************************************************************
1704 * ExDeletePagedLookasideList (NTOSKRNL.EXE.@)
1706 void WINAPI
ExDeletePagedLookasideList( PPAGED_LOOKASIDE_LIST lookaside
)
1708 FIXME("(%p) stub\n", lookaside
);
1712 /***********************************************************************
1713 * ExFreePool (NTOSKRNL.EXE.@)
1715 void WINAPI
ExFreePool( void *ptr
)
1717 ExFreePoolWithTag( ptr
, 0 );
1721 /***********************************************************************
1722 * ExFreePoolWithTag (NTOSKRNL.EXE.@)
1724 void WINAPI
ExFreePoolWithTag( void *ptr
, ULONG tag
)
1726 TRACE( "%p\n", ptr
);
1727 HeapFree( GetProcessHeap(), 0, ptr
);
1731 /***********************************************************************
1732 * ExInitializeResourceLite (NTOSKRNL.EXE.@)
1734 NTSTATUS WINAPI
ExInitializeResourceLite(PERESOURCE Resource
)
1736 FIXME( "stub: %p\n", Resource
);
1737 return STATUS_NOT_IMPLEMENTED
;
1741 /***********************************************************************
1742 * ExInitializeNPagedLookasideList (NTOSKRNL.EXE.@)
1744 void WINAPI
ExInitializeNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside
,
1745 PALLOCATE_FUNCTION Allocate
,
1746 PFREE_FUNCTION Free
,
1752 FIXME( "stub: %p, %p, %p, %u, %lu, %u, %u\n", Lookaside
, Allocate
, Free
, Flags
, Size
, Tag
, Depth
);
1755 /***********************************************************************
1756 * ExInitializePagedLookasideList (NTOSKRNL.EXE.@)
1758 void WINAPI
ExInitializePagedLookasideList(PPAGED_LOOKASIDE_LIST Lookaside
,
1759 PALLOCATE_FUNCTION Allocate
,
1760 PFREE_FUNCTION Free
,
1766 FIXME( "stub: %p, %p, %p, %u, %lu, %u, %u\n", Lookaside
, Allocate
, Free
, Flags
, Size
, Tag
, Depth
);
1769 /***********************************************************************
1770 * ExInitializeZone (NTOSKRNL.EXE.@)
1772 NTSTATUS WINAPI
ExInitializeZone(PZONE_HEADER Zone
,
1774 PVOID InitialSegment
,
1775 ULONG InitialSegmentSize
)
1777 FIXME( "stub: %p, %u, %p, %u\n", Zone
, BlockSize
, InitialSegment
, InitialSegmentSize
);
1778 return STATUS_NOT_IMPLEMENTED
;
1781 /***********************************************************************
1782 * FsRtlRegisterUncProvider (NTOSKRNL.EXE.@)
1784 NTSTATUS WINAPI
FsRtlRegisterUncProvider(PHANDLE MupHandle
, PUNICODE_STRING RedirDevName
,
1785 BOOLEAN MailslotsSupported
)
1787 FIXME("(%p %p %d): stub\n", MupHandle
, RedirDevName
, MailslotsSupported
);
1788 return STATUS_NOT_IMPLEMENTED
;
1791 /***********************************************************************
1792 * IoGetCurrentProcess / PsGetCurrentProcess (NTOSKRNL.EXE.@)
1794 PEPROCESS WINAPI
IoGetCurrentProcess(void)
1800 /***********************************************************************
1801 * KeGetCurrentThread / PsGetCurrentThread (NTOSKRNL.EXE.@)
1803 PRKTHREAD WINAPI
KeGetCurrentThread(void)
1809 /***********************************************************************
1810 * KeInitializeEvent (NTOSKRNL.EXE.@)
1812 void WINAPI
KeInitializeEvent( PRKEVENT Event
, EVENT_TYPE Type
, BOOLEAN State
)
1814 FIXME( "stub: %p %d %d\n", Event
, Type
, State
);
1818 /***********************************************************************
1819 * KeInitializeMutex (NTOSKRNL.EXE.@)
1821 void WINAPI
KeInitializeMutex(PRKMUTEX Mutex
, ULONG Level
)
1823 FIXME( "stub: %p, %u\n", Mutex
, Level
);
1827 /***********************************************************************
1828 * KeWaitForMutexObject (NTOSKRNL.EXE.@)
1830 NTSTATUS WINAPI
KeWaitForMutexObject(PRKMUTEX Mutex
, KWAIT_REASON WaitReason
, KPROCESSOR_MODE WaitMode
,
1831 BOOLEAN Alertable
, PLARGE_INTEGER Timeout
)
1833 FIXME( "stub: %p, %d, %d, %d, %p\n", Mutex
, WaitReason
, WaitMode
, Alertable
, Timeout
);
1834 return STATUS_NOT_IMPLEMENTED
;
1838 /***********************************************************************
1839 * KeReleaseMutex (NTOSKRNL.EXE.@)
1841 LONG WINAPI
KeReleaseMutex(PRKMUTEX Mutex
, BOOLEAN Wait
)
1843 FIXME( "stub: %p, %d\n", Mutex
, Wait
);
1844 return STATUS_NOT_IMPLEMENTED
;
1848 /***********************************************************************
1849 * KeInitializeSemaphore (NTOSKRNL.EXE.@)
1851 void WINAPI
KeInitializeSemaphore( PRKSEMAPHORE Semaphore
, LONG Count
, LONG Limit
)
1853 FIXME( "(%p %d %d) stub\n", Semaphore
, Count
, Limit
);
1857 /***********************************************************************
1858 * KeInitializeSpinLock (NTOSKRNL.EXE.@)
1860 void WINAPI
KeInitializeSpinLock( PKSPIN_LOCK SpinLock
)
1862 FIXME( "stub: %p\n", SpinLock
);
1866 /***********************************************************************
1867 * KeInitializeTimerEx (NTOSKRNL.EXE.@)
1869 void WINAPI
KeInitializeTimerEx( PKTIMER Timer
, TIMER_TYPE Type
)
1871 FIXME( "stub: %p %d\n", Timer
, Type
);
1875 /***********************************************************************
1876 * KeInitializeTimer (NTOSKRNL.EXE.@)
1878 void WINAPI
KeInitializeTimer( PKTIMER Timer
)
1880 KeInitializeTimerEx(Timer
, NotificationTimer
);
1883 /***********************************************************************
1884 * KeInsertQueue (NTOSKRNL.EXE.@)
1886 LONG WINAPI
KeInsertQueue(PRKQUEUE Queue
, PLIST_ENTRY Entry
)
1888 FIXME( "stub: %p %p\n", Queue
, Entry
);
1892 /**********************************************************************
1893 * KeQueryActiveProcessors (NTOSKRNL.EXE.@)
1895 * Return the active Processors as bitmask
1898 * active Processors as bitmask
1901 KAFFINITY WINAPI
KeQueryActiveProcessors( void )
1903 DWORD_PTR AffinityMask
;
1905 GetProcessAffinityMask( GetCurrentProcess(), &AffinityMask
, NULL
);
1906 return AffinityMask
;
1910 /**********************************************************************
1911 * KeQueryInterruptTime (NTOSKRNL.EXE.@)
1913 * Return the interrupt time count
1916 ULONGLONG WINAPI
KeQueryInterruptTime( void )
1918 LARGE_INTEGER totaltime
;
1920 KeQueryTickCount(&totaltime
);
1921 return totaltime
.QuadPart
;
1925 /***********************************************************************
1926 * KeQuerySystemTime (NTOSKRNL.EXE.@)
1928 void WINAPI
KeQuerySystemTime( LARGE_INTEGER
*time
)
1930 NtQuerySystemTime( time
);
1934 /***********************************************************************
1935 * KeQueryTickCount (NTOSKRNL.EXE.@)
1937 void WINAPI
KeQueryTickCount( LARGE_INTEGER
*count
)
1939 count
->QuadPart
= NtGetTickCount();
1940 /* update the global variable too */
1941 KeTickCount
.LowPart
= count
->u
.LowPart
;
1942 KeTickCount
.High1Time
= count
->u
.HighPart
;
1943 KeTickCount
.High2Time
= count
->u
.HighPart
;
1947 /***********************************************************************
1948 * KeReleaseSemaphore (NTOSKRNL.EXE.@)
1950 LONG WINAPI
KeReleaseSemaphore( PRKSEMAPHORE Semaphore
, KPRIORITY Increment
,
1951 LONG Adjustment
, BOOLEAN Wait
)
1953 FIXME("(%p %d %d %d) stub\n", Semaphore
, Increment
, Adjustment
, Wait
);
1958 /***********************************************************************
1959 * KeQueryTimeIncrement (NTOSKRNL.EXE.@)
1961 ULONG WINAPI
KeQueryTimeIncrement(void)
1967 /***********************************************************************
1968 * KeResetEvent (NTOSKRNL.EXE.@)
1970 LONG WINAPI
KeResetEvent( PRKEVENT Event
)
1972 FIXME("(%p): stub\n", Event
);
1977 /***********************************************************************
1978 * KeSetEvent (NTOSKRNL.EXE.@)
1980 LONG WINAPI
KeSetEvent( PRKEVENT Event
, KPRIORITY Increment
, BOOLEAN Wait
)
1982 FIXME("(%p, %d, %d): stub\n", Event
, Increment
, Wait
);
1987 /***********************************************************************
1988 * KeSetPriorityThread (NTOSKRNL.EXE.@)
1990 KPRIORITY WINAPI
KeSetPriorityThread( PKTHREAD Thread
, KPRIORITY Priority
)
1992 FIXME("(%p %d)\n", Thread
, Priority
);
1996 /***********************************************************************
1997 * KeSetSystemAffinityThread (NTOSKRNL.EXE.@)
1999 VOID WINAPI
KeSetSystemAffinityThread(KAFFINITY Affinity
)
2001 FIXME("(%lx) stub\n", Affinity
);
2004 /***********************************************************************
2005 * KeWaitForSingleObject (NTOSKRNL.EXE.@)
2007 NTSTATUS WINAPI
KeWaitForSingleObject(PVOID Object
,
2008 KWAIT_REASON WaitReason
,
2009 KPROCESSOR_MODE WaitMode
,
2011 PLARGE_INTEGER Timeout
)
2013 FIXME( "stub: %p, %d, %d, %d, %p\n", Object
, WaitReason
, WaitMode
, Alertable
, Timeout
);
2014 return STATUS_NOT_IMPLEMENTED
;
2017 /***********************************************************************
2018 * KeWaitForMultipleObjects (NTOSKRNL.EXE.@)
2020 NTSTATUS WINAPI
KeWaitForMultipleObjects(ULONG Count
, PVOID Object
[], WAIT_TYPE WaitType
,
2021 KWAIT_REASON WaitReason
, KPROCESSOR_MODE WaitMode
,
2022 BOOLEAN Alertable
, PLARGE_INTEGER Timeout
,
2023 PKWAIT_BLOCK WaitBlockArray
)
2025 FIXME( "stub: %u, %p, %d, %d, %d, %d, %p, %p\n", Count
, Object
, WaitType
, WaitReason
, WaitMode
,
2026 Alertable
, Timeout
, WaitBlockArray
);
2027 return STATUS_NOT_IMPLEMENTED
;
2030 /***********************************************************************
2031 * IoRegisterFileSystem (NTOSKRNL.EXE.@)
2033 VOID WINAPI
IoRegisterFileSystem(PDEVICE_OBJECT DeviceObject
)
2035 FIXME("(%p): stub\n", DeviceObject
);
2038 /***********************************************************************
2039 * IoUnregisterFileSystem (NTOSKRNL.EXE.@)
2041 VOID WINAPI
IoUnregisterFileSystem(PDEVICE_OBJECT DeviceObject
)
2043 FIXME("(%p): stub\n", DeviceObject
);
2046 /***********************************************************************
2047 * MmAllocateNonCachedMemory (NTOSKRNL.EXE.@)
2049 PVOID WINAPI
MmAllocateNonCachedMemory( SIZE_T size
)
2051 TRACE( "%lu\n", size
);
2052 return VirtualAlloc( NULL
, size
, MEM_RESERVE
|MEM_COMMIT
, PAGE_READWRITE
|PAGE_NOCACHE
);
2055 /***********************************************************************
2056 * MmAllocateContiguousMemory (NTOSKRNL.EXE.@)
2058 PVOID WINAPI
MmAllocateContiguousMemory( SIZE_T size
, PHYSICAL_ADDRESS highest_valid_address
)
2060 FIXME( "%lu, %s stub\n", size
, wine_dbgstr_longlong(highest_valid_address
.QuadPart
) );
2064 /***********************************************************************
2065 * MmAllocateContiguousMemorySpecifyCache (NTOSKRNL.EXE.@)
2067 PVOID WINAPI
MmAllocateContiguousMemorySpecifyCache( SIZE_T size
,
2068 PHYSICAL_ADDRESS lowest_valid_address
,
2069 PHYSICAL_ADDRESS highest_valid_address
,
2070 PHYSICAL_ADDRESS BoundaryAddressMultiple
,
2071 MEMORY_CACHING_TYPE CacheType
)
2077 /***********************************************************************
2078 * MmAllocatePagesForMdl (NTOSKRNL.EXE.@)
2080 PMDL WINAPI
MmAllocatePagesForMdl(PHYSICAL_ADDRESS lowaddress
, PHYSICAL_ADDRESS highaddress
,
2081 PHYSICAL_ADDRESS skipbytes
, SIZE_T size
)
2083 FIXME("%s %s %s %lu: stub\n", wine_dbgstr_longlong(lowaddress
.QuadPart
), wine_dbgstr_longlong(highaddress
.QuadPart
),
2084 wine_dbgstr_longlong(skipbytes
.QuadPart
), size
);
2088 /***********************************************************************
2089 * MmFreeNonCachedMemory (NTOSKRNL.EXE.@)
2091 void WINAPI
MmFreeNonCachedMemory( void *addr
, SIZE_T size
)
2093 TRACE( "%p %lu\n", addr
, size
);
2094 VirtualFree( addr
, 0, MEM_RELEASE
);
2097 /***********************************************************************
2098 * MmIsAddressValid (NTOSKRNL.EXE.@)
2100 * Check if the process can access the virtual address without a pagefault
2103 * VirtualAddress [I] Address to check
2107 * Success: TRUE (Accessing the Address works without a Pagefault)
2110 BOOLEAN WINAPI
MmIsAddressValid(PVOID VirtualAddress
)
2112 TRACE("(%p)\n", VirtualAddress
);
2113 return !IsBadWritePtr(VirtualAddress
, 1);
2116 /***********************************************************************
2117 * MmMapIoSpace (NTOSKRNL.EXE.@)
2119 PVOID WINAPI
MmMapIoSpace( PHYSICAL_ADDRESS PhysicalAddress
, DWORD NumberOfBytes
, DWORD CacheType
)
2121 FIXME( "stub: 0x%08x%08x, %d, %d\n", PhysicalAddress
.u
.HighPart
, PhysicalAddress
.u
.LowPart
, NumberOfBytes
, CacheType
);
2126 /***********************************************************************
2127 * MmLockPagableSectionByHandle (NTOSKRNL.EXE.@)
2129 VOID WINAPI
MmLockPagableSectionByHandle(PVOID ImageSectionHandle
)
2131 FIXME("stub %p\n", ImageSectionHandle
);
2134 /***********************************************************************
2135 * MmMapLockedPagesSpecifyCache (NTOSKRNL.EXE.@)
2137 PVOID WINAPI
MmMapLockedPagesSpecifyCache(PMDLX MemoryDescriptorList
, KPROCESSOR_MODE AccessMode
, MEMORY_CACHING_TYPE CacheType
,
2138 PVOID BaseAddress
, ULONG BugCheckOnFailure
, MM_PAGE_PRIORITY Priority
)
2140 FIXME("(%p, %u, %u, %p, %u, %u): stub\n", MemoryDescriptorList
, AccessMode
, CacheType
, BaseAddress
, BugCheckOnFailure
, Priority
);
2145 /***********************************************************************
2146 * MmUnlockPagableImageSection (NTOSKRNL.EXE.@)
2148 VOID WINAPI
MmUnlockPagableImageSection(PVOID ImageSectionHandle
)
2150 FIXME("stub %p\n", ImageSectionHandle
);
2153 /***********************************************************************
2154 * MmPageEntireDriver (NTOSKRNL.EXE.@)
2156 PVOID WINAPI
MmPageEntireDriver(PVOID AddrInSection
)
2158 TRACE("%p\n", AddrInSection
);
2159 return AddrInSection
;
2163 /***********************************************************************
2164 * MmProbeAndLockPages (NTOSKRNL.EXE.@)
2166 void WINAPI
MmProbeAndLockPages(PMDLX MemoryDescriptorList
, KPROCESSOR_MODE AccessMode
, LOCK_OPERATION Operation
)
2168 FIXME("(%p, %u, %u): stub\n", MemoryDescriptorList
, AccessMode
, Operation
);
2172 /***********************************************************************
2173 * MmResetDriverPaging (NTOSKRNL.EXE.@)
2175 void WINAPI
MmResetDriverPaging(PVOID AddrInSection
)
2177 TRACE("%p\n", AddrInSection
);
2181 /***********************************************************************
2182 * MmUnlockPages (NTOSKRNL.EXE.@)
2184 void WINAPI
MmUnlockPages(PMDLX MemoryDescriptorList
)
2186 FIXME("(%p): stub\n", MemoryDescriptorList
);
2190 /***********************************************************************
2191 * MmUnmapIoSpace (NTOSKRNL.EXE.@)
2193 VOID WINAPI
MmUnmapIoSpace( PVOID BaseAddress
, SIZE_T NumberOfBytes
)
2195 FIXME( "stub: %p, %lu\n", BaseAddress
, NumberOfBytes
);
2199 /***********************************************************************
2200 * ObReferenceObjectByHandle (NTOSKRNL.EXE.@)
2202 NTSTATUS WINAPI
ObReferenceObjectByHandle( HANDLE obj
, ACCESS_MASK access
,
2204 KPROCESSOR_MODE mode
, PVOID
* ptr
,
2205 POBJECT_HANDLE_INFORMATION info
)
2207 FIXME( "stub: %p %x %p %d %p %p\n", obj
, access
, type
, mode
, ptr
, info
);
2208 return STATUS_NOT_IMPLEMENTED
;
2211 /***********************************************************************
2212 * ObReferenceObjectByName (NTOSKRNL.EXE.@)
2214 NTSTATUS WINAPI
ObReferenceObjectByName( UNICODE_STRING
*ObjectName
,
2216 ACCESS_STATE
*AccessState
,
2217 ACCESS_MASK DesiredAccess
,
2218 POBJECT_TYPE ObjectType
,
2219 KPROCESSOR_MODE AccessMode
,
2223 struct wine_driver
*driver
;
2224 struct wine_rb_entry
*entry
;
2226 TRACE("mostly-stub:%s %i %p %i %p %i %p %p\n", debugstr_us(ObjectName
),
2227 Attributes
, AccessState
, DesiredAccess
, ObjectType
, AccessMode
,
2228 ParseContext
, Object
);
2230 if (AccessState
) FIXME("Unhandled AccessState\n");
2231 if (DesiredAccess
) FIXME("Unhandled DesiredAccess\n");
2232 if (ParseContext
) FIXME("Unhandled ParseContext\n");
2233 if (ObjectType
) FIXME("Unhandled ObjectType\n");
2235 if (AccessMode
!= KernelMode
)
2237 FIXME("UserMode access not implemented\n");
2238 return STATUS_NOT_IMPLEMENTED
;
2241 EnterCriticalSection(&drivers_cs
);
2242 entry
= wine_rb_get(&wine_drivers
, ObjectName
);
2243 LeaveCriticalSection(&drivers_cs
);
2246 FIXME("Object (%s) not found, may not be tracked.\n", debugstr_us(ObjectName
));
2247 return STATUS_NOT_IMPLEMENTED
;
2250 driver
= WINE_RB_ENTRY_VALUE(entry
, struct wine_driver
, entry
);
2251 *Object
= &driver
->driver_obj
;
2252 return STATUS_SUCCESS
;
2256 static void ObReferenceObject( void *obj
)
2258 TRACE( "(%p): stub\n", obj
);
2262 /***********************************************************************
2263 * ObDereferenceObject (NTOSKRNL.EXE.@)
2265 void WINAPI
ObDereferenceObject( void *obj
)
2267 TRACE( "(%p): stub\n", obj
);
2271 /***********************************************************************
2272 * ObfReferenceObject (NTOSKRNL.EXE.@)
2274 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
2275 DEFINE_FASTCALL1_ENTRYPOINT( ObfReferenceObject
)
2276 void WINAPI DECLSPEC_HIDDEN
__regs_ObfReferenceObject( void *obj
)
2278 void WINAPI
ObfReferenceObject( void *obj
)
2281 ObReferenceObject( obj
);
2285 /***********************************************************************
2286 * ObfDereferenceObject (NTOSKRNL.EXE.@)
2288 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
2289 DEFINE_FASTCALL1_ENTRYPOINT( ObfDereferenceObject
)
2290 void WINAPI DECLSPEC_HIDDEN
__regs_ObfDereferenceObject( void *obj
)
2292 void WINAPI
ObfDereferenceObject( void *obj
)
2295 ObDereferenceObject( obj
);
2299 /***********************************************************************
2300 * IoGetAttachedDeviceReference (NTOSKRNL.EXE.@)
2302 DEVICE_OBJECT
* WINAPI
IoGetAttachedDeviceReference( DEVICE_OBJECT
*device
)
2304 DEVICE_OBJECT
*result
= IoGetAttachedDevice( device
);
2305 ObReferenceObject( result
);
2310 /***********************************************************************
2311 * PsCreateSystemThread (NTOSKRNL.EXE.@)
2313 NTSTATUS WINAPI
PsCreateSystemThread(PHANDLE ThreadHandle
, ULONG DesiredAccess
,
2314 POBJECT_ATTRIBUTES ObjectAttributes
,
2315 HANDLE ProcessHandle
, PCLIENT_ID ClientId
,
2316 PKSTART_ROUTINE StartRoutine
, PVOID StartContext
)
2318 if (!ProcessHandle
) ProcessHandle
= GetCurrentProcess();
2319 return RtlCreateUserThread(ProcessHandle
, 0, FALSE
, 0, 0,
2320 0, StartRoutine
, StartContext
,
2321 ThreadHandle
, ClientId
);
2324 /***********************************************************************
2325 * PsGetCurrentProcessId (NTOSKRNL.EXE.@)
2327 HANDLE WINAPI
PsGetCurrentProcessId(void)
2329 if (GetCurrentThreadId() == request_thread
)
2330 return UlongToHandle(client_pid
);
2331 return UlongToHandle(GetCurrentProcessId());
2335 /***********************************************************************
2336 * PsGetCurrentThreadId (NTOSKRNL.EXE.@)
2338 HANDLE WINAPI
PsGetCurrentThreadId(void)
2340 if (GetCurrentThreadId() == request_thread
)
2341 return UlongToHandle(client_tid
);
2342 return UlongToHandle(GetCurrentThreadId());
2346 /***********************************************************************
2347 * PsGetVersion (NTOSKRNL.EXE.@)
2349 BOOLEAN WINAPI
PsGetVersion(ULONG
*major
, ULONG
*minor
, ULONG
*build
, UNICODE_STRING
*version
)
2351 RTL_OSVERSIONINFOEXW info
;
2353 info
.dwOSVersionInfoSize
= sizeof(info
);
2354 RtlGetVersion( &info
);
2355 if (major
) *major
= info
.dwMajorVersion
;
2356 if (minor
) *minor
= info
.dwMinorVersion
;
2357 if (build
) *build
= info
.dwBuildNumber
;
2361 #if 0 /* FIXME: GameGuard passes an uninitialized pointer in version->Buffer */
2362 size_t len
= min( strlenW(info
.szCSDVersion
)*sizeof(WCHAR
), version
->MaximumLength
);
2363 memcpy( version
->Buffer
, info
.szCSDVersion
, len
);
2364 if (len
< version
->MaximumLength
) version
->Buffer
[len
/ sizeof(WCHAR
)] = 0;
2365 version
->Length
= len
;
2372 /***********************************************************************
2373 * PsImpersonateClient (NTOSKRNL.EXE.@)
2375 NTSTATUS WINAPI
PsImpersonateClient(PETHREAD Thread
, PACCESS_TOKEN Token
, BOOLEAN CopyOnOpen
,
2376 BOOLEAN EffectiveOnly
, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
)
2378 FIXME("(%p, %p, %u, %u, %u): stub\n", Thread
, Token
, CopyOnOpen
, EffectiveOnly
, ImpersonationLevel
);
2380 return STATUS_NOT_IMPLEMENTED
;
2384 /***********************************************************************
2385 * PsSetCreateProcessNotifyRoutine (NTOSKRNL.EXE.@)
2387 NTSTATUS WINAPI
PsSetCreateProcessNotifyRoutine( PCREATE_PROCESS_NOTIFY_ROUTINE callback
, BOOLEAN remove
)
2389 FIXME( "stub: %p %d\n", callback
, remove
);
2390 return STATUS_SUCCESS
;
2394 /***********************************************************************
2395 * PsSetCreateThreadNotifyRoutine (NTOSKRNL.EXE.@)
2397 NTSTATUS WINAPI
PsSetCreateThreadNotifyRoutine( PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine
)
2399 FIXME( "stub: %p\n", NotifyRoutine
);
2400 return STATUS_SUCCESS
;
2404 /***********************************************************************
2405 * PsRemoveCreateThreadNotifyRoutine (NTOSKRNL.EXE.@)
2407 NTSTATUS WINAPI
PsRemoveCreateThreadNotifyRoutine( PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine
)
2409 FIXME( "stub: %p\n", NotifyRoutine
);
2410 return STATUS_SUCCESS
;
2414 /***********************************************************************
2415 * PsRemoveLoadImageNotifyRoutine (NTOSKRNL.EXE.@)
2417 NTSTATUS WINAPI
PsRemoveLoadImageNotifyRoutine(PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine
)
2419 FIXME( "stub: %p\n", NotifyRoutine
);
2420 return STATUS_SUCCESS
;
2424 /***********************************************************************
2425 * PsTerminateSystemThread (NTOSKRNL.EXE.@)
2427 NTSTATUS WINAPI
PsTerminateSystemThread(NTSTATUS ExitStatus
)
2429 FIXME( "stub: %u\n", ExitStatus
);
2430 return STATUS_NOT_IMPLEMENTED
;
2434 /***********************************************************************
2435 * MmGetSystemRoutineAddress (NTOSKRNL.EXE.@)
2437 PVOID WINAPI
MmGetSystemRoutineAddress(PUNICODE_STRING SystemRoutineName
)
2440 STRING routineNameA
;
2443 static const WCHAR ntoskrnlW
[] = {'n','t','o','s','k','r','n','l','.','e','x','e',0};
2444 static const WCHAR halW
[] = {'h','a','l','.','d','l','l',0};
2446 if (!SystemRoutineName
) return NULL
;
2448 if (RtlUnicodeStringToAnsiString( &routineNameA
, SystemRoutineName
, TRUE
) == STATUS_SUCCESS
)
2450 /* We only support functions exported from ntoskrnl.exe or hal.dll */
2451 hMod
= GetModuleHandleW( ntoskrnlW
);
2452 pFunc
= GetProcAddress( hMod
, routineNameA
.Buffer
);
2455 hMod
= GetModuleHandleW( halW
);
2456 if (hMod
) pFunc
= GetProcAddress( hMod
, routineNameA
.Buffer
);
2458 RtlFreeAnsiString( &routineNameA
);
2462 TRACE( "%s -> %p\n", debugstr_us(SystemRoutineName
), pFunc
);
2464 FIXME( "%s not found\n", debugstr_us(SystemRoutineName
) );
2469 /***********************************************************************
2470 * MmQuerySystemSize (NTOSKRNL.EXE.@)
2472 MM_SYSTEMSIZE WINAPI
MmQuerySystemSize(void)
2475 return MmLargeSystem
;
2478 /***********************************************************************
2479 * KeInitializeDpc (NTOSKRNL.EXE.@)
2481 VOID WINAPI
KeInitializeDpc(PRKDPC Dpc
, PKDEFERRED_ROUTINE DeferredRoutine
, PVOID DeferredContext
)
2486 /***********************************************************************
2487 * READ_REGISTER_BUFFER_UCHAR (NTOSKRNL.EXE.@)
2489 VOID WINAPI
READ_REGISTER_BUFFER_UCHAR(PUCHAR Register
, PUCHAR Buffer
, ULONG Count
)
2494 /*****************************************************
2495 * PoSetPowerState (NTOSKRNL.EXE.@)
2497 POWER_STATE WINAPI
PoSetPowerState(PDEVICE_OBJECT DeviceObject
, POWER_STATE_TYPE Type
, POWER_STATE State
)
2499 FIXME("(%p %u %u) stub\n", DeviceObject
, Type
, State
.DeviceState
);
2503 /*****************************************************
2504 * IoWMIRegistrationControl (NTOSKRNL.EXE.@)
2506 NTSTATUS WINAPI
IoWMIRegistrationControl(PDEVICE_OBJECT DeviceObject
, ULONG Action
)
2508 FIXME("(%p %u) stub\n", DeviceObject
, Action
);
2509 return STATUS_SUCCESS
;
2512 /*****************************************************
2513 * PsSetLoadImageNotifyRoutine (NTOSKRNL.EXE.@)
2515 NTSTATUS WINAPI
PsSetLoadImageNotifyRoutine(PLOAD_IMAGE_NOTIFY_ROUTINE routine
)
2517 FIXME("(%p) stub\n", routine
);
2518 return STATUS_SUCCESS
;
2521 /*****************************************************
2522 * PsLookupProcessByProcessId (NTOSKRNL.EXE.@)
2524 NTSTATUS WINAPI
PsLookupProcessByProcessId(HANDLE processid
, PEPROCESS
*process
)
2527 if (!once
++) FIXME("(%p %p) stub\n", processid
, process
);
2528 return STATUS_NOT_IMPLEMENTED
;
2532 /*****************************************************
2533 * IoSetThreadHardErrorMode (NTOSKRNL.EXE.@)
2535 BOOLEAN WINAPI
IoSetThreadHardErrorMode(BOOLEAN EnableHardErrors
)
2542 /*****************************************************
2543 * IoInitializeRemoveLockEx (NTOSKRNL.EXE.@)
2545 VOID WINAPI
IoInitializeRemoveLockEx(PIO_REMOVE_LOCK lock
, ULONG tag
,
2546 ULONG maxmin
, ULONG high
, ULONG size
)
2548 FIXME("(%p %u %u %u %u) stub\n", lock
, tag
, maxmin
, high
, size
);
2552 /*****************************************************
2553 * IoAcquireRemoveLockEx (NTOSKRNL.EXE.@)
2556 NTSTATUS WINAPI
IoAcquireRemoveLockEx(PIO_REMOVE_LOCK lock
, PVOID tag
,
2557 LPCSTR file
, ULONG line
, ULONG lock_size
)
2559 FIXME("(%p, %p, %s, %u, %u): stub\n", lock
, tag
, debugstr_a(file
), line
, lock_size
);
2561 return STATUS_NOT_IMPLEMENTED
;
2565 /*****************************************************
2568 BOOL WINAPI
DllMain( HINSTANCE inst
, DWORD reason
, LPVOID reserved
)
2570 static void *handler
;
2571 LARGE_INTEGER count
;
2575 case DLL_PROCESS_ATTACH
:
2576 DisableThreadLibraryCalls( inst
);
2577 #if defined(__i386__) || defined(__x86_64__)
2578 handler
= RtlAddVectoredExceptionHandler( TRUE
, vectored_handler
);
2580 KeQueryTickCount( &count
); /* initialize the global KeTickCount */
2582 case DLL_PROCESS_DETACH
:
2583 if (reserved
) break;
2584 RtlRemoveVectoredExceptionHandler( handler
);
2590 /*****************************************************
2591 * Ke386IoSetAccessProcess (NTOSKRNL.EXE.@)
2593 BOOLEAN WINAPI
Ke386IoSetAccessProcess(PEPROCESS
*process
, ULONG flag
)
2595 FIXME("(%p %d) stub\n", process
, flag
);
2599 /*****************************************************
2600 * Ke386SetIoAccessMap (NTOSKRNL.EXE.@)
2602 BOOLEAN WINAPI
Ke386SetIoAccessMap(ULONG flag
, PVOID buffer
)
2604 FIXME("(%d %p) stub\n", flag
, buffer
);
2608 /*****************************************************
2609 * IoCreateSynchronizationEvent (NTOSKRNL.EXE.@)
2611 PKEVENT WINAPI
IoCreateSynchronizationEvent(PUNICODE_STRING name
, PHANDLE handle
)
2613 FIXME("(%p %p) stub\n", name
, handle
);
2617 /*****************************************************
2618 * IoStartNextPacket (NTOSKRNL.EXE.@)
2620 VOID WINAPI
IoStartNextPacket(PDEVICE_OBJECT deviceobject
, BOOLEAN cancelable
)
2622 FIXME("(%p %d) stub\n", deviceobject
, cancelable
);
2625 /*****************************************************
2626 * ObQueryNameString (NTOSKRNL.EXE.@)
2628 NTSTATUS WINAPI
ObQueryNameString(PVOID object
, POBJECT_NAME_INFORMATION name
, ULONG maxlength
, PULONG returnlength
)
2630 FIXME("(%p %p %u %p) stub\n", object
, name
, maxlength
, returnlength
);
2631 return STATUS_NOT_IMPLEMENTED
;
2634 /*****************************************************
2635 * IoRegisterPlugPlayNotification (NTOSKRNL.EXE.@)
2637 NTSTATUS WINAPI
IoRegisterPlugPlayNotification(IO_NOTIFICATION_EVENT_CATEGORY category
, ULONG flags
, PVOID data
,
2638 PDRIVER_OBJECT driver
, PDRIVER_NOTIFICATION_CALLBACK_ROUTINE callback
,
2639 PVOID context
, PVOID
*notification
)
2641 FIXME("(%u %u %p %p %p %p %p) stub\n", category
, flags
, data
, driver
, callback
, context
, notification
);
2642 return STATUS_SUCCESS
;
2645 /*****************************************************
2646 * IoCsqInitialize (NTOSKRNL.EXE.@)
2648 NTSTATUS WINAPI
IoCsqInitialize(PIO_CSQ csq
, PIO_CSQ_INSERT_IRP insert_irp
, PIO_CSQ_REMOVE_IRP remove_irp
,
2649 PIO_CSQ_PEEK_NEXT_IRP peek_irp
, PIO_CSQ_ACQUIRE_LOCK acquire_lock
,
2650 PIO_CSQ_RELEASE_LOCK release_lock
, PIO_CSQ_COMPLETE_CANCELED_IRP complete_irp
)
2652 FIXME("(%p %p %p %p %p %p %p) stub\n",
2653 csq
, insert_irp
, remove_irp
, peek_irp
, acquire_lock
, release_lock
, complete_irp
);
2654 return STATUS_SUCCESS
;
2657 /***********************************************************************
2658 * ExAcquireResourceExclusiveLite (NTOSKRNL.EXE.@)
2660 BOOLEAN WINAPI
ExAcquireResourceExclusiveLite( PERESOURCE resource
, BOOLEAN wait
)
2662 FIXME( ":%p %u stub\n", resource
, wait
);
2666 /***********************************************************************
2667 * ExDeleteResourceLite (NTOSKRNL.EXE.@)
2669 NTSTATUS WINAPI
ExDeleteResourceLite(PERESOURCE resource
)
2671 FIXME("(%p): stub\n", resource
);
2672 return STATUS_NOT_IMPLEMENTED
;
2675 /*****************************************************
2676 * ExInterlockedRemoveHeadList (NTOSKRNL.EXE.@)
2678 PLIST_ENTRY WINAPI
ExInterlockedRemoveHeadList(PLIST_ENTRY head
, PKSPIN_LOCK lock
)
2680 FIXME("(%p %p) stub\n", head
, lock
);
2684 /***********************************************************************
2685 * ExfInterlockedRemoveHeadList (NTOSKRNL.EXE.@)
2687 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
2688 DEFINE_FASTCALL2_ENTRYPOINT( ExfInterlockedRemoveHeadList
)
2689 PLIST_ENTRY WINAPI DECLSPEC_HIDDEN
__regs_ExfInterlockedRemoveHeadList(PLIST_ENTRY head
, PKSPIN_LOCK lock
)
2691 PLIST_ENTRY WINAPI
ExfInterlockedRemoveHeadList(PLIST_ENTRY head
, PKSPIN_LOCK lock
)
2694 FIXME("(%p %p) stub\n", head
, lock
);
2695 return ExInterlockedRemoveHeadList( head
, lock
);
2698 /***********************************************************************
2699 * ExReleaseResourceForThreadLite (NTOSKRNL.EXE.@)
2701 void WINAPI
ExReleaseResourceForThreadLite( PERESOURCE resource
, ERESOURCE_THREAD tid
)
2703 FIXME( "stub: %p %lu\n", resource
, tid
);
2706 /***********************************************************************
2707 * KeEnterCriticalRegion (NTOSKRNL.EXE.@)
2709 void WINAPI
KeEnterCriticalRegion(void)
2714 /***********************************************************************
2715 * KeLeaveCriticalRegion (NTOSKRNL.EXE.@)
2717 void WINAPI
KeLeaveCriticalRegion(void)
2722 /***********************************************************************
2723 * ProbeForRead (NTOSKRNL.EXE.@)
2725 void WINAPI
ProbeForRead(void *address
, SIZE_T length
, ULONG alignment
)
2727 FIXME("(%p %lu %u) stub\n", address
, length
, alignment
);
2730 /***********************************************************************
2731 * ProbeForWrite (NTOSKRNL.EXE.@)
2733 void WINAPI
ProbeForWrite(void *address
, SIZE_T length
, ULONG alignment
)
2735 FIXME("(%p %lu %u) stub\n", address
, length
, alignment
);
2738 /***********************************************************************
2739 * CmRegisterCallback (NTOSKRNL.EXE.@)
2741 NTSTATUS WINAPI
CmRegisterCallback(EX_CALLBACK_FUNCTION
*function
, void *context
, LARGE_INTEGER
*cookie
)
2743 FIXME("(%p %p %p): stub\n", function
, context
, cookie
);
2744 return STATUS_NOT_IMPLEMENTED
;
2747 /***********************************************************************
2748 * CmUnRegisterCallback (NTOSKRNL.EXE.@)
2750 NTSTATUS WINAPI
CmUnRegisterCallback(LARGE_INTEGER cookie
)
2752 FIXME("(%s): stub\n", wine_dbgstr_longlong(cookie
.QuadPart
));
2753 return STATUS_NOT_IMPLEMENTED
;
2756 /***********************************************************************
2757 * KeDelayExecutionThread (NTOSKRNL.EXE.@)
2759 NTSTATUS WINAPI
KeDelayExecutionThread(KPROCESSOR_MODE waitmode
, BOOLEAN alertable
, PLARGE_INTEGER interval
)
2761 FIXME("(%u, %u, %p): stub\n", waitmode
, alertable
, interval
);
2762 return STATUS_NOT_IMPLEMENTED
;
2765 /***********************************************************************
2766 * IoAttachDevice (NTOSKRNL.EXE.@)
2768 NTSTATUS WINAPI
IoAttachDevice(DEVICE_OBJECT
*source
, UNICODE_STRING
*target
, DEVICE_OBJECT
*attached
)
2770 FIXME("(%p, %s, %p): stub\n", source
, debugstr_us(target
), attached
);
2771 return STATUS_NOT_IMPLEMENTED
;
2775 static NTSTATUS
open_driver( const UNICODE_STRING
*service_name
, SC_HANDLE
*service
)
2777 QUERY_SERVICE_CONFIGW
*service_config
= NULL
;
2778 SC_HANDLE manager_handle
;
2779 DWORD config_size
= 0;
2782 if (!(name
= RtlAllocateHeap( GetProcessHeap(), 0, service_name
->Length
+ sizeof(WCHAR
) )))
2783 return STATUS_NO_MEMORY
;
2785 memcpy( name
, service_name
->Buffer
, service_name
->Length
);
2786 name
[ service_name
->Length
/ sizeof(WCHAR
) ] = 0;
2788 if (strncmpW( name
, servicesW
, strlenW(servicesW
) ))
2790 FIXME( "service name %s is not a keypath\n", debugstr_us(service_name
) );
2791 RtlFreeHeap( GetProcessHeap(), 0, name
);
2792 return STATUS_NOT_IMPLEMENTED
;
2795 if (!(manager_handle
= OpenSCManagerW( NULL
, NULL
, SC_MANAGER_CONNECT
)))
2797 WARN( "failed to connect to service manager\n" );
2798 RtlFreeHeap( GetProcessHeap(), 0, name
);
2799 return STATUS_NOT_SUPPORTED
;
2802 *service
= OpenServiceW( manager_handle
, name
+ strlenW(servicesW
), SERVICE_ALL_ACCESS
);
2803 RtlFreeHeap( GetProcessHeap(), 0, name
);
2804 CloseServiceHandle( manager_handle
);
2808 WARN( "failed to open service %s\n", debugstr_us(service_name
) );
2809 return STATUS_UNSUCCESSFUL
;
2812 QueryServiceConfigW( *service
, NULL
, 0, &config_size
);
2813 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
)
2815 WARN( "failed to query service config\n" );
2819 if (!(service_config
= RtlAllocateHeap( GetProcessHeap(), 0, config_size
)))
2822 if (!QueryServiceConfigW( *service
, service_config
, config_size
, &config_size
))
2824 WARN( "failed to query service config\n" );
2828 if (service_config
->dwServiceType
!= SERVICE_KERNEL_DRIVER
&&
2829 service_config
->dwServiceType
!= SERVICE_FILE_SYSTEM_DRIVER
)
2831 WARN( "service %s is not a kernel driver\n", debugstr_us(service_name
) );
2835 TRACE( "opened service for driver %s\n", debugstr_us(service_name
) );
2836 RtlFreeHeap( GetProcessHeap(), 0, service_config
);
2837 return STATUS_SUCCESS
;
2840 CloseServiceHandle( *service
);
2841 RtlFreeHeap( GetProcessHeap(), 0, service_config
);
2842 return STATUS_UNSUCCESSFUL
;
2846 /***********************************************************************
2847 * ZwLoadDriver (NTOSKRNL.EXE.@)
2849 NTSTATUS WINAPI
ZwLoadDriver( const UNICODE_STRING
*service_name
)
2851 SERVICE_STATUS_PROCESS service_status
;
2852 SC_HANDLE service_handle
;
2853 ULONGLONG start_time
;
2857 TRACE( "(%s)\n", debugstr_us(service_name
) );
2859 if ((status
= open_driver( service_name
, &service_handle
)) != STATUS_SUCCESS
)
2862 TRACE( "trying to start %s\n", debugstr_us(service_name
) );
2864 start_time
= GetTickCount64();
2867 if (StartServiceW( service_handle
, 0, NULL
)) break;
2868 if (GetLastError() == ERROR_SERVICE_ALREADY_RUNNING
) break;
2869 if (GetLastError() != ERROR_SERVICE_DATABASE_LOCKED
) goto error
;
2870 if (GetTickCount64() - start_time
> 30000) goto error
;
2874 start_time
= GetTickCount64();
2877 if (!QueryServiceStatusEx( service_handle
, SC_STATUS_PROCESS_INFO
,
2878 (BYTE
*)&service_status
, sizeof(service_status
), &bytes
)) goto error
;
2879 if (service_status
.dwCurrentState
!= SERVICE_START_PENDING
) break;
2880 if (GetTickCount64() - start_time
> 30000) goto error
;
2884 if (service_status
.dwCurrentState
== SERVICE_RUNNING
)
2886 if (service_status
.dwProcessId
!= GetCurrentProcessId())
2887 FIXME( "driver %s was loaded into a different process\n", debugstr_us(service_name
) );
2889 status
= STATUS_SUCCESS
;
2894 WARN( "failed to start service %s\n", debugstr_us(service_name
) );
2895 status
= STATUS_UNSUCCESSFUL
;
2898 TRACE( "returning status %08x\n", status
);
2899 CloseServiceHandle( service_handle
);
2904 /***********************************************************************
2905 * ZwUnloadDriver (NTOSKRNL.EXE.@)
2907 NTSTATUS WINAPI
ZwUnloadDriver( const UNICODE_STRING
*service_name
)
2909 SERVICE_STATUS service_status
;
2910 SC_HANDLE service_handle
;
2911 ULONGLONG start_time
;
2914 TRACE( "(%s)\n", debugstr_us(service_name
) );
2916 if ((status
= open_driver( service_name
, &service_handle
)) != STATUS_SUCCESS
)
2919 if (!ControlService( service_handle
, SERVICE_CONTROL_STOP
, &service_status
))
2922 start_time
= GetTickCount64();
2925 if (!QueryServiceStatus( service_handle
, &service_status
)) goto error
;
2926 if (service_status
.dwCurrentState
!= SERVICE_STOP_PENDING
) break;
2927 if (GetTickCount64() - start_time
> 30000) goto error
;
2931 if (service_status
.dwCurrentState
== SERVICE_STOPPED
)
2933 status
= STATUS_SUCCESS
;
2938 WARN( "failed to stop service %s\n", debugstr_us(service_name
) );
2939 status
= STATUS_UNSUCCESSFUL
;
2942 TRACE( "returning status %08x\n", status
);
2943 CloseServiceHandle( service_handle
);
2948 static NTSTATUS WINAPI
internal_complete( DEVICE_OBJECT
*device
, IRP
*irp
, void *context
)
2950 HANDLE event
= context
;
2952 return STATUS_MORE_PROCESSING_REQUIRED
;
2956 static NTSTATUS
send_device_irp( DEVICE_OBJECT
*device
, IRP
*irp
, ULONG_PTR
*info
)
2959 HANDLE event
= CreateEventA( NULL
, FALSE
, FALSE
, NULL
);
2960 DEVICE_OBJECT
*toplevel_device
;
2962 irp
->IoStatus
.u
.Status
= STATUS_NOT_SUPPORTED
;
2963 IoSetCompletionRoutine( irp
, internal_complete
, event
, TRUE
, TRUE
, TRUE
);
2965 toplevel_device
= IoGetAttachedDeviceReference( device
);
2966 status
= IoCallDriver( toplevel_device
, irp
);
2968 if (status
== STATUS_PENDING
)
2969 WaitForSingleObject( event
, INFINITE
);
2971 status
= irp
->IoStatus
.u
.Status
;
2973 *info
= irp
->IoStatus
.Information
;
2974 IoCompleteRequest( irp
, IO_NO_INCREMENT
);
2975 ObDereferenceObject( toplevel_device
);
2976 CloseHandle( event
);
2981 static NTSTATUS
get_device_id( DEVICE_OBJECT
*device
, BUS_QUERY_ID_TYPE type
, WCHAR
**id
)
2983 IO_STACK_LOCATION
*irpsp
;
2984 IO_STATUS_BLOCK irp_status
;
2987 if (!(irp
= IoBuildSynchronousFsdRequest( IRP_MJ_PNP
, device
, NULL
, 0, NULL
, NULL
, &irp_status
)))
2988 return STATUS_NO_MEMORY
;
2990 irpsp
= IoGetNextIrpStackLocation( irp
);
2991 irpsp
->MinorFunction
= IRP_MN_QUERY_ID
;
2992 irpsp
->Parameters
.QueryId
.IdType
= type
;
2994 return send_device_irp( device
, irp
, (ULONG_PTR
*)id
);
2998 static BOOL
get_driver_for_id( const WCHAR
*id
, WCHAR
*driver
)
3000 static const WCHAR serviceW
[] = {'S','e','r','v','i','c','e',0};
3001 static const UNICODE_STRING service_str
= { sizeof(serviceW
) - sizeof(WCHAR
), sizeof(serviceW
), (WCHAR
*)serviceW
};
3002 static const WCHAR critical_fmtW
[] =
3003 {'\\','R','e','g','i','s','t','r','y',
3004 '\\','M','a','c','h','i','n','e',
3005 '\\','S','y','s','t','e','m',
3006 '\\','C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t',
3007 '\\','C','o','n','t','r','o','l',
3008 '\\','C','r','i','t','i','c','a','l','D','e','v','i','c','e','D','a','t','a','b','a','s','e',
3010 WCHAR buffer
[FIELD_OFFSET( KEY_VALUE_PARTIAL_INFORMATION
, Data
[MAX_SERVICE_NAME
* sizeof(WCHAR
)] )];
3011 KEY_VALUE_PARTIAL_INFORMATION
*info
= (KEY_VALUE_PARTIAL_INFORMATION
*)buffer
;
3012 OBJECT_ATTRIBUTES attr
;
3019 if (!(keyW
= RtlAllocateHeap( GetProcessHeap(), 0, sizeof(critical_fmtW
) + strlenW(id
) * sizeof(WCHAR
) )))
3020 return STATUS_NO_MEMORY
;
3022 sprintfW( keyW
, critical_fmtW
, id
);
3023 RtlInitUnicodeString( &key
, keyW
);
3024 InitializeObjectAttributes( &attr
, &key
, OBJ_CASE_INSENSITIVE
| OBJ_KERNEL_HANDLE
, NULL
, NULL
);
3026 status
= NtOpenKey( &hkey
, KEY_ALL_ACCESS
, &attr
);
3027 RtlFreeUnicodeString( &key
);
3028 if (status
!= STATUS_SUCCESS
)
3030 TRACE_(plugplay
)( "no driver found for %s\n", debugstr_w(id
) );
3034 status
= NtQueryValueKey( hkey
, &service_str
, KeyValuePartialInformation
,
3035 info
, sizeof(buffer
) - sizeof(WCHAR
), &len
);
3037 if (status
!= STATUS_SUCCESS
|| info
->Type
!= REG_SZ
)
3039 TRACE_(plugplay
)( "no driver found for %s\n", debugstr_w(id
) );
3043 memcpy( driver
, info
->Data
, info
->DataLength
);
3044 driver
[ info
->DataLength
/ sizeof(WCHAR
) ] = 0;
3045 TRACE_(plugplay
)( "found driver %s for %s\n", debugstr_w(driver
), debugstr_w(id
) );
3050 static NTSTATUS
send_pnp_irp( DEVICE_OBJECT
*device
, UCHAR minor
)
3052 IO_STACK_LOCATION
*irpsp
;
3053 IO_STATUS_BLOCK irp_status
;
3056 if (!(irp
= IoBuildSynchronousFsdRequest( IRP_MJ_PNP
, device
, NULL
, 0, NULL
, NULL
, &irp_status
)))
3057 return STATUS_NO_MEMORY
;
3059 irpsp
= IoGetNextIrpStackLocation( irp
);
3060 irpsp
->MinorFunction
= minor
;
3062 irpsp
->Parameters
.StartDevice
.AllocatedResources
= NULL
;
3063 irpsp
->Parameters
.StartDevice
.AllocatedResourcesTranslated
= NULL
;
3065 return send_device_irp( device
, irp
, NULL
);
3069 static NTSTATUS
send_power_irp( DEVICE_OBJECT
*device
, DEVICE_POWER_STATE power
)
3071 IO_STATUS_BLOCK irp_status
;
3072 IO_STACK_LOCATION
*irpsp
;
3075 if (!(irp
= IoBuildSynchronousFsdRequest( IRP_MJ_POWER
, device
, NULL
, 0, NULL
, NULL
, &irp_status
)))
3076 return STATUS_NO_MEMORY
;
3078 irpsp
= IoGetNextIrpStackLocation( irp
);
3079 irpsp
->MinorFunction
= IRP_MN_SET_POWER
;
3081 irpsp
->Parameters
.Power
.Type
= DevicePowerState
;
3082 irpsp
->Parameters
.Power
.State
.DeviceState
= power
;
3084 return send_device_irp( device
, irp
, NULL
);
3088 static void handle_bus_relations( DEVICE_OBJECT
*device
)
3090 static const WCHAR driverW
[] = {'\\','D','r','i','v','e','r','\\',0};
3091 WCHAR buffer
[MAX_SERVICE_NAME
+ sizeof(servicesW
)/sizeof(WCHAR
)];
3092 WCHAR driver
[MAX_SERVICE_NAME
] = {0};
3093 DRIVER_OBJECT
*driver_obj
;
3094 UNICODE_STRING string
;
3098 TRACE_(plugplay
)( "(%p)\n", device
);
3100 /* We could (should?) do a full IRP_MN_QUERY_DEVICE_RELATIONS query,
3101 * but we don't have to, we have the DEVICE_OBJECT of the new device
3102 * so we can simply handle the process here */
3104 status
= get_device_id( device
, BusQueryCompatibleIDs
, &ids
);
3105 if (status
!= STATUS_SUCCESS
|| !ids
)
3107 ERR_(plugplay
)( "Failed to get device IDs\n" );
3111 for (ptr
= ids
; *ptr
; ptr
+= strlenW(ptr
) + 1)
3113 if (get_driver_for_id( ptr
, driver
))
3116 RtlFreeHeap( GetProcessHeap(), 0, ids
);
3120 ERR_(plugplay
)( "No matching driver found for device\n" );
3124 strcpyW( buffer
, servicesW
);
3125 strcatW( buffer
, driver
);
3126 RtlInitUnicodeString( &string
, buffer
);
3127 if (ZwLoadDriver( &string
) != STATUS_SUCCESS
)
3129 ERR_(plugplay
)( "Failed to load driver %s\n", debugstr_w(driver
) );
3133 strcpyW( buffer
, driverW
);
3134 strcatW( buffer
, driver
);
3135 RtlInitUnicodeString( &string
, buffer
);
3136 if (ObReferenceObjectByName( &string
, OBJ_CASE_INSENSITIVE
, NULL
,
3137 0, NULL
, KernelMode
, NULL
, (void **)&driver_obj
) != STATUS_SUCCESS
)
3139 ERR_(plugplay
)( "Failed to locate loaded driver %s\n", debugstr_w(driver
) );
3143 if (driver_obj
->DriverExtension
->AddDevice
)
3144 status
= driver_obj
->DriverExtension
->AddDevice( driver_obj
, device
);
3146 status
= STATUS_NOT_IMPLEMENTED
;
3148 ObDereferenceObject( driver_obj
);
3150 if (status
!= STATUS_SUCCESS
)
3152 ERR_(plugplay
)( "AddDevice failed for driver %s\n", debugstr_w(driver
) );
3156 send_pnp_irp( device
, IRP_MN_START_DEVICE
);
3157 send_power_irp( device
, PowerDeviceD0
);
3161 static void handle_removal_relations( DEVICE_OBJECT
*device
)
3163 TRACE_(plugplay
)( "(%p)\n", device
);
3165 send_power_irp( device
, PowerDeviceD3
);
3166 send_pnp_irp( device
, IRP_MN_SURPRISE_REMOVAL
);
3167 send_pnp_irp( device
, IRP_MN_REMOVE_DEVICE
);
3171 /***********************************************************************
3172 * IoInvalidateDeviceRelations (NTOSKRNL.EXE.@)
3174 void WINAPI
IoInvalidateDeviceRelations( DEVICE_OBJECT
*device_object
, DEVICE_RELATION_TYPE type
)
3176 TRACE( "(%p, %i)\n", device_object
, type
);
3181 handle_bus_relations( device_object
);
3183 case RemovalRelations
:
3184 handle_removal_relations( device_object
);
3187 FIXME( "unhandled relation %i\n", type
);
3192 /***********************************************************************
3193 * KeSetTimerEx (NTOSKRNL.EXE.@)
3195 BOOL WINAPI
KeSetTimerEx( KTIMER
*timer
, LARGE_INTEGER duetime
, LONG period
, KDPC
*dpc
)
3197 FIXME("stub: %p %s %u %p\n", timer
, wine_dbgstr_longlong(duetime
.QuadPart
), period
, dpc
);
3201 /***********************************************************************
3202 * IoCreateFile (NTOSKRNL.EXE.@)
3204 NTSTATUS WINAPI
IoCreateFile(HANDLE
*handle
, ACCESS_MASK access
, OBJECT_ATTRIBUTES
*attr
,
3205 IO_STATUS_BLOCK
*io
, LARGE_INTEGER
*alloc_size
, ULONG attributes
, ULONG sharing
,
3206 ULONG disposition
, ULONG create_options
, VOID
*ea_buffer
, ULONG ea_length
,
3207 CREATE_FILE_TYPE file_type
, VOID
*parameters
, ULONG options
)
3210 return STATUS_NOT_IMPLEMENTED
;
3213 /***********************************************************************
3214 * KeClearEvent (NTOSKRNL.EXE.@)
3216 VOID WINAPI
KeClearEvent(PRKEVENT event
)
3218 FIXME("stub: %p\n", event
);
3221 /***********************************************************************
3222 * KeAcquireInStackQueuedSpinLock (NTOSKRNL.EXE.@)
3224 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
3225 DEFINE_FASTCALL2_ENTRYPOINT( KeAcquireInStackQueuedSpinLock
)
3226 void WINAPI DECLSPEC_HIDDEN
__regs_KeAcquireInStackQueuedSpinLock( KSPIN_LOCK
*spinlock
,
3227 KLOCK_QUEUE_HANDLE
*handle
)
3229 void WINAPI
KeAcquireInStackQueuedSpinLock( KSPIN_LOCK
*spinlock
, KLOCK_QUEUE_HANDLE
*handle
)
3232 FIXME( "stub: %p %p\n", spinlock
, handle
);
3235 /***********************************************************************
3236 * KeReleaseInStackQueuedSpinLock (NTOSKRNL.EXE.@)
3238 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
3239 DEFINE_FASTCALL1_ENTRYPOINT( KeReleaseInStackQueuedSpinLock
)
3240 void WINAPI DECLSPEC_HIDDEN
__regs_KeReleaseInStackQueuedSpinLock( KLOCK_QUEUE_HANDLE
*handle
)
3242 void WINAPI
KeReleaseInStackQueuedSpinLock( KLOCK_QUEUE_HANDLE
*handle
)
3245 FIXME( "stub: %p\n", handle
);
3248 /***********************************************************************
3249 * KeAcquireSpinLockRaiseToDpc (NTOSKRNL.EXE.@)
3251 KIRQL WINAPI
KeAcquireSpinLockRaiseToDpc(KSPIN_LOCK
*spinlock
)
3253 FIXME( "stub: %p\n", spinlock
);
3257 /***********************************************************************
3258 * KeReleaseSpinLock (NTOSKRNL.EXE.@)
3260 void WINAPI
KeReleaseSpinLock( KSPIN_LOCK
*spinlock
, KIRQL irql
)
3262 FIXME( "stub: %p %u\n", spinlock
, irql
);
3265 /***********************************************************************
3266 * IoCreateNotificationEvent (NTOSKRNL.EXE.@)
3268 PKEVENT WINAPI
IoCreateNotificationEvent(UNICODE_STRING
*name
, HANDLE
*handle
)
3270 FIXME( "stub: %s %p\n", debugstr_us(name
), handle
);