2 * ntoskrnl.exe implementation
4 * Copyright (C) 2007 Alexandre Julliard
5 * Copyright (C) 2010 Damjan Jovanovic
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/port.h"
27 #define NONAMELESSUNION
28 #define NONAMELESSSTRUCT
31 #define WIN32_NO_STATUS
37 #include "ddk/ntddk.h"
38 #include "ddk/ntifs.h"
39 #include "wine/unicode.h"
40 #include "wine/server.h"
41 #include "wine/list.h"
42 #include "wine/debug.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(ntoskrnl
);
45 WINE_DECLARE_DEBUG_CHANNEL(relay
);
47 BOOLEAN KdDebuggerEnabled
= FALSE
;
48 ULONG InitSafeBootMode
= 0;
50 extern LONG CALLBACK
vectored_handler( EXCEPTION_POINTERS
*ptrs
);
52 KSYSTEM_TIME KeTickCount
= { 0, 0, 0 };
54 typedef struct _KSERVICE_TABLE_DESCRIPTOR
60 } KSERVICE_TABLE_DESCRIPTOR
, *PKSERVICE_TABLE_DESCRIPTOR
;
62 KSERVICE_TABLE_DESCRIPTOR KeServiceDescriptorTable
[4] = { { 0 } };
64 typedef void (WINAPI
*PCREATE_PROCESS_NOTIFY_ROUTINE
)(HANDLE
,HANDLE
,BOOLEAN
);
65 typedef void (WINAPI
*PCREATE_THREAD_NOTIFY_ROUTINE
)(HANDLE
,HANDLE
,BOOLEAN
);
67 /* tid of the thread running client request */
68 static DWORD request_thread
;
70 /* pid/tid of the client thread */
71 static DWORD client_tid
;
72 static DWORD client_pid
;
75 #define DEFINE_FASTCALL1_ENTRYPOINT( name ) \
76 __ASM_STDCALL_FUNC( name, 4, \
80 "jmp " __ASM_NAME("__regs_") #name __ASM_STDCALL(4))
81 #define DEFINE_FASTCALL2_ENTRYPOINT( name ) \
82 __ASM_STDCALL_FUNC( name, 8, \
87 "jmp " __ASM_NAME("__regs_") #name __ASM_STDCALL(8))
88 #define DEFINE_FASTCALL3_ENTRYPOINT( name ) \
89 __ASM_STDCALL_FUNC( name, 12, \
94 "jmp " __ASM_NAME("__regs_") #name __ASM_STDCALL(12))
97 static inline LPCSTR
debugstr_us( const UNICODE_STRING
*us
)
99 if (!us
) return "<null>";
100 return debugstr_wn( us
->Buffer
, us
->Length
/ sizeof(WCHAR
) );
103 static HANDLE
get_device_manager(void)
105 static HANDLE device_manager
;
106 HANDLE handle
= 0, ret
= device_manager
;
110 SERVER_START_REQ( create_device_manager
)
112 req
->access
= SYNCHRONIZE
;
114 if (!wine_server_call( req
)) handle
= wine_server_ptr_handle( reply
->handle
);
120 ERR( "failed to create the device manager\n" );
123 if (!(ret
= InterlockedCompareExchangePointer( &device_manager
, handle
, 0 )))
126 NtClose( handle
); /* somebody beat us to it */
131 static NTSTATUS
dispatch_irp( DEVICE_OBJECT
*device
, IRP
*irp
)
135 KeQueryTickCount( &count
); /* update the global KeTickCount */
137 device
->CurrentIrp
= irp
;
139 IoCallDriver( device
, irp
);
141 device
->CurrentIrp
= NULL
;
143 return STATUS_SUCCESS
;
146 /* process a create request for a given file */
147 static NTSTATUS
dispatch_create( const irp_params_t
*params
, void *in_buff
, ULONG in_size
,
148 ULONG out_size
, HANDLE irp_handle
)
151 IO_STACK_LOCATION
*irpsp
;
153 DEVICE_OBJECT
*device
= wine_server_get_ptr( params
->create
.device
);
155 if (!(file
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*file
) ))) return STATUS_NO_MEMORY
;
157 TRACE( "device %p -> file %p\n", device
, file
);
159 file
->Type
= 5; /* MSDN */
160 file
->Size
= sizeof(*file
);
161 file
->DeviceObject
= device
;
163 if (!(irp
= IoAllocateIrp( device
->StackSize
, FALSE
)))
165 HeapFree( GetProcessHeap(), 0, file
);
166 return STATUS_NO_MEMORY
;
169 irpsp
= IoGetNextIrpStackLocation( irp
);
170 irpsp
->MajorFunction
= IRP_MJ_CREATE
;
171 irpsp
->DeviceObject
= device
;
172 irpsp
->CompletionRoutine
= NULL
;
173 irpsp
->Parameters
.Create
.SecurityContext
= NULL
; /* FIXME */
174 irpsp
->Parameters
.Create
.Options
= params
->create
.options
;
175 irpsp
->Parameters
.Create
.ShareAccess
= params
->create
.sharing
;
176 irpsp
->Parameters
.Create
.FileAttributes
= 0;
177 irpsp
->Parameters
.Create
.EaLength
= 0;
179 irp
->Tail
.Overlay
.OriginalFileObject
= file
;
180 irp
->RequestorMode
= UserMode
;
181 irp
->AssociatedIrp
.SystemBuffer
= NULL
;
182 irp
->UserBuffer
= NULL
;
183 irp
->UserIosb
= irp_handle
; /* note: we abuse UserIosb to store the server irp handle */
184 irp
->UserEvent
= NULL
;
186 if (device
->DriverObject
->MajorFunction
[IRP_MJ_CREATE
]) return dispatch_irp( device
, irp
);
188 irp
->IoStatus
.u
.Status
= STATUS_SUCCESS
;
189 IoCompleteRequest( irp
, IO_NO_INCREMENT
);
190 return STATUS_SUCCESS
;
193 /* process a close request for a given file */
194 static NTSTATUS
dispatch_close( const irp_params_t
*params
, void *in_buff
, ULONG in_size
,
195 ULONG out_size
, HANDLE irp_handle
)
198 IO_STACK_LOCATION
*irpsp
;
199 DEVICE_OBJECT
*device
;
200 FILE_OBJECT
*file
= wine_server_get_ptr( params
->close
.file
);
202 if (!file
) return STATUS_INVALID_HANDLE
;
204 device
= file
->DeviceObject
;
206 TRACE( "device %p file %p\n", device
, file
);
208 if (!(irp
= IoAllocateIrp( device
->StackSize
, FALSE
)))
210 HeapFree( GetProcessHeap(), 0, file
);
211 return STATUS_NO_MEMORY
;
214 irpsp
= IoGetNextIrpStackLocation( irp
);
215 irpsp
->MajorFunction
= IRP_MJ_CLOSE
;
216 irpsp
->DeviceObject
= device
;
217 irpsp
->CompletionRoutine
= NULL
;
218 irpsp
->Parameters
.Create
.SecurityContext
= NULL
; /* FIXME */
219 irpsp
->Parameters
.Create
.Options
= params
->create
.options
;
220 irpsp
->Parameters
.Create
.ShareAccess
= params
->create
.sharing
;
221 irpsp
->Parameters
.Create
.FileAttributes
= 0;
222 irpsp
->Parameters
.Create
.EaLength
= 0;
224 irp
->Tail
.Overlay
.OriginalFileObject
= file
;
225 irp
->RequestorMode
= UserMode
;
226 irp
->AssociatedIrp
.SystemBuffer
= NULL
;
227 irp
->UserBuffer
= NULL
;
228 irp
->UserIosb
= irp_handle
; /* note: we abuse UserIosb to store the server irp handle */
229 irp
->UserEvent
= NULL
;
231 if (!device
->DriverObject
->MajorFunction
[IRP_MJ_CLOSE
])
233 irp
->IoStatus
.u
.Status
= STATUS_SUCCESS
;
234 IoCompleteRequest( irp
, IO_NO_INCREMENT
);
236 else dispatch_irp( device
, irp
);
238 HeapFree( GetProcessHeap(), 0, file
); /* FIXME: async close processing not supported */
239 return STATUS_SUCCESS
;
242 /* process a read request for a given device */
243 static NTSTATUS
dispatch_read( const irp_params_t
*params
, void *in_buff
, ULONG in_size
,
244 ULONG out_size
, HANDLE irp_handle
)
248 LARGE_INTEGER offset
;
249 IO_STACK_LOCATION
*irpsp
;
250 DEVICE_OBJECT
*device
;
251 FILE_OBJECT
*file
= wine_server_get_ptr( params
->read
.file
);
253 if (!file
) return STATUS_INVALID_HANDLE
;
255 device
= file
->DeviceObject
;
256 if (!device
->DriverObject
->MajorFunction
[IRP_MJ_READ
]) return STATUS_NOT_SUPPORTED
;
258 TRACE( "device %p file %p size %u\n", device
, file
, out_size
);
260 if (!(out_buff
= HeapAlloc( GetProcessHeap(), 0, out_size
))) return STATUS_NO_MEMORY
;
262 offset
.QuadPart
= params
->read
.pos
;
264 /* note: we abuse UserIosb to store the server irp handle */
265 if (!(irp
= IoBuildSynchronousFsdRequest( IRP_MJ_READ
, device
, out_buff
, out_size
,
266 &offset
, NULL
, irp_handle
)))
268 HeapFree( GetProcessHeap(), 0, out_buff
);
269 return STATUS_NO_MEMORY
;
272 irp
->Tail
.Overlay
.OriginalFileObject
= file
;
273 irp
->RequestorMode
= UserMode
;
275 irpsp
= IoGetNextIrpStackLocation( irp
);
276 irpsp
->Parameters
.Read
.Key
= params
->read
.key
;
278 return dispatch_irp( device
, irp
);
281 /* process a write request for a given device */
282 static NTSTATUS
dispatch_write( const irp_params_t
*params
, void *in_buff
, ULONG in_size
,
283 ULONG out_size
, HANDLE irp_handle
)
286 LARGE_INTEGER offset
;
287 IO_STACK_LOCATION
*irpsp
;
288 DEVICE_OBJECT
*device
;
289 FILE_OBJECT
*file
= wine_server_get_ptr( params
->write
.file
);
291 if (!file
) return STATUS_INVALID_HANDLE
;
293 device
= file
->DeviceObject
;
294 if (!device
->DriverObject
->MajorFunction
[IRP_MJ_WRITE
]) return STATUS_NOT_SUPPORTED
;
296 TRACE( "device %p file %p size %u\n", device
, file
, in_size
);
298 offset
.QuadPart
= params
->write
.pos
;
300 /* note: we abuse UserIosb to store the server irp handle */
301 if (!(irp
= IoBuildSynchronousFsdRequest( IRP_MJ_WRITE
, device
, in_buff
, in_size
,
302 &offset
, NULL
, irp_handle
)))
303 return STATUS_NO_MEMORY
;
305 irp
->Tail
.Overlay
.OriginalFileObject
= file
;
306 irp
->RequestorMode
= UserMode
;
308 irpsp
= IoGetNextIrpStackLocation( irp
);
309 irpsp
->Parameters
.Write
.Key
= params
->write
.key
;
311 return dispatch_irp( device
, irp
);
314 /* process a flush request for a given device */
315 static NTSTATUS
dispatch_flush( const irp_params_t
*params
, void *in_buff
, ULONG in_size
,
316 ULONG out_size
, HANDLE irp_handle
)
319 DEVICE_OBJECT
*device
;
320 FILE_OBJECT
*file
= wine_server_get_ptr( params
->flush
.file
);
322 if (!file
) return STATUS_INVALID_HANDLE
;
324 device
= file
->DeviceObject
;
325 if (!device
->DriverObject
->MajorFunction
[IRP_MJ_FLUSH_BUFFERS
]) return STATUS_NOT_SUPPORTED
;
327 TRACE( "device %p file %p\n", device
, file
);
329 /* note: we abuse UserIosb to store the server irp handle */
330 if (!(irp
= IoBuildSynchronousFsdRequest( IRP_MJ_FLUSH_BUFFERS
, device
, in_buff
, in_size
,
331 NULL
, NULL
, irp_handle
)))
332 return STATUS_NO_MEMORY
;
334 irp
->Tail
.Overlay
.OriginalFileObject
= file
;
335 irp
->RequestorMode
= UserMode
;
337 return dispatch_irp( device
, irp
);
340 /* process an ioctl request for a given device */
341 static NTSTATUS
dispatch_ioctl( const irp_params_t
*params
, void *in_buff
, ULONG in_size
,
342 ULONG out_size
, HANDLE irp_handle
)
345 void *out_buff
= NULL
;
346 DEVICE_OBJECT
*device
;
347 FILE_OBJECT
*file
= wine_server_get_ptr( params
->ioctl
.file
);
349 if (!file
) return STATUS_INVALID_HANDLE
;
351 device
= file
->DeviceObject
;
352 if (!device
->DriverObject
->MajorFunction
[IRP_MJ_DEVICE_CONTROL
]) return STATUS_NOT_SUPPORTED
;
354 TRACE( "ioctl %x device %p file %p in_size %u out_size %u\n",
355 params
->ioctl
.code
, device
, file
, in_size
, out_size
);
357 if ((params
->ioctl
.code
& 3) == METHOD_BUFFERED
) out_size
= max( in_size
, out_size
);
361 if (!(out_buff
= HeapAlloc( GetProcessHeap(), 0, out_size
))) return STATUS_NO_MEMORY
;
362 if ((params
->ioctl
.code
& 3) == METHOD_BUFFERED
)
364 memcpy( out_buff
, in_buff
, in_size
);
369 /* note: we abuse UserIosb to store the server handle to the ioctl */
370 irp
= IoBuildDeviceIoControlRequest( params
->ioctl
.code
, device
, in_buff
, in_size
, out_buff
, out_size
,
371 FALSE
, NULL
, irp_handle
);
374 HeapFree( GetProcessHeap(), 0, out_buff
);
375 return STATUS_NO_MEMORY
;
378 irp
->Tail
.Overlay
.OriginalFileObject
= file
;
379 irp
->RequestorMode
= UserMode
;
381 return dispatch_irp( device
, irp
);
384 typedef NTSTATUS (*dispatch_func
)( const irp_params_t
*params
, void *in_buff
, ULONG in_size
,
385 ULONG out_size
, HANDLE irp_handle
);
387 static const dispatch_func dispatch_funcs
[IRP_MJ_MAXIMUM_FUNCTION
+ 1] =
389 dispatch_create
, /* IRP_MJ_CREATE */
390 NULL
, /* IRP_MJ_CREATE_NAMED_PIPE */
391 dispatch_close
, /* IRP_MJ_CLOSE */
392 dispatch_read
, /* IRP_MJ_READ */
393 dispatch_write
, /* IRP_MJ_WRITE */
394 NULL
, /* IRP_MJ_QUERY_INFORMATION */
395 NULL
, /* IRP_MJ_SET_INFORMATION */
396 NULL
, /* IRP_MJ_QUERY_EA */
397 NULL
, /* IRP_MJ_SET_EA */
398 dispatch_flush
, /* IRP_MJ_FLUSH_BUFFERS */
399 NULL
, /* IRP_MJ_QUERY_VOLUME_INFORMATION */
400 NULL
, /* IRP_MJ_SET_VOLUME_INFORMATION */
401 NULL
, /* IRP_MJ_DIRECTORY_CONTROL */
402 NULL
, /* IRP_MJ_FILE_SYSTEM_CONTROL */
403 dispatch_ioctl
, /* IRP_MJ_DEVICE_CONTROL */
404 NULL
, /* IRP_MJ_INTERNAL_DEVICE_CONTROL */
405 NULL
, /* IRP_MJ_SHUTDOWN */
406 NULL
, /* IRP_MJ_LOCK_CONTROL */
407 NULL
, /* IRP_MJ_CLEANUP */
408 NULL
, /* IRP_MJ_CREATE_MAILSLOT */
409 NULL
, /* IRP_MJ_QUERY_SECURITY */
410 NULL
, /* IRP_MJ_SET_SECURITY */
411 NULL
, /* IRP_MJ_POWER */
412 NULL
, /* IRP_MJ_SYSTEM_CONTROL */
413 NULL
, /* IRP_MJ_DEVICE_CHANGE */
414 NULL
, /* IRP_MJ_QUERY_QUOTA */
415 NULL
, /* IRP_MJ_SET_QUOTA */
416 NULL
, /* IRP_MJ_PNP */
420 /***********************************************************************
421 * wine_ntoskrnl_main_loop (Not a Windows API)
423 NTSTATUS CDECL
wine_ntoskrnl_main_loop( HANDLE stop_event
)
425 HANDLE manager
= get_device_manager();
427 NTSTATUS status
= STATUS_SUCCESS
;
428 irp_params_t irp_params
;
430 ULONG in_size
= 4096, out_size
= 0;
433 request_thread
= GetCurrentThreadId();
435 if (!(in_buff
= HeapAlloc( GetProcessHeap(), 0, in_size
)))
437 ERR( "failed to allocate buffer\n" );
438 return STATUS_NO_MEMORY
;
441 handles
[0] = stop_event
;
442 handles
[1] = manager
;
446 SERVER_START_REQ( get_next_device_request
)
448 req
->manager
= wine_server_obj_handle( manager
);
449 req
->prev
= wine_server_obj_handle( irp
);
450 req
->status
= status
;
451 wine_server_set_reply( req
, in_buff
, in_size
);
452 if (!(status
= wine_server_call( req
)))
454 irp
= wine_server_ptr_handle( reply
->next
);
455 irp_params
= reply
->params
;
456 client_tid
= reply
->client_tid
;
457 client_pid
= reply
->client_pid
;
458 in_size
= reply
->in_size
;
459 out_size
= reply
->out_size
;
463 irp
= 0; /* no previous irp */
465 in_size
= reply
->in_size
;
473 if (irp_params
.major
> IRP_MJ_MAXIMUM_FUNCTION
|| !dispatch_funcs
[irp_params
.major
])
475 WARN( "unsupported request %u\n", irp_params
.major
);
476 status
= STATUS_NOT_SUPPORTED
;
479 status
= dispatch_funcs
[irp_params
.major
]( &irp_params
, in_buff
, in_size
, out_size
, irp
);
480 if (status
== STATUS_SUCCESS
) irp
= 0; /* status reported by IoCompleteRequest */
482 case STATUS_BUFFER_OVERFLOW
:
483 HeapFree( GetProcessHeap(), 0, in_buff
);
484 in_buff
= HeapAlloc( GetProcessHeap(), 0, in_size
);
485 /* restart with larger buffer */
490 DWORD ret
= WaitForMultipleObjectsEx( 2, handles
, FALSE
, INFINITE
, TRUE
);
491 if (ret
== WAIT_OBJECT_0
)
493 HeapFree( GetProcessHeap(), 0, in_buff
);
494 return STATUS_SUCCESS
;
496 if (ret
!= WAIT_IO_COMPLETION
) break;
504 /***********************************************************************
505 * IoAcquireCancelSpinLock (NTOSKRNL.EXE.@)
507 void WINAPI
IoAcquireCancelSpinLock(PKIRQL irql
)
509 FIXME("(%p): stub\n", irql
);
513 /***********************************************************************
514 * IoReleaseCancelSpinLock (NTOSKRNL.EXE.@)
516 void WINAPI
IoReleaseCancelSpinLock(PKIRQL irql
)
518 FIXME("(%p): stub\n", irql
);
522 /***********************************************************************
523 * IoAllocateDriverObjectExtension (NTOSKRNL.EXE.@)
525 NTSTATUS WINAPI
IoAllocateDriverObjectExtension( PDRIVER_OBJECT DriverObject
,
526 PVOID ClientIdentificationAddress
,
527 ULONG DriverObjectExtensionSize
,
528 PVOID
*DriverObjectExtension
)
530 FIXME( "stub: %p, %p, %u, %p\n", DriverObject
, ClientIdentificationAddress
,
531 DriverObjectExtensionSize
, DriverObjectExtension
);
532 return STATUS_NOT_IMPLEMENTED
;
536 /***********************************************************************
537 * IoGetDriverObjectExtension (NTOSKRNL.EXE.@)
539 PVOID WINAPI
IoGetDriverObjectExtension( PDRIVER_OBJECT DriverObject
,
540 PVOID ClientIdentificationAddress
)
542 FIXME( "stub: %p, %p\n", DriverObject
, ClientIdentificationAddress
);
547 /***********************************************************************
548 * IoInitializeIrp (NTOSKRNL.EXE.@)
550 void WINAPI
IoInitializeIrp( IRP
*irp
, USHORT size
, CCHAR stack_size
)
552 TRACE( "%p, %u, %d\n", irp
, size
, stack_size
);
554 RtlZeroMemory( irp
, size
);
556 irp
->Type
= IO_TYPE_IRP
;
558 InitializeListHead( &irp
->ThreadListEntry
);
559 irp
->StackCount
= stack_size
;
560 irp
->CurrentLocation
= stack_size
+ 1;
561 irp
->Tail
.Overlay
.s
.u2
.CurrentStackLocation
=
562 (PIO_STACK_LOCATION
)(irp
+ 1) + stack_size
;
566 /***********************************************************************
567 * IoInitializeTimer (NTOSKRNL.EXE.@)
569 NTSTATUS WINAPI
IoInitializeTimer(PDEVICE_OBJECT DeviceObject
,
570 PIO_TIMER_ROUTINE TimerRoutine
,
573 FIXME( "stub: %p, %p, %p\n", DeviceObject
, TimerRoutine
, Context
);
574 return STATUS_NOT_IMPLEMENTED
;
578 /***********************************************************************
579 * IoStartTimer (NTOSKRNL.EXE.@)
581 void WINAPI
IoStartTimer(PDEVICE_OBJECT DeviceObject
)
583 FIXME( "stub: %p\n", DeviceObject
);
587 /***********************************************************************
588 * IoAllocateIrp (NTOSKRNL.EXE.@)
590 PIRP WINAPI
IoAllocateIrp( CCHAR stack_size
, BOOLEAN charge_quota
)
595 TRACE( "%d, %d\n", stack_size
, charge_quota
);
597 size
= sizeof(IRP
) + stack_size
* sizeof(IO_STACK_LOCATION
);
598 irp
= ExAllocatePool( NonPagedPool
, size
);
601 IoInitializeIrp( irp
, size
, stack_size
);
602 irp
->AllocationFlags
= IRP_ALLOCATED_FIXED_SIZE
;
604 irp
->AllocationFlags
|= IRP_LOOKASIDE_ALLOCATION
;
609 /***********************************************************************
610 * IoFreeIrp (NTOSKRNL.EXE.@)
612 void WINAPI
IoFreeIrp( IRP
*irp
)
616 TRACE( "%p\n", irp
);
618 mdl
= irp
->MdlAddress
;
621 MDL
*next
= mdl
->Next
;
630 /***********************************************************************
631 * IoAllocateErrorLogEntry (NTOSKRNL.EXE.@)
633 PVOID WINAPI
IoAllocateErrorLogEntry( PVOID IoObject
, UCHAR EntrySize
)
635 FIXME( "stub: %p, %u\n", IoObject
, EntrySize
);
640 /***********************************************************************
641 * IoAllocateMdl (NTOSKRNL.EXE.@)
643 PMDL WINAPI
IoAllocateMdl( PVOID va
, ULONG length
, BOOLEAN secondary
, BOOLEAN charge_quota
, IRP
*irp
)
646 ULONG_PTR address
= (ULONG_PTR
)va
;
647 ULONG_PTR page_address
;
648 SIZE_T nb_pages
, mdl_size
;
650 TRACE("(%p, %u, %i, %i, %p)\n", va
, length
, secondary
, charge_quota
, irp
);
653 FIXME("Charge quota is not yet supported\n");
655 /* FIXME: We suppose that page size is 4096 */
656 page_address
= address
& ~(4096 - 1);
657 nb_pages
= (((address
+ length
- 1) & ~(4096 - 1)) - page_address
) / 4096 + 1;
659 mdl_size
= sizeof(MDL
) + nb_pages
* sizeof(PVOID
);
661 mdl
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, mdl_size
);
665 mdl
->Size
= mdl_size
;
666 mdl
->Process
= NULL
; /* FIXME: IoGetCurrentProcess */
667 mdl
->StartVa
= (PVOID
)page_address
;
668 mdl
->ByteCount
= length
;
669 mdl
->ByteOffset
= address
- page_address
;
671 if (!irp
) return mdl
;
673 if (secondary
) /* add it at the end */
675 MDL
**pmdl
= &irp
->MdlAddress
;
676 while (*pmdl
) pmdl
= &(*pmdl
)->Next
;
681 mdl
->Next
= irp
->MdlAddress
;
682 irp
->MdlAddress
= mdl
;
688 /***********************************************************************
689 * IoFreeMdl (NTOSKRNL.EXE.@)
691 void WINAPI
IoFreeMdl(PMDL mdl
)
694 HeapFree(GetProcessHeap(), 0, mdl
);
698 /***********************************************************************
699 * IoAllocateWorkItem (NTOSKRNL.EXE.@)
701 PIO_WORKITEM WINAPI
IoAllocateWorkItem( PDEVICE_OBJECT DeviceObject
)
703 FIXME( "stub: %p\n", DeviceObject
);
708 /***********************************************************************
709 * IoAttachDeviceToDeviceStack (NTOSKRNL.EXE.@)
711 PDEVICE_OBJECT WINAPI
IoAttachDeviceToDeviceStack( DEVICE_OBJECT
*source
,
712 DEVICE_OBJECT
*target
)
714 TRACE( "%p, %p\n", source
, target
);
715 target
->AttachedDevice
= source
;
716 source
->StackSize
= target
->StackSize
+ 1;
721 /***********************************************************************
722 * IoBuildDeviceIoControlRequest (NTOSKRNL.EXE.@)
724 PIRP WINAPI
IoBuildDeviceIoControlRequest( ULONG code
, PDEVICE_OBJECT device
,
725 PVOID in_buff
, ULONG in_len
,
726 PVOID out_buff
, ULONG out_len
,
727 BOOLEAN internal
, PKEVENT event
,
728 PIO_STATUS_BLOCK iosb
)
731 PIO_STACK_LOCATION irpsp
;
733 TRACE( "%x, %p, %p, %u, %p, %u, %u, %p, %p\n",
734 code
, device
, in_buff
, in_len
, out_buff
, out_len
, internal
, event
, iosb
);
739 irp
= IoAllocateIrp( device
->StackSize
, FALSE
);
743 irpsp
= IoGetNextIrpStackLocation( irp
);
744 irpsp
->MajorFunction
= internal
? IRP_MJ_INTERNAL_DEVICE_CONTROL
: IRP_MJ_DEVICE_CONTROL
;
745 irpsp
->Parameters
.DeviceIoControl
.IoControlCode
= code
;
746 irpsp
->Parameters
.DeviceIoControl
.InputBufferLength
= in_len
;
747 irpsp
->Parameters
.DeviceIoControl
.OutputBufferLength
= out_len
;
748 irpsp
->DeviceObject
= device
;
749 irpsp
->CompletionRoutine
= NULL
;
753 case METHOD_BUFFERED
:
754 irp
->AssociatedIrp
.SystemBuffer
= in_buff
;
756 case METHOD_IN_DIRECT
:
757 case METHOD_OUT_DIRECT
:
758 irp
->AssociatedIrp
.SystemBuffer
= in_buff
;
759 IoAllocateMdl( out_buff
, out_len
, FALSE
, FALSE
, irp
);
762 irpsp
->Parameters
.DeviceIoControl
.Type3InputBuffer
= in_buff
;
766 irp
->RequestorMode
= KernelMode
;
767 irp
->UserBuffer
= out_buff
;
768 irp
->UserIosb
= iosb
;
769 irp
->UserEvent
= event
;
774 /**********************************************************
775 * IoBuildSynchronousFsdRequest (NTOSKRNL.EXE.@)
777 PIRP WINAPI
IoBuildSynchronousFsdRequest(ULONG majorfunc
, PDEVICE_OBJECT device
,
778 PVOID buffer
, ULONG length
, PLARGE_INTEGER startoffset
,
779 PKEVENT event
, PIO_STATUS_BLOCK iosb
)
782 PIO_STACK_LOCATION irpsp
;
784 TRACE("(%d %p %p %d %p %p %p)\n", majorfunc
, device
, buffer
, length
, startoffset
, event
, iosb
);
786 if (!(irp
= IoAllocateIrp( device
->StackSize
, FALSE
))) return NULL
;
788 irpsp
= IoGetNextIrpStackLocation( irp
);
789 irpsp
->MajorFunction
= majorfunc
;
790 irpsp
->DeviceObject
= device
;
791 irpsp
->CompletionRoutine
= NULL
;
793 irp
->AssociatedIrp
.SystemBuffer
= buffer
;
794 if (device
->Flags
& DO_DIRECT_IO
) IoAllocateMdl( buffer
, length
, FALSE
, FALSE
, irp
);
799 irpsp
->Parameters
.Read
.Length
= length
;
800 irpsp
->Parameters
.Read
.ByteOffset
= *startoffset
;
803 irpsp
->Parameters
.Write
.Length
= length
;
804 irpsp
->Parameters
.Write
.ByteOffset
= *startoffset
;
807 irp
->RequestorMode
= KernelMode
;
808 irp
->UserIosb
= iosb
;
809 irp
->UserEvent
= event
;
810 irp
->UserBuffer
= buffer
;
815 /***********************************************************************
816 * IoCreateDriver (NTOSKRNL.EXE.@)
818 NTSTATUS WINAPI
IoCreateDriver( UNICODE_STRING
*name
, PDRIVER_INITIALIZE init
)
820 DRIVER_OBJECT
*driver
;
821 DRIVER_EXTENSION
*extension
;
824 TRACE("(%s, %p)\n", debugstr_us(name
), init
);
826 if (!(driver
= RtlAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY
,
827 sizeof(*driver
) + sizeof(*extension
) )))
828 return STATUS_NO_MEMORY
;
830 if ((status
= RtlDuplicateUnicodeString( 1, name
, &driver
->DriverName
)))
832 RtlFreeHeap( GetProcessHeap(), 0, driver
);
836 extension
= (DRIVER_EXTENSION
*)(driver
+ 1);
837 driver
->Size
= sizeof(*driver
);
838 driver
->DriverInit
= init
;
839 driver
->DriverExtension
= extension
;
840 extension
->DriverObject
= driver
;
841 extension
->ServiceKeyName
= driver
->DriverName
;
843 status
= driver
->DriverInit( driver
, name
);
847 RtlFreeUnicodeString( &driver
->DriverName
);
848 RtlFreeHeap( GetProcessHeap(), 0, driver
);
854 /***********************************************************************
855 * IoDeleteDriver (NTOSKRNL.EXE.@)
857 void WINAPI
IoDeleteDriver( DRIVER_OBJECT
*driver
)
859 TRACE("(%p)\n", driver
);
861 RtlFreeUnicodeString( &driver
->DriverName
);
862 RtlFreeHeap( GetProcessHeap(), 0, driver
);
866 /***********************************************************************
867 * IoCreateDevice (NTOSKRNL.EXE.@)
869 NTSTATUS WINAPI
IoCreateDevice( DRIVER_OBJECT
*driver
, ULONG ext_size
,
870 UNICODE_STRING
*name
, DEVICE_TYPE type
,
871 ULONG characteristics
, BOOLEAN exclusive
,
872 DEVICE_OBJECT
**ret_device
)
875 DEVICE_OBJECT
*device
;
877 HANDLE manager
= get_device_manager();
879 TRACE( "(%p, %u, %s, %u, %x, %u, %p)\n",
880 driver
, ext_size
, debugstr_us(name
), type
, characteristics
, exclusive
, ret_device
);
882 if (!(device
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*device
) + ext_size
)))
883 return STATUS_NO_MEMORY
;
885 SERVER_START_REQ( create_device
)
890 req
->manager
= wine_server_obj_handle( manager
);
891 req
->user_ptr
= wine_server_client_ptr( device
);
892 if (name
) wine_server_add_data( req
, name
->Buffer
, name
->Length
);
893 if (!(status
= wine_server_call( req
))) handle
= wine_server_ptr_handle( reply
->handle
);
897 if (status
== STATUS_SUCCESS
)
899 device
->DriverObject
= driver
;
900 device
->DeviceExtension
= device
+ 1;
901 device
->DeviceType
= type
;
902 device
->StackSize
= 1;
903 device
->Reserved
= handle
;
905 device
->NextDevice
= driver
->DeviceObject
;
906 driver
->DeviceObject
= device
;
908 *ret_device
= device
;
910 else HeapFree( GetProcessHeap(), 0, device
);
916 /***********************************************************************
917 * IoDeleteDevice (NTOSKRNL.EXE.@)
919 void WINAPI
IoDeleteDevice( DEVICE_OBJECT
*device
)
923 TRACE( "%p\n", device
);
925 SERVER_START_REQ( delete_device
)
927 req
->handle
= wine_server_obj_handle( device
->Reserved
);
928 status
= wine_server_call( req
);
932 if (status
== STATUS_SUCCESS
)
934 DEVICE_OBJECT
**prev
= &device
->DriverObject
->DeviceObject
;
935 while (*prev
&& *prev
!= device
) prev
= &(*prev
)->NextDevice
;
936 if (*prev
) *prev
= (*prev
)->NextDevice
;
937 NtClose( device
->Reserved
);
938 HeapFree( GetProcessHeap(), 0, device
);
943 /***********************************************************************
944 * IoCreateSymbolicLink (NTOSKRNL.EXE.@)
946 NTSTATUS WINAPI
IoCreateSymbolicLink( UNICODE_STRING
*name
, UNICODE_STRING
*target
)
949 OBJECT_ATTRIBUTES attr
;
951 attr
.Length
= sizeof(attr
);
952 attr
.RootDirectory
= 0;
953 attr
.ObjectName
= name
;
954 attr
.Attributes
= OBJ_CASE_INSENSITIVE
| OBJ_OPENIF
;
955 attr
.SecurityDescriptor
= NULL
;
956 attr
.SecurityQualityOfService
= NULL
;
958 TRACE( "%s -> %s\n", debugstr_us(name
), debugstr_us(target
) );
959 /* FIXME: store handle somewhere */
960 return NtCreateSymbolicLinkObject( &handle
, SYMBOLIC_LINK_ALL_ACCESS
, &attr
, target
);
964 /***********************************************************************
965 * IoDeleteSymbolicLink (NTOSKRNL.EXE.@)
967 NTSTATUS WINAPI
IoDeleteSymbolicLink( UNICODE_STRING
*name
)
970 OBJECT_ATTRIBUTES attr
;
973 attr
.Length
= sizeof(attr
);
974 attr
.RootDirectory
= 0;
975 attr
.ObjectName
= name
;
976 attr
.Attributes
= OBJ_CASE_INSENSITIVE
;
977 attr
.SecurityDescriptor
= NULL
;
978 attr
.SecurityQualityOfService
= NULL
;
980 if (!(status
= NtOpenSymbolicLinkObject( &handle
, 0, &attr
)))
982 SERVER_START_REQ( unlink_object
)
984 req
->handle
= wine_server_obj_handle( handle
);
985 status
= wine_server_call( req
);
994 /***********************************************************************
995 * IoGetDeviceInterfaces (NTOSKRNL.EXE.@)
997 NTSTATUS WINAPI
IoGetDeviceInterfaces( const GUID
*InterfaceClassGuid
,
998 PDEVICE_OBJECT PhysicalDeviceObject
,
999 ULONG Flags
, PWSTR
*SymbolicLinkList
)
1001 FIXME( "stub: %s %p %x %p\n", debugstr_guid(InterfaceClassGuid
),
1002 PhysicalDeviceObject
, Flags
, SymbolicLinkList
);
1003 return STATUS_NOT_IMPLEMENTED
;
1007 /***********************************************************************
1008 * IoGetDeviceObjectPointer (NTOSKRNL.EXE.@)
1010 NTSTATUS WINAPI
IoGetDeviceObjectPointer( UNICODE_STRING
*name
, ACCESS_MASK access
, PFILE_OBJECT
*file
, PDEVICE_OBJECT
*device
)
1012 static DEVICE_OBJECT stub_device
;
1013 static DRIVER_OBJECT stub_driver
;
1015 FIXME( "stub: %s %x %p %p\n", debugstr_us(name
), access
, file
, device
);
1017 stub_device
.StackSize
= 0x80; /* minimum value to appease SecuROM 5.x */
1018 stub_device
.DriverObject
= &stub_driver
;
1021 *device
= &stub_device
;
1023 return STATUS_SUCCESS
;
1026 /***********************************************************************
1027 * IoGetAttachedDevice (NTOSKRNL.EXE.@)
1029 PDEVICE_OBJECT WINAPI
IoGetAttachedDevice( PDEVICE_OBJECT device
)
1031 FIXME( "stub: %p\n", device
);
1036 /***********************************************************************
1037 * IoGetDeviceProperty (NTOSKRNL.EXE.@)
1039 NTSTATUS WINAPI
IoGetDeviceProperty( DEVICE_OBJECT
*device
, DEVICE_REGISTRY_PROPERTY device_property
,
1040 ULONG buffer_length
, PVOID property_buffer
, PULONG result_length
)
1042 FIXME( "%p %d %u %p %p: stub\n", device
, device_property
, buffer_length
,
1043 property_buffer
, result_length
);
1044 return STATUS_NOT_IMPLEMENTED
;
1048 /***********************************************************************
1049 * IoCallDriver (NTOSKRNL.EXE.@)
1051 NTSTATUS WINAPI
IoCallDriver( DEVICE_OBJECT
*device
, IRP
*irp
)
1053 PDRIVER_DISPATCH dispatch
;
1054 IO_STACK_LOCATION
*irpsp
;
1057 --irp
->CurrentLocation
;
1058 irpsp
= --irp
->Tail
.Overlay
.s
.u2
.CurrentStackLocation
;
1059 dispatch
= device
->DriverObject
->MajorFunction
[irpsp
->MajorFunction
];
1061 if (TRACE_ON(relay
))
1062 DPRINTF( "%04x:Call driver dispatch %p (device=%p,irp=%p)\n",
1063 GetCurrentThreadId(), dispatch
, device
, irp
);
1065 status
= dispatch( device
, irp
);
1067 if (TRACE_ON(relay
))
1068 DPRINTF( "%04x:Ret driver dispatch %p (device=%p,irp=%p) retval=%08x\n",
1069 GetCurrentThreadId(), dispatch
, device
, irp
, status
);
1075 /***********************************************************************
1076 * IofCallDriver (NTOSKRNL.EXE.@)
1078 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
1079 DEFINE_FASTCALL2_ENTRYPOINT( IofCallDriver
)
1080 NTSTATUS WINAPI
__regs_IofCallDriver( DEVICE_OBJECT
*device
, IRP
*irp
)
1082 NTSTATUS WINAPI
IofCallDriver( DEVICE_OBJECT
*device
, IRP
*irp
)
1085 TRACE( "%p %p\n", device
, irp
);
1086 return IoCallDriver( device
, irp
);
1090 /***********************************************************************
1091 * IoGetRelatedDeviceObject (NTOSKRNL.EXE.@)
1093 PDEVICE_OBJECT WINAPI
IoGetRelatedDeviceObject( PFILE_OBJECT obj
)
1095 FIXME( "stub: %p\n", obj
);
1099 static CONFIGURATION_INFORMATION configuration_information
;
1101 /***********************************************************************
1102 * IoGetConfigurationInformation (NTOSKRNL.EXE.@)
1104 PCONFIGURATION_INFORMATION WINAPI
IoGetConfigurationInformation(void)
1106 FIXME( "partial stub\n" );
1107 /* FIXME: return actual devices on system */
1108 return &configuration_information
;
1112 /***********************************************************************
1113 * IoIsWdmVersionAvailable (NTOSKRNL.EXE.@)
1115 NTSTATUS WINAPI
IoIsWdmVersionAvailable(UCHAR MajorVersion
, UCHAR MinorVersion
)
1121 TRACE( "%d, 0x%X\n", MajorVersion
, MinorVersion
);
1123 version
= GetVersion();
1124 major
= LOBYTE(version
);
1125 minor
= HIBYTE(LOWORD(version
));
1127 if (MajorVersion
== 6 && MinorVersion
== 0)
1129 /* Windows Vista, Windows Server 2008, Windows 7 */
1131 else if (MajorVersion
== 1)
1133 if (MinorVersion
== 0x30)
1135 /* Windows server 2003 */
1139 else if (MinorVersion
== 0x20)
1145 else if (MinorVersion
== 0x10)
1151 else if (MinorVersion
== 0x05)
1155 MinorVersion
= 0x5a;
1157 else if (MinorVersion
== 0x00)
1161 MinorVersion
= 0x0a;
1165 FIXME( "unknown major %d minor 0x%X\n", MajorVersion
, MinorVersion
);
1171 FIXME( "unknown major %d minor 0x%X\n", MajorVersion
, MinorVersion
);
1174 return major
> MajorVersion
|| (major
== MajorVersion
&& minor
>= MinorVersion
);
1178 /***********************************************************************
1179 * IoQueryDeviceDescription (NTOSKRNL.EXE.@)
1181 NTSTATUS WINAPI
IoQueryDeviceDescription(PINTERFACE_TYPE itype
, PULONG bus
, PCONFIGURATION_TYPE ctype
,
1182 PULONG cnum
, PCONFIGURATION_TYPE ptype
, PULONG pnum
,
1183 PIO_QUERY_DEVICE_ROUTINE callout
, PVOID context
)
1185 FIXME( "(%p %p %p %p %p %p %p %p)\n", itype
, bus
, ctype
, cnum
, ptype
, pnum
, callout
, context
);
1186 return STATUS_NOT_IMPLEMENTED
;
1190 /***********************************************************************
1191 * IoRegisterDriverReinitialization (NTOSKRNL.EXE.@)
1193 void WINAPI
IoRegisterDriverReinitialization( PDRIVER_OBJECT obj
, PDRIVER_REINITIALIZE reinit
, PVOID context
)
1195 FIXME( "stub: %p %p %p\n", obj
, reinit
, context
);
1199 /***********************************************************************
1200 * IoRegisterShutdownNotification (NTOSKRNL.EXE.@)
1202 NTSTATUS WINAPI
IoRegisterShutdownNotification( PDEVICE_OBJECT obj
)
1204 FIXME( "stub: %p\n", obj
);
1205 return STATUS_SUCCESS
;
1209 /***********************************************************************
1210 * IoUnregisterShutdownNotification (NTOSKRNL.EXE.@)
1212 VOID WINAPI
IoUnregisterShutdownNotification( PDEVICE_OBJECT obj
)
1214 FIXME( "stub: %p\n", obj
);
1218 /***********************************************************************
1219 * IoReportResourceUsage (NTOSKRNL.EXE.@)
1221 NTSTATUS WINAPI
IoReportResourceUsage(PUNICODE_STRING name
, PDRIVER_OBJECT drv_obj
, PCM_RESOURCE_LIST drv_list
,
1222 ULONG drv_size
, PDRIVER_OBJECT dev_obj
, PCM_RESOURCE_LIST dev_list
,
1223 ULONG dev_size
, BOOLEAN overwrite
, PBOOLEAN detected
)
1225 FIXME("(%s %p %p %u %p %p %u %d %p) stub\n", debugstr_w(name
? name
->Buffer
: NULL
),
1226 drv_obj
, drv_list
, drv_size
, dev_obj
, dev_list
, dev_size
, overwrite
, detected
);
1227 return STATUS_NOT_IMPLEMENTED
;
1231 /***********************************************************************
1232 * IoCompleteRequest (NTOSKRNL.EXE.@)
1234 VOID WINAPI
IoCompleteRequest( IRP
*irp
, UCHAR priority_boost
)
1236 IO_STACK_LOCATION
*irpsp
;
1237 PIO_COMPLETION_ROUTINE routine
;
1238 NTSTATUS status
, stat
;
1242 TRACE( "%p %u\n", irp
, priority_boost
);
1244 status
= irp
->IoStatus
.u
.Status
;
1245 while (irp
->CurrentLocation
<= irp
->StackCount
)
1247 irpsp
= irp
->Tail
.Overlay
.s
.u2
.CurrentStackLocation
;
1248 routine
= irpsp
->CompletionRoutine
;
1250 /* FIXME: add SL_INVOKE_ON_CANCEL support */
1253 if ((irpsp
->Control
& SL_INVOKE_ON_SUCCESS
) && STATUS_SUCCESS
== status
)
1255 if ((irpsp
->Control
& SL_INVOKE_ON_ERROR
) && STATUS_SUCCESS
!= status
)
1258 ++irp
->CurrentLocation
;
1259 ++irp
->Tail
.Overlay
.s
.u2
.CurrentStackLocation
;
1262 TRACE( "calling %p( %p, %p, %p )\n", routine
,
1263 irpsp
->DeviceObject
, irp
, irpsp
->Context
);
1264 stat
= routine( irpsp
->DeviceObject
, irp
, irpsp
->Context
);
1265 TRACE( "CompletionRoutine returned %x\n", stat
);
1266 if (STATUS_MORE_PROCESSING_REQUIRED
== stat
)
1271 handle
= (HANDLE
)irp
->UserIosb
;
1274 HANDLE manager
= get_device_manager();
1275 void *out_buff
= irp
->UserBuffer
;
1276 FILE_OBJECT
*file
= irp
->Tail
.Overlay
.OriginalFileObject
;
1278 SERVER_START_REQ( set_irp_result
)
1280 req
->manager
= wine_server_obj_handle( manager
);
1281 req
->handle
= wine_server_obj_handle( handle
);
1282 req
->status
= irp
->IoStatus
.u
.Status
;
1283 req
->file_ptr
= wine_server_client_ptr( file
);
1284 if (irp
->IoStatus
.u
.Status
>= 0)
1286 req
->size
= irp
->IoStatus
.Information
;
1287 if (out_buff
) wine_server_add_data( req
, out_buff
, irp
->IoStatus
.Information
);
1289 wine_server_call( req
);
1292 HeapFree( GetProcessHeap(), 0, out_buff
);
1299 /***********************************************************************
1300 * IofCompleteRequest (NTOSKRNL.EXE.@)
1302 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
1303 DEFINE_FASTCALL2_ENTRYPOINT( IofCompleteRequest
)
1304 void WINAPI
__regs_IofCompleteRequest( IRP
*irp
, UCHAR priority_boost
)
1306 void WINAPI
IofCompleteRequest( IRP
*irp
, UCHAR priority_boost
)
1309 TRACE( "%p %u\n", irp
, priority_boost
);
1310 IoCompleteRequest( irp
, priority_boost
);
1314 /***********************************************************************
1315 * InterlockedCompareExchange (NTOSKRNL.EXE.@)
1317 #ifdef DEFINE_FASTCALL3_ENTRYPOINT
1318 DEFINE_FASTCALL3_ENTRYPOINT( NTOSKRNL_InterlockedCompareExchange
)
1319 LONG WINAPI
__regs_NTOSKRNL_InterlockedCompareExchange( LONG
volatile *dest
, LONG xchg
, LONG compare
)
1321 LONG WINAPI
NTOSKRNL_InterlockedCompareExchange( LONG
volatile *dest
, LONG xchg
, LONG compare
)
1324 return InterlockedCompareExchange( dest
, xchg
, compare
);
1328 /***********************************************************************
1329 * InterlockedDecrement (NTOSKRNL.EXE.@)
1331 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
1332 DEFINE_FASTCALL1_ENTRYPOINT( NTOSKRNL_InterlockedDecrement
)
1333 LONG WINAPI
__regs_NTOSKRNL_InterlockedDecrement( LONG
volatile *dest
)
1335 LONG WINAPI
NTOSKRNL_InterlockedDecrement( LONG
volatile *dest
)
1338 return InterlockedDecrement( dest
);
1342 /***********************************************************************
1343 * InterlockedExchange (NTOSKRNL.EXE.@)
1345 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
1346 DEFINE_FASTCALL2_ENTRYPOINT( NTOSKRNL_InterlockedExchange
)
1347 LONG WINAPI
__regs_NTOSKRNL_InterlockedExchange( LONG
volatile *dest
, LONG val
)
1349 LONG WINAPI
NTOSKRNL_InterlockedExchange( LONG
volatile *dest
, LONG val
)
1352 return InterlockedExchange( dest
, val
);
1356 /***********************************************************************
1357 * InterlockedExchangeAdd (NTOSKRNL.EXE.@)
1359 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
1360 DEFINE_FASTCALL2_ENTRYPOINT( NTOSKRNL_InterlockedExchangeAdd
)
1361 LONG WINAPI
__regs_NTOSKRNL_InterlockedExchangeAdd( LONG
volatile *dest
, LONG incr
)
1363 LONG WINAPI
NTOSKRNL_InterlockedExchangeAdd( LONG
volatile *dest
, LONG incr
)
1366 return InterlockedExchangeAdd( dest
, incr
);
1370 /***********************************************************************
1371 * InterlockedIncrement (NTOSKRNL.EXE.@)
1373 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
1374 DEFINE_FASTCALL1_ENTRYPOINT( NTOSKRNL_InterlockedIncrement
)
1375 LONG WINAPI
__regs_NTOSKRNL_InterlockedIncrement( LONG
volatile *dest
)
1377 LONG WINAPI
NTOSKRNL_InterlockedIncrement( LONG
volatile *dest
)
1380 return InterlockedIncrement( dest
);
1384 /***********************************************************************
1385 * ExAllocatePool (NTOSKRNL.EXE.@)
1387 PVOID WINAPI
ExAllocatePool( POOL_TYPE type
, SIZE_T size
)
1389 return ExAllocatePoolWithTag( type
, size
, 0 );
1393 /***********************************************************************
1394 * ExAllocatePoolWithQuota (NTOSKRNL.EXE.@)
1396 PVOID WINAPI
ExAllocatePoolWithQuota( POOL_TYPE type
, SIZE_T size
)
1398 return ExAllocatePoolWithTag( type
, size
, 0 );
1402 /***********************************************************************
1403 * ExAllocatePoolWithTag (NTOSKRNL.EXE.@)
1405 PVOID WINAPI
ExAllocatePoolWithTag( POOL_TYPE type
, SIZE_T size
, ULONG tag
)
1407 /* FIXME: handle page alignment constraints */
1408 void *ret
= HeapAlloc( GetProcessHeap(), 0, size
);
1409 TRACE( "%lu pool %u -> %p\n", size
, type
, ret
);
1414 /***********************************************************************
1415 * ExAllocatePoolWithQuotaTag (NTOSKRNL.EXE.@)
1417 PVOID WINAPI
ExAllocatePoolWithQuotaTag( POOL_TYPE type
, SIZE_T size
, ULONG tag
)
1419 return ExAllocatePoolWithTag( type
, size
, tag
);
1423 /***********************************************************************
1424 * ExCreateCallback (NTOSKRNL.EXE.@)
1426 NTSTATUS WINAPI
ExCreateCallback(PCALLBACK_OBJECT
*obj
, POBJECT_ATTRIBUTES attr
,
1427 BOOLEAN create
, BOOLEAN allow_multiple
)
1429 FIXME("(%p, %p, %u, %u): stub\n", obj
, attr
, create
, allow_multiple
);
1431 return STATUS_NOT_IMPLEMENTED
;
1435 /***********************************************************************
1436 * ExFreePool (NTOSKRNL.EXE.@)
1438 void WINAPI
ExFreePool( void *ptr
)
1440 ExFreePoolWithTag( ptr
, 0 );
1444 /***********************************************************************
1445 * ExFreePoolWithTag (NTOSKRNL.EXE.@)
1447 void WINAPI
ExFreePoolWithTag( void *ptr
, ULONG tag
)
1449 TRACE( "%p\n", ptr
);
1450 HeapFree( GetProcessHeap(), 0, ptr
);
1454 /***********************************************************************
1455 * ExInitializeResourceLite (NTOSKRNL.EXE.@)
1457 NTSTATUS WINAPI
ExInitializeResourceLite(PERESOURCE Resource
)
1459 FIXME( "stub: %p\n", Resource
);
1460 return STATUS_NOT_IMPLEMENTED
;
1464 /***********************************************************************
1465 * ExInitializeNPagedLookasideList (NTOSKRNL.EXE.@)
1467 void WINAPI
ExInitializeNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside
,
1468 PALLOCATE_FUNCTION Allocate
,
1469 PFREE_FUNCTION Free
,
1475 FIXME( "stub: %p, %p, %p, %u, %lu, %u, %u\n", Lookaside
, Allocate
, Free
, Flags
, Size
, Tag
, Depth
);
1478 /***********************************************************************
1479 * ExInitializePagedLookasideList (NTOSKRNL.EXE.@)
1481 void WINAPI
ExInitializePagedLookasideList(PPAGED_LOOKASIDE_LIST Lookaside
,
1482 PALLOCATE_FUNCTION Allocate
,
1483 PFREE_FUNCTION Free
,
1489 FIXME( "stub: %p, %p, %p, %u, %lu, %u, %u\n", Lookaside
, Allocate
, Free
, Flags
, Size
, Tag
, Depth
);
1492 /***********************************************************************
1493 * ExInitializeZone (NTOSKRNL.EXE.@)
1495 NTSTATUS WINAPI
ExInitializeZone(PZONE_HEADER Zone
,
1497 PVOID InitialSegment
,
1498 ULONG InitialSegmentSize
)
1500 FIXME( "stub: %p, %u, %p, %u\n", Zone
, BlockSize
, InitialSegment
, InitialSegmentSize
);
1501 return STATUS_NOT_IMPLEMENTED
;
1504 /***********************************************************************
1505 * FsRtlRegisterUncProvider (NTOSKRNL.EXE.@)
1507 NTSTATUS WINAPI
FsRtlRegisterUncProvider(PHANDLE MupHandle
, PUNICODE_STRING RedirDevName
,
1508 BOOLEAN MailslotsSupported
)
1510 FIXME("(%p %p %d): stub\n", MupHandle
, RedirDevName
, MailslotsSupported
);
1511 return STATUS_NOT_IMPLEMENTED
;
1514 /***********************************************************************
1515 * IoGetCurrentProcess / PsGetCurrentProcess (NTOSKRNL.EXE.@)
1517 PEPROCESS WINAPI
IoGetCurrentProcess(void)
1523 /***********************************************************************
1524 * KeGetCurrentThread / PsGetCurrentThread (NTOSKRNL.EXE.@)
1526 PRKTHREAD WINAPI
KeGetCurrentThread(void)
1532 /***********************************************************************
1533 * KeInitializeEvent (NTOSKRNL.EXE.@)
1535 void WINAPI
KeInitializeEvent( PRKEVENT Event
, EVENT_TYPE Type
, BOOLEAN State
)
1537 FIXME( "stub: %p %d %d\n", Event
, Type
, State
);
1541 /***********************************************************************
1542 * KeInitializeMutex (NTOSKRNL.EXE.@)
1544 void WINAPI
KeInitializeMutex(PRKMUTEX Mutex
, ULONG Level
)
1546 FIXME( "stub: %p, %u\n", Mutex
, Level
);
1550 /***********************************************************************
1551 * KeWaitForMutexObject (NTOSKRNL.EXE.@)
1553 NTSTATUS WINAPI
KeWaitForMutexObject(PRKMUTEX Mutex
, KWAIT_REASON WaitReason
, KPROCESSOR_MODE WaitMode
,
1554 BOOLEAN Alertable
, PLARGE_INTEGER Timeout
)
1556 FIXME( "stub: %p, %d, %d, %d, %p\n", Mutex
, WaitReason
, WaitMode
, Alertable
, Timeout
);
1557 return STATUS_NOT_IMPLEMENTED
;
1561 /***********************************************************************
1562 * KeReleaseMutex (NTOSKRNL.EXE.@)
1564 LONG WINAPI
KeReleaseMutex(PRKMUTEX Mutex
, BOOLEAN Wait
)
1566 FIXME( "stub: %p, %d\n", Mutex
, Wait
);
1567 return STATUS_NOT_IMPLEMENTED
;
1571 /***********************************************************************
1572 * KeInitializeSemaphore (NTOSKRNL.EXE.@)
1574 void WINAPI
KeInitializeSemaphore( PRKSEMAPHORE Semaphore
, LONG Count
, LONG Limit
)
1576 FIXME( "(%p %d %d) stub\n", Semaphore
, Count
, Limit
);
1580 /***********************************************************************
1581 * KeInitializeSpinLock (NTOSKRNL.EXE.@)
1583 void WINAPI
KeInitializeSpinLock( PKSPIN_LOCK SpinLock
)
1585 FIXME( "stub: %p\n", SpinLock
);
1589 /***********************************************************************
1590 * KeInitializeTimerEx (NTOSKRNL.EXE.@)
1592 void WINAPI
KeInitializeTimerEx( PKTIMER Timer
, TIMER_TYPE Type
)
1594 FIXME( "stub: %p %d\n", Timer
, Type
);
1598 /***********************************************************************
1599 * KeInitializeTimer (NTOSKRNL.EXE.@)
1601 void WINAPI
KeInitializeTimer( PKTIMER Timer
)
1603 KeInitializeTimerEx(Timer
, NotificationTimer
);
1606 /***********************************************************************
1607 * KeInsertQueue (NTOSKRNL.EXE.@)
1609 LONG WINAPI
KeInsertQueue(PRKQUEUE Queue
, PLIST_ENTRY Entry
)
1611 FIXME( "stub: %p %p\n", Queue
, Entry
);
1615 /**********************************************************************
1616 * KeQueryActiveProcessors (NTOSKRNL.EXE.@)
1618 * Return the active Processors as bitmask
1621 * active Processors as bitmask
1624 KAFFINITY WINAPI
KeQueryActiveProcessors( void )
1626 DWORD_PTR AffinityMask
;
1628 GetProcessAffinityMask( GetCurrentProcess(), &AffinityMask
, NULL
);
1629 return AffinityMask
;
1633 /**********************************************************************
1634 * KeQueryInterruptTime (NTOSKRNL.EXE.@)
1636 * Return the interrupt time count
1639 ULONGLONG WINAPI
KeQueryInterruptTime( void )
1641 LARGE_INTEGER totaltime
;
1643 KeQueryTickCount(&totaltime
);
1644 return totaltime
.QuadPart
;
1648 /***********************************************************************
1649 * KeQuerySystemTime (NTOSKRNL.EXE.@)
1651 void WINAPI
KeQuerySystemTime( LARGE_INTEGER
*time
)
1653 NtQuerySystemTime( time
);
1657 /***********************************************************************
1658 * KeQueryTickCount (NTOSKRNL.EXE.@)
1660 void WINAPI
KeQueryTickCount( LARGE_INTEGER
*count
)
1662 count
->QuadPart
= NtGetTickCount();
1663 /* update the global variable too */
1664 KeTickCount
.LowPart
= count
->u
.LowPart
;
1665 KeTickCount
.High1Time
= count
->u
.HighPart
;
1666 KeTickCount
.High2Time
= count
->u
.HighPart
;
1670 /***********************************************************************
1671 * KeReleaseSemaphore (NTOSKRNL.EXE.@)
1673 LONG WINAPI
KeReleaseSemaphore( PRKSEMAPHORE Semaphore
, KPRIORITY Increment
,
1674 LONG Adjustment
, BOOLEAN Wait
)
1676 FIXME("(%p %d %d %d) stub\n", Semaphore
, Increment
, Adjustment
, Wait
);
1681 /***********************************************************************
1682 * KeQueryTimeIncrement (NTOSKRNL.EXE.@)
1684 ULONG WINAPI
KeQueryTimeIncrement(void)
1690 /***********************************************************************
1691 * KeResetEvent (NTOSKRNL.EXE.@)
1693 LONG WINAPI
KeResetEvent( PRKEVENT Event
)
1695 FIXME("(%p): stub\n", Event
);
1700 /***********************************************************************
1701 * KeSetEvent (NTOSKRNL.EXE.@)
1703 LONG WINAPI
KeSetEvent( PRKEVENT Event
, KPRIORITY Increment
, BOOLEAN Wait
)
1705 FIXME("(%p, %d, %d): stub\n", Event
, Increment
, Wait
);
1710 /***********************************************************************
1711 * KeSetPriorityThread (NTOSKRNL.EXE.@)
1713 KPRIORITY WINAPI
KeSetPriorityThread( PKTHREAD Thread
, KPRIORITY Priority
)
1715 FIXME("(%p %d)\n", Thread
, Priority
);
1719 /***********************************************************************
1720 * KeSetSystemAffinityThread (NTOSKRNL.EXE.@)
1722 VOID WINAPI
KeSetSystemAffinityThread(KAFFINITY Affinity
)
1724 FIXME("(%lx) stub\n", Affinity
);
1727 /***********************************************************************
1728 * KeWaitForSingleObject (NTOSKRNL.EXE.@)
1730 NTSTATUS WINAPI
KeWaitForSingleObject(PVOID Object
,
1731 KWAIT_REASON WaitReason
,
1732 KPROCESSOR_MODE WaitMode
,
1734 PLARGE_INTEGER Timeout
)
1736 FIXME( "stub: %p, %d, %d, %d, %p\n", Object
, WaitReason
, WaitMode
, Alertable
, Timeout
);
1737 return STATUS_NOT_IMPLEMENTED
;
1740 /***********************************************************************
1741 * IoRegisterFileSystem (NTOSKRNL.EXE.@)
1743 VOID WINAPI
IoRegisterFileSystem(PDEVICE_OBJECT DeviceObject
)
1745 FIXME("(%p): stub\n", DeviceObject
);
1748 /***********************************************************************
1749 * IoUnregisterFileSystem (NTOSKRNL.EXE.@)
1751 VOID WINAPI
IoUnregisterFileSystem(PDEVICE_OBJECT DeviceObject
)
1753 FIXME("(%p): stub\n", DeviceObject
);
1756 /***********************************************************************
1757 * MmAllocateNonCachedMemory (NTOSKRNL.EXE.@)
1759 PVOID WINAPI
MmAllocateNonCachedMemory( SIZE_T size
)
1761 TRACE( "%lu\n", size
);
1762 return VirtualAlloc( NULL
, size
, MEM_RESERVE
|MEM_COMMIT
, PAGE_READWRITE
|PAGE_NOCACHE
);
1765 /***********************************************************************
1766 * MmAllocateContiguousMemory (NTOSKRNL.EXE.@)
1768 PVOID WINAPI
MmAllocateContiguousMemory( SIZE_T size
, PHYSICAL_ADDRESS highest_valid_address
)
1770 FIXME( "%lu, %s stub\n", size
, wine_dbgstr_longlong(highest_valid_address
.QuadPart
) );
1774 /***********************************************************************
1775 * MmAllocateContiguousMemorySpecifyCache (NTOSKRNL.EXE.@)
1777 PVOID WINAPI
MmAllocateContiguousMemorySpecifyCache( SIZE_T size
,
1778 PHYSICAL_ADDRESS lowest_valid_address
,
1779 PHYSICAL_ADDRESS highest_valid_address
,
1780 PHYSICAL_ADDRESS BoundaryAddressMultiple
,
1781 MEMORY_CACHING_TYPE CacheType
)
1787 /***********************************************************************
1788 * MmAllocatePagesForMdl (NTOSKRNL.EXE.@)
1790 PMDL WINAPI
MmAllocatePagesForMdl(PHYSICAL_ADDRESS lowaddress
, PHYSICAL_ADDRESS highaddress
,
1791 PHYSICAL_ADDRESS skipbytes
, SIZE_T size
)
1793 FIXME("%s %s %s %lu: stub\n", wine_dbgstr_longlong(lowaddress
.QuadPart
), wine_dbgstr_longlong(highaddress
.QuadPart
),
1794 wine_dbgstr_longlong(skipbytes
.QuadPart
), size
);
1798 /***********************************************************************
1799 * MmFreeNonCachedMemory (NTOSKRNL.EXE.@)
1801 void WINAPI
MmFreeNonCachedMemory( void *addr
, SIZE_T size
)
1803 TRACE( "%p %lu\n", addr
, size
);
1804 VirtualFree( addr
, 0, MEM_RELEASE
);
1807 /***********************************************************************
1808 * MmIsAddressValid (NTOSKRNL.EXE.@)
1810 * Check if the process can access the virtual address without a pagefault
1813 * VirtualAddress [I] Address to check
1817 * Success: TRUE (Accessing the Address works without a Pagefault)
1820 BOOLEAN WINAPI
MmIsAddressValid(PVOID VirtualAddress
)
1822 TRACE("(%p)\n", VirtualAddress
);
1823 return !IsBadWritePtr(VirtualAddress
, 1);
1826 /***********************************************************************
1827 * MmMapIoSpace (NTOSKRNL.EXE.@)
1829 PVOID WINAPI
MmMapIoSpace( PHYSICAL_ADDRESS PhysicalAddress
, DWORD NumberOfBytes
, DWORD CacheType
)
1831 FIXME( "stub: 0x%08x%08x, %d, %d\n", PhysicalAddress
.u
.HighPart
, PhysicalAddress
.u
.LowPart
, NumberOfBytes
, CacheType
);
1836 /***********************************************************************
1837 * MmLockPagableSectionByHandle (NTOSKRNL.EXE.@)
1839 VOID WINAPI
MmLockPagableSectionByHandle(PVOID ImageSectionHandle
)
1841 FIXME("stub %p\n", ImageSectionHandle
);
1844 /***********************************************************************
1845 * MmMapLockedPagesSpecifyCache (NTOSKRNL.EXE.@)
1847 PVOID WINAPI
MmMapLockedPagesSpecifyCache(PMDLX MemoryDescriptorList
, KPROCESSOR_MODE AccessMode
, MEMORY_CACHING_TYPE CacheType
,
1848 PVOID BaseAddress
, ULONG BugCheckOnFailure
, MM_PAGE_PRIORITY Priority
)
1850 FIXME("(%p, %u, %u, %p, %u, %u): stub\n", MemoryDescriptorList
, AccessMode
, CacheType
, BaseAddress
, BugCheckOnFailure
, Priority
);
1855 /***********************************************************************
1856 * MmUnlockPagableImageSection (NTOSKRNL.EXE.@)
1858 VOID WINAPI
MmUnlockPagableImageSection(PVOID ImageSectionHandle
)
1860 FIXME("stub %p\n", ImageSectionHandle
);
1863 /***********************************************************************
1864 * MmPageEntireDriver (NTOSKRNL.EXE.@)
1866 PVOID WINAPI
MmPageEntireDriver(PVOID AddrInSection
)
1868 TRACE("%p\n", AddrInSection
);
1869 return AddrInSection
;
1873 /***********************************************************************
1874 * MmProbeAndLockPages (NTOSKRNL.EXE.@)
1876 void WINAPI
MmProbeAndLockPages(PMDLX MemoryDescriptorList
, KPROCESSOR_MODE AccessMode
, LOCK_OPERATION Operation
)
1878 FIXME("(%p, %u, %u): stub\n", MemoryDescriptorList
, AccessMode
, Operation
);
1882 /***********************************************************************
1883 * MmResetDriverPaging (NTOSKRNL.EXE.@)
1885 void WINAPI
MmResetDriverPaging(PVOID AddrInSection
)
1887 TRACE("%p\n", AddrInSection
);
1891 /***********************************************************************
1892 * MmUnlockPages (NTOSKRNL.EXE.@)
1894 void WINAPI
MmUnlockPages(PMDLX MemoryDescriptorList
)
1896 FIXME("(%p): stub\n", MemoryDescriptorList
);
1900 /***********************************************************************
1901 * MmUnmapIoSpace (NTOSKRNL.EXE.@)
1903 VOID WINAPI
MmUnmapIoSpace( PVOID BaseAddress
, SIZE_T NumberOfBytes
)
1905 FIXME( "stub: %p, %lu\n", BaseAddress
, NumberOfBytes
);
1908 /***********************************************************************
1909 * ObfReferenceObject (NTOSKRNL.EXE.@)
1911 VOID WINAPI
ObfReferenceObject(PVOID Object
)
1913 FIXME("(%p): stub\n", Object
);
1916 /***********************************************************************
1917 * ObReferenceObjectByHandle (NTOSKRNL.EXE.@)
1919 NTSTATUS WINAPI
ObReferenceObjectByHandle( HANDLE obj
, ACCESS_MASK access
,
1921 KPROCESSOR_MODE mode
, PVOID
* ptr
,
1922 POBJECT_HANDLE_INFORMATION info
)
1924 FIXME( "stub: %p %x %p %d %p %p\n", obj
, access
, type
, mode
, ptr
, info
);
1925 return STATUS_NOT_IMPLEMENTED
;
1928 /***********************************************************************
1929 * ObReferenceObjectByName (NTOSKRNL.EXE.@)
1931 NTSTATUS WINAPI
ObReferenceObjectByName( UNICODE_STRING
*ObjectName
,
1933 ACCESS_STATE
*AccessState
,
1934 ACCESS_MASK DesiredAccess
,
1935 POBJECT_TYPE ObjectType
,
1936 KPROCESSOR_MODE AccessMode
,
1941 return STATUS_NOT_IMPLEMENTED
;
1944 /***********************************************************************
1945 * ObfDereferenceObject (NTOSKRNL.EXE.@)
1947 #ifdef DEFINE_FASTCALL1_ENTRYPOINT
1948 DEFINE_FASTCALL1_ENTRYPOINT( ObfDereferenceObject
)
1949 void WINAPI
__regs_ObfDereferenceObject( VOID
*obj
)
1951 void WINAPI
ObfDereferenceObject( VOID
*obj
)
1954 FIXME( "stub: %p\n", obj
);
1958 /***********************************************************************
1959 * PsCreateSystemThread (NTOSKRNL.EXE.@)
1961 NTSTATUS WINAPI
PsCreateSystemThread(PHANDLE ThreadHandle
, ULONG DesiredAccess
,
1962 POBJECT_ATTRIBUTES ObjectAttributes
,
1963 HANDLE ProcessHandle
, PCLIENT_ID ClientId
,
1964 PKSTART_ROUTINE StartRoutine
, PVOID StartContext
)
1966 if (!ProcessHandle
) ProcessHandle
= GetCurrentProcess();
1967 return RtlCreateUserThread(ProcessHandle
, 0, FALSE
, 0, 0,
1968 0, StartRoutine
, StartContext
,
1969 ThreadHandle
, ClientId
);
1972 /***********************************************************************
1973 * PsGetCurrentProcessId (NTOSKRNL.EXE.@)
1975 HANDLE WINAPI
PsGetCurrentProcessId(void)
1977 if (GetCurrentThreadId() == request_thread
)
1978 return UlongToHandle(client_pid
);
1979 return UlongToHandle(GetCurrentProcessId());
1983 /***********************************************************************
1984 * PsGetCurrentThreadId (NTOSKRNL.EXE.@)
1986 HANDLE WINAPI
PsGetCurrentThreadId(void)
1988 if (GetCurrentThreadId() == request_thread
)
1989 return UlongToHandle(client_tid
);
1990 return UlongToHandle(GetCurrentThreadId());
1994 /***********************************************************************
1995 * PsGetVersion (NTOSKRNL.EXE.@)
1997 BOOLEAN WINAPI
PsGetVersion(ULONG
*major
, ULONG
*minor
, ULONG
*build
, UNICODE_STRING
*version
)
1999 RTL_OSVERSIONINFOEXW info
;
2001 info
.dwOSVersionInfoSize
= sizeof(info
);
2002 RtlGetVersion( &info
);
2003 if (major
) *major
= info
.dwMajorVersion
;
2004 if (minor
) *minor
= info
.dwMinorVersion
;
2005 if (build
) *build
= info
.dwBuildNumber
;
2009 #if 0 /* FIXME: GameGuard passes an uninitialized pointer in version->Buffer */
2010 size_t len
= min( strlenW(info
.szCSDVersion
)*sizeof(WCHAR
), version
->MaximumLength
);
2011 memcpy( version
->Buffer
, info
.szCSDVersion
, len
);
2012 if (len
< version
->MaximumLength
) version
->Buffer
[len
/ sizeof(WCHAR
)] = 0;
2013 version
->Length
= len
;
2020 /***********************************************************************
2021 * PsImpersonateClient (NTOSKRNL.EXE.@)
2023 NTSTATUS WINAPI
PsImpersonateClient(PETHREAD Thread
, PACCESS_TOKEN Token
, BOOLEAN CopyOnOpen
,
2024 BOOLEAN EffectiveOnly
, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
)
2026 FIXME("(%p, %p, %u, %u, %u): stub\n", Thread
, Token
, CopyOnOpen
, EffectiveOnly
, ImpersonationLevel
);
2028 return STATUS_NOT_IMPLEMENTED
;
2032 /***********************************************************************
2033 * PsSetCreateProcessNotifyRoutine (NTOSKRNL.EXE.@)
2035 NTSTATUS WINAPI
PsSetCreateProcessNotifyRoutine( PCREATE_PROCESS_NOTIFY_ROUTINE callback
, BOOLEAN remove
)
2037 FIXME( "stub: %p %d\n", callback
, remove
);
2038 return STATUS_SUCCESS
;
2042 /***********************************************************************
2043 * PsSetCreateThreadNotifyRoutine (NTOSKRNL.EXE.@)
2045 NTSTATUS WINAPI
PsSetCreateThreadNotifyRoutine( PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine
)
2047 FIXME( "stub: %p\n", NotifyRoutine
);
2048 return STATUS_SUCCESS
;
2052 /***********************************************************************
2053 * PsTerminateSystemThread (NTOSKRNL.EXE.@)
2055 NTSTATUS WINAPI
PsTerminateSystemThread(NTSTATUS ExitStatus
)
2057 FIXME( "stub: %u\n", ExitStatus
);
2058 return STATUS_NOT_IMPLEMENTED
;
2062 /***********************************************************************
2063 * MmGetSystemRoutineAddress (NTOSKRNL.EXE.@)
2065 PVOID WINAPI
MmGetSystemRoutineAddress(PUNICODE_STRING SystemRoutineName
)
2068 STRING routineNameA
;
2071 static const WCHAR ntoskrnlW
[] = {'n','t','o','s','k','r','n','l','.','e','x','e',0};
2072 static const WCHAR halW
[] = {'h','a','l','.','d','l','l',0};
2074 if (!SystemRoutineName
) return NULL
;
2076 if (RtlUnicodeStringToAnsiString( &routineNameA
, SystemRoutineName
, TRUE
) == STATUS_SUCCESS
)
2078 /* We only support functions exported from ntoskrnl.exe or hal.dll */
2079 hMod
= GetModuleHandleW( ntoskrnlW
);
2080 pFunc
= GetProcAddress( hMod
, routineNameA
.Buffer
);
2083 hMod
= GetModuleHandleW( halW
);
2084 if (hMod
) pFunc
= GetProcAddress( hMod
, routineNameA
.Buffer
);
2086 RtlFreeAnsiString( &routineNameA
);
2090 TRACE( "%s -> %p\n", debugstr_us(SystemRoutineName
), pFunc
);
2092 FIXME( "%s not found\n", debugstr_us(SystemRoutineName
) );
2097 /***********************************************************************
2098 * MmQuerySystemSize (NTOSKRNL.EXE.@)
2100 MM_SYSTEMSIZE WINAPI
MmQuerySystemSize(void)
2103 return MmLargeSystem
;
2106 /***********************************************************************
2107 * KeInitializeDpc (NTOSKRNL.EXE.@)
2109 VOID WINAPI
KeInitializeDpc(PRKDPC Dpc
, PKDEFERRED_ROUTINE DeferredRoutine
, PVOID DeferredContext
)
2114 /***********************************************************************
2115 * READ_REGISTER_BUFFER_UCHAR (NTOSKRNL.EXE.@)
2117 VOID WINAPI
READ_REGISTER_BUFFER_UCHAR(PUCHAR Register
, PUCHAR Buffer
, ULONG Count
)
2122 /*****************************************************
2123 * PoSetPowerState (NTOSKRNL.EXE.@)
2125 POWER_STATE WINAPI
PoSetPowerState(PDEVICE_OBJECT DeviceObject
, POWER_STATE_TYPE Type
, POWER_STATE State
)
2127 FIXME("(%p %u %u) stub\n", DeviceObject
, Type
, State
.DeviceState
);
2131 /*****************************************************
2132 * IoWMIRegistrationControl (NTOSKRNL.EXE.@)
2134 NTSTATUS WINAPI
IoWMIRegistrationControl(PDEVICE_OBJECT DeviceObject
, ULONG Action
)
2136 FIXME("(%p %u) stub\n", DeviceObject
, Action
);
2137 return STATUS_SUCCESS
;
2140 /*****************************************************
2141 * PsSetLoadImageNotifyRoutine (NTOSKRNL.EXE.@)
2143 NTSTATUS WINAPI
PsSetLoadImageNotifyRoutine(PLOAD_IMAGE_NOTIFY_ROUTINE routine
)
2145 FIXME("(%p) stub\n", routine
);
2146 return STATUS_SUCCESS
;
2149 /*****************************************************
2150 * PsLookupProcessByProcessId (NTOSKRNL.EXE.@)
2152 NTSTATUS WINAPI
PsLookupProcessByProcessId(HANDLE processid
, PEPROCESS
*process
)
2155 if (!once
++) FIXME("(%p %p) stub\n", processid
, process
);
2156 return STATUS_NOT_IMPLEMENTED
;
2160 /*****************************************************
2161 * IoSetThreadHardErrorMode (NTOSKRNL.EXE.@)
2163 BOOLEAN WINAPI
IoSetThreadHardErrorMode(BOOLEAN EnableHardErrors
)
2170 /*****************************************************
2171 * IoInitializeRemoveLockEx (NTOSKRNL.EXE.@)
2173 VOID WINAPI
IoInitializeRemoveLockEx(PIO_REMOVE_LOCK lock
, ULONG tag
,
2174 ULONG maxmin
, ULONG high
, ULONG size
)
2176 FIXME("(%p %u %u %u %u) stub\n", lock
, tag
, maxmin
, high
, size
);
2180 /*****************************************************
2181 * IoAcquireRemoveLockEx (NTOSKRNL.EXE.@)
2184 NTSTATUS WINAPI
IoAcquireRemoveLockEx(PIO_REMOVE_LOCK lock
, PVOID tag
,
2185 LPCSTR file
, ULONG line
, ULONG lock_size
)
2187 FIXME("(%p, %p, %s, %u, %u): stub\n", lock
, tag
, debugstr_a(file
), line
, lock_size
);
2189 return STATUS_NOT_IMPLEMENTED
;
2193 /*****************************************************
2196 BOOL WINAPI
DllMain( HINSTANCE inst
, DWORD reason
, LPVOID reserved
)
2198 static void *handler
;
2199 LARGE_INTEGER count
;
2203 case DLL_PROCESS_ATTACH
:
2204 DisableThreadLibraryCalls( inst
);
2205 #if defined(__i386__) || defined(__x86_64__)
2206 handler
= RtlAddVectoredExceptionHandler( TRUE
, vectored_handler
);
2208 KeQueryTickCount( &count
); /* initialize the global KeTickCount */
2210 case DLL_PROCESS_DETACH
:
2211 if (reserved
) break;
2212 RtlRemoveVectoredExceptionHandler( handler
);
2218 /*****************************************************
2219 * Ke386IoSetAccessProcess (NTOSKRNL.EXE.@)
2221 BOOLEAN WINAPI
Ke386IoSetAccessProcess(PEPROCESS
*process
, ULONG flag
)
2223 FIXME("(%p %d) stub\n", process
, flag
);
2227 /*****************************************************
2228 * Ke386SetIoAccessMap (NTOSKRNL.EXE.@)
2230 BOOLEAN WINAPI
Ke386SetIoAccessMap(ULONG flag
, PVOID buffer
)
2232 FIXME("(%d %p) stub\n", flag
, buffer
);
2236 /*****************************************************
2237 * IoCreateSynchronizationEvent (NTOSKRNL.EXE.@)
2239 PKEVENT WINAPI
IoCreateSynchronizationEvent(PUNICODE_STRING name
, PHANDLE handle
)
2241 FIXME("(%p %p) stub\n", name
, handle
);
2245 /*****************************************************
2246 * IoStartNextPacket (NTOSKRNL.EXE.@)
2248 VOID WINAPI
IoStartNextPacket(PDEVICE_OBJECT deviceobject
, BOOLEAN cancelable
)
2250 FIXME("(%p %d) stub\n", deviceobject
, cancelable
);
2253 /*****************************************************
2254 * ObQueryNameString (NTOSKRNL.EXE.@)
2256 NTSTATUS WINAPI
ObQueryNameString(PVOID object
, POBJECT_NAME_INFORMATION name
, ULONG maxlength
, PULONG returnlength
)
2258 FIXME("(%p %p %u %p) stub\n", object
, name
, maxlength
, returnlength
);
2259 return STATUS_NOT_IMPLEMENTED
;
2262 /*****************************************************
2263 * IoRegisterPlugPlayNotification (NTOSKRNL.EXE.@)
2265 NTSTATUS WINAPI
IoRegisterPlugPlayNotification(IO_NOTIFICATION_EVENT_CATEGORY category
, ULONG flags
, PVOID data
,
2266 PDRIVER_OBJECT driver
, PDRIVER_NOTIFICATION_CALLBACK_ROUTINE callback
,
2267 PVOID context
, PVOID
*notification
)
2269 FIXME("(%u %u %p %p %p %p %p) stub\n", category
, flags
, data
, driver
, callback
, context
, notification
);
2270 return STATUS_SUCCESS
;
2273 /*****************************************************
2274 * IoCsqInitialize (NTOSKRNL.EXE.@)
2276 NTSTATUS WINAPI
IoCsqInitialize(PIO_CSQ csq
, PIO_CSQ_INSERT_IRP insert_irp
, PIO_CSQ_REMOVE_IRP remove_irp
,
2277 PIO_CSQ_PEEK_NEXT_IRP peek_irp
, PIO_CSQ_ACQUIRE_LOCK acquire_lock
,
2278 PIO_CSQ_RELEASE_LOCK release_lock
, PIO_CSQ_COMPLETE_CANCELED_IRP complete_irp
)
2280 FIXME("(%p %p %p %p %p %p %p) stub\n",
2281 csq
, insert_irp
, remove_irp
, peek_irp
, acquire_lock
, release_lock
, complete_irp
);
2282 return STATUS_SUCCESS
;
2285 /*****************************************************
2286 * ExInterlockedRemoveHeadList (NTOSKRNL.EXE.@)
2288 PLIST_ENTRY WINAPI
ExInterlockedRemoveHeadList(PLIST_ENTRY head
, PKSPIN_LOCK lock
)
2290 FIXME("(%p %p) stub\n", head
, lock
);
2294 /***********************************************************************
2295 * ExfInterlockedRemoveHeadList (NTOSKRNL.EXE.@)
2297 #ifdef DEFINE_FASTCALL2_ENTRYPOINT
2298 DEFINE_FASTCALL2_ENTRYPOINT( ExfInterlockedRemoveHeadList
)
2299 PLIST_ENTRY WINAPI
__regs_ExfInterlockedRemoveHeadList(PLIST_ENTRY head
, PKSPIN_LOCK lock
)
2301 PLIST_ENTRY WINAPI
ExfInterlockedRemoveHeadList(PLIST_ENTRY head
, PKSPIN_LOCK lock
)
2304 FIXME("(%p %p) stub\n", head
, lock
);
2305 return ExInterlockedRemoveHeadList( head
, lock
);
2308 /***********************************************************************
2309 * KeEnterCriticalRegion (NTOSKRNL.EXE.@)
2311 void WINAPI
KeEnterCriticalRegion(void)
2316 /***********************************************************************
2317 * KeLeaveCriticalRegion (NTOSKRNL.EXE.@)
2319 void WINAPI
KeLeaveCriticalRegion(void)