2007-05-15 21:41:50 +02:00
|
|
|
/*
|
|
|
|
* ntoskrnl.exe implementation
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Alexandre Julliard
|
2010-03-17 21:46:57 +01:00
|
|
|
* Copyright (C) 2010 Damjan Jovanovic
|
2016-08-24 06:11:07 +02:00
|
|
|
* Copyright (C) 2016 Sebastian Lackner
|
2016-09-01 09:28:00 +02:00
|
|
|
* Copyright (C) 2016 CodeWeavers, Aric Stewart
|
2007-05-15 21:41:50 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
|
|
|
|
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
|
|
|
#include "windef.h"
|
2016-08-24 06:11:07 +02:00
|
|
|
#include "winsvc.h"
|
2007-05-15 21:41:50 +02:00
|
|
|
#include "winternl.h"
|
2007-05-18 16:37:23 +02:00
|
|
|
#include "excpt.h"
|
2011-11-01 13:03:12 +01:00
|
|
|
#include "winioctl.h"
|
2014-12-23 22:29:30 +01:00
|
|
|
#include "ddk/csq.h"
|
2008-08-29 00:31:58 +02:00
|
|
|
#include "ddk/ntddk.h"
|
2014-03-18 23:54:29 +01:00
|
|
|
#include "ddk/ntifs.h"
|
2015-11-17 05:34:47 +01:00
|
|
|
#include "ddk/wdm.h"
|
2007-05-15 21:41:50 +02:00
|
|
|
#include "wine/unicode.h"
|
|
|
|
#include "wine/server.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2016-08-03 18:41:30 +02:00
|
|
|
#include "wine/rbtree.h"
|
|
|
|
|
2007-05-15 21:41:50 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ntoskrnl);
|
2007-05-16 21:13:34 +02:00
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(relay);
|
2016-09-14 09:30:43 +02:00
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(plugplay);
|
2007-05-15 21:41:50 +02:00
|
|
|
|
2011-06-29 05:46:10 +02:00
|
|
|
BOOLEAN KdDebuggerEnabled = FALSE;
|
2014-10-14 17:14:00 +02:00
|
|
|
ULONG InitSafeBootMode = 0;
|
2011-06-29 05:46:10 +02:00
|
|
|
|
2009-12-30 20:39:47 +01:00
|
|
|
extern LONG CALLBACK vectored_handler( EXCEPTION_POINTERS *ptrs );
|
2007-05-15 21:49:26 +02:00
|
|
|
|
2008-07-21 14:47:55 +02:00
|
|
|
KSYSTEM_TIME KeTickCount = { 0, 0, 0 };
|
2007-05-15 21:49:26 +02:00
|
|
|
|
|
|
|
typedef struct _KSERVICE_TABLE_DESCRIPTOR
|
|
|
|
{
|
|
|
|
PULONG_PTR Base;
|
|
|
|
PULONG Count;
|
|
|
|
ULONG Limit;
|
|
|
|
PUCHAR Number;
|
|
|
|
} KSERVICE_TABLE_DESCRIPTOR, *PKSERVICE_TABLE_DESCRIPTOR;
|
|
|
|
|
2008-07-21 14:47:55 +02:00
|
|
|
KSERVICE_TABLE_DESCRIPTOR KeServiceDescriptorTable[4] = { { 0 } };
|
2007-05-15 21:49:26 +02:00
|
|
|
|
2007-05-17 09:49:28 +02:00
|
|
|
typedef void (WINAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)(HANDLE,HANDLE,BOOLEAN);
|
2008-12-28 14:31:51 +01:00
|
|
|
typedef void (WINAPI *PCREATE_THREAD_NOTIFY_ROUTINE)(HANDLE,HANDLE,BOOLEAN);
|
2007-05-15 21:49:26 +02:00
|
|
|
|
2016-08-24 06:11:07 +02:00
|
|
|
static const WCHAR servicesW[] = {'\\','R','e','g','i','s','t','r','y',
|
|
|
|
'\\','M','a','c','h','i','n','e',
|
|
|
|
'\\','S','y','s','t','e','m',
|
|
|
|
'\\','C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t',
|
|
|
|
'\\','S','e','r','v','i','c','e','s',
|
|
|
|
'\\',0};
|
|
|
|
|
2016-09-14 09:30:43 +02:00
|
|
|
#define MAX_SERVICE_NAME 260
|
|
|
|
|
2011-10-27 14:20:19 +02:00
|
|
|
/* tid of the thread running client request */
|
|
|
|
static DWORD request_thread;
|
|
|
|
|
|
|
|
/* pid/tid of the client thread */
|
|
|
|
static DWORD client_tid;
|
|
|
|
static DWORD client_pid;
|
|
|
|
|
2016-08-03 18:41:30 +02:00
|
|
|
struct wine_driver
|
|
|
|
{
|
|
|
|
struct wine_rb_entry entry;
|
|
|
|
|
|
|
|
DRIVER_OBJECT driver_obj;
|
|
|
|
DRIVER_EXTENSION driver_extension;
|
|
|
|
};
|
|
|
|
|
2016-09-19 15:13:58 +02:00
|
|
|
static NTSTATUS get_device_id( DEVICE_OBJECT *device, BUS_QUERY_ID_TYPE type, WCHAR **id );
|
|
|
|
|
2016-08-03 18:41:30 +02:00
|
|
|
static int wine_drivers_rb_compare( const void *key, const struct wine_rb_entry *entry )
|
|
|
|
{
|
|
|
|
const struct wine_driver *driver = WINE_RB_ENTRY_VALUE( entry, const struct wine_driver, entry );
|
|
|
|
const UNICODE_STRING *k = key;
|
|
|
|
|
|
|
|
return RtlCompareUnicodeString( k, &driver->driver_obj.DriverName, FALSE );
|
|
|
|
}
|
|
|
|
|
2016-08-30 21:30:33 +02:00
|
|
|
static struct wine_rb_tree wine_drivers = { wine_drivers_rb_compare };
|
|
|
|
|
|
|
|
static CRITICAL_SECTION drivers_cs;
|
|
|
|
static CRITICAL_SECTION_DEBUG critsect_debug =
|
2016-08-03 18:41:30 +02:00
|
|
|
{
|
2016-08-30 21:30:33 +02:00
|
|
|
0, 0, &drivers_cs,
|
|
|
|
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
|
|
|
|
0, 0, { (DWORD_PTR)(__FILE__ ": drivers_cs") }
|
2016-08-03 18:41:30 +02:00
|
|
|
};
|
2016-08-30 21:30:33 +02:00
|
|
|
static CRITICAL_SECTION drivers_cs = { &critsect_debug, -1, 0, 0, 0, 0 };
|
2016-08-03 18:41:30 +02:00
|
|
|
|
2007-05-15 21:56:05 +02:00
|
|
|
#ifdef __i386__
|
|
|
|
#define DEFINE_FASTCALL1_ENTRYPOINT( name ) \
|
2009-06-14 15:34:34 +02:00
|
|
|
__ASM_STDCALL_FUNC( name, 4, \
|
2007-05-15 21:56:05 +02:00
|
|
|
"popl %eax\n\t" \
|
|
|
|
"pushl %ecx\n\t" \
|
|
|
|
"pushl %eax\n\t" \
|
2009-06-14 15:34:34 +02:00
|
|
|
"jmp " __ASM_NAME("__regs_") #name __ASM_STDCALL(4))
|
2007-05-15 21:56:05 +02:00
|
|
|
#define DEFINE_FASTCALL2_ENTRYPOINT( name ) \
|
2009-06-14 15:34:34 +02:00
|
|
|
__ASM_STDCALL_FUNC( name, 8, \
|
2007-05-15 21:56:05 +02:00
|
|
|
"popl %eax\n\t" \
|
|
|
|
"pushl %edx\n\t" \
|
|
|
|
"pushl %ecx\n\t" \
|
|
|
|
"pushl %eax\n\t" \
|
2009-06-14 15:34:34 +02:00
|
|
|
"jmp " __ASM_NAME("__regs_") #name __ASM_STDCALL(8))
|
|
|
|
#define DEFINE_FASTCALL3_ENTRYPOINT( name ) \
|
|
|
|
__ASM_STDCALL_FUNC( name, 12, \
|
|
|
|
"popl %eax\n\t" \
|
|
|
|
"pushl %edx\n\t" \
|
|
|
|
"pushl %ecx\n\t" \
|
|
|
|
"pushl %eax\n\t" \
|
|
|
|
"jmp " __ASM_NAME("__regs_") #name __ASM_STDCALL(12))
|
2007-05-15 21:56:05 +02:00
|
|
|
#endif
|
|
|
|
|
2007-05-15 21:41:50 +02:00
|
|
|
static inline LPCSTR debugstr_us( const UNICODE_STRING *us )
|
|
|
|
{
|
|
|
|
if (!us) return "<null>";
|
|
|
|
return debugstr_wn( us->Buffer, us->Length / sizeof(WCHAR) );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HANDLE get_device_manager(void)
|
|
|
|
{
|
|
|
|
static HANDLE device_manager;
|
|
|
|
HANDLE handle = 0, ret = device_manager;
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
SERVER_START_REQ( create_device_manager )
|
|
|
|
{
|
|
|
|
req->access = SYNCHRONIZE;
|
|
|
|
req->attributes = 0;
|
2008-12-08 16:05:17 +01:00
|
|
|
if (!wine_server_call( req )) handle = wine_server_ptr_handle( reply->handle );
|
2007-05-15 21:41:50 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
|
|
|
if (!handle)
|
|
|
|
{
|
|
|
|
ERR( "failed to create the device manager\n" );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (!(ret = InterlockedCompareExchangePointer( &device_manager, handle, 0 )))
|
|
|
|
ret = handle;
|
|
|
|
else
|
|
|
|
NtClose( handle ); /* somebody beat us to it */
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-10-10 17:15:39 +02:00
|
|
|
/* transfer result of IRP back to wineserver */
|
|
|
|
static NTSTATUS WINAPI dispatch_irp_completion( DEVICE_OBJECT *device, IRP *irp, void *context )
|
|
|
|
{
|
|
|
|
FILE_OBJECT *file = irp->Tail.Overlay.OriginalFileObject;
|
2016-10-12 18:53:55 +02:00
|
|
|
HANDLE irp_handle = context;
|
2016-10-10 17:15:39 +02:00
|
|
|
void *out_buff = irp->UserBuffer;
|
2016-10-12 18:53:55 +02:00
|
|
|
|
|
|
|
if (irp->Flags & IRP_WRITE_OPERATION)
|
|
|
|
out_buff = NULL; /* do not transfer back input buffer */
|
2016-10-10 17:15:39 +02:00
|
|
|
|
|
|
|
SERVER_START_REQ( set_irp_result )
|
|
|
|
{
|
2016-10-12 18:53:55 +02:00
|
|
|
req->handle = wine_server_obj_handle( irp_handle );
|
2016-10-10 17:15:39 +02:00
|
|
|
req->status = irp->IoStatus.u.Status;
|
|
|
|
req->file_ptr = wine_server_client_ptr( file );
|
|
|
|
if (irp->IoStatus.u.Status >= 0)
|
|
|
|
{
|
|
|
|
req->size = irp->IoStatus.Information;
|
|
|
|
if (out_buff) wine_server_add_data( req, out_buff, irp->IoStatus.Information );
|
|
|
|
}
|
|
|
|
wine_server_call( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
2016-10-13 00:46:34 +02:00
|
|
|
if (irp->Flags & IRP_CLOSE_OPERATION)
|
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, file );
|
|
|
|
irp->Tail.Overlay.OriginalFileObject = NULL;
|
|
|
|
}
|
|
|
|
|
2016-10-13 00:51:48 +02:00
|
|
|
if (irp->UserBuffer != irp->AssociatedIrp.SystemBuffer)
|
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, irp->UserBuffer );
|
|
|
|
irp->UserBuffer = NULL;
|
|
|
|
}
|
2016-10-10 17:15:39 +02:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dispatch_irp( DEVICE_OBJECT *device, IRP *irp, HANDLE irp_handle )
|
2007-05-16 21:13:34 +02:00
|
|
|
{
|
2007-05-18 16:48:54 +02:00
|
|
|
LARGE_INTEGER count;
|
2015-05-05 07:24:00 +02:00
|
|
|
|
2016-10-10 17:15:39 +02:00
|
|
|
IoSetCompletionRoutine( irp, dispatch_irp_completion, irp_handle, TRUE, TRUE, TRUE );
|
2015-05-05 07:24:00 +02:00
|
|
|
KeQueryTickCount( &count ); /* update the global KeTickCount */
|
|
|
|
|
|
|
|
device->CurrentIrp = irp;
|
|
|
|
IoCallDriver( device, irp );
|
|
|
|
device->CurrentIrp = NULL;
|
|
|
|
}
|
|
|
|
|
2015-07-08 11:56:01 +02:00
|
|
|
/* process a create request for a given file */
|
|
|
|
static NTSTATUS dispatch_create( const irp_params_t *params, void *in_buff, ULONG in_size,
|
|
|
|
ULONG out_size, HANDLE irp_handle )
|
|
|
|
{
|
|
|
|
IRP *irp;
|
|
|
|
IO_STACK_LOCATION *irpsp;
|
|
|
|
FILE_OBJECT *file;
|
|
|
|
DEVICE_OBJECT *device = wine_server_get_ptr( params->create.device );
|
|
|
|
|
|
|
|
if (!(file = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*file) ))) return STATUS_NO_MEMORY;
|
|
|
|
|
|
|
|
TRACE( "device %p -> file %p\n", device, file );
|
|
|
|
|
|
|
|
file->Type = 5; /* MSDN */
|
|
|
|
file->Size = sizeof(*file);
|
|
|
|
file->DeviceObject = device;
|
|
|
|
|
|
|
|
if (!(irp = IoAllocateIrp( device->StackSize, FALSE )))
|
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, file );
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
irpsp = IoGetNextIrpStackLocation( irp );
|
|
|
|
irpsp->MajorFunction = IRP_MJ_CREATE;
|
|
|
|
irpsp->DeviceObject = device;
|
|
|
|
irpsp->Parameters.Create.SecurityContext = NULL; /* FIXME */
|
|
|
|
irpsp->Parameters.Create.Options = params->create.options;
|
|
|
|
irpsp->Parameters.Create.ShareAccess = params->create.sharing;
|
|
|
|
irpsp->Parameters.Create.FileAttributes = 0;
|
|
|
|
irpsp->Parameters.Create.EaLength = 0;
|
|
|
|
|
|
|
|
irp->Tail.Overlay.OriginalFileObject = file;
|
2015-07-08 12:04:32 +02:00
|
|
|
irp->RequestorMode = UserMode;
|
2015-07-08 11:56:01 +02:00
|
|
|
irp->AssociatedIrp.SystemBuffer = NULL;
|
|
|
|
irp->UserBuffer = NULL;
|
2016-10-10 17:15:39 +02:00
|
|
|
irp->UserIosb = NULL;
|
2015-07-08 11:56:01 +02:00
|
|
|
irp->UserEvent = NULL;
|
|
|
|
|
2016-10-12 18:53:55 +02:00
|
|
|
irp->Flags |= IRP_CREATE_OPERATION;
|
2016-10-10 17:15:39 +02:00
|
|
|
dispatch_irp( device, irp, irp_handle );
|
2015-07-08 11:56:42 +02:00
|
|
|
|
2016-10-13 00:51:48 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, in_buff );
|
2015-07-08 11:56:01 +02:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* process a close request for a given file */
|
|
|
|
static NTSTATUS dispatch_close( const irp_params_t *params, void *in_buff, ULONG in_size,
|
|
|
|
ULONG out_size, HANDLE irp_handle )
|
|
|
|
{
|
|
|
|
IRP *irp;
|
|
|
|
IO_STACK_LOCATION *irpsp;
|
|
|
|
DEVICE_OBJECT *device;
|
|
|
|
FILE_OBJECT *file = wine_server_get_ptr( params->close.file );
|
|
|
|
|
|
|
|
if (!file) return STATUS_INVALID_HANDLE;
|
|
|
|
|
|
|
|
device = file->DeviceObject;
|
|
|
|
|
|
|
|
TRACE( "device %p file %p\n", device, file );
|
|
|
|
|
|
|
|
if (!(irp = IoAllocateIrp( device->StackSize, FALSE )))
|
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, file );
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
irpsp = IoGetNextIrpStackLocation( irp );
|
|
|
|
irpsp->MajorFunction = IRP_MJ_CLOSE;
|
|
|
|
irpsp->DeviceObject = device;
|
|
|
|
|
|
|
|
irp->Tail.Overlay.OriginalFileObject = file;
|
2015-07-08 12:04:32 +02:00
|
|
|
irp->RequestorMode = UserMode;
|
2015-07-08 11:56:01 +02:00
|
|
|
irp->AssociatedIrp.SystemBuffer = NULL;
|
|
|
|
irp->UserBuffer = NULL;
|
2016-10-10 17:15:39 +02:00
|
|
|
irp->UserIosb = NULL;
|
2015-07-08 11:56:01 +02:00
|
|
|
irp->UserEvent = NULL;
|
|
|
|
|
2016-10-12 18:53:55 +02:00
|
|
|
irp->Flags |= IRP_CLOSE_OPERATION;
|
2016-10-10 17:15:39 +02:00
|
|
|
dispatch_irp( device, irp, irp_handle );
|
2015-07-08 11:56:01 +02:00
|
|
|
|
2016-10-13 00:51:48 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, in_buff );
|
2015-07-08 11:56:01 +02:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2015-05-05 07:24:00 +02:00
|
|
|
/* process a read request for a given device */
|
2015-07-08 10:50:00 +02:00
|
|
|
static NTSTATUS dispatch_read( const irp_params_t *params, void *in_buff, ULONG in_size,
|
|
|
|
ULONG out_size, HANDLE irp_handle )
|
2015-05-05 07:24:00 +02:00
|
|
|
{
|
|
|
|
IRP *irp;
|
|
|
|
void *out_buff;
|
|
|
|
LARGE_INTEGER offset;
|
|
|
|
IO_STACK_LOCATION *irpsp;
|
2015-07-08 12:04:32 +02:00
|
|
|
DEVICE_OBJECT *device;
|
|
|
|
FILE_OBJECT *file = wine_server_get_ptr( params->read.file );
|
|
|
|
|
|
|
|
if (!file) return STATUS_INVALID_HANDLE;
|
2015-07-08 10:50:00 +02:00
|
|
|
|
2015-07-08 12:04:32 +02:00
|
|
|
device = file->DeviceObject;
|
2015-05-05 07:24:00 +02:00
|
|
|
|
2015-07-08 12:04:32 +02:00
|
|
|
TRACE( "device %p file %p size %u\n", device, file, out_size );
|
2015-05-05 07:24:00 +02:00
|
|
|
|
|
|
|
if (!(out_buff = HeapAlloc( GetProcessHeap(), 0, out_size ))) return STATUS_NO_MEMORY;
|
|
|
|
|
|
|
|
offset.QuadPart = params->read.pos;
|
|
|
|
|
|
|
|
if (!(irp = IoBuildSynchronousFsdRequest( IRP_MJ_READ, device, out_buff, out_size,
|
2016-10-10 17:15:39 +02:00
|
|
|
&offset, NULL, NULL )))
|
2015-05-05 07:24:00 +02:00
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, out_buff );
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
}
|
|
|
|
|
2015-07-08 12:04:32 +02:00
|
|
|
irp->Tail.Overlay.OriginalFileObject = file;
|
|
|
|
irp->RequestorMode = UserMode;
|
|
|
|
|
2015-05-05 07:24:00 +02:00
|
|
|
irpsp = IoGetNextIrpStackLocation( irp );
|
|
|
|
irpsp->Parameters.Read.Key = params->read.key;
|
|
|
|
|
2016-10-12 18:53:55 +02:00
|
|
|
irp->Flags |= IRP_READ_OPERATION;
|
2016-10-13 00:51:48 +02:00
|
|
|
irp->Flags |= IRP_DEALLOCATE_BUFFER; /* deallocate out_buff */
|
2016-10-10 17:15:39 +02:00
|
|
|
dispatch_irp( device, irp, irp_handle );
|
2016-10-07 05:19:46 +02:00
|
|
|
|
2016-10-13 00:51:48 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, in_buff );
|
2016-10-07 05:19:46 +02:00
|
|
|
return STATUS_SUCCESS;
|
2015-05-05 07:24:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* process a write request for a given device */
|
2015-07-08 10:50:00 +02:00
|
|
|
static NTSTATUS dispatch_write( const irp_params_t *params, void *in_buff, ULONG in_size,
|
|
|
|
ULONG out_size, HANDLE irp_handle )
|
2015-05-05 07:24:00 +02:00
|
|
|
{
|
|
|
|
IRP *irp;
|
|
|
|
LARGE_INTEGER offset;
|
|
|
|
IO_STACK_LOCATION *irpsp;
|
2015-07-08 12:04:32 +02:00
|
|
|
DEVICE_OBJECT *device;
|
|
|
|
FILE_OBJECT *file = wine_server_get_ptr( params->write.file );
|
2015-07-08 10:50:00 +02:00
|
|
|
|
2015-07-08 12:04:32 +02:00
|
|
|
if (!file) return STATUS_INVALID_HANDLE;
|
|
|
|
|
|
|
|
device = file->DeviceObject;
|
2015-05-05 07:24:00 +02:00
|
|
|
|
2015-07-08 12:04:32 +02:00
|
|
|
TRACE( "device %p file %p size %u\n", device, file, in_size );
|
2015-05-05 07:24:00 +02:00
|
|
|
|
|
|
|
offset.QuadPart = params->write.pos;
|
|
|
|
|
|
|
|
if (!(irp = IoBuildSynchronousFsdRequest( IRP_MJ_WRITE, device, in_buff, in_size,
|
2016-10-10 17:15:39 +02:00
|
|
|
&offset, NULL, NULL )))
|
2015-05-05 07:24:00 +02:00
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
|
2015-07-08 12:04:32 +02:00
|
|
|
irp->Tail.Overlay.OriginalFileObject = file;
|
|
|
|
irp->RequestorMode = UserMode;
|
|
|
|
|
2015-05-05 07:24:00 +02:00
|
|
|
irpsp = IoGetNextIrpStackLocation( irp );
|
|
|
|
irpsp->Parameters.Write.Key = params->write.key;
|
|
|
|
|
2016-10-12 18:53:55 +02:00
|
|
|
irp->Flags |= IRP_WRITE_OPERATION;
|
2016-10-13 00:51:48 +02:00
|
|
|
irp->Flags |= IRP_DEALLOCATE_BUFFER; /* deallocate in_buff */
|
2016-10-10 17:15:39 +02:00
|
|
|
dispatch_irp( device, irp, irp_handle );
|
2016-10-07 05:19:46 +02:00
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
2015-05-05 07:24:00 +02:00
|
|
|
}
|
|
|
|
|
2015-05-06 10:14:31 +02:00
|
|
|
/* process a flush request for a given device */
|
2015-07-08 10:50:00 +02:00
|
|
|
static NTSTATUS dispatch_flush( const irp_params_t *params, void *in_buff, ULONG in_size,
|
|
|
|
ULONG out_size, HANDLE irp_handle )
|
2015-05-06 10:14:31 +02:00
|
|
|
{
|
|
|
|
IRP *irp;
|
2015-07-08 12:04:32 +02:00
|
|
|
DEVICE_OBJECT *device;
|
|
|
|
FILE_OBJECT *file = wine_server_get_ptr( params->flush.file );
|
2015-07-08 10:50:00 +02:00
|
|
|
|
2015-07-08 12:04:32 +02:00
|
|
|
if (!file) return STATUS_INVALID_HANDLE;
|
|
|
|
|
|
|
|
device = file->DeviceObject;
|
2015-05-06 10:14:31 +02:00
|
|
|
|
2015-07-08 12:04:32 +02:00
|
|
|
TRACE( "device %p file %p\n", device, file );
|
2015-05-06 10:14:31 +02:00
|
|
|
|
2016-10-07 05:20:01 +02:00
|
|
|
if (!(irp = IoBuildSynchronousFsdRequest( IRP_MJ_FLUSH_BUFFERS, device, NULL, 0,
|
2016-10-10 17:15:39 +02:00
|
|
|
NULL, NULL, NULL )))
|
2015-05-06 10:14:31 +02:00
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
|
2015-07-08 12:04:32 +02:00
|
|
|
irp->Tail.Overlay.OriginalFileObject = file;
|
|
|
|
irp->RequestorMode = UserMode;
|
|
|
|
|
2016-10-10 17:15:39 +02:00
|
|
|
dispatch_irp( device, irp, irp_handle );
|
2016-10-07 05:19:46 +02:00
|
|
|
|
2016-10-13 00:51:48 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, in_buff );
|
2016-10-07 05:19:46 +02:00
|
|
|
return STATUS_SUCCESS;
|
2015-05-06 10:14:31 +02:00
|
|
|
}
|
|
|
|
|
2015-05-05 07:24:00 +02:00
|
|
|
/* process an ioctl request for a given device */
|
2015-07-08 10:50:00 +02:00
|
|
|
static NTSTATUS dispatch_ioctl( const irp_params_t *params, void *in_buff, ULONG in_size,
|
|
|
|
ULONG out_size, HANDLE irp_handle )
|
2015-05-05 07:24:00 +02:00
|
|
|
{
|
|
|
|
IRP *irp;
|
|
|
|
void *out_buff = NULL;
|
2016-10-16 08:48:55 +02:00
|
|
|
void *to_free = NULL;
|
2015-07-08 12:04:32 +02:00
|
|
|
DEVICE_OBJECT *device;
|
|
|
|
FILE_OBJECT *file = wine_server_get_ptr( params->ioctl.file );
|
|
|
|
|
|
|
|
if (!file) return STATUS_INVALID_HANDLE;
|
2015-07-08 10:50:00 +02:00
|
|
|
|
2015-07-08 12:04:32 +02:00
|
|
|
device = file->DeviceObject;
|
2015-05-05 07:24:00 +02:00
|
|
|
|
2015-07-08 12:04:32 +02:00
|
|
|
TRACE( "ioctl %x device %p file %p in_size %u out_size %u\n",
|
|
|
|
params->ioctl.code, device, file, in_size, out_size );
|
2015-05-05 07:24:00 +02:00
|
|
|
|
2015-03-11 14:48:22 +01:00
|
|
|
if (out_size)
|
2011-11-01 13:03:12 +01:00
|
|
|
{
|
2016-10-16 08:51:06 +02:00
|
|
|
if ((params->ioctl.code & 3) != METHOD_BUFFERED)
|
|
|
|
{
|
|
|
|
if (in_size < out_size) return STATUS_INVALID_DEVICE_REQUEST;
|
|
|
|
in_size -= out_size;
|
|
|
|
if (!(out_buff = HeapAlloc( GetProcessHeap(), 0, out_size ))) return STATUS_NO_MEMORY;
|
|
|
|
memcpy( out_buff, (char *)in_buff + in_size, out_size );
|
|
|
|
}
|
|
|
|
else if (out_size > in_size)
|
2015-03-11 14:48:22 +01:00
|
|
|
{
|
2016-10-16 08:51:06 +02:00
|
|
|
if (!(out_buff = HeapAlloc( GetProcessHeap(), 0, out_size ))) return STATUS_NO_MEMORY;
|
2015-03-11 14:48:22 +01:00
|
|
|
memcpy( out_buff, in_buff, in_size );
|
2016-10-16 08:48:55 +02:00
|
|
|
to_free = in_buff;
|
2015-03-11 14:48:22 +01:00
|
|
|
in_buff = out_buff;
|
|
|
|
}
|
2016-10-16 08:51:06 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
out_buff = in_buff;
|
|
|
|
out_size = in_size;
|
|
|
|
}
|
2011-11-01 13:03:12 +01:00
|
|
|
}
|
2015-03-04 14:21:45 +01:00
|
|
|
|
2015-05-05 07:24:00 +02:00
|
|
|
irp = IoBuildDeviceIoControlRequest( params->ioctl.code, device, in_buff, in_size, out_buff, out_size,
|
2016-10-10 17:15:39 +02:00
|
|
|
FALSE, NULL, NULL );
|
2015-03-04 14:21:45 +01:00
|
|
|
if (!irp)
|
|
|
|
{
|
2015-03-11 14:48:22 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, out_buff );
|
2015-03-04 14:21:45 +01:00
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
}
|
2015-07-08 12:04:32 +02:00
|
|
|
|
2016-10-16 08:51:06 +02:00
|
|
|
if (out_size && (params->ioctl.code & 3) != METHOD_BUFFERED)
|
|
|
|
HeapReAlloc( GetProcessHeap(), HEAP_REALLOC_IN_PLACE_ONLY, in_buff, in_size );
|
|
|
|
|
2015-07-08 12:04:32 +02:00
|
|
|
irp->Tail.Overlay.OriginalFileObject = file;
|
|
|
|
irp->RequestorMode = UserMode;
|
2016-10-13 00:51:48 +02:00
|
|
|
irp->AssociatedIrp.SystemBuffer = in_buff;
|
2015-07-08 12:04:32 +02:00
|
|
|
|
2016-10-13 00:51:48 +02:00
|
|
|
irp->Flags |= IRP_DEALLOCATE_BUFFER; /* deallocate in_buff */
|
2016-10-10 17:15:39 +02:00
|
|
|
dispatch_irp( device, irp, irp_handle );
|
2016-10-07 05:19:46 +02:00
|
|
|
|
2016-10-16 08:48:55 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, to_free );
|
2016-10-07 05:19:46 +02:00
|
|
|
return STATUS_SUCCESS;
|
2015-05-05 07:24:00 +02:00
|
|
|
}
|
2007-05-16 21:13:34 +02:00
|
|
|
|
2015-07-08 10:50:00 +02:00
|
|
|
typedef NTSTATUS (*dispatch_func)( const irp_params_t *params, void *in_buff, ULONG in_size,
|
|
|
|
ULONG out_size, HANDLE irp_handle );
|
2007-05-16 21:13:34 +02:00
|
|
|
|
2015-05-05 07:24:00 +02:00
|
|
|
static const dispatch_func dispatch_funcs[IRP_MJ_MAXIMUM_FUNCTION + 1] =
|
|
|
|
{
|
2015-07-08 11:56:01 +02:00
|
|
|
dispatch_create, /* IRP_MJ_CREATE */
|
2015-05-05 07:24:00 +02:00
|
|
|
NULL, /* IRP_MJ_CREATE_NAMED_PIPE */
|
2015-07-08 11:56:01 +02:00
|
|
|
dispatch_close, /* IRP_MJ_CLOSE */
|
2015-05-05 07:24:00 +02:00
|
|
|
dispatch_read, /* IRP_MJ_READ */
|
|
|
|
dispatch_write, /* IRP_MJ_WRITE */
|
|
|
|
NULL, /* IRP_MJ_QUERY_INFORMATION */
|
|
|
|
NULL, /* IRP_MJ_SET_INFORMATION */
|
|
|
|
NULL, /* IRP_MJ_QUERY_EA */
|
|
|
|
NULL, /* IRP_MJ_SET_EA */
|
2015-05-06 10:14:31 +02:00
|
|
|
dispatch_flush, /* IRP_MJ_FLUSH_BUFFERS */
|
2015-05-05 07:24:00 +02:00
|
|
|
NULL, /* IRP_MJ_QUERY_VOLUME_INFORMATION */
|
|
|
|
NULL, /* IRP_MJ_SET_VOLUME_INFORMATION */
|
|
|
|
NULL, /* IRP_MJ_DIRECTORY_CONTROL */
|
|
|
|
NULL, /* IRP_MJ_FILE_SYSTEM_CONTROL */
|
|
|
|
dispatch_ioctl, /* IRP_MJ_DEVICE_CONTROL */
|
|
|
|
NULL, /* IRP_MJ_INTERNAL_DEVICE_CONTROL */
|
|
|
|
NULL, /* IRP_MJ_SHUTDOWN */
|
|
|
|
NULL, /* IRP_MJ_LOCK_CONTROL */
|
|
|
|
NULL, /* IRP_MJ_CLEANUP */
|
|
|
|
NULL, /* IRP_MJ_CREATE_MAILSLOT */
|
|
|
|
NULL, /* IRP_MJ_QUERY_SECURITY */
|
|
|
|
NULL, /* IRP_MJ_SET_SECURITY */
|
|
|
|
NULL, /* IRP_MJ_POWER */
|
|
|
|
NULL, /* IRP_MJ_SYSTEM_CONTROL */
|
|
|
|
NULL, /* IRP_MJ_DEVICE_CHANGE */
|
|
|
|
NULL, /* IRP_MJ_QUERY_QUOTA */
|
|
|
|
NULL, /* IRP_MJ_SET_QUOTA */
|
|
|
|
NULL, /* IRP_MJ_PNP */
|
|
|
|
};
|
2007-05-16 21:13:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* wine_ntoskrnl_main_loop (Not a Windows API)
|
|
|
|
*/
|
2008-12-16 15:36:59 +01:00
|
|
|
NTSTATUS CDECL wine_ntoskrnl_main_loop( HANDLE stop_event )
|
2007-05-16 21:13:34 +02:00
|
|
|
{
|
|
|
|
HANDLE manager = get_device_manager();
|
2015-05-05 04:34:15 +02:00
|
|
|
HANDLE irp = 0;
|
2007-05-16 21:13:34 +02:00
|
|
|
NTSTATUS status = STATUS_SUCCESS;
|
2015-05-06 04:21:40 +02:00
|
|
|
irp_params_t irp_params;
|
2007-05-16 21:13:34 +02:00
|
|
|
ULONG in_size = 4096, out_size = 0;
|
2016-10-13 00:51:48 +02:00
|
|
|
void *in_buff = NULL;
|
2007-05-16 21:13:34 +02:00
|
|
|
HANDLE handles[2];
|
|
|
|
|
2011-10-27 14:20:19 +02:00
|
|
|
request_thread = GetCurrentThreadId();
|
|
|
|
|
2007-05-16 21:13:34 +02:00
|
|
|
handles[0] = stop_event;
|
|
|
|
handles[1] = manager;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
2016-10-13 00:51:48 +02:00
|
|
|
if (!in_buff && !(in_buff = HeapAlloc( GetProcessHeap(), 0, in_size )))
|
|
|
|
{
|
|
|
|
ERR( "failed to allocate buffer\n" );
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
}
|
|
|
|
|
2007-05-16 21:13:34 +02:00
|
|
|
SERVER_START_REQ( get_next_device_request )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->manager = wine_server_obj_handle( manager );
|
2015-05-05 04:34:15 +02:00
|
|
|
req->prev = wine_server_obj_handle( irp );
|
2007-05-16 21:13:34 +02:00
|
|
|
req->status = status;
|
|
|
|
wine_server_set_reply( req, in_buff, in_size );
|
|
|
|
if (!(status = wine_server_call( req )))
|
|
|
|
{
|
2015-05-05 04:34:15 +02:00
|
|
|
irp = wine_server_ptr_handle( reply->next );
|
2015-05-06 04:21:40 +02:00
|
|
|
irp_params = reply->params;
|
2012-03-15 17:15:56 +01:00
|
|
|
client_tid = reply->client_tid;
|
|
|
|
client_pid = reply->client_pid;
|
2011-10-27 14:20:19 +02:00
|
|
|
in_size = reply->in_size;
|
|
|
|
out_size = reply->out_size;
|
2007-05-16 21:13:34 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-05-05 04:34:15 +02:00
|
|
|
irp = 0; /* no previous irp */
|
2016-10-13 00:51:48 +02:00
|
|
|
if (status == STATUS_BUFFER_OVERFLOW)
|
|
|
|
in_size = reply->in_size;
|
2007-05-16 21:13:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
2016-10-13 00:51:48 +02:00
|
|
|
switch (status)
|
2007-05-16 21:13:34 +02:00
|
|
|
{
|
|
|
|
case STATUS_SUCCESS:
|
2015-07-08 10:50:00 +02:00
|
|
|
if (irp_params.major > IRP_MJ_MAXIMUM_FUNCTION || !dispatch_funcs[irp_params.major])
|
2015-05-05 04:34:15 +02:00
|
|
|
{
|
2015-05-05 07:24:00 +02:00
|
|
|
WARN( "unsupported request %u\n", irp_params.major );
|
2015-05-05 04:34:15 +02:00
|
|
|
status = STATUS_NOT_SUPPORTED;
|
|
|
|
break;
|
|
|
|
}
|
2015-07-08 10:50:00 +02:00
|
|
|
status = dispatch_funcs[irp_params.major]( &irp_params, in_buff, in_size, out_size, irp );
|
2016-10-13 00:51:48 +02:00
|
|
|
if (status == STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
irp = 0; /* status reported by IoCompleteRequest */
|
|
|
|
in_size = 4096;
|
|
|
|
in_buff = NULL;
|
|
|
|
}
|
2007-05-16 21:13:34 +02:00
|
|
|
break;
|
|
|
|
case STATUS_BUFFER_OVERFLOW:
|
|
|
|
HeapFree( GetProcessHeap(), 0, in_buff );
|
2016-10-13 00:51:48 +02:00
|
|
|
in_buff = NULL;
|
2007-05-16 21:13:34 +02:00
|
|
|
/* restart with larger buffer */
|
|
|
|
break;
|
|
|
|
case STATUS_PENDING:
|
2015-03-13 09:02:35 +01:00
|
|
|
for (;;)
|
2009-01-10 21:56:10 +01:00
|
|
|
{
|
2015-03-13 09:02:35 +01:00
|
|
|
DWORD ret = WaitForMultipleObjectsEx( 2, handles, FALSE, INFINITE, TRUE );
|
|
|
|
if (ret == WAIT_OBJECT_0)
|
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, in_buff );
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
if (ret != WAIT_IO_COMPLETION) break;
|
2009-01-10 21:56:10 +01:00
|
|
|
}
|
2007-05-16 21:13:34 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-29 14:52:57 +02:00
|
|
|
|
2012-10-02 06:36:52 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoAcquireCancelSpinLock (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI IoAcquireCancelSpinLock(PKIRQL irql)
|
|
|
|
{
|
|
|
|
FIXME("(%p): stub\n", irql);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IoReleaseCancelSpinLock (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI IoReleaseCancelSpinLock(PKIRQL irql)
|
|
|
|
{
|
|
|
|
FIXME("(%p): stub\n", irql);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-16 10:19:08 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* IoAllocateDriverObjectExtension (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoAllocateDriverObjectExtension( PDRIVER_OBJECT DriverObject,
|
|
|
|
PVOID ClientIdentificationAddress,
|
|
|
|
ULONG DriverObjectExtensionSize,
|
|
|
|
PVOID *DriverObjectExtension )
|
|
|
|
{
|
2008-12-28 12:56:29 +01:00
|
|
|
FIXME( "stub: %p, %p, %u, %p\n", DriverObject, ClientIdentificationAddress,
|
2008-12-16 10:19:08 +01:00
|
|
|
DriverObjectExtensionSize, DriverObjectExtension );
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IoGetDriverObjectExtension (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PVOID WINAPI IoGetDriverObjectExtension( PDRIVER_OBJECT DriverObject,
|
|
|
|
PVOID ClientIdentificationAddress )
|
|
|
|
{
|
2008-12-28 12:56:29 +01:00
|
|
|
FIXME( "stub: %p, %p\n", DriverObject, ClientIdentificationAddress );
|
2008-12-16 10:19:08 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-29 14:52:57 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoInitializeIrp (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI IoInitializeIrp( IRP *irp, USHORT size, CCHAR stack_size )
|
|
|
|
{
|
2008-10-03 15:51:26 +02:00
|
|
|
TRACE( "%p, %u, %d\n", irp, size, stack_size );
|
|
|
|
|
|
|
|
RtlZeroMemory( irp, size );
|
|
|
|
|
|
|
|
irp->Type = IO_TYPE_IRP;
|
|
|
|
irp->Size = size;
|
|
|
|
InitializeListHead( &irp->ThreadListEntry );
|
|
|
|
irp->StackCount = stack_size;
|
|
|
|
irp->CurrentLocation = stack_size + 1;
|
2010-02-24 17:50:03 +01:00
|
|
|
irp->Tail.Overlay.s.u2.CurrentStackLocation =
|
2008-10-03 15:51:26 +02:00
|
|
|
(PIO_STACK_LOCATION)(irp + 1) + stack_size;
|
2008-07-29 14:52:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-14 14:01:38 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoInitializeTimer (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoInitializeTimer(PDEVICE_OBJECT DeviceObject,
|
|
|
|
PIO_TIMER_ROUTINE TimerRoutine,
|
|
|
|
PVOID Context)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p, %p, %p\n", DeviceObject, TimerRoutine, Context );
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-14 14:05:54 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoStartTimer (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI IoStartTimer(PDEVICE_OBJECT DeviceObject)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p\n", DeviceObject );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-04 16:59:18 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* IoStopTimer (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI IoStopTimer(PDEVICE_OBJECT DeviceObject)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p\n", DeviceObject );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-29 14:52:57 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoAllocateIrp (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PIRP WINAPI IoAllocateIrp( CCHAR stack_size, BOOLEAN charge_quota )
|
|
|
|
{
|
2008-10-03 15:51:26 +02:00
|
|
|
SIZE_T size;
|
|
|
|
PIRP irp;
|
2016-03-29 22:13:16 +02:00
|
|
|
CCHAR loc_count = stack_size;
|
2008-10-03 15:51:26 +02:00
|
|
|
|
|
|
|
TRACE( "%d, %d\n", stack_size, charge_quota );
|
|
|
|
|
2016-03-29 22:13:16 +02:00
|
|
|
if (loc_count < 8 && loc_count != 1)
|
|
|
|
loc_count = 8;
|
|
|
|
|
|
|
|
size = sizeof(IRP) + loc_count * sizeof(IO_STACK_LOCATION);
|
2008-10-03 15:51:26 +02:00
|
|
|
irp = ExAllocatePool( NonPagedPool, size );
|
2008-10-30 21:56:59 +01:00
|
|
|
if (irp == NULL)
|
|
|
|
return NULL;
|
|
|
|
IoInitializeIrp( irp, size, stack_size );
|
2016-03-29 22:13:16 +02:00
|
|
|
if (stack_size >= 1 && stack_size <= 8)
|
|
|
|
irp->AllocationFlags = IRP_ALLOCATED_FIXED_SIZE;
|
2008-10-03 15:51:26 +02:00
|
|
|
if (charge_quota)
|
|
|
|
irp->AllocationFlags |= IRP_LOOKASIDE_ALLOCATION;
|
|
|
|
return irp;
|
2008-07-29 14:52:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IoFreeIrp (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI IoFreeIrp( IRP *irp )
|
|
|
|
{
|
2015-03-04 14:45:06 +01:00
|
|
|
MDL *mdl;
|
|
|
|
|
2008-10-03 15:51:26 +02:00
|
|
|
TRACE( "%p\n", irp );
|
|
|
|
|
2015-03-04 14:45:06 +01:00
|
|
|
mdl = irp->MdlAddress;
|
|
|
|
while (mdl)
|
|
|
|
{
|
|
|
|
MDL *next = mdl->Next;
|
|
|
|
IoFreeMdl( mdl );
|
|
|
|
mdl = next;
|
|
|
|
}
|
|
|
|
|
2008-10-03 15:51:26 +02:00
|
|
|
ExFreePool( irp );
|
2008-07-29 14:52:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-09 19:22:14 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* IoAllocateErrorLogEntry (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PVOID WINAPI IoAllocateErrorLogEntry( PVOID IoObject, UCHAR EntrySize )
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p, %u\n", IoObject, EntrySize );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-08 22:40:43 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* IoAllocateMdl (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2015-03-04 14:45:06 +01:00
|
|
|
PMDL WINAPI IoAllocateMdl( PVOID va, ULONG length, BOOLEAN secondary, BOOLEAN charge_quota, IRP *irp )
|
2007-11-08 22:40:43 +01:00
|
|
|
{
|
2016-10-16 08:53:29 +02:00
|
|
|
SIZE_T mdl_size;
|
2012-09-27 23:12:28 +02:00
|
|
|
PMDL mdl;
|
|
|
|
|
2015-03-04 14:45:06 +01:00
|
|
|
TRACE("(%p, %u, %i, %i, %p)\n", va, length, secondary, charge_quota, irp);
|
2012-10-02 00:09:51 +02:00
|
|
|
|
2015-03-04 14:45:06 +01:00
|
|
|
if (charge_quota)
|
2012-10-02 00:09:51 +02:00
|
|
|
FIXME("Charge quota is not yet supported\n");
|
|
|
|
|
2016-10-16 08:53:29 +02:00
|
|
|
mdl_size = sizeof(MDL) + sizeof(PFN_NUMBER) * ADDRESS_AND_SIZE_TO_SPAN_PAGES(va, length);
|
|
|
|
mdl = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, mdl_size );
|
2012-09-27 23:12:28 +02:00
|
|
|
if (!mdl)
|
|
|
|
return NULL;
|
|
|
|
|
2016-10-16 08:53:29 +02:00
|
|
|
MmInitializeMdl( mdl, va, length );
|
2012-10-02 00:09:51 +02:00
|
|
|
|
2015-03-04 14:45:06 +01:00
|
|
|
if (!irp) return mdl;
|
|
|
|
|
|
|
|
if (secondary) /* add it at the end */
|
|
|
|
{
|
|
|
|
MDL **pmdl = &irp->MdlAddress;
|
|
|
|
while (*pmdl) pmdl = &(*pmdl)->Next;
|
|
|
|
*pmdl = mdl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mdl->Next = irp->MdlAddress;
|
|
|
|
irp->MdlAddress = mdl;
|
|
|
|
}
|
2012-09-27 23:12:28 +02:00
|
|
|
return mdl;
|
2007-11-08 22:40:43 +01:00
|
|
|
}
|
|
|
|
|
2007-05-15 21:41:50 +02:00
|
|
|
|
2012-09-27 23:12:36 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoFreeMdl (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2015-03-04 14:45:06 +01:00
|
|
|
void WINAPI IoFreeMdl(PMDL mdl)
|
2012-09-27 23:12:36 +02:00
|
|
|
{
|
2015-03-04 14:45:06 +01:00
|
|
|
TRACE("%p\n", mdl);
|
2012-09-27 23:12:36 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, mdl);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-08 22:09:08 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* IoAllocateWorkItem (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PIO_WORKITEM WINAPI IoAllocateWorkItem( PDEVICE_OBJECT DeviceObject )
|
|
|
|
{
|
2007-11-13 09:28:53 +01:00
|
|
|
FIXME( "stub: %p\n", DeviceObject );
|
2007-11-08 22:09:08 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-10-03 15:51:26 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoAttachDeviceToDeviceStack (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PDEVICE_OBJECT WINAPI IoAttachDeviceToDeviceStack( DEVICE_OBJECT *source,
|
|
|
|
DEVICE_OBJECT *target )
|
|
|
|
{
|
|
|
|
TRACE( "%p, %p\n", source, target );
|
|
|
|
target->AttachedDevice = source;
|
|
|
|
source->StackSize = target->StackSize + 1;
|
|
|
|
return target;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IoBuildDeviceIoControlRequest (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2015-03-04 14:21:45 +01:00
|
|
|
PIRP WINAPI IoBuildDeviceIoControlRequest( ULONG code, PDEVICE_OBJECT device,
|
|
|
|
PVOID in_buff, ULONG in_len,
|
|
|
|
PVOID out_buff, ULONG out_len,
|
|
|
|
BOOLEAN internal, PKEVENT event,
|
|
|
|
PIO_STATUS_BLOCK iosb )
|
2008-10-03 15:51:26 +02:00
|
|
|
{
|
|
|
|
PIRP irp;
|
|
|
|
PIO_STACK_LOCATION irpsp;
|
2016-10-16 08:57:21 +02:00
|
|
|
MDL *mdl;
|
2008-10-03 15:51:26 +02:00
|
|
|
|
|
|
|
TRACE( "%x, %p, %p, %u, %p, %u, %u, %p, %p\n",
|
2015-03-04 14:21:45 +01:00
|
|
|
code, device, in_buff, in_len, out_buff, out_len, internal, event, iosb );
|
2008-10-03 15:51:26 +02:00
|
|
|
|
2015-03-04 14:21:45 +01:00
|
|
|
if (device == NULL)
|
2008-10-03 15:51:26 +02:00
|
|
|
return NULL;
|
|
|
|
|
2015-03-04 14:21:45 +01:00
|
|
|
irp = IoAllocateIrp( device->StackSize, FALSE );
|
2008-10-03 15:51:26 +02:00
|
|
|
if (irp == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2010-04-10 17:17:57 +02:00
|
|
|
irpsp = IoGetNextIrpStackLocation( irp );
|
2015-03-04 14:21:45 +01:00
|
|
|
irpsp->MajorFunction = internal ? IRP_MJ_INTERNAL_DEVICE_CONTROL : IRP_MJ_DEVICE_CONTROL;
|
|
|
|
irpsp->Parameters.DeviceIoControl.IoControlCode = code;
|
|
|
|
irpsp->Parameters.DeviceIoControl.InputBufferLength = in_len;
|
|
|
|
irpsp->Parameters.DeviceIoControl.OutputBufferLength = out_len;
|
|
|
|
irpsp->DeviceObject = device;
|
|
|
|
irpsp->CompletionRoutine = NULL;
|
2008-10-03 15:51:26 +02:00
|
|
|
|
2015-03-11 14:48:22 +01:00
|
|
|
switch (code & 3)
|
|
|
|
{
|
|
|
|
case METHOD_BUFFERED:
|
|
|
|
irp->AssociatedIrp.SystemBuffer = in_buff;
|
|
|
|
break;
|
|
|
|
case METHOD_IN_DIRECT:
|
|
|
|
case METHOD_OUT_DIRECT:
|
|
|
|
irp->AssociatedIrp.SystemBuffer = in_buff;
|
2016-10-16 08:57:21 +02:00
|
|
|
|
|
|
|
mdl = IoAllocateMdl( out_buff, out_len, FALSE, FALSE, irp );
|
|
|
|
if (!mdl)
|
|
|
|
{
|
|
|
|
IoFreeIrp( irp );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
mdl->MdlFlags |= MDL_MAPPED_TO_SYSTEM_VA;
|
|
|
|
mdl->MappedSystemVa = out_buff;
|
2015-03-11 14:48:22 +01:00
|
|
|
break;
|
|
|
|
case METHOD_NEITHER:
|
|
|
|
irpsp->Parameters.DeviceIoControl.Type3InputBuffer = in_buff;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
irp->RequestorMode = KernelMode;
|
|
|
|
irp->UserBuffer = out_buff;
|
2015-03-04 14:21:45 +01:00
|
|
|
irp->UserIosb = iosb;
|
|
|
|
irp->UserEvent = event;
|
2008-10-03 15:51:26 +02:00
|
|
|
return irp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-12-02 09:22:10 +01:00
|
|
|
/**********************************************************
|
|
|
|
* IoBuildSynchronousFsdRequest (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PIRP WINAPI IoBuildSynchronousFsdRequest(ULONG majorfunc, PDEVICE_OBJECT device,
|
|
|
|
PVOID buffer, ULONG length, PLARGE_INTEGER startoffset,
|
|
|
|
PKEVENT event, PIO_STATUS_BLOCK iosb)
|
|
|
|
{
|
|
|
|
PIRP irp;
|
|
|
|
PIO_STACK_LOCATION irpsp;
|
|
|
|
|
2015-05-05 07:22:52 +02:00
|
|
|
TRACE("(%d %p %p %d %p %p %p)\n", majorfunc, device, buffer, length, startoffset, event, iosb);
|
2014-12-02 09:22:10 +01:00
|
|
|
|
2015-05-05 07:22:52 +02:00
|
|
|
if (!(irp = IoAllocateIrp( device->StackSize, FALSE ))) return NULL;
|
2014-12-02 09:22:10 +01:00
|
|
|
|
|
|
|
irpsp = IoGetNextIrpStackLocation( irp );
|
|
|
|
irpsp->MajorFunction = majorfunc;
|
2015-05-05 07:22:52 +02:00
|
|
|
irpsp->DeviceObject = device;
|
|
|
|
irpsp->CompletionRoutine = NULL;
|
|
|
|
|
|
|
|
irp->AssociatedIrp.SystemBuffer = buffer;
|
2016-10-16 08:57:21 +02:00
|
|
|
|
|
|
|
if (device->Flags & DO_DIRECT_IO)
|
|
|
|
{
|
|
|
|
MDL *mdl = IoAllocateMdl( buffer, length, FALSE, FALSE, irp );
|
|
|
|
if (!mdl)
|
|
|
|
{
|
|
|
|
IoFreeIrp( irp );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
mdl->MdlFlags |= MDL_MAPPED_TO_SYSTEM_VA;
|
|
|
|
mdl->MappedSystemVa = buffer;
|
|
|
|
}
|
2014-12-02 09:22:10 +01:00
|
|
|
|
2015-05-05 07:22:52 +02:00
|
|
|
switch (majorfunc)
|
|
|
|
{
|
|
|
|
case IRP_MJ_READ:
|
|
|
|
irpsp->Parameters.Read.Length = length;
|
|
|
|
irpsp->Parameters.Read.ByteOffset = *startoffset;
|
|
|
|
break;
|
|
|
|
case IRP_MJ_WRITE:
|
|
|
|
irpsp->Parameters.Write.Length = length;
|
|
|
|
irpsp->Parameters.Write.ByteOffset = *startoffset;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
irp->RequestorMode = KernelMode;
|
2014-12-02 09:22:10 +01:00
|
|
|
irp->UserIosb = iosb;
|
|
|
|
irp->UserEvent = event;
|
|
|
|
irp->UserBuffer = buffer;
|
|
|
|
return irp;
|
|
|
|
}
|
|
|
|
|
2016-07-22 20:45:21 +02:00
|
|
|
static void build_driver_keypath( const WCHAR *name, UNICODE_STRING *keypath )
|
|
|
|
{
|
|
|
|
static const WCHAR driverW[] = {'\\','D','r','i','v','e','r','\\',0};
|
|
|
|
WCHAR *str;
|
|
|
|
|
|
|
|
/* Check what prefix is present */
|
|
|
|
if (strncmpW( name, servicesW, strlenW(servicesW) ) == 0)
|
|
|
|
{
|
|
|
|
FIXME( "Driver name %s is malformed as the keypath\n", debugstr_w(name) );
|
|
|
|
RtlCreateUnicodeString( keypath, name );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (strncmpW( name, driverW, strlenW(driverW) ) == 0)
|
|
|
|
name += strlenW(driverW);
|
|
|
|
else
|
2016-07-29 12:55:12 +02:00
|
|
|
FIXME( "Driver name %s does not properly begin with \\Driver\\\n", debugstr_w(name) );
|
2016-07-22 20:45:21 +02:00
|
|
|
|
|
|
|
str = HeapAlloc( GetProcessHeap(), 0, sizeof(servicesW) + strlenW(name)*sizeof(WCHAR));
|
|
|
|
lstrcpyW( str, servicesW );
|
|
|
|
lstrcatW( str, name );
|
|
|
|
RtlInitUnicodeString( keypath, str );
|
|
|
|
}
|
2014-12-02 09:22:10 +01:00
|
|
|
|
2016-08-03 18:41:30 +02:00
|
|
|
|
2016-10-05 23:30:10 +02:00
|
|
|
static NTSTATUS WINAPI unhandled_irp( DEVICE_OBJECT *device, IRP *irp )
|
|
|
|
{
|
|
|
|
TRACE( "(%p, %p)\n", device, irp );
|
|
|
|
irp->IoStatus.u.Status = STATUS_INVALID_DEVICE_REQUEST;
|
|
|
|
IoCompleteRequest( irp, IO_NO_INCREMENT );
|
|
|
|
return STATUS_INVALID_DEVICE_REQUEST;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-18 19:46:06 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* IoCreateDriver (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoCreateDriver( UNICODE_STRING *name, PDRIVER_INITIALIZE init )
|
|
|
|
{
|
2016-08-03 18:41:30 +02:00
|
|
|
struct wine_driver *driver;
|
2007-12-18 19:46:06 +01:00
|
|
|
NTSTATUS status;
|
2016-10-05 23:30:10 +02:00
|
|
|
unsigned int i;
|
2007-12-18 19:46:06 +01:00
|
|
|
|
2012-09-29 22:28:24 +02:00
|
|
|
TRACE("(%s, %p)\n", debugstr_us(name), init);
|
|
|
|
|
2007-12-18 19:46:06 +01:00
|
|
|
if (!(driver = RtlAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY,
|
2016-08-03 18:41:30 +02:00
|
|
|
sizeof(*driver) )))
|
2007-12-18 19:46:06 +01:00
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
|
2016-08-03 18:41:30 +02:00
|
|
|
if ((status = RtlDuplicateUnicodeString( 1, name, &driver->driver_obj.DriverName )))
|
2007-12-18 19:46:06 +01:00
|
|
|
{
|
|
|
|
RtlFreeHeap( GetProcessHeap(), 0, driver );
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2016-08-03 18:41:30 +02:00
|
|
|
driver->driver_obj.Size = sizeof(driver->driver_obj);
|
|
|
|
driver->driver_obj.DriverInit = init;
|
|
|
|
driver->driver_obj.DriverExtension = &driver->driver_extension;
|
|
|
|
driver->driver_extension.DriverObject = &driver->driver_obj;
|
|
|
|
build_driver_keypath( driver->driver_obj.DriverName.Buffer, &driver->driver_extension.ServiceKeyName );
|
2016-10-05 23:30:10 +02:00
|
|
|
for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
|
|
|
|
driver->driver_obj.MajorFunction[i] = unhandled_irp;
|
2007-12-18 19:46:06 +01:00
|
|
|
|
2016-08-03 18:41:30 +02:00
|
|
|
status = driver->driver_obj.DriverInit( &driver->driver_obj, &driver->driver_extension.ServiceKeyName );
|
2007-12-18 19:46:06 +01:00
|
|
|
if (status)
|
|
|
|
{
|
2016-08-03 18:41:30 +02:00
|
|
|
RtlFreeUnicodeString( &driver->driver_obj.DriverName );
|
2016-08-03 18:41:42 +02:00
|
|
|
RtlFreeUnicodeString( &driver->driver_extension.ServiceKeyName );
|
2007-12-18 19:46:06 +01:00
|
|
|
RtlFreeHeap( GetProcessHeap(), 0, driver );
|
2016-10-05 23:30:10 +02:00
|
|
|
return status;
|
2007-12-18 19:46:06 +01:00
|
|
|
}
|
2016-10-05 23:30:10 +02:00
|
|
|
|
|
|
|
for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
|
2016-08-03 18:41:30 +02:00
|
|
|
{
|
2016-10-05 23:30:10 +02:00
|
|
|
if (driver->driver_obj.MajorFunction[i]) continue;
|
|
|
|
driver->driver_obj.MajorFunction[i] = unhandled_irp;
|
2016-08-03 18:41:30 +02:00
|
|
|
}
|
|
|
|
|
2016-10-05 23:30:10 +02:00
|
|
|
EnterCriticalSection( &drivers_cs );
|
|
|
|
if (wine_rb_put( &wine_drivers, &driver->driver_obj.DriverName, &driver->entry ))
|
|
|
|
ERR( "failed to insert driver %s in tree\n", debugstr_us(name) );
|
|
|
|
LeaveCriticalSection( &drivers_cs );
|
|
|
|
return STATUS_SUCCESS;
|
2007-12-18 19:46:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IoDeleteDriver (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2016-08-03 18:41:30 +02:00
|
|
|
void WINAPI IoDeleteDriver( DRIVER_OBJECT *driver_object )
|
2007-12-18 19:46:06 +01:00
|
|
|
{
|
2016-08-03 18:41:30 +02:00
|
|
|
TRACE( "(%p)\n", driver_object );
|
|
|
|
|
|
|
|
EnterCriticalSection( &drivers_cs );
|
2016-09-12 13:44:09 +02:00
|
|
|
wine_rb_remove_key( &wine_drivers, &driver_object->DriverName );
|
2016-08-03 18:41:30 +02:00
|
|
|
LeaveCriticalSection( &drivers_cs );
|
2012-09-29 22:28:24 +02:00
|
|
|
|
2016-08-03 18:41:30 +02:00
|
|
|
RtlFreeUnicodeString( &driver_object->DriverName );
|
|
|
|
RtlFreeUnicodeString( &driver_object->DriverExtension->ServiceKeyName );
|
|
|
|
RtlFreeHeap( GetProcessHeap(), 0, CONTAINING_RECORD( driver_object, struct wine_driver, driver_obj ) );
|
2007-12-18 19:46:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-15 21:41:50 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoCreateDevice (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoCreateDevice( DRIVER_OBJECT *driver, ULONG ext_size,
|
|
|
|
UNICODE_STRING *name, DEVICE_TYPE type,
|
|
|
|
ULONG characteristics, BOOLEAN exclusive,
|
|
|
|
DEVICE_OBJECT **ret_device )
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
DEVICE_OBJECT *device;
|
|
|
|
HANDLE handle = 0;
|
|
|
|
HANDLE manager = get_device_manager();
|
|
|
|
|
|
|
|
TRACE( "(%p, %u, %s, %u, %x, %u, %p)\n",
|
|
|
|
driver, ext_size, debugstr_us(name), type, characteristics, exclusive, ret_device );
|
|
|
|
|
|
|
|
if (!(device = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*device) + ext_size )))
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
|
|
|
|
SERVER_START_REQ( create_device )
|
|
|
|
{
|
|
|
|
req->access = 0;
|
|
|
|
req->attributes = 0;
|
|
|
|
req->rootdir = 0;
|
2008-12-08 16:05:17 +01:00
|
|
|
req->manager = wine_server_obj_handle( manager );
|
2008-12-29 17:28:40 +01:00
|
|
|
req->user_ptr = wine_server_client_ptr( device );
|
2007-05-15 21:41:50 +02:00
|
|
|
if (name) wine_server_add_data( req, name->Buffer, name->Length );
|
2008-12-08 16:05:17 +01:00
|
|
|
if (!(status = wine_server_call( req ))) handle = wine_server_ptr_handle( reply->handle );
|
2007-05-15 21:41:50 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
|
|
|
if (status == STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
device->DriverObject = driver;
|
|
|
|
device->DeviceExtension = device + 1;
|
|
|
|
device->DeviceType = type;
|
2008-10-03 14:26:25 +02:00
|
|
|
device->StackSize = 1;
|
2007-05-15 21:41:50 +02:00
|
|
|
device->Reserved = handle;
|
|
|
|
|
|
|
|
device->NextDevice = driver->DeviceObject;
|
|
|
|
driver->DeviceObject = device;
|
|
|
|
|
|
|
|
*ret_device = device;
|
|
|
|
}
|
|
|
|
else HeapFree( GetProcessHeap(), 0, device );
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IoDeleteDevice (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI IoDeleteDevice( DEVICE_OBJECT *device )
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
TRACE( "%p\n", device );
|
|
|
|
|
|
|
|
SERVER_START_REQ( delete_device )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( device->Reserved );
|
2007-05-15 21:41:50 +02:00
|
|
|
status = wine_server_call( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
|
|
|
if (status == STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
DEVICE_OBJECT **prev = &device->DriverObject->DeviceObject;
|
|
|
|
while (*prev && *prev != device) prev = &(*prev)->NextDevice;
|
|
|
|
if (*prev) *prev = (*prev)->NextDevice;
|
|
|
|
NtClose( device->Reserved );
|
|
|
|
HeapFree( GetProcessHeap(), 0, device );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-15 21:45:51 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoCreateSymbolicLink (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoCreateSymbolicLink( UNICODE_STRING *name, UNICODE_STRING *target )
|
|
|
|
{
|
|
|
|
HANDLE handle;
|
|
|
|
OBJECT_ATTRIBUTES attr;
|
|
|
|
|
|
|
|
attr.Length = sizeof(attr);
|
|
|
|
attr.RootDirectory = 0;
|
|
|
|
attr.ObjectName = name;
|
|
|
|
attr.Attributes = OBJ_CASE_INSENSITIVE | OBJ_OPENIF;
|
|
|
|
attr.SecurityDescriptor = NULL;
|
|
|
|
attr.SecurityQualityOfService = NULL;
|
|
|
|
|
|
|
|
TRACE( "%s -> %s\n", debugstr_us(name), debugstr_us(target) );
|
|
|
|
/* FIXME: store handle somewhere */
|
|
|
|
return NtCreateSymbolicLinkObject( &handle, SYMBOLIC_LINK_ALL_ACCESS, &attr, target );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-29 15:04:47 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoDeleteSymbolicLink (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoDeleteSymbolicLink( UNICODE_STRING *name )
|
|
|
|
{
|
2008-10-20 16:21:22 +02:00
|
|
|
HANDLE handle;
|
|
|
|
OBJECT_ATTRIBUTES attr;
|
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
attr.Length = sizeof(attr);
|
|
|
|
attr.RootDirectory = 0;
|
|
|
|
attr.ObjectName = name;
|
|
|
|
attr.Attributes = OBJ_CASE_INSENSITIVE;
|
|
|
|
attr.SecurityDescriptor = NULL;
|
|
|
|
attr.SecurityQualityOfService = NULL;
|
|
|
|
|
|
|
|
if (!(status = NtOpenSymbolicLinkObject( &handle, 0, &attr )))
|
|
|
|
{
|
|
|
|
SERVER_START_REQ( unlink_object )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( handle );
|
2008-10-20 16:21:22 +02:00
|
|
|
status = wine_server_call( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
NtClose( handle );
|
|
|
|
}
|
|
|
|
return status;
|
2008-07-29 15:04:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-03 15:49:10 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* IoGetDeviceInterfaces (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2013-09-25 10:39:19 +02:00
|
|
|
NTSTATUS WINAPI IoGetDeviceInterfaces( const GUID *InterfaceClassGuid,
|
2011-02-03 15:49:10 +01:00
|
|
|
PDEVICE_OBJECT PhysicalDeviceObject,
|
|
|
|
ULONG Flags, PWSTR *SymbolicLinkList )
|
|
|
|
{
|
|
|
|
FIXME( "stub: %s %p %x %p\n", debugstr_guid(InterfaceClassGuid),
|
|
|
|
PhysicalDeviceObject, Flags, SymbolicLinkList );
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-28 23:22:15 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoGetDeviceObjectPointer (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoGetDeviceObjectPointer( UNICODE_STRING *name, ACCESS_MASK access, PFILE_OBJECT *file, PDEVICE_OBJECT *device )
|
|
|
|
{
|
2015-06-15 02:58:20 +02:00
|
|
|
static DEVICE_OBJECT stub_device;
|
|
|
|
static DRIVER_OBJECT stub_driver;
|
|
|
|
|
2008-08-28 23:22:15 +02:00
|
|
|
FIXME( "stub: %s %x %p %p\n", debugstr_us(name), access, file, device );
|
2012-09-29 22:28:24 +02:00
|
|
|
|
2015-06-15 02:58:20 +02:00
|
|
|
stub_device.StackSize = 0x80; /* minimum value to appease SecuROM 5.x */
|
|
|
|
stub_device.DriverObject = &stub_driver;
|
|
|
|
|
2014-12-02 09:22:10 +01:00
|
|
|
*file = NULL;
|
2015-06-15 02:58:20 +02:00
|
|
|
*device = &stub_device;
|
2014-12-02 09:22:10 +01:00
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
2008-08-28 23:22:15 +02:00
|
|
|
}
|
|
|
|
|
2014-12-02 09:22:10 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* IoGetAttachedDevice (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2016-09-07 11:21:22 +02:00
|
|
|
DEVICE_OBJECT* WINAPI IoGetAttachedDevice( DEVICE_OBJECT *device )
|
2014-12-02 09:22:10 +01:00
|
|
|
{
|
2016-09-07 11:21:22 +02:00
|
|
|
DEVICE_OBJECT *result = device;
|
2014-12-02 09:22:10 +01:00
|
|
|
|
2016-09-07 11:21:22 +02:00
|
|
|
TRACE( "(%p)\n", device );
|
|
|
|
|
|
|
|
while (result->AttachedDevice)
|
|
|
|
result = result->AttachedDevice;
|
|
|
|
|
|
|
|
return result;
|
2014-12-02 09:22:10 +01:00
|
|
|
}
|
2008-08-28 23:46:51 +02:00
|
|
|
|
2016-09-07 11:21:22 +02:00
|
|
|
|
2010-04-14 21:28:59 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoGetDeviceProperty (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoGetDeviceProperty( DEVICE_OBJECT *device, DEVICE_REGISTRY_PROPERTY device_property,
|
|
|
|
ULONG buffer_length, PVOID property_buffer, PULONG result_length )
|
|
|
|
{
|
2016-01-29 16:44:36 +01:00
|
|
|
NTSTATUS status = STATUS_NOT_IMPLEMENTED;
|
|
|
|
TRACE( "%p %d %u %p %p\n", device, device_property, buffer_length,
|
2010-04-14 21:28:59 +02:00
|
|
|
property_buffer, result_length );
|
2016-01-29 16:44:36 +01:00
|
|
|
switch (device_property)
|
|
|
|
{
|
2016-09-19 15:13:58 +02:00
|
|
|
case DevicePropertyEnumeratorName:
|
|
|
|
{
|
|
|
|
WCHAR *id, *ptr;
|
|
|
|
|
|
|
|
status = get_device_id( device, BusQueryInstanceID, &id );
|
|
|
|
if (status != STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
ERR( "Failed to get device id\n" );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
struprW( id );
|
|
|
|
ptr = strchrW( id, '\\' );
|
|
|
|
if (ptr) *ptr = 0;
|
|
|
|
|
|
|
|
*result_length = sizeof(WCHAR) * (strlenW(id) + 1);
|
|
|
|
if (buffer_length >= *result_length)
|
|
|
|
memcpy( property_buffer, id, *result_length );
|
|
|
|
else
|
|
|
|
status = STATUS_BUFFER_TOO_SMALL;
|
|
|
|
|
|
|
|
HeapFree( GetProcessHeap(), 0, id );
|
|
|
|
break;
|
|
|
|
}
|
2016-01-29 16:44:36 +01:00
|
|
|
case DevicePropertyPhysicalDeviceObjectName:
|
|
|
|
{
|
|
|
|
ULONG used_len, len = buffer_length + sizeof(OBJECT_NAME_INFORMATION);
|
|
|
|
OBJECT_NAME_INFORMATION *name = HeapAlloc(GetProcessHeap(), 0, len);
|
|
|
|
|
|
|
|
status = NtQueryObject(device->Reserved, ObjectNameInformation, name, len, &used_len);
|
|
|
|
if (status == STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
/* Ensure room for NULL termination */
|
|
|
|
if (buffer_length >= name->Name.MaximumLength)
|
|
|
|
memcpy(property_buffer, name->Name.Buffer, name->Name.MaximumLength);
|
|
|
|
else
|
|
|
|
status = STATUS_BUFFER_TOO_SMALL;
|
|
|
|
*result_length = name->Name.MaximumLength;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (status == STATUS_INFO_LENGTH_MISMATCH ||
|
|
|
|
status == STATUS_BUFFER_OVERFLOW)
|
|
|
|
{
|
|
|
|
status = STATUS_BUFFER_TOO_SMALL;
|
|
|
|
*result_length = used_len - sizeof(OBJECT_NAME_INFORMATION);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*result_length = 0;
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, name);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
FIXME("unhandled property %d\n", device_property);
|
|
|
|
}
|
|
|
|
return status;
|
2010-04-14 21:28:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-10-03 15:51:26 +02:00
|
|
|
/***********************************************************************
|
2010-04-13 20:42:13 +02:00
|
|
|
* IoCallDriver (NTOSKRNL.EXE.@)
|
2008-10-03 15:51:26 +02:00
|
|
|
*/
|
2010-04-13 20:42:13 +02:00
|
|
|
NTSTATUS WINAPI IoCallDriver( DEVICE_OBJECT *device, IRP *irp )
|
2008-10-03 15:51:26 +02:00
|
|
|
{
|
|
|
|
PDRIVER_DISPATCH dispatch;
|
|
|
|
IO_STACK_LOCATION *irpsp;
|
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
--irp->CurrentLocation;
|
2010-02-24 17:50:03 +01:00
|
|
|
irpsp = --irp->Tail.Overlay.s.u2.CurrentStackLocation;
|
2008-10-03 15:51:26 +02:00
|
|
|
dispatch = device->DriverObject->MajorFunction[irpsp->MajorFunction];
|
2015-03-04 14:21:45 +01:00
|
|
|
|
2017-11-25 11:48:11 +01:00
|
|
|
TRACE_(relay)( "\1Call driver dispatch %p (device=%p,irp=%p)\n", dispatch, device, irp );
|
2015-03-04 14:21:45 +01:00
|
|
|
|
2008-10-03 15:51:26 +02:00
|
|
|
status = dispatch( device, irp );
|
|
|
|
|
2017-11-25 11:48:11 +01:00
|
|
|
TRACE_(relay)( "\1Ret driver dispatch %p (device=%p,irp=%p) retval=%08x\n",
|
|
|
|
dispatch, device, irp, status );
|
2015-03-04 14:21:45 +01:00
|
|
|
|
2008-10-03 15:51:26 +02:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-13 20:42:13 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IofCallDriver (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
#ifdef DEFINE_FASTCALL2_ENTRYPOINT
|
|
|
|
DEFINE_FASTCALL2_ENTRYPOINT( IofCallDriver )
|
2017-07-25 11:48:46 +02:00
|
|
|
NTSTATUS WINAPI DECLSPEC_HIDDEN __regs_IofCallDriver( DEVICE_OBJECT *device, IRP *irp )
|
2010-04-13 20:42:13 +02:00
|
|
|
#else
|
|
|
|
NTSTATUS WINAPI IofCallDriver( DEVICE_OBJECT *device, IRP *irp )
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
TRACE( "%p %p\n", device, irp );
|
|
|
|
return IoCallDriver( device, irp );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-28 23:46:51 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoGetRelatedDeviceObject (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PDEVICE_OBJECT WINAPI IoGetRelatedDeviceObject( PFILE_OBJECT obj )
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p\n", obj );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-09-08 01:01:55 +02:00
|
|
|
static CONFIGURATION_INFORMATION configuration_information;
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IoGetConfigurationInformation (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PCONFIGURATION_INFORMATION WINAPI IoGetConfigurationInformation(void)
|
|
|
|
{
|
|
|
|
FIXME( "partial stub\n" );
|
|
|
|
/* FIXME: return actual devices on system */
|
|
|
|
return &configuration_information;
|
|
|
|
}
|
|
|
|
|
2008-08-28 23:46:51 +02:00
|
|
|
|
2010-03-17 21:46:57 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* IoIsWdmVersionAvailable (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoIsWdmVersionAvailable(UCHAR MajorVersion, UCHAR MinorVersion)
|
|
|
|
{
|
|
|
|
DWORD version;
|
|
|
|
DWORD major;
|
|
|
|
DWORD minor;
|
|
|
|
|
|
|
|
TRACE( "%d, 0x%X\n", MajorVersion, MinorVersion );
|
|
|
|
|
|
|
|
version = GetVersion();
|
|
|
|
major = LOBYTE(version);
|
|
|
|
minor = HIBYTE(LOWORD(version));
|
|
|
|
|
|
|
|
if (MajorVersion == 6 && MinorVersion == 0)
|
|
|
|
{
|
|
|
|
/* Windows Vista, Windows Server 2008, Windows 7 */
|
|
|
|
}
|
|
|
|
else if (MajorVersion == 1)
|
|
|
|
{
|
|
|
|
if (MinorVersion == 0x30)
|
|
|
|
{
|
|
|
|
/* Windows server 2003 */
|
|
|
|
MajorVersion = 6;
|
|
|
|
MinorVersion = 0;
|
|
|
|
}
|
|
|
|
else if (MinorVersion == 0x20)
|
|
|
|
{
|
|
|
|
/* Windows XP */
|
|
|
|
MajorVersion = 5;
|
|
|
|
MinorVersion = 1;
|
|
|
|
}
|
|
|
|
else if (MinorVersion == 0x10)
|
|
|
|
{
|
|
|
|
/* Windows 2000 */
|
|
|
|
MajorVersion = 5;
|
|
|
|
MinorVersion = 0;
|
|
|
|
}
|
|
|
|
else if (MinorVersion == 0x05)
|
|
|
|
{
|
|
|
|
/* Windows ME */
|
|
|
|
MajorVersion = 4;
|
|
|
|
MinorVersion = 0x5a;
|
|
|
|
}
|
|
|
|
else if (MinorVersion == 0x00)
|
|
|
|
{
|
|
|
|
/* Windows 98 */
|
|
|
|
MajorVersion = 4;
|
|
|
|
MinorVersion = 0x0a;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME( "unknown major %d minor 0x%X\n", MajorVersion, MinorVersion );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME( "unknown major %d minor 0x%X\n", MajorVersion, MinorVersion );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return major > MajorVersion || (major == MajorVersion && minor >= MinorVersion);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-14 13:31:57 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoQueryDeviceDescription (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoQueryDeviceDescription(PINTERFACE_TYPE itype, PULONG bus, PCONFIGURATION_TYPE ctype,
|
|
|
|
PULONG cnum, PCONFIGURATION_TYPE ptype, PULONG pnum,
|
|
|
|
PIO_QUERY_DEVICE_ROUTINE callout, PVOID context)
|
|
|
|
{
|
|
|
|
FIXME( "(%p %p %p %p %p %p %p %p)\n", itype, bus, ctype, cnum, ptype, pnum, callout, context);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-29 00:31:58 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoRegisterDriverReinitialization (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI IoRegisterDriverReinitialization( PDRIVER_OBJECT obj, PDRIVER_REINITIALIZE reinit, PVOID context )
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p %p %p\n", obj, reinit, context );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-29 00:36:35 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoRegisterShutdownNotification (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoRegisterShutdownNotification( PDEVICE_OBJECT obj )
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p\n", obj );
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-27 16:04:59 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* IoUnregisterShutdownNotification (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
VOID WINAPI IoUnregisterShutdownNotification( PDEVICE_OBJECT obj )
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p\n", obj );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-20 18:26:14 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoReportResourceForDetection (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoReportResourceForDetection( DRIVER_OBJECT *drv_obj, CM_RESOURCE_LIST *drv_list, ULONG drv_size,
|
|
|
|
DEVICE_OBJECT *dev_obj, CM_RESOURCE_LIST *dev_list, ULONG dev_size,
|
|
|
|
BOOLEAN *conflict )
|
|
|
|
{
|
|
|
|
FIXME( "(%p, %p, %u, %p, %p, %u, %p): stub\n", drv_obj, drv_list, drv_size,
|
|
|
|
dev_obj, dev_list, dev_size, conflict );
|
|
|
|
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-21 11:33:12 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoReportResourceUsage (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2017-04-20 18:26:04 +02:00
|
|
|
NTSTATUS WINAPI IoReportResourceUsage( UNICODE_STRING *name, DRIVER_OBJECT *drv_obj, CM_RESOURCE_LIST *drv_list,
|
|
|
|
ULONG drv_size, DRIVER_OBJECT *dev_obj, CM_RESOURCE_LIST *dev_list,
|
|
|
|
ULONG dev_size, BOOLEAN overwrite, BOOLEAN *conflict )
|
2009-08-21 11:33:12 +02:00
|
|
|
{
|
2016-02-13 09:23:05 +01:00
|
|
|
FIXME( "(%s, %p, %p, %u, %p, %p, %u, %d, %p): stub\n", debugstr_us(name),
|
2017-04-20 18:26:04 +02:00
|
|
|
drv_obj, drv_list, drv_size, dev_obj, dev_list, dev_size, overwrite, conflict );
|
|
|
|
|
2009-08-21 11:33:12 +02:00
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-15 21:56:05 +02:00
|
|
|
/***********************************************************************
|
2010-03-23 16:52:49 +01:00
|
|
|
* IoCompleteRequest (NTOSKRNL.EXE.@)
|
2007-05-15 21:56:05 +02:00
|
|
|
*/
|
2010-03-23 16:52:49 +01:00
|
|
|
VOID WINAPI IoCompleteRequest( IRP *irp, UCHAR priority_boost )
|
2007-05-15 21:56:05 +02:00
|
|
|
{
|
2008-10-03 15:51:26 +02:00
|
|
|
IO_STACK_LOCATION *irpsp;
|
|
|
|
PIO_COMPLETION_ROUTINE routine;
|
|
|
|
NTSTATUS status, stat;
|
|
|
|
int call_flag = 0;
|
|
|
|
|
2007-05-15 21:56:05 +02:00
|
|
|
TRACE( "%p %u\n", irp, priority_boost );
|
2008-10-03 15:51:26 +02:00
|
|
|
|
|
|
|
status = irp->IoStatus.u.Status;
|
|
|
|
while (irp->CurrentLocation <= irp->StackCount)
|
|
|
|
{
|
2010-02-24 17:50:03 +01:00
|
|
|
irpsp = irp->Tail.Overlay.s.u2.CurrentStackLocation;
|
2008-10-03 15:51:26 +02:00
|
|
|
routine = irpsp->CompletionRoutine;
|
|
|
|
call_flag = 0;
|
|
|
|
/* FIXME: add SL_INVOKE_ON_CANCEL support */
|
|
|
|
if (routine)
|
|
|
|
{
|
|
|
|
if ((irpsp->Control & SL_INVOKE_ON_SUCCESS) && STATUS_SUCCESS == status)
|
|
|
|
call_flag = 1;
|
|
|
|
if ((irpsp->Control & SL_INVOKE_ON_ERROR) && STATUS_SUCCESS != status)
|
|
|
|
call_flag = 1;
|
|
|
|
}
|
|
|
|
++irp->CurrentLocation;
|
2010-02-24 17:50:03 +01:00
|
|
|
++irp->Tail.Overlay.s.u2.CurrentStackLocation;
|
2008-10-03 15:51:26 +02:00
|
|
|
if (call_flag)
|
|
|
|
{
|
|
|
|
TRACE( "calling %p( %p, %p, %p )\n", routine,
|
|
|
|
irpsp->DeviceObject, irp, irpsp->Context );
|
|
|
|
stat = routine( irpsp->DeviceObject, irp, irpsp->Context );
|
2008-10-09 11:00:00 +02:00
|
|
|
TRACE( "CompletionRoutine returned %x\n", stat );
|
2008-10-03 15:51:26 +02:00
|
|
|
if (STATUS_MORE_PROCESSING_REQUIRED == stat)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2015-03-11 14:48:22 +01:00
|
|
|
|
2016-10-13 00:51:48 +02:00
|
|
|
if (irp->Flags & IRP_DEALLOCATE_BUFFER)
|
|
|
|
HeapFree( GetProcessHeap(), 0, irp->AssociatedIrp.SystemBuffer );
|
|
|
|
|
2015-03-04 14:22:14 +01:00
|
|
|
IoFreeIrp( irp );
|
2007-05-15 21:56:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-23 16:52:49 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* IofCompleteRequest (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
#ifdef DEFINE_FASTCALL2_ENTRYPOINT
|
|
|
|
DEFINE_FASTCALL2_ENTRYPOINT( IofCompleteRequest )
|
2017-07-25 11:48:46 +02:00
|
|
|
void WINAPI DECLSPEC_HIDDEN __regs_IofCompleteRequest( IRP *irp, UCHAR priority_boost )
|
2010-03-23 16:52:49 +01:00
|
|
|
#else
|
|
|
|
void WINAPI IofCompleteRequest( IRP *irp, UCHAR priority_boost )
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
TRACE( "%p %u\n", irp, priority_boost );
|
|
|
|
IoCompleteRequest( irp, priority_boost );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-25 16:22:24 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedCompareExchange (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2009-06-14 15:34:34 +02:00
|
|
|
#ifdef DEFINE_FASTCALL3_ENTRYPOINT
|
|
|
|
DEFINE_FASTCALL3_ENTRYPOINT( NTOSKRNL_InterlockedCompareExchange )
|
2017-07-25 11:48:46 +02:00
|
|
|
LONG WINAPI DECLSPEC_HIDDEN __regs_NTOSKRNL_InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare )
|
2008-04-25 16:22:24 +02:00
|
|
|
#else
|
|
|
|
LONG WINAPI NTOSKRNL_InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare )
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
return InterlockedCompareExchange( dest, xchg, compare );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedDecrement (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
#ifdef DEFINE_FASTCALL1_ENTRYPOINT
|
|
|
|
DEFINE_FASTCALL1_ENTRYPOINT( NTOSKRNL_InterlockedDecrement )
|
2017-07-25 11:48:46 +02:00
|
|
|
LONG WINAPI DECLSPEC_HIDDEN __regs_NTOSKRNL_InterlockedDecrement( LONG volatile *dest )
|
2008-04-25 16:22:24 +02:00
|
|
|
#else
|
|
|
|
LONG WINAPI NTOSKRNL_InterlockedDecrement( LONG volatile *dest )
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
return InterlockedDecrement( dest );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedExchange (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
#ifdef DEFINE_FASTCALL2_ENTRYPOINT
|
|
|
|
DEFINE_FASTCALL2_ENTRYPOINT( NTOSKRNL_InterlockedExchange )
|
2017-07-25 11:48:46 +02:00
|
|
|
LONG WINAPI DECLSPEC_HIDDEN __regs_NTOSKRNL_InterlockedExchange( LONG volatile *dest, LONG val )
|
2008-04-25 16:22:24 +02:00
|
|
|
#else
|
|
|
|
LONG WINAPI NTOSKRNL_InterlockedExchange( LONG volatile *dest, LONG val )
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
return InterlockedExchange( dest, val );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedExchangeAdd (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
#ifdef DEFINE_FASTCALL2_ENTRYPOINT
|
|
|
|
DEFINE_FASTCALL2_ENTRYPOINT( NTOSKRNL_InterlockedExchangeAdd )
|
2017-07-25 11:48:46 +02:00
|
|
|
LONG WINAPI DECLSPEC_HIDDEN __regs_NTOSKRNL_InterlockedExchangeAdd( LONG volatile *dest, LONG incr )
|
2008-04-25 16:22:24 +02:00
|
|
|
#else
|
|
|
|
LONG WINAPI NTOSKRNL_InterlockedExchangeAdd( LONG volatile *dest, LONG incr )
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
return InterlockedExchangeAdd( dest, incr );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedIncrement (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
#ifdef DEFINE_FASTCALL1_ENTRYPOINT
|
|
|
|
DEFINE_FASTCALL1_ENTRYPOINT( NTOSKRNL_InterlockedIncrement )
|
2017-07-25 11:48:46 +02:00
|
|
|
LONG WINAPI DECLSPEC_HIDDEN __regs_NTOSKRNL_InterlockedIncrement( LONG volatile *dest )
|
2008-04-25 16:22:24 +02:00
|
|
|
#else
|
|
|
|
LONG WINAPI NTOSKRNL_InterlockedIncrement( LONG volatile *dest )
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
return InterlockedIncrement( dest );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-13 09:21:43 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedPopEntrySList (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
#ifdef DEFINE_FASTCALL1_ENTRYPOINT
|
|
|
|
DEFINE_FASTCALL1_ENTRYPOINT( NTOSKRNL_InterlockedPopEntrySList )
|
2017-07-25 11:48:46 +02:00
|
|
|
PSLIST_ENTRY WINAPI DECLSPEC_HIDDEN __regs_NTOSKRNL_InterlockedPopEntrySList( PSLIST_HEADER list )
|
2016-02-13 09:21:43 +01:00
|
|
|
#else
|
|
|
|
PSLIST_ENTRY WINAPI NTOSKRNL_InterlockedPopEntrySList( PSLIST_HEADER list )
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
return InterlockedPopEntrySList( list );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-13 09:22:21 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedPushEntrySList (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
#ifdef DEFINE_FASTCALL2_ENTRYPOINT
|
|
|
|
DEFINE_FASTCALL2_ENTRYPOINT( NTOSKRNL_InterlockedPushEntrySList )
|
2017-07-25 11:48:46 +02:00
|
|
|
PSLIST_ENTRY WINAPI DECLSPEC_HIDDEN __regs_NTOSKRNL_InterlockedPushEntrySList( PSLIST_HEADER list,
|
|
|
|
PSLIST_ENTRY entry )
|
2016-02-13 09:22:21 +01:00
|
|
|
#else
|
|
|
|
PSLIST_ENTRY WINAPI NTOSKRNL_InterlockedPushEntrySList( PSLIST_HEADER list, PSLIST_ENTRY entry )
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
return InterlockedPushEntrySList( list, entry );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-16 17:39:32 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ExAllocatePool (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PVOID WINAPI ExAllocatePool( POOL_TYPE type, SIZE_T size )
|
|
|
|
{
|
|
|
|
return ExAllocatePoolWithTag( type, size, 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ExAllocatePoolWithQuota (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PVOID WINAPI ExAllocatePoolWithQuota( POOL_TYPE type, SIZE_T size )
|
|
|
|
{
|
|
|
|
return ExAllocatePoolWithTag( type, size, 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ExAllocatePoolWithTag (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PVOID WINAPI ExAllocatePoolWithTag( POOL_TYPE type, SIZE_T size, ULONG tag )
|
|
|
|
{
|
|
|
|
/* FIXME: handle page alignment constraints */
|
|
|
|
void *ret = HeapAlloc( GetProcessHeap(), 0, size );
|
|
|
|
TRACE( "%lu pool %u -> %p\n", size, type, ret );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ExAllocatePoolWithQuotaTag (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PVOID WINAPI ExAllocatePoolWithQuotaTag( POOL_TYPE type, SIZE_T size, ULONG tag )
|
|
|
|
{
|
|
|
|
return ExAllocatePoolWithTag( type, size, tag );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-03 08:55:06 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ExCreateCallback (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI ExCreateCallback(PCALLBACK_OBJECT *obj, POBJECT_ATTRIBUTES attr,
|
|
|
|
BOOLEAN create, BOOLEAN allow_multiple)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p, %u, %u): stub\n", obj, attr, create, allow_multiple);
|
|
|
|
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-13 08:31:32 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ExDeleteNPagedLookasideList (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI ExDeleteNPagedLookasideList( PNPAGED_LOOKASIDE_LIST lookaside )
|
|
|
|
{
|
|
|
|
FIXME("(%p) stub\n", lookaside);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-13 08:32:00 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ExDeletePagedLookasideList (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI ExDeletePagedLookasideList( PPAGED_LOOKASIDE_LIST lookaside )
|
|
|
|
{
|
|
|
|
FIXME("(%p) stub\n", lookaside);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-16 17:39:32 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ExFreePool (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI ExFreePool( void *ptr )
|
|
|
|
{
|
|
|
|
ExFreePoolWithTag( ptr, 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ExFreePoolWithTag (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI ExFreePoolWithTag( void *ptr, ULONG tag )
|
|
|
|
{
|
|
|
|
TRACE( "%p\n", ptr );
|
|
|
|
HeapFree( GetProcessHeap(), 0, ptr );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-14 14:11:44 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ExInitializeResourceLite (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI ExInitializeResourceLite(PERESOURCE Resource)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p\n", Resource );
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-15 18:23:28 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ExInitializeNPagedLookasideList (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI ExInitializeNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside,
|
|
|
|
PALLOCATE_FUNCTION Allocate,
|
|
|
|
PFREE_FUNCTION Free,
|
|
|
|
ULONG Flags,
|
|
|
|
SIZE_T Size,
|
|
|
|
ULONG Tag,
|
|
|
|
USHORT Depth)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p, %p, %p, %u, %lu, %u, %u\n", Lookaside, Allocate, Free, Flags, Size, Tag, Depth );
|
|
|
|
}
|
|
|
|
|
2011-12-01 20:07:52 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ExInitializePagedLookasideList (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI ExInitializePagedLookasideList(PPAGED_LOOKASIDE_LIST Lookaside,
|
|
|
|
PALLOCATE_FUNCTION Allocate,
|
|
|
|
PFREE_FUNCTION Free,
|
|
|
|
ULONG Flags,
|
|
|
|
SIZE_T Size,
|
|
|
|
ULONG Tag,
|
|
|
|
USHORT Depth)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p, %p, %p, %u, %lu, %u, %u\n", Lookaside, Allocate, Free, Flags, Size, Tag, Depth );
|
|
|
|
}
|
2009-06-15 18:23:28 +02:00
|
|
|
|
2009-06-14 14:16:49 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ExInitializeZone (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI ExInitializeZone(PZONE_HEADER Zone,
|
|
|
|
ULONG BlockSize,
|
|
|
|
PVOID InitialSegment,
|
|
|
|
ULONG InitialSegmentSize)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p, %u, %p, %u\n", Zone, BlockSize, InitialSegment, InitialSegmentSize );
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2009-06-17 23:29:33 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* FsRtlRegisterUncProvider (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI FsRtlRegisterUncProvider(PHANDLE MupHandle, PUNICODE_STRING RedirDevName,
|
|
|
|
BOOLEAN MailslotsSupported)
|
|
|
|
{
|
|
|
|
FIXME("(%p %p %d): stub\n", MupHandle, RedirDevName, MailslotsSupported);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
2009-06-14 14:16:49 +02:00
|
|
|
|
2011-12-27 14:46:10 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* IoGetCurrentProcess / PsGetCurrentProcess (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PEPROCESS WINAPI IoGetCurrentProcess(void)
|
|
|
|
{
|
|
|
|
FIXME("() stub\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-12-30 11:02:01 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* KeGetCurrentThread / PsGetCurrentThread (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PRKTHREAD WINAPI KeGetCurrentThread(void)
|
|
|
|
{
|
|
|
|
FIXME("() stub\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-12-28 12:55:00 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* KeInitializeEvent (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI KeInitializeEvent( PRKEVENT Event, EVENT_TYPE Type, BOOLEAN State )
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p %d %d\n", Event, Type, State );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-14 13:25:19 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* KeInitializeMutex (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI KeInitializeMutex(PRKMUTEX Mutex, ULONG Level)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p, %u\n", Mutex, Level );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-12 13:40:31 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* KeWaitForMutexObject (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI KeWaitForMutexObject(PRKMUTEX Mutex, KWAIT_REASON WaitReason, KPROCESSOR_MODE WaitMode,
|
|
|
|
BOOLEAN Alertable, PLARGE_INTEGER Timeout)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p, %d, %d, %d, %p\n", Mutex, WaitReason, WaitMode, Alertable, Timeout );
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* KeReleaseMutex (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
LONG WINAPI KeReleaseMutex(PRKMUTEX Mutex, BOOLEAN Wait)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p, %d\n", Mutex, Wait );
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-21 10:12:41 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* KeInitializeSemaphore (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI KeInitializeSemaphore( PRKSEMAPHORE Semaphore, LONG Count, LONG Limit )
|
|
|
|
{
|
|
|
|
FIXME( "(%p %d %d) stub\n", Semaphore , Count, Limit );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-08 18:45:39 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* KeInitializeSpinLock (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI KeInitializeSpinLock( PKSPIN_LOCK SpinLock )
|
|
|
|
{
|
2008-12-28 12:56:29 +01:00
|
|
|
FIXME( "stub: %p\n", SpinLock );
|
2008-01-08 18:45:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* KeInitializeTimerEx (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI KeInitializeTimerEx( PKTIMER Timer, TIMER_TYPE Type )
|
|
|
|
{
|
2008-12-28 12:56:29 +01:00
|
|
|
FIXME( "stub: %p %d\n", Timer, Type );
|
2008-01-08 18:45:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-18 23:19:09 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* KeInitializeTimer (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI KeInitializeTimer( PKTIMER Timer )
|
|
|
|
{
|
2008-01-08 18:45:39 +01:00
|
|
|
KeInitializeTimerEx(Timer, NotificationTimer);
|
2007-06-18 23:19:09 +02:00
|
|
|
}
|
|
|
|
|
2014-03-18 23:54:29 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* KeInsertQueue (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
LONG WINAPI KeInsertQueue(PRKQUEUE Queue, PLIST_ENTRY Entry)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p %p\n", Queue, Entry );
|
|
|
|
return 0;
|
|
|
|
}
|
2007-06-18 23:19:09 +02:00
|
|
|
|
2008-04-07 21:10:12 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* KeQueryActiveProcessors (NTOSKRNL.EXE.@)
|
|
|
|
*
|
|
|
|
* Return the active Processors as bitmask
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* active Processors as bitmask
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
KAFFINITY WINAPI KeQueryActiveProcessors( void )
|
|
|
|
{
|
|
|
|
DWORD_PTR AffinityMask;
|
|
|
|
|
|
|
|
GetProcessAffinityMask( GetCurrentProcess(), &AffinityMask, NULL);
|
|
|
|
return AffinityMask;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-07 21:15:46 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* KeQueryInterruptTime (NTOSKRNL.EXE.@)
|
|
|
|
*
|
|
|
|
* Return the interrupt time count
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
ULONGLONG WINAPI KeQueryInterruptTime( void )
|
|
|
|
{
|
|
|
|
LARGE_INTEGER totaltime;
|
|
|
|
|
|
|
|
KeQueryTickCount(&totaltime);
|
|
|
|
return totaltime.QuadPart;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-18 16:48:54 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* KeQuerySystemTime (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI KeQuerySystemTime( LARGE_INTEGER *time )
|
|
|
|
{
|
|
|
|
NtQuerySystemTime( time );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* KeQueryTickCount (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI KeQueryTickCount( LARGE_INTEGER *count )
|
|
|
|
{
|
|
|
|
count->QuadPart = NtGetTickCount();
|
|
|
|
/* update the global variable too */
|
|
|
|
KeTickCount.LowPart = count->u.LowPart;
|
|
|
|
KeTickCount.High1Time = count->u.HighPart;
|
|
|
|
KeTickCount.High2Time = count->u.HighPart;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-29 10:13:16 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* KeReleaseSemaphore (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
LONG WINAPI KeReleaseSemaphore( PRKSEMAPHORE Semaphore, KPRIORITY Increment,
|
|
|
|
LONG Adjustment, BOOLEAN Wait )
|
|
|
|
{
|
|
|
|
FIXME("(%p %d %d %d) stub\n", Semaphore, Increment, Adjustment, Wait );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-18 16:48:54 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* KeQueryTimeIncrement (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
ULONG WINAPI KeQueryTimeIncrement(void)
|
|
|
|
{
|
|
|
|
return 10000;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-12 20:35:19 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* KeResetEvent (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
LONG WINAPI KeResetEvent( PRKEVENT Event )
|
|
|
|
{
|
|
|
|
FIXME("(%p): stub\n", Event);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* KeSetEvent (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
LONG WINAPI KeSetEvent( PRKEVENT Event, KPRIORITY Increment, BOOLEAN Wait )
|
|
|
|
{
|
|
|
|
FIXME("(%p, %d, %d): stub\n", Event, Increment, Wait);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-29 10:13:37 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* KeSetPriorityThread (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
KPRIORITY WINAPI KeSetPriorityThread( PKTHREAD Thread, KPRIORITY Priority )
|
|
|
|
{
|
|
|
|
FIXME("(%p %d)\n", Thread, Priority);
|
|
|
|
return Priority;
|
|
|
|
}
|
|
|
|
|
2015-01-02 12:44:38 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* KeSetSystemAffinityThread (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
VOID WINAPI KeSetSystemAffinityThread(KAFFINITY Affinity)
|
|
|
|
{
|
|
|
|
FIXME("(%lx) stub\n", Affinity);
|
|
|
|
}
|
2009-12-29 10:13:37 +01:00
|
|
|
|
2009-06-14 13:49:17 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* KeWaitForSingleObject (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI KeWaitForSingleObject(PVOID Object,
|
|
|
|
KWAIT_REASON WaitReason,
|
|
|
|
KPROCESSOR_MODE WaitMode,
|
|
|
|
BOOLEAN Alertable,
|
|
|
|
PLARGE_INTEGER Timeout)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p, %d, %d, %d, %p\n", Object, WaitReason, WaitMode, Alertable, Timeout );
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2014-12-24 22:35:23 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* KeWaitForMultipleObjects (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI KeWaitForMultipleObjects(ULONG Count, PVOID Object[], WAIT_TYPE WaitType,
|
|
|
|
KWAIT_REASON WaitReason, KPROCESSOR_MODE WaitMode,
|
|
|
|
BOOLEAN Alertable, PLARGE_INTEGER Timeout,
|
|
|
|
PKWAIT_BLOCK WaitBlockArray)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %u, %p, %d, %d, %d, %d, %p, %p\n", Count, Object, WaitType, WaitReason, WaitMode,
|
|
|
|
Alertable, Timeout, WaitBlockArray );
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2009-06-17 23:25:43 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoRegisterFileSystem (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
VOID WINAPI IoRegisterFileSystem(PDEVICE_OBJECT DeviceObject)
|
|
|
|
{
|
|
|
|
FIXME("(%p): stub\n", DeviceObject);
|
|
|
|
}
|
2009-06-14 13:49:17 +02:00
|
|
|
|
2009-06-17 23:27:42 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoUnregisterFileSystem (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
VOID WINAPI IoUnregisterFileSystem(PDEVICE_OBJECT DeviceObject)
|
|
|
|
{
|
|
|
|
FIXME("(%p): stub\n", DeviceObject);
|
|
|
|
}
|
|
|
|
|
2007-05-16 17:39:32 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MmAllocateNonCachedMemory (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2007-08-15 14:52:23 +02:00
|
|
|
PVOID WINAPI MmAllocateNonCachedMemory( SIZE_T size )
|
2007-05-16 17:39:32 +02:00
|
|
|
{
|
|
|
|
TRACE( "%lu\n", size );
|
|
|
|
return VirtualAlloc( NULL, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE|PAGE_NOCACHE );
|
|
|
|
}
|
|
|
|
|
2009-11-13 19:02:08 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MmAllocateContiguousMemory (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PVOID WINAPI MmAllocateContiguousMemory( SIZE_T size, PHYSICAL_ADDRESS highest_valid_address )
|
|
|
|
{
|
|
|
|
FIXME( "%lu, %s stub\n", size, wine_dbgstr_longlong(highest_valid_address.QuadPart) );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-06-27 10:45:48 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MmAllocateContiguousMemorySpecifyCache (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PVOID WINAPI MmAllocateContiguousMemorySpecifyCache( SIZE_T size,
|
|
|
|
PHYSICAL_ADDRESS lowest_valid_address,
|
|
|
|
PHYSICAL_ADDRESS highest_valid_address,
|
|
|
|
PHYSICAL_ADDRESS BoundaryAddressMultiple,
|
|
|
|
MEMORY_CACHING_TYPE CacheType )
|
|
|
|
{
|
|
|
|
FIXME(": stub\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-11-13 17:35:39 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MmAllocatePagesForMdl (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PMDL WINAPI MmAllocatePagesForMdl(PHYSICAL_ADDRESS lowaddress, PHYSICAL_ADDRESS highaddress,
|
|
|
|
PHYSICAL_ADDRESS skipbytes, SIZE_T size)
|
|
|
|
{
|
|
|
|
FIXME("%s %s %s %lu: stub\n", wine_dbgstr_longlong(lowaddress.QuadPart), wine_dbgstr_longlong(highaddress.QuadPart),
|
|
|
|
wine_dbgstr_longlong(skipbytes.QuadPart), size);
|
|
|
|
return NULL;
|
|
|
|
}
|
2007-05-16 17:39:32 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MmFreeNonCachedMemory (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI MmFreeNonCachedMemory( void *addr, SIZE_T size )
|
|
|
|
{
|
|
|
|
TRACE( "%p %lu\n", addr, size );
|
|
|
|
VirtualFree( addr, 0, MEM_RELEASE );
|
|
|
|
}
|
|
|
|
|
2008-03-21 21:25:40 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MmIsAddressValid (NTOSKRNL.EXE.@)
|
|
|
|
*
|
|
|
|
* Check if the process can access the virtual address without a pagefault
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* VirtualAddress [I] Address to check
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Failure: FALSE
|
|
|
|
* Success: TRUE (Accessing the Address works without a Pagefault)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI MmIsAddressValid(PVOID VirtualAddress)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", VirtualAddress);
|
|
|
|
return !IsBadWritePtr(VirtualAddress, 1);
|
|
|
|
}
|
|
|
|
|
2010-07-18 22:22:43 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MmMapIoSpace (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PVOID WINAPI MmMapIoSpace( PHYSICAL_ADDRESS PhysicalAddress, DWORD NumberOfBytes, DWORD CacheType )
|
|
|
|
{
|
|
|
|
FIXME( "stub: 0x%08x%08x, %d, %d\n", PhysicalAddress.u.HighPart, PhysicalAddress.u.LowPart, NumberOfBytes, CacheType );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-09-29 22:28:16 +02:00
|
|
|
|
2014-03-18 23:23:03 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MmLockPagableSectionByHandle (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
VOID WINAPI MmLockPagableSectionByHandle(PVOID ImageSectionHandle)
|
|
|
|
{
|
|
|
|
FIXME("stub %p\n", ImageSectionHandle);
|
|
|
|
}
|
|
|
|
|
2012-09-29 22:28:16 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MmMapLockedPagesSpecifyCache (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2012-10-02 18:37:28 +02:00
|
|
|
PVOID WINAPI MmMapLockedPagesSpecifyCache(PMDLX MemoryDescriptorList, KPROCESSOR_MODE AccessMode, MEMORY_CACHING_TYPE CacheType,
|
|
|
|
PVOID BaseAddress, ULONG BugCheckOnFailure, MM_PAGE_PRIORITY Priority)
|
2012-09-29 22:28:16 +02:00
|
|
|
{
|
|
|
|
FIXME("(%p, %u, %u, %p, %u, %u): stub\n", MemoryDescriptorList, AccessMode, CacheType, BaseAddress, BugCheckOnFailure, Priority);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-03-19 00:12:02 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MmUnlockPagableImageSection (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
VOID WINAPI MmUnlockPagableImageSection(PVOID ImageSectionHandle)
|
|
|
|
{
|
|
|
|
FIXME("stub %p\n", ImageSectionHandle);
|
|
|
|
}
|
2012-09-29 22:28:16 +02:00
|
|
|
|
2008-02-05 19:19:52 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MmPageEntireDriver (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PVOID WINAPI MmPageEntireDriver(PVOID AddrInSection)
|
|
|
|
{
|
|
|
|
TRACE("%p\n", AddrInSection);
|
|
|
|
return AddrInSection;
|
|
|
|
}
|
|
|
|
|
2012-09-29 22:28:08 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MmProbeAndLockPages (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2012-10-02 18:37:28 +02:00
|
|
|
void WINAPI MmProbeAndLockPages(PMDLX MemoryDescriptorList, KPROCESSOR_MODE AccessMode, LOCK_OPERATION Operation)
|
2012-09-29 22:28:08 +02:00
|
|
|
{
|
|
|
|
FIXME("(%p, %u, %u): stub\n", MemoryDescriptorList, AccessMode, Operation);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-05 19:19:52 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MmResetDriverPaging (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI MmResetDriverPaging(PVOID AddrInSection)
|
|
|
|
{
|
|
|
|
TRACE("%p\n", AddrInSection);
|
|
|
|
}
|
|
|
|
|
2012-09-29 22:28:00 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MmUnlockPages (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2012-10-02 18:37:28 +02:00
|
|
|
void WINAPI MmUnlockPages(PMDLX MemoryDescriptorList)
|
2012-09-29 22:28:00 +02:00
|
|
|
{
|
|
|
|
FIXME("(%p): stub\n", MemoryDescriptorList);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-07-18 22:22:43 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MmUnmapIoSpace (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
VOID WINAPI MmUnmapIoSpace( PVOID BaseAddress, SIZE_T NumberOfBytes )
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p, %lu\n", BaseAddress, NumberOfBytes );
|
|
|
|
}
|
|
|
|
|
2008-08-29 00:45:48 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ObReferenceObjectByHandle (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI ObReferenceObjectByHandle( HANDLE obj, ACCESS_MASK access,
|
|
|
|
POBJECT_TYPE type,
|
|
|
|
KPROCESSOR_MODE mode, PVOID* ptr,
|
|
|
|
POBJECT_HANDLE_INFORMATION info)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p %x %p %d %p %p\n", obj, access, type, mode, ptr, info);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2011-05-24 11:53:26 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ObReferenceObjectByName (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI ObReferenceObjectByName( UNICODE_STRING *ObjectName,
|
|
|
|
ULONG Attributes,
|
|
|
|
ACCESS_STATE *AccessState,
|
|
|
|
ACCESS_MASK DesiredAccess,
|
|
|
|
POBJECT_TYPE ObjectType,
|
|
|
|
KPROCESSOR_MODE AccessMode,
|
|
|
|
void *ParseContext,
|
|
|
|
void **Object)
|
|
|
|
{
|
2016-08-04 18:53:57 +02:00
|
|
|
struct wine_driver *driver;
|
|
|
|
struct wine_rb_entry *entry;
|
|
|
|
|
|
|
|
TRACE("mostly-stub:%s %i %p %i %p %i %p %p\n", debugstr_us(ObjectName),
|
|
|
|
Attributes, AccessState, DesiredAccess, ObjectType, AccessMode,
|
|
|
|
ParseContext, Object);
|
|
|
|
|
|
|
|
if (AccessState) FIXME("Unhandled AccessState\n");
|
|
|
|
if (DesiredAccess) FIXME("Unhandled DesiredAccess\n");
|
|
|
|
if (ParseContext) FIXME("Unhandled ParseContext\n");
|
|
|
|
if (ObjectType) FIXME("Unhandled ObjectType\n");
|
|
|
|
|
|
|
|
if (AccessMode != KernelMode)
|
|
|
|
{
|
|
|
|
FIXME("UserMode access not implemented\n");
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
EnterCriticalSection(&drivers_cs);
|
|
|
|
entry = wine_rb_get(&wine_drivers, ObjectName);
|
|
|
|
LeaveCriticalSection(&drivers_cs);
|
|
|
|
if (!entry)
|
|
|
|
{
|
|
|
|
FIXME("Object (%s) not found, may not be tracked.\n", debugstr_us(ObjectName));
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
driver = WINE_RB_ENTRY_VALUE(entry, struct wine_driver, entry);
|
|
|
|
*Object = &driver->driver_obj;
|
|
|
|
return STATUS_SUCCESS;
|
2011-05-24 11:53:26 +02:00
|
|
|
}
|
2008-08-29 00:45:48 +02:00
|
|
|
|
2016-02-13 09:22:52 +01:00
|
|
|
|
2016-09-07 11:21:22 +02:00
|
|
|
static void ObReferenceObject( void *obj )
|
|
|
|
{
|
|
|
|
TRACE( "(%p): stub\n", obj );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-08 15:35:18 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ObDereferenceObject (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI ObDereferenceObject( void *obj )
|
|
|
|
{
|
|
|
|
TRACE( "(%p): stub\n", obj );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-13 09:22:52 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ObfReferenceObject (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
#ifdef DEFINE_FASTCALL1_ENTRYPOINT
|
|
|
|
DEFINE_FASTCALL1_ENTRYPOINT( ObfReferenceObject )
|
2017-07-25 11:48:46 +02:00
|
|
|
void WINAPI DECLSPEC_HIDDEN __regs_ObfReferenceObject( void *obj )
|
2016-02-13 09:22:52 +01:00
|
|
|
#else
|
|
|
|
void WINAPI ObfReferenceObject( void *obj )
|
|
|
|
#endif
|
|
|
|
{
|
2016-09-07 11:21:22 +02:00
|
|
|
ObReferenceObject( obj );
|
2016-02-13 09:22:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-29 00:55:01 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ObfDereferenceObject (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2008-12-02 15:38:28 +01:00
|
|
|
#ifdef DEFINE_FASTCALL1_ENTRYPOINT
|
|
|
|
DEFINE_FASTCALL1_ENTRYPOINT( ObfDereferenceObject )
|
2017-07-25 11:48:46 +02:00
|
|
|
void WINAPI DECLSPEC_HIDDEN __regs_ObfDereferenceObject( void *obj )
|
2008-12-02 15:38:28 +01:00
|
|
|
#else
|
2016-02-13 09:22:52 +01:00
|
|
|
void WINAPI ObfDereferenceObject( void *obj )
|
2008-12-02 15:38:28 +01:00
|
|
|
#endif
|
2008-08-29 00:55:01 +02:00
|
|
|
{
|
2016-08-08 15:35:18 +02:00
|
|
|
ObDereferenceObject( obj );
|
2008-08-29 00:55:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-07 11:21:22 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoGetAttachedDeviceReference (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
DEVICE_OBJECT* WINAPI IoGetAttachedDeviceReference( DEVICE_OBJECT *device )
|
|
|
|
{
|
|
|
|
DEVICE_OBJECT *result = IoGetAttachedDevice( device );
|
|
|
|
ObReferenceObject( result );
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-21 00:44:46 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* PsCreateSystemThread (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI PsCreateSystemThread(PHANDLE ThreadHandle, ULONG DesiredAccess,
|
|
|
|
POBJECT_ATTRIBUTES ObjectAttributes,
|
|
|
|
HANDLE ProcessHandle, PCLIENT_ID ClientId,
|
2007-09-27 18:53:23 +02:00
|
|
|
PKSTART_ROUTINE StartRoutine, PVOID StartContext)
|
2007-09-21 00:44:46 +02:00
|
|
|
{
|
|
|
|
if (!ProcessHandle) ProcessHandle = GetCurrentProcess();
|
|
|
|
return RtlCreateUserThread(ProcessHandle, 0, FALSE, 0, 0,
|
|
|
|
0, StartRoutine, StartContext,
|
|
|
|
ThreadHandle, ClientId);
|
|
|
|
}
|
2007-05-16 17:39:32 +02:00
|
|
|
|
2007-05-17 09:49:28 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* PsGetCurrentProcessId (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI PsGetCurrentProcessId(void)
|
|
|
|
{
|
2011-10-27 14:20:19 +02:00
|
|
|
if (GetCurrentThreadId() == request_thread)
|
|
|
|
return UlongToHandle(client_pid);
|
|
|
|
return UlongToHandle(GetCurrentProcessId());
|
2007-05-17 09:49:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* PsGetCurrentThreadId (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI PsGetCurrentThreadId(void)
|
|
|
|
{
|
2011-10-27 14:20:19 +02:00
|
|
|
if (GetCurrentThreadId() == request_thread)
|
|
|
|
return UlongToHandle(client_tid);
|
|
|
|
return UlongToHandle(GetCurrentThreadId());
|
2007-05-17 09:49:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* PsGetVersion (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI PsGetVersion(ULONG *major, ULONG *minor, ULONG *build, UNICODE_STRING *version )
|
|
|
|
{
|
|
|
|
RTL_OSVERSIONINFOEXW info;
|
|
|
|
|
2009-10-20 07:23:13 +02:00
|
|
|
info.dwOSVersionInfoSize = sizeof(info);
|
2007-05-17 09:49:28 +02:00
|
|
|
RtlGetVersion( &info );
|
|
|
|
if (major) *major = info.dwMajorVersion;
|
|
|
|
if (minor) *minor = info.dwMinorVersion;
|
|
|
|
if (build) *build = info.dwBuildNumber;
|
|
|
|
|
|
|
|
if (version)
|
|
|
|
{
|
|
|
|
#if 0 /* FIXME: GameGuard passes an uninitialized pointer in version->Buffer */
|
|
|
|
size_t len = min( strlenW(info.szCSDVersion)*sizeof(WCHAR), version->MaximumLength );
|
|
|
|
memcpy( version->Buffer, info.szCSDVersion, len );
|
|
|
|
if (len < version->MaximumLength) version->Buffer[len / sizeof(WCHAR)] = 0;
|
|
|
|
version->Length = len;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-02 00:10:38 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* PsImpersonateClient (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI PsImpersonateClient(PETHREAD Thread, PACCESS_TOKEN Token, BOOLEAN CopyOnOpen,
|
|
|
|
BOOLEAN EffectiveOnly, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p, %u, %u, %u): stub\n", Thread, Token, CopyOnOpen, EffectiveOnly, ImpersonationLevel);
|
|
|
|
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-17 09:49:28 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* PsSetCreateProcessNotifyRoutine (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI PsSetCreateProcessNotifyRoutine( PCREATE_PROCESS_NOTIFY_ROUTINE callback, BOOLEAN remove )
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p %d\n", callback, remove );
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-12-28 14:31:51 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* PsSetCreateThreadNotifyRoutine (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI PsSetCreateThreadNotifyRoutine( PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine )
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p\n", NotifyRoutine );
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-18 09:14:19 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* PsRemoveCreateThreadNotifyRoutine (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI PsRemoveCreateThreadNotifyRoutine( PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine )
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p\n", NotifyRoutine );
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-04 02:56:30 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* PsRemoveLoadImageNotifyRoutine (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI PsRemoveLoadImageNotifyRoutine(PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p\n", NotifyRoutine );
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-14 14:19:45 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* PsTerminateSystemThread (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI PsTerminateSystemThread(NTSTATUS ExitStatus)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %u\n", ExitStatus );
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-17 11:01:10 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MmGetSystemRoutineAddress (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PVOID WINAPI MmGetSystemRoutineAddress(PUNICODE_STRING SystemRoutineName)
|
|
|
|
{
|
|
|
|
HMODULE hMod;
|
|
|
|
STRING routineNameA;
|
|
|
|
PVOID pFunc = NULL;
|
|
|
|
|
|
|
|
static const WCHAR ntoskrnlW[] = {'n','t','o','s','k','r','n','l','.','e','x','e',0};
|
|
|
|
static const WCHAR halW[] = {'h','a','l','.','d','l','l',0};
|
|
|
|
|
|
|
|
if (!SystemRoutineName) return NULL;
|
|
|
|
|
|
|
|
if (RtlUnicodeStringToAnsiString( &routineNameA, SystemRoutineName, TRUE ) == STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
/* We only support functions exported from ntoskrnl.exe or hal.dll */
|
|
|
|
hMod = GetModuleHandleW( ntoskrnlW );
|
|
|
|
pFunc = GetProcAddress( hMod, routineNameA.Buffer );
|
|
|
|
if (!pFunc)
|
|
|
|
{
|
|
|
|
hMod = GetModuleHandleW( halW );
|
|
|
|
if (hMod) pFunc = GetProcAddress( hMod, routineNameA.Buffer );
|
|
|
|
}
|
|
|
|
RtlFreeAnsiString( &routineNameA );
|
|
|
|
}
|
|
|
|
|
2011-02-25 17:50:44 +01:00
|
|
|
if (pFunc)
|
|
|
|
TRACE( "%s -> %p\n", debugstr_us(SystemRoutineName), pFunc );
|
|
|
|
else
|
|
|
|
FIXME( "%s not found\n", debugstr_us(SystemRoutineName) );
|
2008-11-17 11:01:10 +01:00
|
|
|
return pFunc;
|
|
|
|
}
|
2007-05-17 09:49:28 +02:00
|
|
|
|
2009-03-01 09:48:51 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MmQuerySystemSize (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
MM_SYSTEMSIZE WINAPI MmQuerySystemSize(void)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return MmLargeSystem;
|
|
|
|
}
|
|
|
|
|
2010-09-22 09:06:07 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* KeInitializeDpc (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
VOID WINAPI KeInitializeDpc(PRKDPC Dpc, PKDEFERRED_ROUTINE DeferredRoutine, PVOID DeferredContext)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
}
|
2009-03-01 09:48:51 +01:00
|
|
|
|
2010-09-22 09:07:03 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* READ_REGISTER_BUFFER_UCHAR (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
VOID WINAPI READ_REGISTER_BUFFER_UCHAR(PUCHAR Register, PUCHAR Buffer, ULONG Count)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
}
|
|
|
|
|
2010-11-21 16:58:54 +01:00
|
|
|
/*****************************************************
|
|
|
|
* PoSetPowerState (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
POWER_STATE WINAPI PoSetPowerState(PDEVICE_OBJECT DeviceObject, POWER_STATE_TYPE Type, POWER_STATE State)
|
|
|
|
{
|
|
|
|
FIXME("(%p %u %u) stub\n", DeviceObject, Type, State.DeviceState);
|
|
|
|
return State;
|
|
|
|
}
|
|
|
|
|
2010-12-08 23:17:24 +01:00
|
|
|
/*****************************************************
|
|
|
|
* IoWMIRegistrationControl (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoWMIRegistrationControl(PDEVICE_OBJECT DeviceObject, ULONG Action)
|
|
|
|
{
|
2012-10-13 13:11:28 +02:00
|
|
|
FIXME("(%p %u) stub\n", DeviceObject, Action);
|
2010-12-08 23:17:24 +01:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-03-19 10:26:58 +01:00
|
|
|
/*****************************************************
|
|
|
|
* PsSetLoadImageNotifyRoutine (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI PsSetLoadImageNotifyRoutine(PLOAD_IMAGE_NOTIFY_ROUTINE routine)
|
|
|
|
{
|
|
|
|
FIXME("(%p) stub\n", routine);
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-05-07 20:22:29 +02:00
|
|
|
/*****************************************************
|
|
|
|
* PsLookupProcessByProcessId (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI PsLookupProcessByProcessId(HANDLE processid, PEPROCESS *process)
|
|
|
|
{
|
2015-03-27 08:15:14 +01:00
|
|
|
static int once;
|
|
|
|
if (!once++) FIXME("(%p %p) stub\n", processid, process);
|
2011-05-07 20:22:29 +02:00
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2011-06-05 22:48:37 +02:00
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
* IoSetThreadHardErrorMode (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI IoSetThreadHardErrorMode(BOOLEAN EnableHardErrors)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-12-29 16:10:23 +01:00
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
* IoInitializeRemoveLockEx (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
VOID WINAPI IoInitializeRemoveLockEx(PIO_REMOVE_LOCK lock, ULONG tag,
|
2012-10-13 13:11:28 +02:00
|
|
|
ULONG maxmin, ULONG high, ULONG size)
|
2011-12-29 16:10:23 +01:00
|
|
|
{
|
|
|
|
FIXME("(%p %u %u %u %u) stub\n", lock, tag, maxmin, high, size);
|
|
|
|
}
|
|
|
|
|
2012-10-13 13:11:28 +02:00
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
* IoAcquireRemoveLockEx (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
|
|
|
|
NTSTATUS WINAPI IoAcquireRemoveLockEx(PIO_REMOVE_LOCK lock, PVOID tag,
|
|
|
|
LPCSTR file, ULONG line, ULONG lock_size)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p, %s, %u, %u): stub\n", lock, tag, debugstr_a(file), line, lock_size);
|
|
|
|
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-15 21:41:50 +02:00
|
|
|
/*****************************************************
|
|
|
|
* DllMain
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
|
|
|
|
{
|
2009-02-02 16:21:25 +01:00
|
|
|
static void *handler;
|
2007-05-18 16:48:54 +02:00
|
|
|
LARGE_INTEGER count;
|
|
|
|
|
2007-05-15 21:41:50 +02:00
|
|
|
switch(reason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
DisableThreadLibraryCalls( inst );
|
2015-06-19 03:58:41 +02:00
|
|
|
#if defined(__i386__) || defined(__x86_64__)
|
2009-02-02 16:21:25 +01:00
|
|
|
handler = RtlAddVectoredExceptionHandler( TRUE, vectored_handler );
|
2009-12-30 20:39:47 +01:00
|
|
|
#endif
|
2007-05-18 16:48:54 +02:00
|
|
|
KeQueryTickCount( &count ); /* initialize the global KeTickCount */
|
2007-05-15 21:41:50 +02:00
|
|
|
break;
|
2009-01-30 11:44:13 +01:00
|
|
|
case DLL_PROCESS_DETACH:
|
2013-05-20 12:28:08 +02:00
|
|
|
if (reserved) break;
|
2009-02-02 16:21:25 +01:00
|
|
|
RtlRemoveVectoredExceptionHandler( handler );
|
2009-01-30 11:44:13 +01:00
|
|
|
break;
|
2007-05-15 21:41:50 +02:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
2011-12-29 23:14:16 +01:00
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
* Ke386IoSetAccessProcess (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI Ke386IoSetAccessProcess(PEPROCESS *process, ULONG flag)
|
|
|
|
{
|
|
|
|
FIXME("(%p %d) stub\n", process, flag);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-12-29 23:17:54 +01:00
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
* Ke386SetIoAccessMap (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI Ke386SetIoAccessMap(ULONG flag, PVOID buffer)
|
|
|
|
{
|
|
|
|
FIXME("(%d %p) stub\n", flag, buffer);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2012-01-18 09:36:43 +01:00
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
* IoCreateSynchronizationEvent (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PKEVENT WINAPI IoCreateSynchronizationEvent(PUNICODE_STRING name, PHANDLE handle)
|
|
|
|
{
|
|
|
|
FIXME("(%p %p) stub\n", name, handle);
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-03-08 22:14:28 +01:00
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
* IoStartNextPacket (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
VOID WINAPI IoStartNextPacket(PDEVICE_OBJECT deviceobject, BOOLEAN cancelable)
|
|
|
|
{
|
|
|
|
FIXME("(%p %d) stub\n", deviceobject, cancelable);
|
|
|
|
}
|
2014-10-29 18:32:36 +01:00
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
* ObQueryNameString (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI ObQueryNameString(PVOID object, POBJECT_NAME_INFORMATION name, ULONG maxlength, PULONG returnlength)
|
|
|
|
{
|
|
|
|
FIXME("(%p %p %u %p) stub\n", object, name, maxlength, returnlength);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
2014-11-03 20:08:24 +01:00
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
* IoRegisterPlugPlayNotification (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoRegisterPlugPlayNotification(IO_NOTIFICATION_EVENT_CATEGORY category, ULONG flags, PVOID data,
|
|
|
|
PDRIVER_OBJECT driver, PDRIVER_NOTIFICATION_CALLBACK_ROUTINE callback,
|
|
|
|
PVOID context, PVOID *notification)
|
|
|
|
{
|
|
|
|
FIXME("(%u %u %p %p %p %p %p) stub\n", category, flags, data, driver, callback, context, notification);
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
2014-12-23 22:29:30 +01:00
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
* IoCsqInitialize (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoCsqInitialize(PIO_CSQ csq, PIO_CSQ_INSERT_IRP insert_irp, PIO_CSQ_REMOVE_IRP remove_irp,
|
|
|
|
PIO_CSQ_PEEK_NEXT_IRP peek_irp, PIO_CSQ_ACQUIRE_LOCK acquire_lock,
|
|
|
|
PIO_CSQ_RELEASE_LOCK release_lock, PIO_CSQ_COMPLETE_CANCELED_IRP complete_irp)
|
|
|
|
{
|
|
|
|
FIXME("(%p %p %p %p %p %p %p) stub\n",
|
|
|
|
csq, insert_irp, remove_irp, peek_irp, acquire_lock, release_lock, complete_irp);
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
2015-02-05 03:16:51 +01:00
|
|
|
|
2015-11-09 06:28:01 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ExAcquireResourceExclusiveLite (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI ExAcquireResourceExclusiveLite( PERESOURCE resource, BOOLEAN wait )
|
|
|
|
{
|
|
|
|
FIXME( ":%p %u stub\n", resource, wait );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2015-11-09 06:30:11 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ExDeleteResourceLite (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI ExDeleteResourceLite(PERESOURCE resource)
|
|
|
|
{
|
|
|
|
FIXME("(%p): stub\n", resource);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-02-05 03:16:51 +01:00
|
|
|
/*****************************************************
|
|
|
|
* ExInterlockedRemoveHeadList (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PLIST_ENTRY WINAPI ExInterlockedRemoveHeadList(PLIST_ENTRY head, PKSPIN_LOCK lock)
|
|
|
|
{
|
|
|
|
FIXME("(%p %p) stub\n", head, lock);
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-02-05 19:55:25 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ExfInterlockedRemoveHeadList (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
#ifdef DEFINE_FASTCALL2_ENTRYPOINT
|
|
|
|
DEFINE_FASTCALL2_ENTRYPOINT( ExfInterlockedRemoveHeadList )
|
2017-07-25 11:48:46 +02:00
|
|
|
PLIST_ENTRY WINAPI DECLSPEC_HIDDEN __regs_ExfInterlockedRemoveHeadList(PLIST_ENTRY head, PKSPIN_LOCK lock)
|
2015-02-05 19:55:25 +01:00
|
|
|
#else
|
|
|
|
PLIST_ENTRY WINAPI ExfInterlockedRemoveHeadList(PLIST_ENTRY head, PKSPIN_LOCK lock)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
FIXME("(%p %p) stub\n", head, lock);
|
|
|
|
return ExInterlockedRemoveHeadList( head, lock );
|
|
|
|
}
|
2015-09-29 05:03:06 +02:00
|
|
|
|
2015-11-09 06:34:58 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ExReleaseResourceForThreadLite (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI ExReleaseResourceForThreadLite( PERESOURCE resource, ERESOURCE_THREAD tid )
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p %lu\n", resource, tid );
|
|
|
|
}
|
|
|
|
|
2015-09-29 05:03:06 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* KeEnterCriticalRegion (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI KeEnterCriticalRegion(void)
|
|
|
|
{
|
|
|
|
FIXME(": stub\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* KeLeaveCriticalRegion (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI KeLeaveCriticalRegion(void)
|
|
|
|
{
|
|
|
|
FIXME(": stub\n");
|
|
|
|
}
|
2015-11-13 08:30:26 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ProbeForRead (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI ProbeForRead(void *address, SIZE_T length, ULONG alignment)
|
|
|
|
{
|
|
|
|
FIXME("(%p %lu %u) stub\n", address, length, alignment);
|
|
|
|
}
|
2015-11-13 08:31:05 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ProbeForWrite (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI ProbeForWrite(void *address, SIZE_T length, ULONG alignment)
|
|
|
|
{
|
|
|
|
FIXME("(%p %lu %u) stub\n", address, length, alignment);
|
|
|
|
}
|
2015-11-17 05:34:47 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CmRegisterCallback (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI CmRegisterCallback(EX_CALLBACK_FUNCTION *function, void *context, LARGE_INTEGER *cookie)
|
|
|
|
{
|
|
|
|
FIXME("(%p %p %p): stub\n", function, context, cookie);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CmUnRegisterCallback (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI CmUnRegisterCallback(LARGE_INTEGER cookie)
|
|
|
|
{
|
|
|
|
FIXME("(%s): stub\n", wine_dbgstr_longlong(cookie.QuadPart));
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
2016-04-04 02:57:36 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* KeDelayExecutionThread (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI KeDelayExecutionThread(KPROCESSOR_MODE waitmode, BOOLEAN alertable, PLARGE_INTEGER interval)
|
|
|
|
{
|
2016-04-04 21:01:34 +02:00
|
|
|
FIXME("(%u, %u, %p): stub\n", waitmode, alertable, interval);
|
2016-04-04 02:57:36 +02:00
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
2016-07-12 04:59:22 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IoAttachDevice (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoAttachDevice(DEVICE_OBJECT *source, UNICODE_STRING *target, DEVICE_OBJECT *attached)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %s, %p): stub\n", source, debugstr_us(target), attached);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
2016-08-24 06:11:07 +02:00
|
|
|
|
|
|
|
|
|
|
|
static NTSTATUS open_driver( const UNICODE_STRING *service_name, SC_HANDLE *service )
|
|
|
|
{
|
|
|
|
QUERY_SERVICE_CONFIGW *service_config = NULL;
|
|
|
|
SC_HANDLE manager_handle;
|
|
|
|
DWORD config_size = 0;
|
|
|
|
WCHAR *name;
|
|
|
|
|
|
|
|
if (!(name = RtlAllocateHeap( GetProcessHeap(), 0, service_name->Length + sizeof(WCHAR) )))
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
|
|
|
|
memcpy( name, service_name->Buffer, service_name->Length );
|
|
|
|
name[ service_name->Length / sizeof(WCHAR) ] = 0;
|
|
|
|
|
|
|
|
if (strncmpW( name, servicesW, strlenW(servicesW) ))
|
|
|
|
{
|
|
|
|
FIXME( "service name %s is not a keypath\n", debugstr_us(service_name) );
|
|
|
|
RtlFreeHeap( GetProcessHeap(), 0, name );
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(manager_handle = OpenSCManagerW( NULL, NULL, SC_MANAGER_CONNECT )))
|
|
|
|
{
|
|
|
|
WARN( "failed to connect to service manager\n" );
|
|
|
|
RtlFreeHeap( GetProcessHeap(), 0, name );
|
|
|
|
return STATUS_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
*service = OpenServiceW( manager_handle, name + strlenW(servicesW), SERVICE_ALL_ACCESS );
|
|
|
|
RtlFreeHeap( GetProcessHeap(), 0, name );
|
|
|
|
CloseServiceHandle( manager_handle );
|
|
|
|
|
|
|
|
if (!*service)
|
|
|
|
{
|
|
|
|
WARN( "failed to open service %s\n", debugstr_us(service_name) );
|
|
|
|
return STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
|
|
|
|
QueryServiceConfigW( *service, NULL, 0, &config_size );
|
|
|
|
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
|
|
|
|
{
|
|
|
|
WARN( "failed to query service config\n" );
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(service_config = RtlAllocateHeap( GetProcessHeap(), 0, config_size )))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (!QueryServiceConfigW( *service, service_config, config_size, &config_size ))
|
|
|
|
{
|
|
|
|
WARN( "failed to query service config\n" );
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (service_config->dwServiceType != SERVICE_KERNEL_DRIVER &&
|
|
|
|
service_config->dwServiceType != SERVICE_FILE_SYSTEM_DRIVER)
|
|
|
|
{
|
|
|
|
WARN( "service %s is not a kernel driver\n", debugstr_us(service_name) );
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE( "opened service for driver %s\n", debugstr_us(service_name) );
|
|
|
|
RtlFreeHeap( GetProcessHeap(), 0, service_config );
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
|
|
|
|
error:
|
|
|
|
CloseServiceHandle( *service );
|
|
|
|
RtlFreeHeap( GetProcessHeap(), 0, service_config );
|
|
|
|
return STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ZwLoadDriver (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI ZwLoadDriver( const UNICODE_STRING *service_name )
|
|
|
|
{
|
|
|
|
SERVICE_STATUS_PROCESS service_status;
|
|
|
|
SC_HANDLE service_handle;
|
2016-09-01 21:46:13 +02:00
|
|
|
ULONGLONG start_time;
|
2016-08-24 06:11:07 +02:00
|
|
|
NTSTATUS status;
|
|
|
|
DWORD bytes;
|
|
|
|
|
|
|
|
TRACE( "(%s)\n", debugstr_us(service_name) );
|
|
|
|
|
|
|
|
if ((status = open_driver( service_name, &service_handle )) != STATUS_SUCCESS)
|
|
|
|
return status;
|
|
|
|
|
|
|
|
TRACE( "trying to start %s\n", debugstr_us(service_name) );
|
|
|
|
|
2016-09-01 21:46:13 +02:00
|
|
|
start_time = GetTickCount64();
|
|
|
|
for (;;)
|
2016-08-24 06:11:07 +02:00
|
|
|
{
|
|
|
|
if (StartServiceW( service_handle, 0, NULL )) break;
|
|
|
|
if (GetLastError() == ERROR_SERVICE_ALREADY_RUNNING) break;
|
|
|
|
if (GetLastError() != ERROR_SERVICE_DATABASE_LOCKED) goto error;
|
2016-09-01 21:46:13 +02:00
|
|
|
if (GetTickCount64() - start_time > 30000) goto error;
|
|
|
|
Sleep( 100 );
|
2016-08-24 06:11:07 +02:00
|
|
|
}
|
|
|
|
|
2016-09-01 21:46:13 +02:00
|
|
|
start_time = GetTickCount64();
|
|
|
|
for (;;)
|
2016-08-24 06:11:07 +02:00
|
|
|
{
|
|
|
|
if (!QueryServiceStatusEx( service_handle, SC_STATUS_PROCESS_INFO,
|
|
|
|
(BYTE *)&service_status, sizeof(service_status), &bytes )) goto error;
|
|
|
|
if (service_status.dwCurrentState != SERVICE_START_PENDING) break;
|
2016-09-01 21:46:13 +02:00
|
|
|
if (GetTickCount64() - start_time > 30000) goto error;
|
|
|
|
Sleep( 100 );
|
2016-08-24 06:11:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (service_status.dwCurrentState == SERVICE_RUNNING)
|
|
|
|
{
|
|
|
|
if (service_status.dwProcessId != GetCurrentProcessId())
|
|
|
|
FIXME( "driver %s was loaded into a different process\n", debugstr_us(service_name) );
|
|
|
|
|
|
|
|
status = STATUS_SUCCESS;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
error:
|
|
|
|
WARN( "failed to start service %s\n", debugstr_us(service_name) );
|
|
|
|
status = STATUS_UNSUCCESSFUL;
|
|
|
|
|
|
|
|
done:
|
|
|
|
TRACE( "returning status %08x\n", status );
|
|
|
|
CloseServiceHandle( service_handle );
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ZwUnloadDriver (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI ZwUnloadDriver( const UNICODE_STRING *service_name )
|
|
|
|
{
|
|
|
|
SERVICE_STATUS service_status;
|
|
|
|
SC_HANDLE service_handle;
|
2016-09-01 21:46:13 +02:00
|
|
|
ULONGLONG start_time;
|
2016-08-24 06:11:07 +02:00
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
TRACE( "(%s)\n", debugstr_us(service_name) );
|
|
|
|
|
|
|
|
if ((status = open_driver( service_name, &service_handle )) != STATUS_SUCCESS)
|
|
|
|
return status;
|
|
|
|
|
|
|
|
if (!ControlService( service_handle, SERVICE_CONTROL_STOP, &service_status ))
|
|
|
|
goto error;
|
|
|
|
|
2016-09-01 21:46:13 +02:00
|
|
|
start_time = GetTickCount64();
|
|
|
|
for (;;)
|
2016-08-24 06:11:07 +02:00
|
|
|
{
|
|
|
|
if (!QueryServiceStatus( service_handle, &service_status )) goto error;
|
|
|
|
if (service_status.dwCurrentState != SERVICE_STOP_PENDING) break;
|
2016-09-01 21:46:13 +02:00
|
|
|
if (GetTickCount64() - start_time > 30000) goto error;
|
|
|
|
Sleep( 100 );
|
2016-08-24 06:11:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (service_status.dwCurrentState == SERVICE_STOPPED)
|
|
|
|
{
|
|
|
|
status = STATUS_SUCCESS;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
error:
|
|
|
|
WARN( "failed to stop service %s\n", debugstr_us(service_name) );
|
|
|
|
status = STATUS_UNSUCCESSFUL;
|
|
|
|
|
|
|
|
done:
|
|
|
|
TRACE( "returning status %08x\n", status );
|
|
|
|
CloseServiceHandle( service_handle );
|
|
|
|
return status;
|
|
|
|
}
|
2016-09-01 09:28:00 +02:00
|
|
|
|
|
|
|
|
2016-09-14 09:30:43 +02:00
|
|
|
static NTSTATUS WINAPI internal_complete( DEVICE_OBJECT *device, IRP *irp, void *context )
|
|
|
|
{
|
2016-10-14 06:46:12 +02:00
|
|
|
HANDLE event = context;
|
|
|
|
SetEvent( event );
|
2016-09-14 09:30:43 +02:00
|
|
|
return STATUS_MORE_PROCESSING_REQUIRED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static NTSTATUS send_device_irp( DEVICE_OBJECT *device, IRP *irp, ULONG_PTR *info )
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
HANDLE event = CreateEventA( NULL, FALSE, FALSE, NULL );
|
|
|
|
DEVICE_OBJECT *toplevel_device;
|
|
|
|
|
|
|
|
irp->IoStatus.u.Status = STATUS_NOT_SUPPORTED;
|
2016-10-14 06:46:12 +02:00
|
|
|
IoSetCompletionRoutine( irp, internal_complete, event, TRUE, TRUE, TRUE );
|
2016-09-14 09:30:43 +02:00
|
|
|
|
|
|
|
toplevel_device = IoGetAttachedDeviceReference( device );
|
|
|
|
status = IoCallDriver( toplevel_device, irp );
|
|
|
|
|
|
|
|
if (status == STATUS_PENDING)
|
|
|
|
WaitForSingleObject( event, INFINITE );
|
|
|
|
|
|
|
|
status = irp->IoStatus.u.Status;
|
|
|
|
if (info)
|
|
|
|
*info = irp->IoStatus.Information;
|
|
|
|
IoCompleteRequest( irp, IO_NO_INCREMENT );
|
|
|
|
ObDereferenceObject( toplevel_device );
|
|
|
|
CloseHandle( event );
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static NTSTATUS get_device_id( DEVICE_OBJECT *device, BUS_QUERY_ID_TYPE type, WCHAR **id )
|
|
|
|
{
|
|
|
|
IO_STACK_LOCATION *irpsp;
|
|
|
|
IO_STATUS_BLOCK irp_status;
|
|
|
|
IRP *irp;
|
|
|
|
|
|
|
|
if (!(irp = IoBuildSynchronousFsdRequest( IRP_MJ_PNP, device, NULL, 0, NULL, NULL, &irp_status )))
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
|
|
|
|
irpsp = IoGetNextIrpStackLocation( irp );
|
|
|
|
irpsp->MinorFunction = IRP_MN_QUERY_ID;
|
|
|
|
irpsp->Parameters.QueryId.IdType = type;
|
|
|
|
|
|
|
|
return send_device_irp( device, irp, (ULONG_PTR *)id );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static BOOL get_driver_for_id( const WCHAR *id, WCHAR *driver )
|
|
|
|
{
|
|
|
|
static const WCHAR serviceW[] = {'S','e','r','v','i','c','e',0};
|
|
|
|
static const UNICODE_STRING service_str = { sizeof(serviceW) - sizeof(WCHAR), sizeof(serviceW), (WCHAR *)serviceW };
|
|
|
|
static const WCHAR critical_fmtW[] =
|
|
|
|
{'\\','R','e','g','i','s','t','r','y',
|
|
|
|
'\\','M','a','c','h','i','n','e',
|
|
|
|
'\\','S','y','s','t','e','m',
|
|
|
|
'\\','C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t',
|
|
|
|
'\\','C','o','n','t','r','o','l',
|
|
|
|
'\\','C','r','i','t','i','c','a','l','D','e','v','i','c','e','D','a','t','a','b','a','s','e',
|
|
|
|
'\\','%','s',0};
|
|
|
|
WCHAR buffer[FIELD_OFFSET( KEY_VALUE_PARTIAL_INFORMATION, Data[MAX_SERVICE_NAME * sizeof(WCHAR)] )];
|
|
|
|
KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION *)buffer;
|
|
|
|
OBJECT_ATTRIBUTES attr;
|
|
|
|
UNICODE_STRING key;
|
|
|
|
NTSTATUS status;
|
|
|
|
HANDLE hkey;
|
|
|
|
WCHAR *keyW;
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
if (!(keyW = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(critical_fmtW) + strlenW(id) * sizeof(WCHAR) )))
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
|
|
|
|
sprintfW( keyW, critical_fmtW, id );
|
|
|
|
RtlInitUnicodeString( &key, keyW );
|
|
|
|
InitializeObjectAttributes( &attr, &key, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL );
|
|
|
|
|
|
|
|
status = NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr );
|
|
|
|
RtlFreeUnicodeString( &key );
|
|
|
|
if (status != STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
TRACE_(plugplay)( "no driver found for %s\n", debugstr_w(id) );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
status = NtQueryValueKey( hkey, &service_str, KeyValuePartialInformation,
|
|
|
|
info, sizeof(buffer) - sizeof(WCHAR), &len );
|
|
|
|
NtClose( hkey );
|
|
|
|
if (status != STATUS_SUCCESS || info->Type != REG_SZ)
|
|
|
|
{
|
|
|
|
TRACE_(plugplay)( "no driver found for %s\n", debugstr_w(id) );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy( driver, info->Data, info->DataLength );
|
|
|
|
driver[ info->DataLength / sizeof(WCHAR) ] = 0;
|
|
|
|
TRACE_(plugplay)( "found driver %s for %s\n", debugstr_w(driver), debugstr_w(id) );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-15 13:58:21 +02:00
|
|
|
static NTSTATUS send_pnp_irp( DEVICE_OBJECT *device, UCHAR minor )
|
|
|
|
{
|
|
|
|
IO_STACK_LOCATION *irpsp;
|
|
|
|
IO_STATUS_BLOCK irp_status;
|
|
|
|
IRP *irp;
|
|
|
|
|
|
|
|
if (!(irp = IoBuildSynchronousFsdRequest( IRP_MJ_PNP, device, NULL, 0, NULL, NULL, &irp_status )))
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
|
|
|
|
irpsp = IoGetNextIrpStackLocation( irp );
|
|
|
|
irpsp->MinorFunction = minor;
|
|
|
|
|
|
|
|
irpsp->Parameters.StartDevice.AllocatedResources = NULL;
|
|
|
|
irpsp->Parameters.StartDevice.AllocatedResourcesTranslated = NULL;
|
|
|
|
|
|
|
|
return send_device_irp( device, irp, NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static NTSTATUS send_power_irp( DEVICE_OBJECT *device, DEVICE_POWER_STATE power )
|
|
|
|
{
|
|
|
|
IO_STATUS_BLOCK irp_status;
|
|
|
|
IO_STACK_LOCATION *irpsp;
|
|
|
|
IRP *irp;
|
|
|
|
|
|
|
|
if (!(irp = IoBuildSynchronousFsdRequest( IRP_MJ_POWER, device, NULL, 0, NULL, NULL, &irp_status )))
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
|
|
|
|
irpsp = IoGetNextIrpStackLocation( irp );
|
|
|
|
irpsp->MinorFunction = IRP_MN_SET_POWER;
|
|
|
|
|
|
|
|
irpsp->Parameters.Power.Type = DevicePowerState;
|
|
|
|
irpsp->Parameters.Power.State.DeviceState = power;
|
|
|
|
|
|
|
|
return send_device_irp( device, irp, NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-14 09:30:43 +02:00
|
|
|
static void handle_bus_relations( DEVICE_OBJECT *device )
|
|
|
|
{
|
|
|
|
static const WCHAR driverW[] = {'\\','D','r','i','v','e','r','\\',0};
|
|
|
|
WCHAR buffer[MAX_SERVICE_NAME + sizeof(servicesW)/sizeof(WCHAR)];
|
|
|
|
WCHAR driver[MAX_SERVICE_NAME] = {0};
|
|
|
|
DRIVER_OBJECT *driver_obj;
|
|
|
|
UNICODE_STRING string;
|
|
|
|
WCHAR *ids, *ptr;
|
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
TRACE_(plugplay)( "(%p)\n", device );
|
|
|
|
|
|
|
|
/* We could (should?) do a full IRP_MN_QUERY_DEVICE_RELATIONS query,
|
|
|
|
* but we don't have to, we have the DEVICE_OBJECT of the new device
|
|
|
|
* so we can simply handle the process here */
|
|
|
|
|
|
|
|
status = get_device_id( device, BusQueryCompatibleIDs, &ids );
|
|
|
|
if (status != STATUS_SUCCESS || !ids)
|
|
|
|
{
|
|
|
|
ERR_(plugplay)( "Failed to get device IDs\n" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (ptr = ids; *ptr; ptr += strlenW(ptr) + 1)
|
|
|
|
{
|
|
|
|
if (get_driver_for_id( ptr, driver ))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
RtlFreeHeap( GetProcessHeap(), 0, ids );
|
|
|
|
|
|
|
|
if (!driver[0])
|
|
|
|
{
|
|
|
|
ERR_(plugplay)( "No matching driver found for device\n" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpyW( buffer, servicesW );
|
|
|
|
strcatW( buffer, driver );
|
|
|
|
RtlInitUnicodeString( &string, buffer );
|
|
|
|
if (ZwLoadDriver( &string ) != STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
ERR_(plugplay)( "Failed to load driver %s\n", debugstr_w(driver) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpyW( buffer, driverW );
|
|
|
|
strcatW( buffer, driver );
|
|
|
|
RtlInitUnicodeString( &string, buffer );
|
|
|
|
if (ObReferenceObjectByName( &string, OBJ_CASE_INSENSITIVE, NULL,
|
|
|
|
0, NULL, KernelMode, NULL, (void **)&driver_obj ) != STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
ERR_(plugplay)( "Failed to locate loaded driver %s\n", debugstr_w(driver) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (driver_obj->DriverExtension->AddDevice)
|
|
|
|
status = driver_obj->DriverExtension->AddDevice( driver_obj, device );
|
|
|
|
else
|
|
|
|
status = STATUS_NOT_IMPLEMENTED;
|
|
|
|
|
|
|
|
ObDereferenceObject( driver_obj );
|
|
|
|
|
|
|
|
if (status != STATUS_SUCCESS)
|
2016-09-15 13:58:21 +02:00
|
|
|
{
|
2016-09-14 09:30:43 +02:00
|
|
|
ERR_(plugplay)( "AddDevice failed for driver %s\n", debugstr_w(driver) );
|
2016-09-15 13:58:21 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
send_pnp_irp( device, IRP_MN_START_DEVICE );
|
|
|
|
send_power_irp( device, PowerDeviceD0 );
|
2016-09-14 09:30:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-21 13:38:21 +02:00
|
|
|
static void handle_removal_relations( DEVICE_OBJECT *device )
|
|
|
|
{
|
|
|
|
TRACE_(plugplay)( "(%p)\n", device );
|
|
|
|
|
|
|
|
send_power_irp( device, PowerDeviceD3 );
|
|
|
|
send_pnp_irp( device, IRP_MN_SURPRISE_REMOVAL );
|
|
|
|
send_pnp_irp( device, IRP_MN_REMOVE_DEVICE );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-01 09:28:00 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoInvalidateDeviceRelations (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI IoInvalidateDeviceRelations( DEVICE_OBJECT *device_object, DEVICE_RELATION_TYPE type )
|
|
|
|
{
|
2016-09-14 09:30:43 +02:00
|
|
|
TRACE( "(%p, %i)\n", device_object, type );
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case BusRelations:
|
|
|
|
handle_bus_relations( device_object );
|
|
|
|
break;
|
2016-09-21 13:38:21 +02:00
|
|
|
case RemovalRelations:
|
|
|
|
handle_removal_relations( device_object );
|
|
|
|
break;
|
2016-09-14 09:30:43 +02:00
|
|
|
default:
|
|
|
|
FIXME( "unhandled relation %i\n", type );
|
|
|
|
break;
|
|
|
|
}
|
2016-09-01 09:28:00 +02:00
|
|
|
}
|
2016-11-05 02:59:20 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* KeSetTimerEx (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI KeSetTimerEx( KTIMER *timer, LARGE_INTEGER duetime, LONG period, KDPC *dpc )
|
|
|
|
{
|
|
|
|
FIXME("stub: %p %s %u %p\n", timer, wine_dbgstr_longlong(duetime.QuadPart), period, dpc);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2017-01-19 00:24:31 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IoCreateFile (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoCreateFile(HANDLE *handle, ACCESS_MASK access, OBJECT_ATTRIBUTES *attr,
|
|
|
|
IO_STATUS_BLOCK *io, LARGE_INTEGER *alloc_size, ULONG attributes, ULONG sharing,
|
|
|
|
ULONG disposition, ULONG create_options, VOID *ea_buffer, ULONG ea_length,
|
|
|
|
CREATE_FILE_TYPE file_type, VOID *parameters, ULONG options )
|
|
|
|
{
|
|
|
|
FIXME(": stub\n");
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
2017-01-19 00:31:34 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* KeClearEvent (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
VOID WINAPI KeClearEvent(PRKEVENT event)
|
|
|
|
{
|
|
|
|
FIXME("stub: %p\n", event);
|
|
|
|
}
|
2017-03-07 16:01:20 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* KeAcquireInStackQueuedSpinLock (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
#ifdef DEFINE_FASTCALL2_ENTRYPOINT
|
|
|
|
DEFINE_FASTCALL2_ENTRYPOINT( KeAcquireInStackQueuedSpinLock )
|
2017-07-25 11:48:46 +02:00
|
|
|
void WINAPI DECLSPEC_HIDDEN __regs_KeAcquireInStackQueuedSpinLock( KSPIN_LOCK *spinlock,
|
|
|
|
KLOCK_QUEUE_HANDLE *handle )
|
2017-03-07 16:01:20 +01:00
|
|
|
#else
|
|
|
|
void WINAPI KeAcquireInStackQueuedSpinLock( KSPIN_LOCK *spinlock, KLOCK_QUEUE_HANDLE *handle )
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p %p\n", spinlock, handle );
|
|
|
|
}
|
2017-03-07 16:01:48 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* KeReleaseInStackQueuedSpinLock (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
#ifdef DEFINE_FASTCALL1_ENTRYPOINT
|
|
|
|
DEFINE_FASTCALL1_ENTRYPOINT( KeReleaseInStackQueuedSpinLock )
|
2017-07-25 11:48:46 +02:00
|
|
|
void WINAPI DECLSPEC_HIDDEN __regs_KeReleaseInStackQueuedSpinLock( KLOCK_QUEUE_HANDLE *handle )
|
2017-03-07 16:01:48 +01:00
|
|
|
#else
|
|
|
|
void WINAPI KeReleaseInStackQueuedSpinLock( KLOCK_QUEUE_HANDLE *handle )
|
|
|
|
#endif
|
|
|
|
{
|
2017-06-15 21:41:19 +02:00
|
|
|
FIXME( "stub: %p\n", handle );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* KeAcquireSpinLockRaiseToDpc (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
KIRQL WINAPI KeAcquireSpinLockRaiseToDpc(KSPIN_LOCK *spinlock)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p\n", spinlock );
|
|
|
|
return 0;
|
2017-03-07 16:01:48 +01:00
|
|
|
}
|
2017-06-21 20:29:37 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* KeReleaseSpinLock (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2017-07-06 22:41:08 +02:00
|
|
|
void WINAPI KeReleaseSpinLock( KSPIN_LOCK *spinlock, KIRQL irql )
|
2017-06-21 20:29:37 +02:00
|
|
|
{
|
|
|
|
FIXME( "stub: %p %u\n", spinlock, irql );
|
|
|
|
}
|
2017-07-06 22:41:08 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IoCreateNotificationEvent (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PKEVENT WINAPI IoCreateNotificationEvent(UNICODE_STRING *name, HANDLE *handle)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %s %p\n", debugstr_us(name), handle );
|
|
|
|
return NULL;
|
|
|
|
}
|