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 <stdarg.h>
|
2019-05-03 15:40:05 +02:00
|
|
|
#include <assert.h>
|
2007-05-15 21:41:50 +02:00
|
|
|
|
|
|
|
#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"
|
2018-08-17 01:37:43 +02:00
|
|
|
#include "winbase.h"
|
2018-08-25 05:42:58 +02:00
|
|
|
#include "winreg.h"
|
2019-02-27 04:08:42 +01:00
|
|
|
#include "ntsecapi.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/server.h"
|
|
|
|
#include "wine/debug.h"
|
2018-08-17 01:37:37 +02:00
|
|
|
#include "wine/heap.h"
|
2016-08-03 18:41:30 +02:00
|
|
|
#include "wine/rbtree.h"
|
2018-08-25 05:42:58 +02:00
|
|
|
#include "wine/svcctl.h"
|
2016-08-03 18:41:30 +02:00
|
|
|
|
2019-01-25 05:56:23 +01:00
|
|
|
#include "ntoskrnl_private.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);
|
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;
|
2019-02-06 23:35:18 +01:00
|
|
|
USHORT NtBuildNumber = 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
|
|
|
|
2016-09-14 09:30:43 +02:00
|
|
|
#define MAX_SERVICE_NAME 260
|
|
|
|
|
2020-05-27 11:50:48 +02:00
|
|
|
static TP_POOL *dpc_call_tp;
|
|
|
|
static TP_CALLBACK_ENVIRON dpc_call_tpe;
|
|
|
|
DECLARE_CRITICAL_SECTION(dpc_call_cs);
|
2020-05-27 11:50:49 +02:00
|
|
|
static DWORD dpc_call_tls_index;
|
2020-05-27 11:50:48 +02:00
|
|
|
|
2011-10-27 14:20:19 +02:00
|
|
|
/* tid of the thread running client request */
|
|
|
|
static DWORD request_thread;
|
|
|
|
|
2019-04-08 14:04:29 +02:00
|
|
|
/* tid of the client thread */
|
2011-10-27 14:20:19 +02:00
|
|
|
static DWORD client_tid;
|
|
|
|
|
2019-08-22 06:16:51 +02:00
|
|
|
static HANDLE ntoskrnl_heap;
|
|
|
|
|
2020-06-09 18:03:14 +02:00
|
|
|
static void *ldr_notify_cookie;
|
|
|
|
|
2020-05-29 09:53:10 +02:00
|
|
|
static PLOAD_IMAGE_NOTIFY_ROUTINE load_image_notify_routines[8];
|
|
|
|
static unsigned int load_image_notify_routine_count;
|
|
|
|
|
2016-08-03 18:41:30 +02:00
|
|
|
struct wine_driver
|
|
|
|
{
|
|
|
|
DRIVER_OBJECT driver_obj;
|
|
|
|
DRIVER_EXTENSION driver_extension;
|
2018-08-25 05:42:58 +02:00
|
|
|
SERVICE_STATUS_HANDLE service_handle;
|
2019-02-26 13:39:11 +01:00
|
|
|
struct wine_rb_entry entry;
|
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;
|
|
|
|
|
2019-09-19 13:45:11 +02:00
|
|
|
return RtlCompareUnicodeString( k, &driver->driver_obj.DriverName, TRUE );
|
2016-08-03 18:41:30 +02:00
|
|
|
}
|
|
|
|
|
2016-08-30 21:30:33 +02:00
|
|
|
static struct wine_rb_tree wine_drivers = { wine_drivers_rb_compare };
|
|
|
|
|
2019-05-27 13:39:25 +02:00
|
|
|
DECLARE_CRITICAL_SECTION(drivers_cs);
|
2016-08-03 18:41:30 +02:00
|
|
|
|
2007-05-15 21:41:50 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-02-26 13:38:58 +01:00
|
|
|
|
2019-02-26 13:39:11 +01:00
|
|
|
struct object_header
|
|
|
|
{
|
|
|
|
LONG ref;
|
|
|
|
POBJECT_TYPE type;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void free_kernel_object( void *obj )
|
|
|
|
{
|
|
|
|
struct object_header *header = (struct object_header *)obj - 1;
|
|
|
|
HeapFree( GetProcessHeap(), 0, header );
|
|
|
|
}
|
|
|
|
|
2019-03-25 14:37:39 +01:00
|
|
|
void *alloc_kernel_object( POBJECT_TYPE type, HANDLE handle, SIZE_T size, LONG ref )
|
2019-02-26 13:39:11 +01:00
|
|
|
{
|
|
|
|
struct object_header *header;
|
|
|
|
|
|
|
|
if (!(header = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*header) + size)) )
|
|
|
|
return NULL;
|
|
|
|
|
2019-03-25 14:37:39 +01:00
|
|
|
if (handle)
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
SERVER_START_REQ( set_kernel_object_ptr )
|
|
|
|
{
|
|
|
|
req->manager = wine_server_obj_handle( get_device_manager() );
|
|
|
|
req->handle = wine_server_obj_handle( handle );
|
|
|
|
req->user_ptr = wine_server_client_ptr( header + 1 );
|
|
|
|
status = wine_server_call( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
if (status) FIXME( "set_object_reference failed: %#x\n", status );
|
|
|
|
}
|
|
|
|
|
2019-02-26 13:39:11 +01:00
|
|
|
header->ref = ref;
|
|
|
|
header->type = type;
|
|
|
|
return header + 1;
|
|
|
|
}
|
|
|
|
|
2019-05-27 13:39:25 +02:00
|
|
|
DECLARE_CRITICAL_SECTION(obref_cs);
|
2019-02-26 13:39:43 +01:00
|
|
|
|
2019-02-26 13:39:51 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ObDereferenceObject (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI ObDereferenceObject( void *obj )
|
2019-02-26 13:39:11 +01:00
|
|
|
{
|
|
|
|
struct object_header *header = (struct object_header*)obj - 1;
|
2019-02-26 13:39:51 +01:00
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
if (!obj)
|
|
|
|
{
|
|
|
|
FIXME("NULL obj\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-03-25 14:37:57 +01:00
|
|
|
EnterCriticalSection( &obref_cs );
|
|
|
|
|
|
|
|
ref = --header->ref;
|
2019-02-26 13:39:51 +01:00
|
|
|
TRACE( "(%p) ref=%u\n", obj, ref );
|
|
|
|
if (!ref)
|
|
|
|
{
|
2019-03-25 14:37:57 +01:00
|
|
|
if (header->type->release)
|
|
|
|
{
|
|
|
|
header->type->release( obj );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SERVER_START_REQ( release_kernel_object )
|
|
|
|
{
|
|
|
|
req->manager = wine_server_obj_handle( get_device_manager() );
|
|
|
|
req->user_ptr = wine_server_client_ptr( obj );
|
|
|
|
if (wine_server_call( req )) FIXME( "failed to release %p\n", obj );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
}
|
2019-02-26 13:39:51 +01:00
|
|
|
}
|
2019-03-25 14:37:57 +01:00
|
|
|
|
|
|
|
LeaveCriticalSection( &obref_cs );
|
2019-02-26 13:39:11 +01:00
|
|
|
}
|
|
|
|
|
2019-05-31 03:49:03 +02:00
|
|
|
void ObReferenceObject( void *obj )
|
2019-02-26 13:39:29 +01:00
|
|
|
{
|
2019-02-26 13:39:51 +01:00
|
|
|
struct object_header *header = (struct object_header*)obj - 1;
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
if (!obj)
|
|
|
|
{
|
|
|
|
FIXME("NULL obj\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-03-25 14:37:57 +01:00
|
|
|
EnterCriticalSection( &obref_cs );
|
|
|
|
|
|
|
|
ref = ++header->ref;
|
2019-02-26 13:39:51 +01:00
|
|
|
TRACE( "(%p) ref=%u\n", obj, ref );
|
2019-03-25 14:37:57 +01:00
|
|
|
if (ref == 1)
|
|
|
|
{
|
|
|
|
SERVER_START_REQ( grab_kernel_object )
|
|
|
|
{
|
|
|
|
req->manager = wine_server_obj_handle( get_device_manager() );
|
|
|
|
req->user_ptr = wine_server_client_ptr( obj );
|
|
|
|
if (wine_server_call( req )) FIXME( "failed to grab %p reference\n", obj );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection( &obref_cs );
|
2019-02-26 13:39:29 +01:00
|
|
|
}
|
|
|
|
|
2019-05-01 17:54:05 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ObGetObjectType (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
POBJECT_TYPE WINAPI ObGetObjectType( void *object )
|
|
|
|
{
|
|
|
|
struct object_header *header = (struct object_header *)object - 1;
|
|
|
|
return header->type;
|
|
|
|
}
|
|
|
|
|
2019-03-11 14:59:57 +01:00
|
|
|
static const POBJECT_TYPE *known_types[] =
|
|
|
|
{
|
|
|
|
&ExEventObjectType,
|
|
|
|
&ExSemaphoreObjectType,
|
|
|
|
&IoDeviceObjectType,
|
|
|
|
&IoDriverObjectType,
|
|
|
|
&IoFileObjectType,
|
|
|
|
&PsProcessType,
|
|
|
|
&PsThreadType,
|
|
|
|
&SeTokenObjectType
|
|
|
|
};
|
|
|
|
|
2019-05-27 13:39:25 +02:00
|
|
|
DECLARE_CRITICAL_SECTION(handle_map_cs);
|
2019-03-25 14:37:39 +01:00
|
|
|
|
2019-03-27 17:43:39 +01:00
|
|
|
NTSTATUS kernel_object_from_handle( HANDLE handle, POBJECT_TYPE type, void **ret )
|
2019-02-26 13:39:43 +01:00
|
|
|
{
|
|
|
|
void *obj;
|
|
|
|
NTSTATUS status;
|
|
|
|
|
2019-03-25 14:37:39 +01:00
|
|
|
EnterCriticalSection( &handle_map_cs );
|
|
|
|
|
|
|
|
SERVER_START_REQ( get_kernel_object_ptr )
|
|
|
|
{
|
|
|
|
req->manager = wine_server_obj_handle( get_device_manager() );
|
|
|
|
req->handle = wine_server_obj_handle( handle );
|
|
|
|
status = wine_server_call( req );
|
|
|
|
obj = wine_server_get_ptr( reply->user_ptr );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
if (status)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection( &handle_map_cs );
|
|
|
|
return status;
|
|
|
|
}
|
2019-02-26 13:39:43 +01:00
|
|
|
|
2019-05-01 17:54:05 +02:00
|
|
|
if (!obj)
|
2019-03-25 14:37:39 +01:00
|
|
|
{
|
|
|
|
char buf[256];
|
|
|
|
OBJECT_TYPE_INFORMATION *type_info = (OBJECT_TYPE_INFORMATION *)buf;
|
|
|
|
ULONG size;
|
|
|
|
|
|
|
|
status = NtQueryObject( handle, ObjectTypeInformation, buf, sizeof(buf), &size );
|
|
|
|
if (status)
|
2019-03-11 14:59:57 +01:00
|
|
|
{
|
2019-03-25 14:37:39 +01:00
|
|
|
LeaveCriticalSection( &handle_map_cs );
|
|
|
|
return status;
|
2019-03-11 14:59:57 +01:00
|
|
|
}
|
2019-03-25 14:37:39 +01:00
|
|
|
if (!type)
|
2019-03-11 14:59:57 +01:00
|
|
|
{
|
2019-03-25 14:37:39 +01:00
|
|
|
size_t i;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(known_types); i++)
|
|
|
|
{
|
|
|
|
type = *known_types[i];
|
2019-06-17 09:28:35 +02:00
|
|
|
if (!RtlCompareUnicodeStrings( type->name, lstrlenW(type->name), type_info->TypeName.Buffer,
|
2019-03-25 14:37:39 +01:00
|
|
|
type_info->TypeName.Length / sizeof(WCHAR), FALSE ))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i == ARRAY_SIZE(known_types))
|
|
|
|
{
|
|
|
|
FIXME("Unsupported type %s\n", debugstr_us(&type_info->TypeName));
|
|
|
|
LeaveCriticalSection( &handle_map_cs );
|
|
|
|
return STATUS_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
}
|
2019-06-17 09:28:35 +02:00
|
|
|
else if (RtlCompareUnicodeStrings( type->name, lstrlenW(type->name), type_info->TypeName.Buffer,
|
2019-03-25 14:37:39 +01:00
|
|
|
type_info->TypeName.Length / sizeof(WCHAR), FALSE) )
|
|
|
|
{
|
|
|
|
LeaveCriticalSection( &handle_map_cs );
|
|
|
|
return STATUS_OBJECT_TYPE_MISMATCH;
|
2019-03-11 14:59:57 +01:00
|
|
|
}
|
2019-02-26 13:39:43 +01:00
|
|
|
|
2019-03-25 14:37:39 +01:00
|
|
|
if (type->constructor)
|
|
|
|
obj = type->constructor( handle );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME( "No constructor for type %s\n", debugstr_w(type->name) );
|
|
|
|
obj = alloc_kernel_object( type, handle, 0, 0 );
|
|
|
|
}
|
|
|
|
if (!obj) status = STATUS_NO_MEMORY;
|
2019-02-26 13:39:43 +01:00
|
|
|
}
|
2019-05-01 17:54:05 +02:00
|
|
|
else if (type && ObGetObjectType( obj ) != type) status = STATUS_OBJECT_TYPE_MISMATCH;
|
2019-02-26 13:39:43 +01:00
|
|
|
|
2019-03-25 14:37:39 +01:00
|
|
|
LeaveCriticalSection( &handle_map_cs );
|
|
|
|
if (!status) *ret = obj;
|
|
|
|
return status;
|
2019-02-26 13:39:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ObReferenceObjectByHandle (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI ObReferenceObjectByHandle( HANDLE handle, ACCESS_MASK access,
|
|
|
|
POBJECT_TYPE type,
|
|
|
|
KPROCESSOR_MODE mode, void **ptr,
|
|
|
|
POBJECT_HANDLE_INFORMATION info )
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
TRACE( "%p %x %p %d %p %p\n", handle, access, type, mode, ptr, info );
|
|
|
|
|
|
|
|
if (mode != KernelMode)
|
|
|
|
{
|
|
|
|
FIXME("UserMode access not implemented\n");
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
status = kernel_object_from_handle( handle, type, ptr );
|
2019-02-26 13:39:51 +01:00
|
|
|
if (!status) ObReferenceObject( *ptr );
|
2019-02-26 13:39:43 +01:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2019-04-30 16:36:37 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ObOpenObjectByPointer (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI ObOpenObjectByPointer( void *obj, ULONG attr, ACCESS_STATE *access_state,
|
|
|
|
ACCESS_MASK access, POBJECT_TYPE type,
|
|
|
|
KPROCESSOR_MODE mode, HANDLE *handle )
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
TRACE( "%p %x %p %x %p %d %p\n", obj, attr, access_state, access, type, mode, handle );
|
|
|
|
|
|
|
|
if (mode != KernelMode)
|
|
|
|
{
|
|
|
|
FIXME( "UserMode access not implemented\n" );
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2019-08-19 03:02:37 +02:00
|
|
|
if (attr & ~OBJ_KERNEL_HANDLE) FIXME( "attr %#x not supported\n", attr );
|
2019-04-30 16:36:37 +02:00
|
|
|
if (access_state) FIXME( "access_state not implemented\n" );
|
|
|
|
|
|
|
|
if (type && ObGetObjectType( obj ) != type) return STATUS_OBJECT_TYPE_MISMATCH;
|
|
|
|
|
|
|
|
SERVER_START_REQ( get_kernel_object_handle )
|
|
|
|
{
|
|
|
|
req->manager = wine_server_obj_handle( get_device_manager() );
|
|
|
|
req->user_ptr = wine_server_client_ptr( obj );
|
|
|
|
req->access = access;
|
|
|
|
if (!(status = wine_server_call( req )))
|
|
|
|
*handle = wine_server_ptr_handle( reply->handle );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2019-02-26 13:39:29 +01:00
|
|
|
|
2019-02-26 13:39:57 +01:00
|
|
|
static void *create_file_object( HANDLE handle );
|
|
|
|
|
2019-02-26 13:38:58 +01:00
|
|
|
static const WCHAR file_type_name[] = {'F','i','l','e',0};
|
|
|
|
|
|
|
|
static struct _OBJECT_TYPE file_type = {
|
|
|
|
file_type_name,
|
2019-04-25 14:55:10 +02:00
|
|
|
create_file_object
|
2019-02-26 13:38:58 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
POBJECT_TYPE IoFileObjectType = &file_type;
|
|
|
|
|
2019-02-26 13:39:57 +01:00
|
|
|
static void *create_file_object( HANDLE handle )
|
|
|
|
{
|
|
|
|
FILE_OBJECT *file;
|
2019-03-25 14:37:39 +01:00
|
|
|
if (!(file = alloc_kernel_object( IoFileObjectType, handle, sizeof(*file), 0 ))) return NULL;
|
2019-02-26 13:39:57 +01:00
|
|
|
file->Type = 5; /* MSDN */
|
|
|
|
file->Size = sizeof(*file);
|
|
|
|
return file;
|
|
|
|
}
|
2019-02-26 13:38:58 +01:00
|
|
|
|
2019-05-28 14:10:48 +02:00
|
|
|
DECLARE_CRITICAL_SECTION(irp_completion_cs);
|
|
|
|
|
|
|
|
static void WINAPI cancel_completed_irp( DEVICE_OBJECT *device, IRP *irp )
|
|
|
|
{
|
|
|
|
TRACE( "(%p %p)\n", device, irp );
|
|
|
|
|
|
|
|
IoReleaseCancelSpinLock(irp->CancelIrql);
|
|
|
|
|
|
|
|
irp->IoStatus.u.Status = STATUS_CANCELLED;
|
|
|
|
irp->IoStatus.Information = 0;
|
|
|
|
IoCompleteRequest(irp, IO_NO_INCREMENT);
|
|
|
|
}
|
|
|
|
|
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 )
|
|
|
|
{
|
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;
|
2019-05-28 14:10:48 +02:00
|
|
|
NTSTATUS status;
|
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
|
|
|
|
2019-05-28 14:10:48 +02:00
|
|
|
EnterCriticalSection( &irp_completion_cs );
|
|
|
|
|
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;
|
2019-08-07 05:48:43 +02:00
|
|
|
req->size = irp->IoStatus.Information;
|
2019-08-08 04:10:12 +02:00
|
|
|
if (!NT_ERROR(irp->IoStatus.u.Status))
|
2016-10-10 17:15:39 +02:00
|
|
|
{
|
|
|
|
if (out_buff) wine_server_add_data( req, out_buff, irp->IoStatus.Information );
|
|
|
|
}
|
2019-05-28 14:10:48 +02:00
|
|
|
status = wine_server_call( req );
|
2016-10-10 17:15:39 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
2019-05-28 14:10:48 +02:00
|
|
|
if (status == STATUS_MORE_PROCESSING_REQUIRED)
|
|
|
|
{
|
|
|
|
/* IRP is complete, but server may have already ordered cancel call. In such case,
|
|
|
|
* it will return STATUS_MORE_PROCESSING_REQUIRED, leaving the IRP alive until
|
|
|
|
* cancel frees it. */
|
|
|
|
if (irp->Cancel)
|
|
|
|
status = STATUS_SUCCESS;
|
|
|
|
else
|
|
|
|
IoSetCancelRoutine( irp, cancel_completed_irp );
|
|
|
|
}
|
|
|
|
|
2016-10-13 00:51:48 +02:00
|
|
|
if (irp->UserBuffer != irp->AssociatedIrp.SystemBuffer)
|
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, irp->UserBuffer );
|
|
|
|
irp->UserBuffer = NULL;
|
|
|
|
}
|
2019-05-28 14:10:48 +02:00
|
|
|
|
|
|
|
LeaveCriticalSection( &irp_completion_cs );
|
|
|
|
return status;
|
2016-10-10 17:15:39 +02:00
|
|
|
}
|
|
|
|
|
2019-05-27 13:38:27 +02:00
|
|
|
struct dispatch_context
|
|
|
|
{
|
|
|
|
irp_params_t params;
|
|
|
|
HANDLE handle;
|
2019-05-28 14:09:47 +02:00
|
|
|
IRP *irp;
|
2019-05-27 13:38:27 +02:00
|
|
|
ULONG in_size;
|
|
|
|
void *in_buff;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void dispatch_irp( DEVICE_OBJECT *device, IRP *irp, struct dispatch_context *context )
|
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
|
|
|
|
2019-05-27 13:38:27 +02:00
|
|
|
IoSetCompletionRoutine( irp, dispatch_irp_completion, context->handle, TRUE, TRUE, TRUE );
|
2019-05-27 13:39:15 +02:00
|
|
|
context->handle = 0;
|
|
|
|
|
2015-05-05 07:24:00 +02:00
|
|
|
KeQueryTickCount( &count ); /* update the global KeTickCount */
|
|
|
|
|
2019-05-28 14:09:47 +02:00
|
|
|
context->irp = irp;
|
2015-05-05 07:24:00 +02:00
|
|
|
device->CurrentIrp = irp;
|
2019-05-30 13:11:59 +02:00
|
|
|
KeEnterCriticalRegion();
|
2015-05-05 07:24:00 +02:00
|
|
|
IoCallDriver( device, irp );
|
2019-05-30 13:11:59 +02:00
|
|
|
KeLeaveCriticalRegion();
|
2015-05-05 07:24:00 +02:00
|
|
|
device->CurrentIrp = NULL;
|
|
|
|
}
|
|
|
|
|
2015-07-08 11:56:01 +02:00
|
|
|
/* process a create request for a given file */
|
2019-05-27 13:38:27 +02:00
|
|
|
static NTSTATUS dispatch_create( struct dispatch_context *context )
|
2015-07-08 11:56:01 +02:00
|
|
|
{
|
|
|
|
IRP *irp;
|
|
|
|
IO_STACK_LOCATION *irpsp;
|
|
|
|
FILE_OBJECT *file;
|
2019-05-27 13:38:27 +02:00
|
|
|
DEVICE_OBJECT *device = wine_server_get_ptr( context->params.create.device );
|
|
|
|
HANDLE handle = wine_server_ptr_handle( context->params.create.file );
|
2015-07-08 11:56:01 +02:00
|
|
|
|
2019-05-03 15:40:57 +02:00
|
|
|
if (!(file = alloc_kernel_object( IoFileObjectType, handle, sizeof(*file), 0 )))
|
|
|
|
return STATUS_NO_MEMORY;
|
2015-07-08 11:56:01 +02:00
|
|
|
|
|
|
|
TRACE( "device %p -> file %p\n", device, file );
|
|
|
|
|
|
|
|
file->Type = 5; /* MSDN */
|
|
|
|
file->Size = sizeof(*file);
|
|
|
|
file->DeviceObject = device;
|
|
|
|
|
2019-06-06 17:12:51 +02:00
|
|
|
device = IoGetAttachedDevice( device );
|
|
|
|
|
2019-05-03 15:40:57 +02:00
|
|
|
if (!(irp = IoAllocateIrp( device->StackSize, FALSE ))) return STATUS_NO_MEMORY;
|
2015-07-08 11:56:01 +02:00
|
|
|
|
|
|
|
irpsp = IoGetNextIrpStackLocation( irp );
|
|
|
|
irpsp->MajorFunction = IRP_MJ_CREATE;
|
2019-02-06 23:34:11 +01:00
|
|
|
irpsp->FileObject = file;
|
2015-07-08 11:56:01 +02:00
|
|
|
irpsp->Parameters.Create.SecurityContext = NULL; /* FIXME */
|
2019-05-27 13:38:27 +02:00
|
|
|
irpsp->Parameters.Create.Options = context->params.create.options;
|
|
|
|
irpsp->Parameters.Create.ShareAccess = context->params.create.sharing;
|
2015-07-08 11:56:01 +02:00
|
|
|
irpsp->Parameters.Create.FileAttributes = 0;
|
|
|
|
irpsp->Parameters.Create.EaLength = 0;
|
|
|
|
|
|
|
|
irp->Tail.Overlay.OriginalFileObject = file;
|
2019-08-22 06:16:53 +02:00
|
|
|
irp->Tail.Overlay.Thread = (PETHREAD)KeGetCurrentThread();
|
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;
|
2019-05-27 13:38:27 +02:00
|
|
|
dispatch_irp( device, irp, context );
|
2015-07-08 11:56:42 +02:00
|
|
|
|
2015-07-08 11:56:01 +02:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* process a close request for a given file */
|
2019-05-27 13:38:27 +02:00
|
|
|
static NTSTATUS dispatch_close( struct dispatch_context *context )
|
2015-07-08 11:56:01 +02:00
|
|
|
{
|
|
|
|
IRP *irp;
|
|
|
|
IO_STACK_LOCATION *irpsp;
|
|
|
|
DEVICE_OBJECT *device;
|
2019-05-27 13:38:27 +02:00
|
|
|
FILE_OBJECT *file = wine_server_get_ptr( context->params.close.file );
|
2015-07-08 11:56:01 +02:00
|
|
|
|
|
|
|
if (!file) return STATUS_INVALID_HANDLE;
|
|
|
|
|
2019-06-06 17:12:51 +02:00
|
|
|
device = IoGetAttachedDevice( file->DeviceObject );
|
2015-07-08 11:56:01 +02:00
|
|
|
|
|
|
|
TRACE( "device %p file %p\n", device, file );
|
|
|
|
|
|
|
|
if (!(irp = IoAllocateIrp( device->StackSize, FALSE )))
|
|
|
|
{
|
2019-02-26 13:39:51 +01:00
|
|
|
ObDereferenceObject( file );
|
2015-07-08 11:56:01 +02:00
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
irpsp = IoGetNextIrpStackLocation( irp );
|
|
|
|
irpsp->MajorFunction = IRP_MJ_CLOSE;
|
2019-02-06 23:34:11 +01:00
|
|
|
irpsp->FileObject = file;
|
2015-07-08 11:56:01 +02:00
|
|
|
|
|
|
|
irp->Tail.Overlay.OriginalFileObject = file;
|
2019-08-22 06:16:53 +02:00
|
|
|
irp->Tail.Overlay.Thread = (PETHREAD)KeGetCurrentThread();
|
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;
|
2019-05-27 13:38:27 +02:00
|
|
|
dispatch_irp( device, irp, context );
|
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 */
|
2019-05-27 13:38:27 +02:00
|
|
|
static NTSTATUS dispatch_read( struct dispatch_context *context )
|
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;
|
2019-05-27 13:38:27 +02:00
|
|
|
FILE_OBJECT *file = wine_server_get_ptr( context->params.read.file );
|
|
|
|
ULONG out_size = context->params.read.out_size;
|
2015-07-08 12:04:32 +02:00
|
|
|
|
|
|
|
if (!file) return STATUS_INVALID_HANDLE;
|
2015-07-08 10:50:00 +02:00
|
|
|
|
2019-06-06 17:12:51 +02:00
|
|
|
device = IoGetAttachedDevice( 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;
|
|
|
|
|
2019-05-27 13:38:27 +02:00
|
|
|
offset.QuadPart = context->params.read.pos;
|
2015-05-05 07:24:00 +02:00
|
|
|
|
|
|
|
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 );
|
2019-02-06 23:34:11 +01:00
|
|
|
irpsp->FileObject = file;
|
2019-05-27 13:38:27 +02:00
|
|
|
irpsp->Parameters.Read.Key = context->params.read.key;
|
2015-05-05 07:24:00 +02:00
|
|
|
|
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 */
|
2019-05-27 13:38:27 +02:00
|
|
|
dispatch_irp( device, irp, context );
|
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 */
|
2019-05-27 13:38:27 +02:00
|
|
|
static NTSTATUS dispatch_write( struct dispatch_context *context )
|
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;
|
2019-05-27 13:38:27 +02:00
|
|
|
FILE_OBJECT *file = wine_server_get_ptr( context->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;
|
|
|
|
|
2019-06-06 17:12:51 +02:00
|
|
|
device = IoGetAttachedDevice( file->DeviceObject );
|
2015-05-05 07:24:00 +02:00
|
|
|
|
2019-05-27 13:38:27 +02:00
|
|
|
TRACE( "device %p file %p size %u\n", device, file, context->in_size );
|
2015-05-05 07:24:00 +02:00
|
|
|
|
2019-05-27 13:38:27 +02:00
|
|
|
offset.QuadPart = context->params.write.pos;
|
2015-05-05 07:24:00 +02:00
|
|
|
|
2019-05-27 13:38:27 +02:00
|
|
|
if (!(irp = IoBuildSynchronousFsdRequest( IRP_MJ_WRITE, device, context->in_buff, context->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;
|
2019-05-27 13:38:59 +02:00
|
|
|
context->in_buff = NULL;
|
2015-05-05 07:24:00 +02:00
|
|
|
|
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 );
|
2019-02-06 23:34:11 +01:00
|
|
|
irpsp->FileObject = file;
|
2019-05-27 13:38:27 +02:00
|
|
|
irpsp->Parameters.Write.Key = context->params.write.key;
|
2015-05-05 07:24:00 +02:00
|
|
|
|
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 */
|
2019-05-27 13:38:27 +02:00
|
|
|
dispatch_irp( device, irp, context );
|
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 */
|
2019-05-27 13:38:27 +02:00
|
|
|
static NTSTATUS dispatch_flush( struct dispatch_context *context )
|
2015-05-06 10:14:31 +02:00
|
|
|
{
|
|
|
|
IRP *irp;
|
2019-02-06 23:34:11 +01:00
|
|
|
IO_STACK_LOCATION *irpsp;
|
2015-07-08 12:04:32 +02:00
|
|
|
DEVICE_OBJECT *device;
|
2019-05-27 13:38:27 +02:00
|
|
|
FILE_OBJECT *file = wine_server_get_ptr( context->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;
|
|
|
|
|
2019-06-06 17:12:51 +02:00
|
|
|
device = IoGetAttachedDevice( 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;
|
|
|
|
|
2019-02-06 23:34:11 +01:00
|
|
|
irpsp = IoGetNextIrpStackLocation( irp );
|
|
|
|
irpsp->FileObject = file;
|
|
|
|
|
2019-05-27 13:38:27 +02:00
|
|
|
dispatch_irp( device, irp, context );
|
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 */
|
2019-05-27 13:38:27 +02:00
|
|
|
static NTSTATUS dispatch_ioctl( struct dispatch_context *context )
|
2015-05-05 07:24:00 +02:00
|
|
|
{
|
2019-02-06 23:34:11 +01:00
|
|
|
IO_STACK_LOCATION *irpsp;
|
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;
|
2019-05-27 13:38:27 +02:00
|
|
|
FILE_OBJECT *file = wine_server_get_ptr( context->params.ioctl.file );
|
|
|
|
ULONG out_size = context->params.ioctl.out_size;
|
2015-07-08 12:04:32 +02:00
|
|
|
|
|
|
|
if (!file) return STATUS_INVALID_HANDLE;
|
2015-07-08 10:50:00 +02:00
|
|
|
|
2019-06-06 17:12:51 +02:00
|
|
|
device = IoGetAttachedDevice( 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",
|
2019-05-27 13:38:27 +02:00
|
|
|
context->params.ioctl.code, device, file, context->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
|
|
|
{
|
2019-05-27 13:38:27 +02:00
|
|
|
if ((context->params.ioctl.code & 3) != METHOD_BUFFERED)
|
2016-10-16 08:51:06 +02:00
|
|
|
{
|
2019-05-27 13:38:27 +02:00
|
|
|
if (context->in_size < out_size) return STATUS_INVALID_DEVICE_REQUEST;
|
|
|
|
context->in_size -= out_size;
|
2016-10-16 08:51:06 +02:00
|
|
|
if (!(out_buff = HeapAlloc( GetProcessHeap(), 0, out_size ))) return STATUS_NO_MEMORY;
|
2019-05-27 13:38:27 +02:00
|
|
|
memcpy( out_buff, (char *)context->in_buff + context->in_size, out_size );
|
2016-10-16 08:51:06 +02:00
|
|
|
}
|
2019-05-27 13:38:27 +02:00
|
|
|
else if (out_size > context->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;
|
2019-05-27 13:38:27 +02:00
|
|
|
memcpy( out_buff, context->in_buff, context->in_size );
|
|
|
|
to_free = context->in_buff;
|
|
|
|
context->in_buff = out_buff;
|
2015-03-11 14:48:22 +01:00
|
|
|
}
|
2016-10-16 08:51:06 +02:00
|
|
|
else
|
2019-05-27 13:38:27 +02:00
|
|
|
out_buff = context->in_buff;
|
2011-11-01 13:03:12 +01:00
|
|
|
}
|
2015-03-04 14:21:45 +01:00
|
|
|
|
2019-05-27 13:38:27 +02:00
|
|
|
irp = IoBuildDeviceIoControlRequest( context->params.ioctl.code, device, context->in_buff,
|
|
|
|
context->in_size, out_buff, out_size, 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
|
|
|
|
2019-05-27 13:38:27 +02:00
|
|
|
if (out_size && (context->params.ioctl.code & 3) != METHOD_BUFFERED)
|
|
|
|
HeapReAlloc( GetProcessHeap(), HEAP_REALLOC_IN_PLACE_ONLY, context->in_buff, context->in_size );
|
2016-10-16 08:51:06 +02:00
|
|
|
|
2019-02-06 23:34:11 +01:00
|
|
|
irpsp = IoGetNextIrpStackLocation( irp );
|
|
|
|
irpsp->FileObject = file;
|
|
|
|
|
2015-07-08 12:04:32 +02:00
|
|
|
irp->Tail.Overlay.OriginalFileObject = file;
|
|
|
|
irp->RequestorMode = UserMode;
|
2019-05-27 13:38:27 +02:00
|
|
|
irp->AssociatedIrp.SystemBuffer = context->in_buff;
|
2019-05-27 13:38:59 +02:00
|
|
|
context->in_buff = NULL;
|
2015-07-08 12:04:32 +02:00
|
|
|
|
2016-10-13 00:51:48 +02:00
|
|
|
irp->Flags |= IRP_DEALLOCATE_BUFFER; /* deallocate in_buff */
|
2019-05-27 13:38:27 +02:00
|
|
|
dispatch_irp( device, irp, context );
|
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
|
|
|
|
2019-05-27 13:38:27 +02:00
|
|
|
static NTSTATUS dispatch_free( struct dispatch_context *context )
|
2019-03-25 14:38:30 +01:00
|
|
|
{
|
2019-05-27 13:38:27 +02:00
|
|
|
void *obj = wine_server_get_ptr( context->params.free.obj );
|
2019-03-25 14:38:30 +01:00
|
|
|
TRACE( "freeing %p object\n", obj );
|
|
|
|
free_kernel_object( obj );
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2019-05-28 14:10:20 +02:00
|
|
|
static NTSTATUS dispatch_cancel( struct dispatch_context *context )
|
|
|
|
{
|
|
|
|
IRP *irp = wine_server_get_ptr( context->params.cancel.irp );
|
|
|
|
|
2019-05-28 14:10:48 +02:00
|
|
|
TRACE( "%p\n", irp );
|
2019-05-28 14:10:20 +02:00
|
|
|
|
2019-05-28 14:10:48 +02:00
|
|
|
EnterCriticalSection( &irp_completion_cs );
|
|
|
|
IoCancelIrp( irp );
|
|
|
|
LeaveCriticalSection( &irp_completion_cs );
|
2019-05-28 14:10:20 +02:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2019-05-27 13:38:27 +02:00
|
|
|
typedef NTSTATUS (*dispatch_func)( struct dispatch_context *context );
|
2007-05-16 21:13:34 +02:00
|
|
|
|
2019-05-03 15:40:05 +02:00
|
|
|
static const dispatch_func dispatch_funcs[] =
|
2015-05-05 07:24:00 +02:00
|
|
|
{
|
2019-05-03 15:40:05 +02:00
|
|
|
NULL, /* IRP_CALL_NONE */
|
|
|
|
dispatch_create, /* IRP_CALL_CREATE */
|
|
|
|
dispatch_close, /* IRP_CALL_CLOSE */
|
|
|
|
dispatch_read, /* IRP_CALL_READ */
|
|
|
|
dispatch_write, /* IRP_CALL_WRITE */
|
|
|
|
dispatch_flush, /* IRP_CALL_FLUSH */
|
|
|
|
dispatch_ioctl, /* IRP_CALL_IOCTL */
|
2019-05-28 14:10:20 +02:00
|
|
|
dispatch_free, /* IRP_CALL_FREE */
|
|
|
|
dispatch_cancel /* IRP_CALL_CANCEL */
|
2015-05-05 07:24:00 +02:00
|
|
|
};
|
2007-05-16 21:13:34 +02:00
|
|
|
|
2018-08-25 05:42:58 +02:00
|
|
|
/* helper function to update service status */
|
|
|
|
static void set_service_status( SERVICE_STATUS_HANDLE handle, DWORD state, DWORD accepted )
|
|
|
|
{
|
|
|
|
SERVICE_STATUS status;
|
|
|
|
status.dwServiceType = SERVICE_WIN32;
|
|
|
|
status.dwCurrentState = state;
|
|
|
|
status.dwControlsAccepted = accepted;
|
|
|
|
status.dwWin32ExitCode = 0;
|
|
|
|
status.dwServiceSpecificExitCode = 0;
|
|
|
|
status.dwCheckPoint = 0;
|
|
|
|
status.dwWaitHint = (state == SERVICE_START_PENDING) ? 10000 : 0;
|
|
|
|
SetServiceStatus( handle, &status );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void unload_driver( struct wine_rb_entry *entry, void *context )
|
|
|
|
{
|
|
|
|
struct wine_driver *driver = WINE_RB_ENTRY_VALUE( entry, struct wine_driver, entry );
|
|
|
|
SERVICE_STATUS_HANDLE service_handle = driver->service_handle;
|
2020-04-24 03:17:31 +02:00
|
|
|
LDR_DATA_TABLE_ENTRY *ldr;
|
2018-08-25 05:42:58 +02:00
|
|
|
|
|
|
|
if (!service_handle) return; /* not a service */
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_us(&driver->driver_obj.DriverName));
|
|
|
|
|
|
|
|
if (!driver->driver_obj.DriverUnload)
|
|
|
|
{
|
|
|
|
TRACE( "driver %s does not support unloading\n", debugstr_us(&driver->driver_obj.DriverName) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ldr = driver->driver_obj.DriverSection;
|
|
|
|
|
|
|
|
set_service_status( service_handle, SERVICE_STOP_PENDING, 0 );
|
|
|
|
|
|
|
|
TRACE_(relay)( "\1Call driver unload %p (obj=%p)\n", driver->driver_obj.DriverUnload, &driver->driver_obj );
|
|
|
|
|
|
|
|
driver->driver_obj.DriverUnload( &driver->driver_obj );
|
|
|
|
|
|
|
|
TRACE_(relay)( "\1Ret driver unload %p (obj=%p)\n", driver->driver_obj.DriverUnload, &driver->driver_obj );
|
|
|
|
|
2020-04-24 03:17:33 +02:00
|
|
|
FreeLibrary( ldr->DllBase );
|
2018-08-25 05:42:58 +02:00
|
|
|
IoDeleteDriver( &driver->driver_obj );
|
|
|
|
|
|
|
|
set_service_status( service_handle, SERVICE_STOPPED, 0 );
|
|
|
|
CloseServiceHandle( (void *)service_handle );
|
|
|
|
}
|
2007-05-16 21:13:34 +02:00
|
|
|
|
2019-04-29 16:00:40 +02:00
|
|
|
PEPROCESS PsInitialSystemProcess = NULL;
|
|
|
|
|
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();
|
2019-05-27 13:38:27 +02:00
|
|
|
struct dispatch_context context;
|
2007-05-16 21:13:34 +02:00
|
|
|
NTSTATUS status = STATUS_SUCCESS;
|
|
|
|
HANDLE handles[2];
|
|
|
|
|
2020-06-27 13:11:30 +02:00
|
|
|
context.handle = NULL;
|
|
|
|
context.irp = NULL;
|
2019-05-27 13:38:27 +02:00
|
|
|
context.in_size = 4096;
|
|
|
|
context.in_buff = NULL;
|
|
|
|
|
2019-04-29 16:00:40 +02:00
|
|
|
/* Set the system process global before setting up the request thread trickery */
|
|
|
|
PsInitialSystemProcess = IoGetCurrentProcess();
|
2011-10-27 14:20:19 +02:00
|
|
|
request_thread = GetCurrentThreadId();
|
|
|
|
|
2019-06-22 17:12:31 +02:00
|
|
|
pnp_manager_start();
|
|
|
|
|
2007-05-16 21:13:34 +02:00
|
|
|
handles[0] = stop_event;
|
|
|
|
handles[1] = manager;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
2019-04-08 14:04:07 +02:00
|
|
|
NtCurrentTeb()->Reserved5[1] = NULL;
|
2019-05-27 13:38:27 +02:00
|
|
|
if (!context.in_buff && !(context.in_buff = HeapAlloc( GetProcessHeap(), 0, context.in_size )))
|
2016-10-13 00:51:48 +02:00
|
|
|
{
|
|
|
|
ERR( "failed to allocate buffer\n" );
|
2018-08-25 05:42:58 +02:00
|
|
|
status = STATUS_NO_MEMORY;
|
|
|
|
goto done;
|
2016-10-13 00:51:48 +02:00
|
|
|
}
|
|
|
|
|
2007-05-16 21:13:34 +02:00
|
|
|
SERVER_START_REQ( get_next_device_request )
|
|
|
|
{
|
2019-05-28 14:09:47 +02:00
|
|
|
req->manager = wine_server_obj_handle( manager );
|
|
|
|
req->prev = wine_server_obj_handle( context.handle );
|
|
|
|
req->user_ptr = wine_server_client_ptr( context.irp );
|
|
|
|
req->status = status;
|
2019-05-27 13:38:27 +02:00
|
|
|
wine_server_set_reply( req, context.in_buff, context.in_size );
|
2007-05-16 21:13:34 +02:00
|
|
|
if (!(status = wine_server_call( req )))
|
|
|
|
{
|
2019-05-27 13:38:27 +02:00
|
|
|
context.handle = wine_server_ptr_handle( reply->next );
|
|
|
|
context.params = reply->params;
|
|
|
|
context.in_size = reply->in_size;
|
2012-03-15 17:15:56 +01:00
|
|
|
client_tid = reply->client_tid;
|
2019-04-08 14:04:43 +02:00
|
|
|
NtCurrentTeb()->Reserved5[1] = wine_server_get_ptr( reply->client_thread );
|
2007-05-16 21:13:34 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-05-27 13:38:27 +02:00
|
|
|
context.handle = 0; /* no previous irp */
|
2016-10-13 00:51:48 +02:00
|
|
|
if (status == STATUS_BUFFER_OVERFLOW)
|
2019-05-27 13:38:27 +02:00
|
|
|
context.in_size = reply->in_size;
|
2007-05-16 21:13:34 +02:00
|
|
|
}
|
2019-05-28 14:09:47 +02:00
|
|
|
context.irp = NULL;
|
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:
|
2019-05-27 13:38:27 +02:00
|
|
|
assert( context.params.type != IRP_CALL_NONE && context.params.type < ARRAY_SIZE(dispatch_funcs) );
|
|
|
|
status = dispatch_funcs[context.params.type]( &context );
|
2019-05-27 13:39:15 +02:00
|
|
|
if (!context.in_buff) context.in_size = 4096;
|
2007-05-16 21:13:34 +02:00
|
|
|
break;
|
|
|
|
case STATUS_BUFFER_OVERFLOW:
|
2019-05-27 13:38:27 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, context.in_buff );
|
|
|
|
context.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)
|
|
|
|
{
|
2019-05-27 13:38:27 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, context.in_buff );
|
2018-08-25 05:42:58 +02:00
|
|
|
status = STATUS_SUCCESS;
|
|
|
|
goto done;
|
2015-03-13 09:02:35 +01:00
|
|
|
}
|
|
|
|
if (ret != WAIT_IO_COMPLETION) break;
|
2009-01-10 21:56:10 +01:00
|
|
|
}
|
2007-05-16 21:13:34 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-08-25 05:42:58 +02:00
|
|
|
|
|
|
|
done:
|
2019-06-22 17:12:31 +02:00
|
|
|
/* Native PnP drivers expect that all of their devices will be removed when
|
|
|
|
* their unload routine is called, so we must stop the PnP manager first. */
|
|
|
|
pnp_manager_stop();
|
2018-08-25 05:42:58 +02:00
|
|
|
wine_rb_destroy( &wine_drivers, unload_driver, NULL );
|
|
|
|
return status;
|
2007-05-16 21:13:34 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-05-29 09:53:08 +02:00
|
|
|
void WINAPI IoReuseIrp(IRP *irp, NTSTATUS iostatus)
|
|
|
|
{
|
|
|
|
UCHAR AllocationFlags;
|
|
|
|
|
|
|
|
TRACE("irp %p, iostatus %#x.\n", irp, iostatus);
|
|
|
|
|
|
|
|
AllocationFlags = irp->AllocationFlags;
|
|
|
|
IoInitializeIrp(irp, irp->Size, irp->StackCount);
|
|
|
|
irp->AllocationFlags = AllocationFlags;
|
|
|
|
irp->IoStatus.u.Status = iostatus;
|
|
|
|
}
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-01 17:54:14 +02:00
|
|
|
struct _IO_WORKITEM
|
|
|
|
{
|
|
|
|
DEVICE_OBJECT *device;
|
2019-05-01 17:54:23 +02:00
|
|
|
PIO_WORKITEM_ROUTINE worker;
|
|
|
|
void *context;
|
2019-05-01 17:54:14 +02:00
|
|
|
};
|
|
|
|
|
2007-11-08 22:09:08 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* IoAllocateWorkItem (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2019-05-01 17:54:14 +02:00
|
|
|
PIO_WORKITEM WINAPI IoAllocateWorkItem( PDEVICE_OBJECT device )
|
2007-11-08 22:09:08 +01:00
|
|
|
{
|
2019-05-01 17:54:14 +02:00
|
|
|
PIO_WORKITEM work_item;
|
|
|
|
|
|
|
|
TRACE( "%p\n", device );
|
|
|
|
|
|
|
|
if (!(work_item = ExAllocatePool( PagedPool, sizeof(*work_item) ))) return NULL;
|
|
|
|
work_item->device = device;
|
|
|
|
return work_item;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IoFreeWorkItem (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI IoFreeWorkItem( PIO_WORKITEM work_item )
|
|
|
|
{
|
|
|
|
TRACE( "%p\n", work_item );
|
|
|
|
ExFreePool( work_item );
|
2007-11-08 22:09:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-09 10:59:20 +02:00
|
|
|
static void WINAPI run_work_item_worker(TP_CALLBACK_INSTANCE *instance, void *context)
|
2019-05-01 17:54:23 +02:00
|
|
|
{
|
|
|
|
PIO_WORKITEM work_item = context;
|
|
|
|
DEVICE_OBJECT *device = work_item->device;
|
|
|
|
|
|
|
|
TRACE( "%p: calling %p(%p %p)\n", work_item, work_item->worker, device, work_item->context );
|
|
|
|
work_item->worker( device, work_item->context );
|
|
|
|
TRACE( "done\n" );
|
|
|
|
|
|
|
|
ObDereferenceObject( device );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IoQueueWorkItem (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI IoQueueWorkItem( PIO_WORKITEM work_item, PIO_WORKITEM_ROUTINE worker,
|
|
|
|
WORK_QUEUE_TYPE type, void *context )
|
|
|
|
{
|
|
|
|
TRACE( "%p %p %u %p\n", work_item, worker, type, context );
|
|
|
|
|
|
|
|
ObReferenceObject( work_item->device );
|
|
|
|
work_item->worker = worker;
|
|
|
|
work_item->context = context;
|
|
|
|
TrySubmitThreadpoolCallback( run_work_item_worker, work_item, NULL );
|
|
|
|
}
|
|
|
|
|
2019-05-27 14:37:49 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoGetAttachedDevice (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
DEVICE_OBJECT* WINAPI IoGetAttachedDevice( DEVICE_OBJECT *device )
|
|
|
|
{
|
|
|
|
DEVICE_OBJECT *result = device;
|
|
|
|
|
|
|
|
TRACE( "(%p)\n", device );
|
|
|
|
|
|
|
|
while (result->AttachedDevice)
|
|
|
|
result = result->AttachedDevice;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-05-27 14:37:46 +02:00
|
|
|
void WINAPI IoDetachDevice( DEVICE_OBJECT *device )
|
|
|
|
{
|
|
|
|
device->AttachedDevice = NULL;
|
|
|
|
}
|
2019-05-01 17:54:23 +02:00
|
|
|
|
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 );
|
2019-05-27 14:37:49 +02:00
|
|
|
target = IoGetAttachedDevice( target );
|
2008-10-03 15:51:26 +02:00
|
|
|
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;
|
2019-05-02 13:21:39 +02:00
|
|
|
irpsp->DeviceObject = NULL;
|
2015-03-04 14:21:45 +01:00
|
|
|
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;
|
2019-05-30 13:12:25 +02:00
|
|
|
irp->Tail.Overlay.Thread = (PETHREAD)KeGetCurrentThread();
|
2008-10-03 15:51:26 +02:00
|
|
|
return irp;
|
|
|
|
}
|
|
|
|
|
2019-05-02 13:20:52 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoBuildAsynchronousFsdRequest (NTOSKRNL.EXE.@)
|
2014-12-02 09:22:10 +01:00
|
|
|
*/
|
2019-05-02 13:20:52 +02:00
|
|
|
PIRP WINAPI IoBuildAsynchronousFsdRequest(ULONG majorfunc, DEVICE_OBJECT *device,
|
|
|
|
void *buffer, ULONG length, LARGE_INTEGER *startoffset,
|
|
|
|
IO_STATUS_BLOCK *iosb)
|
2014-12-02 09:22:10 +01:00
|
|
|
{
|
|
|
|
PIRP irp;
|
|
|
|
PIO_STACK_LOCATION irpsp;
|
|
|
|
|
2019-05-02 13:20:52 +02:00
|
|
|
TRACE( "(%d %p %p %d %p %p)\n", majorfunc, device, buffer, length, startoffset, 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;
|
2019-05-02 13:21:39 +02:00
|
|
|
irpsp->DeviceObject = NULL;
|
2015-05-05 07:22:52 +02:00
|
|
|
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;
|
2019-04-30 16:37:03 +02:00
|
|
|
irpsp->Parameters.Read.ByteOffset.QuadPart = startoffset ? startoffset->QuadPart : 0;
|
2015-05-05 07:22:52 +02:00
|
|
|
break;
|
|
|
|
case IRP_MJ_WRITE:
|
|
|
|
irpsp->Parameters.Write.Length = length;
|
2019-04-30 16:37:03 +02:00
|
|
|
irpsp->Parameters.Write.ByteOffset.QuadPart = startoffset ? startoffset->QuadPart : 0;
|
2015-05-05 07:22:52 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
irp->RequestorMode = KernelMode;
|
2014-12-02 09:22:10 +01:00
|
|
|
irp->UserIosb = iosb;
|
2019-05-02 13:20:52 +02:00
|
|
|
irp->UserEvent = NULL;
|
2014-12-02 09:22:10 +01:00
|
|
|
irp->UserBuffer = buffer;
|
2019-05-30 13:12:25 +02:00
|
|
|
irp->Tail.Overlay.Thread = (PETHREAD)KeGetCurrentThread();
|
2014-12-02 09:22:10 +01:00
|
|
|
return irp;
|
|
|
|
}
|
|
|
|
|
2019-05-02 13:20:52 +02: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)
|
|
|
|
{
|
|
|
|
IRP *irp;
|
|
|
|
|
|
|
|
TRACE("(%d %p %p %d %p %p)\n", majorfunc, device, buffer, length, startoffset, iosb);
|
|
|
|
|
|
|
|
irp = IoBuildAsynchronousFsdRequest( majorfunc, device, buffer, length, startoffset, iosb );
|
|
|
|
if (!irp) return NULL;
|
|
|
|
|
|
|
|
irp->UserEvent = event;
|
|
|
|
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 */
|
2019-06-17 09:28:35 +02:00
|
|
|
if (wcsncmp( name, servicesW, lstrlenW(servicesW) ) == 0)
|
2016-07-22 20:45:21 +02:00
|
|
|
{
|
|
|
|
FIXME( "Driver name %s is malformed as the keypath\n", debugstr_w(name) );
|
|
|
|
RtlCreateUnicodeString( keypath, name );
|
|
|
|
return;
|
|
|
|
}
|
2019-06-17 09:28:35 +02:00
|
|
|
if (wcsncmp( name, driverW, lstrlenW(driverW) ) == 0)
|
|
|
|
name += lstrlenW(driverW);
|
2016-07-22 20:45:21 +02:00
|
|
|
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
|
|
|
|
2019-06-17 09:28:35 +02:00
|
|
|
str = HeapAlloc( GetProcessHeap(), 0, sizeof(servicesW) + lstrlenW(name)*sizeof(WCHAR));
|
2016-07-22 20:45:21 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-02-26 13:39:11 +01:00
|
|
|
static void free_driver_object( void *obj )
|
|
|
|
{
|
|
|
|
struct wine_driver *driver = obj;
|
|
|
|
RtlFreeUnicodeString( &driver->driver_obj.DriverName );
|
|
|
|
RtlFreeUnicodeString( &driver->driver_obj.DriverExtension->ServiceKeyName );
|
|
|
|
free_kernel_object( driver );
|
|
|
|
}
|
|
|
|
|
2019-02-26 13:38:58 +01:00
|
|
|
static const WCHAR driver_type_name[] = {'D','r','i','v','e','r',0};
|
|
|
|
|
|
|
|
static struct _OBJECT_TYPE driver_type =
|
|
|
|
{
|
|
|
|
driver_type_name,
|
2019-02-26 13:39:43 +01:00
|
|
|
NULL,
|
2019-02-26 13:39:11 +01:00
|
|
|
free_driver_object
|
2019-02-26 13:38:58 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
POBJECT_TYPE IoDriverObjectType = &driver_type;
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2019-03-25 14:37:39 +01:00
|
|
|
if (!(driver = alloc_kernel_object( IoDriverObjectType, NULL, sizeof(*driver), 1 )))
|
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
|
|
|
{
|
2019-02-26 13:39:11 +01:00
|
|
|
free_kernel_object( driver );
|
2007-12-18 19:46:06 +01:00
|
|
|
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
|
|
|
|
2019-08-19 03:02:39 +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 );
|
|
|
|
|
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)
|
|
|
|
{
|
2019-08-19 03:02:39 +02:00
|
|
|
IoDeleteDriver( &driver->driver_obj );
|
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
|
|
|
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
|
|
|
|
2019-02-26 13:39:51 +01:00
|
|
|
ObDereferenceObject( driver_object );
|
2007-12-18 19:46:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-02-26 13:38:58 +01:00
|
|
|
static const WCHAR device_type_name[] = {'D','e','v','i','c','e',0};
|
|
|
|
|
|
|
|
static struct _OBJECT_TYPE device_type =
|
|
|
|
{
|
2019-02-26 13:39:21 +01:00
|
|
|
device_type_name,
|
2019-02-26 13:38:58 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
POBJECT_TYPE IoDeviceObjectType = &device_type;
|
|
|
|
|
|
|
|
|
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 )
|
|
|
|
{
|
2019-06-06 17:12:53 +02:00
|
|
|
static const WCHAR auto_format[] = {'\\','D','e','v','i','c','e','\\','%','0','8','x',0};
|
2007-05-15 21:41:50 +02:00
|
|
|
NTSTATUS status;
|
2019-11-07 06:55:02 +01:00
|
|
|
struct wine_device *wine_device;
|
2007-05-15 21:41:50 +02:00
|
|
|
DEVICE_OBJECT *device;
|
|
|
|
HANDLE manager = get_device_manager();
|
2019-06-06 17:12:53 +02:00
|
|
|
static unsigned int auto_idx = 0;
|
|
|
|
WCHAR autoW[17];
|
2007-05-15 21:41:50 +02:00
|
|
|
|
|
|
|
TRACE( "(%p, %u, %s, %u, %x, %u, %p)\n",
|
|
|
|
driver, ext_size, debugstr_us(name), type, characteristics, exclusive, ret_device );
|
|
|
|
|
2019-11-07 06:55:02 +01:00
|
|
|
if (!(wine_device = alloc_kernel_object( IoDeviceObjectType, NULL, sizeof(struct wine_device) + ext_size, 1 )))
|
2007-05-15 21:41:50 +02:00
|
|
|
return STATUS_NO_MEMORY;
|
2019-11-07 06:55:02 +01:00
|
|
|
device = &wine_device->device_obj;
|
2007-05-15 21:41:50 +02:00
|
|
|
|
2019-03-27 17:43:27 +01:00
|
|
|
device->DriverObject = driver;
|
2019-11-07 06:55:02 +01:00
|
|
|
device->DeviceExtension = wine_device + 1;
|
2019-03-27 17:43:27 +01:00
|
|
|
device->DeviceType = type;
|
|
|
|
device->StackSize = 1;
|
|
|
|
|
2019-06-06 17:12:53 +02:00
|
|
|
if (characteristics & FILE_AUTOGENERATED_DEVICE_NAME)
|
2007-05-15 21:41:50 +02:00
|
|
|
{
|
2019-06-06 17:12:53 +02:00
|
|
|
do
|
|
|
|
{
|
2019-06-17 09:28:35 +02:00
|
|
|
swprintf( autoW, ARRAY_SIZE(autoW), auto_format, auto_idx++ );
|
2019-06-06 17:12:53 +02:00
|
|
|
SERVER_START_REQ( create_device )
|
|
|
|
{
|
|
|
|
req->rootdir = 0;
|
|
|
|
req->manager = wine_server_obj_handle( manager );
|
|
|
|
req->user_ptr = wine_server_client_ptr( device );
|
2019-06-17 09:28:35 +02:00
|
|
|
wine_server_add_data( req, autoW, lstrlenW(autoW) * sizeof(WCHAR) );
|
2019-06-06 17:12:53 +02:00
|
|
|
status = wine_server_call( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
} while (status == STATUS_OBJECT_NAME_COLLISION);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SERVER_START_REQ( create_device )
|
|
|
|
{
|
|
|
|
req->rootdir = 0;
|
|
|
|
req->manager = wine_server_obj_handle( manager );
|
|
|
|
req->user_ptr = wine_server_client_ptr( device );
|
|
|
|
if (name) wine_server_add_data( req, name->Buffer, name->Length );
|
|
|
|
status = wine_server_call( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
2007-05-15 21:41:50 +02:00
|
|
|
}
|
|
|
|
|
2019-03-27 17:43:27 +01:00
|
|
|
if (status)
|
2007-05-15 21:41:50 +02:00
|
|
|
{
|
2019-03-27 17:43:27 +01:00
|
|
|
free_kernel_object( device );
|
|
|
|
return status;
|
2007-05-15 21:41:50 +02:00
|
|
|
}
|
|
|
|
|
2019-04-08 14:03:27 +02:00
|
|
|
device->NextDevice = driver->DeviceObject;
|
|
|
|
driver->DeviceObject = device;
|
|
|
|
|
2019-03-27 17:43:27 +01:00
|
|
|
*ret_device = device;
|
|
|
|
return STATUS_SUCCESS;
|
2007-05-15 21:41:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IoDeleteDevice (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI IoDeleteDevice( DEVICE_OBJECT *device )
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
TRACE( "%p\n", device );
|
|
|
|
|
|
|
|
SERVER_START_REQ( delete_device )
|
|
|
|
{
|
2019-03-27 17:43:27 +01:00
|
|
|
req->manager = wine_server_obj_handle( get_device_manager() );
|
|
|
|
req->device = wine_server_client_ptr( device );
|
2007-05-15 21:41:50 +02:00
|
|
|
status = wine_server_call( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
|
|
|
if (status == STATUS_SUCCESS)
|
|
|
|
{
|
2019-11-07 06:55:02 +01:00
|
|
|
struct wine_device *wine_device = CONTAINING_RECORD(device, struct wine_device, device_obj);
|
2007-05-15 21:41:50 +02:00
|
|
|
DEVICE_OBJECT **prev = &device->DriverObject->DeviceObject;
|
|
|
|
while (*prev && *prev != device) prev = &(*prev)->NextDevice;
|
|
|
|
if (*prev) *prev = (*prev)->NextDevice;
|
2019-11-07 06:55:02 +01:00
|
|
|
ExFreePool( wine_device->children );
|
2019-02-26 13:39:51 +01:00
|
|
|
ObDereferenceObject( device );
|
2007-05-15 21:41:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
2020-07-16 03:27:56 +02:00
|
|
|
NTSTATUS ret;
|
2007-05-15 21:45:51 +02:00
|
|
|
|
|
|
|
attr.Length = sizeof(attr);
|
|
|
|
attr.RootDirectory = 0;
|
|
|
|
attr.ObjectName = name;
|
2020-07-16 03:27:56 +02:00
|
|
|
attr.Attributes = OBJ_CASE_INSENSITIVE | OBJ_OPENIF | OBJ_PERMANENT;
|
2007-05-15 21:45:51 +02:00
|
|
|
attr.SecurityDescriptor = NULL;
|
|
|
|
attr.SecurityQualityOfService = NULL;
|
|
|
|
|
|
|
|
TRACE( "%s -> %s\n", debugstr_us(name), debugstr_us(target) );
|
2020-07-16 03:27:56 +02:00
|
|
|
if (!(ret = NtCreateSymbolicLinkObject( &handle, SYMBOLIC_LINK_ALL_ACCESS, &attr, target )))
|
|
|
|
NtClose( handle );
|
|
|
|
return ret;
|
2007-05-15 21:45:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-10-25 05:20:54 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoCreateUnprotectedSymbolicLink (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoCreateUnprotectedSymbolicLink( UNICODE_STRING *name, UNICODE_STRING *target )
|
|
|
|
{
|
|
|
|
HANDLE handle;
|
|
|
|
OBJECT_ATTRIBUTES attr;
|
2020-07-16 03:27:56 +02:00
|
|
|
NTSTATUS ret;
|
2019-10-25 05:20:54 +02:00
|
|
|
|
|
|
|
attr.Length = sizeof(attr);
|
|
|
|
attr.RootDirectory = 0;
|
|
|
|
attr.ObjectName = name;
|
2020-07-16 03:27:56 +02:00
|
|
|
attr.Attributes = OBJ_CASE_INSENSITIVE | OBJ_OPENIF | OBJ_PERMANENT;
|
2019-10-25 05:20:54 +02:00
|
|
|
attr.SecurityDescriptor = NULL;
|
|
|
|
attr.SecurityQualityOfService = NULL;
|
|
|
|
|
|
|
|
TRACE( "%s -> %s\n", debugstr_us(name), debugstr_us(target) );
|
2020-07-16 03:27:56 +02:00
|
|
|
if (!(ret = NtCreateSymbolicLinkObject( &handle, SYMBOLIC_LINK_ALL_ACCESS, &attr, target )))
|
|
|
|
NtClose( handle );
|
|
|
|
return ret;
|
2019-10-25 05:20:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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 )))
|
|
|
|
{
|
2020-07-16 03:27:56 +02:00
|
|
|
NtMakeTemporaryObject( handle );
|
2008-10-20 16:21:22 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
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;
|
2019-05-02 13:21:39 +02:00
|
|
|
irpsp->DeviceObject = device;
|
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.@)
|
|
|
|
*/
|
2019-02-27 17:14:38 +01:00
|
|
|
DEFINE_FASTCALL_WRAPPER( IofCallDriver, 8 )
|
2019-05-16 10:15:26 +02:00
|
|
|
NTSTATUS FASTCALL IofCallDriver( DEVICE_OBJECT *device, IRP *irp )
|
2010-04-13 20:42:13 +02:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-06-24 16:25:00 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoGetStackLimits (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI IoGetStackLimits(ULONG_PTR *low, ULONG_PTR *high)
|
|
|
|
{
|
|
|
|
TEB *teb = NtCurrentTeb();
|
|
|
|
|
|
|
|
TRACE( "%p %p\n", low, high );
|
|
|
|
|
|
|
|
*low = (DWORD_PTR)teb->Tib.StackLimit;
|
|
|
|
*high = (DWORD_PTR)teb->Tib.StackBase;
|
|
|
|
}
|
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 );
|
|
|
|
}
|
|
|
|
|
2019-08-22 06:16:52 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoRegisterBootDriverReinitialization (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI IoRegisterBootDriverReinitialization(DRIVER_OBJECT *driver, PDRIVER_REINITIALIZE proc, void *ctx)
|
|
|
|
{
|
|
|
|
FIXME("driver %p, proc %p, ctx %p, stub!\n", driver, proc, ctx);
|
|
|
|
}
|
2008-08-29 00:31:58 +02:00
|
|
|
|
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;
|
2020-06-16 01:19:56 +02:00
|
|
|
DEVICE_OBJECT *device;
|
2008-10-03 15:51:26 +02:00
|
|
|
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;
|
|
|
|
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;
|
2019-04-30 16:36:56 +02:00
|
|
|
if ((irpsp->Control & SL_INVOKE_ON_CANCEL) && irp->Cancel)
|
|
|
|
call_flag = 1;
|
2008-10-03 15:51:26 +02:00
|
|
|
}
|
|
|
|
++irp->CurrentLocation;
|
2010-02-24 17:50:03 +01:00
|
|
|
++irp->Tail.Overlay.s.u2.CurrentStackLocation;
|
2020-06-16 01:19:56 +02:00
|
|
|
if (irp->CurrentLocation <= irp->StackCount)
|
|
|
|
device = IoGetCurrentIrpStackLocation(irp)->DeviceObject;
|
|
|
|
else
|
|
|
|
device = NULL;
|
2008-10-03 15:51:26 +02:00
|
|
|
if (call_flag)
|
|
|
|
{
|
2020-06-16 01:19:56 +02:00
|
|
|
TRACE( "calling %p( %p, %p, %p )\n", routine, device, irp, irpsp->Context );
|
|
|
|
stat = routine( device, 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 );
|
2019-05-02 13:21:48 +02:00
|
|
|
if (irp->UserEvent) KeSetEvent( irp->UserEvent, IO_NO_INCREMENT, FALSE );
|
2016-10-13 00:51:48 +02:00
|
|
|
|
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.@)
|
|
|
|
*/
|
2019-02-27 17:14:38 +01:00
|
|
|
DEFINE_FASTCALL_WRAPPER( IofCompleteRequest, 8 )
|
2019-05-16 10:15:26 +02:00
|
|
|
void FASTCALL IofCompleteRequest( IRP *irp, UCHAR priority_boost )
|
2010-03-23 16:52:49 +01:00
|
|
|
{
|
|
|
|
TRACE( "%p %u\n", irp, priority_boost );
|
|
|
|
IoCompleteRequest( irp, priority_boost );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-02 13:21:19 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoCancelIrp (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI IoCancelIrp( IRP *irp )
|
|
|
|
{
|
|
|
|
PDRIVER_CANCEL cancel_routine;
|
|
|
|
KIRQL irql;
|
|
|
|
|
|
|
|
TRACE( "(%p)\n", irp );
|
|
|
|
|
|
|
|
IoAcquireCancelSpinLock( &irql );
|
|
|
|
irp->Cancel = TRUE;
|
|
|
|
if (!(cancel_routine = IoSetCancelRoutine( irp, NULL )))
|
|
|
|
{
|
|
|
|
IoReleaseCancelSpinLock( irp->CancelIrql );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* CancelRoutine is responsible for calling IoReleaseCancelSpinLock */
|
|
|
|
irp->CancelIrql = irql;
|
|
|
|
cancel_routine( IoGetCurrentIrpStackLocation(irp)->DeviceObject, irp );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-25 16:22:24 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedCompareExchange (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2019-02-27 17:14:38 +01:00
|
|
|
DEFINE_FASTCALL_WRAPPER( NTOSKRNL_InterlockedCompareExchange, 12 )
|
2019-05-16 10:15:26 +02:00
|
|
|
LONG FASTCALL NTOSKRNL_InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare )
|
2008-04-25 16:22:24 +02:00
|
|
|
{
|
|
|
|
return InterlockedCompareExchange( dest, xchg, compare );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedDecrement (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2019-02-27 17:14:38 +01:00
|
|
|
DEFINE_FASTCALL1_WRAPPER( NTOSKRNL_InterlockedDecrement )
|
2019-05-16 10:15:26 +02:00
|
|
|
LONG FASTCALL NTOSKRNL_InterlockedDecrement( LONG volatile *dest )
|
2008-04-25 16:22:24 +02:00
|
|
|
{
|
|
|
|
return InterlockedDecrement( dest );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedExchange (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2019-02-27 17:14:38 +01:00
|
|
|
DEFINE_FASTCALL_WRAPPER( NTOSKRNL_InterlockedExchange, 8 )
|
2019-05-16 10:15:26 +02:00
|
|
|
LONG FASTCALL NTOSKRNL_InterlockedExchange( LONG volatile *dest, LONG val )
|
2008-04-25 16:22:24 +02:00
|
|
|
{
|
|
|
|
return InterlockedExchange( dest, val );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedExchangeAdd (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2019-02-27 17:14:38 +01:00
|
|
|
DEFINE_FASTCALL_WRAPPER( NTOSKRNL_InterlockedExchangeAdd, 8 )
|
2019-05-16 10:15:26 +02:00
|
|
|
LONG FASTCALL NTOSKRNL_InterlockedExchangeAdd( LONG volatile *dest, LONG incr )
|
2008-04-25 16:22:24 +02:00
|
|
|
{
|
|
|
|
return InterlockedExchangeAdd( dest, incr );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedIncrement (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2019-02-27 17:14:38 +01:00
|
|
|
DEFINE_FASTCALL1_WRAPPER( NTOSKRNL_InterlockedIncrement )
|
2019-05-16 10:15:26 +02:00
|
|
|
LONG FASTCALL NTOSKRNL_InterlockedIncrement( LONG volatile *dest )
|
2008-04-25 16:22:24 +02:00
|
|
|
{
|
|
|
|
return InterlockedIncrement( dest );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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 */
|
2019-08-22 06:16:51 +02:00
|
|
|
void *ret = HeapAlloc( ntoskrnl_heap, 0, size );
|
2007-05-16 17:39:32 +02:00
|
|
|
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);
|
|
|
|
|
2020-05-29 09:53:05 +02:00
|
|
|
return STATUS_SUCCESS;
|
2012-10-03 08:55:06 +02:00
|
|
|
}
|
|
|
|
|
2020-05-29 09:53:06 +02:00
|
|
|
void * WINAPI ExRegisterCallback(PCALLBACK_OBJECT callback_object,
|
|
|
|
PCALLBACK_FUNCTION callback_function, void *callback_context)
|
|
|
|
{
|
|
|
|
FIXME("callback_object %p, callback_function %p, callback_context %p stub.\n",
|
|
|
|
callback_object, callback_function, callback_context);
|
|
|
|
|
|
|
|
return (void *)0xdeadbeef;
|
|
|
|
}
|
2012-10-03 08:55:06 +02:00
|
|
|
|
2020-05-29 09:53:07 +02:00
|
|
|
void WINAPI ExUnregisterCallback(void *callback_registration)
|
|
|
|
{
|
|
|
|
FIXME("callback_registration %p stub.\n", callback_registration);
|
|
|
|
}
|
|
|
|
|
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 );
|
2019-08-22 06:16:51 +02:00
|
|
|
HeapFree( ntoskrnl_heap, 0, ptr );
|
2007-05-16 17:39:32 +02:00
|
|
|
}
|
|
|
|
|
2019-06-24 16:25:13 +02:00
|
|
|
static void initialize_lookaside_list( GENERAL_LOOKASIDE *lookaside, PALLOCATE_FUNCTION allocate, PFREE_FUNCTION free,
|
|
|
|
ULONG type, SIZE_T size, ULONG tag )
|
|
|
|
{
|
|
|
|
|
|
|
|
RtlInitializeSListHead( &lookaside->u.ListHead );
|
|
|
|
lookaside->Depth = 4;
|
|
|
|
lookaside->MaximumDepth = 256;
|
|
|
|
lookaside->TotalAllocates = 0;
|
|
|
|
lookaside->u2.AllocateMisses = 0;
|
|
|
|
lookaside->TotalFrees = 0;
|
|
|
|
lookaside->u3.FreeMisses = 0;
|
|
|
|
lookaside->Type = type;
|
|
|
|
lookaside->Tag = tag;
|
|
|
|
lookaside->Size = size;
|
|
|
|
lookaside->u4.Allocate = allocate ? allocate : ExAllocatePoolWithTag;
|
|
|
|
lookaside->u5.Free = free ? free : ExFreePool;
|
|
|
|
lookaside->LastTotalAllocates = 0;
|
|
|
|
lookaside->u6.LastAllocateMisses = 0;
|
|
|
|
|
|
|
|
/* FIXME: insert in global list of lookadside lists */
|
|
|
|
}
|
|
|
|
|
2009-06-15 18:23:28 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ExInitializeNPagedLookasideList (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2019-02-06 17:52:02 +01:00
|
|
|
void WINAPI ExInitializeNPagedLookasideList(PNPAGED_LOOKASIDE_LIST lookaside,
|
|
|
|
PALLOCATE_FUNCTION allocate,
|
|
|
|
PFREE_FUNCTION free,
|
|
|
|
ULONG flags,
|
|
|
|
SIZE_T size,
|
|
|
|
ULONG tag,
|
|
|
|
USHORT depth)
|
|
|
|
{
|
|
|
|
TRACE( "%p, %p, %p, %u, %lu, %u, %u\n", lookaside, allocate, free, flags, size, tag, depth );
|
2019-06-24 16:25:13 +02:00
|
|
|
initialize_lookaside_list( &lookaside->L, allocate, free, NonPagedPool | flags, size, tag );
|
2009-06-15 18:23:28 +02:00
|
|
|
}
|
|
|
|
|
2011-12-01 20:07:52 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ExInitializePagedLookasideList (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2019-06-24 16:25:13 +02:00
|
|
|
void WINAPI ExInitializePagedLookasideList(PPAGED_LOOKASIDE_LIST lookaside,
|
|
|
|
PALLOCATE_FUNCTION allocate,
|
|
|
|
PFREE_FUNCTION free,
|
|
|
|
ULONG flags,
|
|
|
|
SIZE_T size,
|
|
|
|
ULONG tag,
|
|
|
|
USHORT depth)
|
2011-12-01 20:07:52 +01:00
|
|
|
{
|
2019-06-24 16:25:13 +02:00
|
|
|
TRACE( "%p, %p, %p, %u, %lu, %u, %u\n", lookaside, allocate, free, flags, size, tag, depth );
|
|
|
|
initialize_lookaside_list( &lookaside->L, allocate, free, PagedPool | flags, size, tag );
|
2011-12-01 20:07:52 +01:00
|
|
|
}
|
2009-06-15 18:23:28 +02:00
|
|
|
|
2019-06-24 16:25:21 +02:00
|
|
|
static void delete_lookaside_list( GENERAL_LOOKASIDE *lookaside )
|
|
|
|
{
|
|
|
|
void *entry;
|
|
|
|
while ((entry = RtlInterlockedPopEntrySList(&lookaside->u.ListHead)))
|
|
|
|
lookaside->u5.FreeEx(entry, (LOOKASIDE_LIST_EX*)lookaside);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ExDeleteNPagedLookasideList (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI ExDeleteNPagedLookasideList( PNPAGED_LOOKASIDE_LIST lookaside )
|
|
|
|
{
|
|
|
|
TRACE( "%p\n", lookaside );
|
|
|
|
delete_lookaside_list( &lookaside->L );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ExDeletePagedLookasideList (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI ExDeletePagedLookasideList( PPAGED_LOOKASIDE_LIST lookaside )
|
|
|
|
{
|
|
|
|
TRACE( "%p\n", lookaside );
|
|
|
|
delete_lookaside_list( &lookaside->L );
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-09-14 10:59:47 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* FsRtlIsNameInExpression (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI FsRtlIsNameInExpression(PUNICODE_STRING expression, PUNICODE_STRING name,
|
|
|
|
BOOLEAN ignore, PWCH upcase)
|
|
|
|
{
|
|
|
|
FIXME("stub: %p %p %d %p\n", expression, name, ignore, upcase);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2019-02-26 13:38:58 +01:00
|
|
|
|
2019-04-19 18:24:39 +02:00
|
|
|
static void *create_process_object( HANDLE handle )
|
|
|
|
{
|
|
|
|
PEPROCESS process;
|
|
|
|
|
|
|
|
if (!(process = alloc_kernel_object( PsProcessType, handle, sizeof(*process), 0 ))) return NULL;
|
|
|
|
|
|
|
|
process->header.Type = 3;
|
|
|
|
process->header.WaitListHead.Blink = INVALID_HANDLE_VALUE; /* mark as kernel object */
|
2019-04-29 16:01:34 +02:00
|
|
|
NtQueryInformationProcess( handle, ProcessBasicInformation, &process->info, sizeof(process->info), NULL );
|
2020-05-03 18:22:02 +02:00
|
|
|
IsWow64Process( handle, &process->wow64 );
|
2019-04-19 18:24:39 +02:00
|
|
|
return process;
|
|
|
|
}
|
|
|
|
|
2019-02-26 13:38:58 +01:00
|
|
|
static const WCHAR process_type_name[] = {'P','r','o','c','e','s','s',0};
|
|
|
|
|
|
|
|
static struct _OBJECT_TYPE process_type =
|
|
|
|
{
|
2019-04-19 18:24:39 +02:00
|
|
|
process_type_name,
|
|
|
|
create_process_object
|
2019-02-26 13:38:58 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
POBJECT_TYPE PsProcessType = &process_type;
|
|
|
|
|
|
|
|
|
2011-12-27 14:46:10 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* IoGetCurrentProcess / PsGetCurrentProcess (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PEPROCESS WINAPI IoGetCurrentProcess(void)
|
|
|
|
{
|
2019-04-29 16:00:32 +02:00
|
|
|
return KeGetCurrentThread()->process;
|
2011-12-27 14:46:10 +01:00
|
|
|
}
|
|
|
|
|
2019-04-19 18:24:54 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* PsLookupProcessByProcessId (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI PsLookupProcessByProcessId( HANDLE processid, PEPROCESS *process )
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
HANDLE handle;
|
|
|
|
|
|
|
|
TRACE( "(%p %p)\n", processid, process );
|
|
|
|
|
|
|
|
if (!(handle = OpenProcess( PROCESS_ALL_ACCESS, FALSE, HandleToUlong(processid) )))
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
status = ObReferenceObjectByHandle( handle, PROCESS_ALL_ACCESS, PsProcessType, KernelMode, (void**)process, NULL );
|
|
|
|
|
|
|
|
NtClose( handle );
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2019-04-29 16:01:34 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* PsGetProcessId (NTOSKRNL.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI PsGetProcessId(PEPROCESS process)
|
|
|
|
{
|
|
|
|
TRACE( "%p -> %lx\n", process, process->info.UniqueProcessId );
|
|
|
|
return (HANDLE)process->info.UniqueProcessId;
|
|
|
|
}
|
|
|
|
|
2019-05-16 19:50:27 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* PsGetProcessInheritedFromUniqueProcessId (NTOSKRNL.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI PsGetProcessInheritedFromUniqueProcessId( PEPROCESS process )
|
|
|
|
{
|
|
|
|
HANDLE id = (HANDLE)process->info.InheritedFromUniqueProcessId;
|
|
|
|
TRACE( "%p -> %p\n", process, id );
|
|
|
|
return id;
|
|
|
|
}
|
2019-02-26 13:38:58 +01:00
|
|
|
|
2019-04-08 14:03:50 +02:00
|
|
|
static void *create_thread_object( HANDLE handle )
|
|
|
|
{
|
2019-04-08 14:04:29 +02:00
|
|
|
THREAD_BASIC_INFORMATION info;
|
2019-04-08 14:03:50 +02:00
|
|
|
struct _KTHREAD *thread;
|
2019-04-29 16:00:32 +02:00
|
|
|
HANDLE process;
|
2019-04-08 14:03:50 +02:00
|
|
|
|
|
|
|
if (!(thread = alloc_kernel_object( PsThreadType, handle, sizeof(*thread), 0 ))) return NULL;
|
|
|
|
|
|
|
|
thread->header.Type = 6;
|
|
|
|
thread->header.WaitListHead.Blink = INVALID_HANDLE_VALUE; /* mark as kernel object */
|
2020-05-26 12:05:09 +02:00
|
|
|
thread->user_affinity = 0;
|
2019-04-08 14:04:29 +02:00
|
|
|
|
|
|
|
if (!NtQueryInformationThread( handle, ThreadBasicInformation, &info, sizeof(info), NULL ))
|
2019-04-29 16:00:32 +02:00
|
|
|
{
|
2019-04-08 14:04:29 +02:00
|
|
|
thread->id = info.ClientId;
|
2019-04-29 16:00:32 +02:00
|
|
|
if ((process = OpenProcess( PROCESS_QUERY_INFORMATION, FALSE, HandleToUlong(thread->id.UniqueProcess) )))
|
|
|
|
{
|
|
|
|
kernel_object_from_handle( process, PsProcessType, (void**)&thread->process );
|
|
|
|
NtClose( process );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-08 14:04:29 +02:00
|
|
|
|
2019-04-08 14:03:50 +02:00
|
|
|
return thread;
|
|
|
|
}
|
|
|
|
|
2019-02-26 13:38:58 +01:00
|
|
|
static const WCHAR thread_type_name[] = {'T','h','r','e','a','d',0};
|
|
|
|
|
|
|
|
static struct _OBJECT_TYPE thread_type =
|
|
|
|
{
|
|
|
|
thread_type_name,
|
2019-04-08 14:03:50 +02:00
|
|
|
create_thread_object
|
2019-02-26 13:38:58 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
POBJECT_TYPE PsThreadType = &thread_type;
|
|
|
|
|
|
|
|
|
2009-12-30 11:02:01 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* KeGetCurrentThread / PsGetCurrentThread (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PRKTHREAD WINAPI KeGetCurrentThread(void)
|
|
|
|
{
|
2019-04-08 14:04:07 +02:00
|
|
|
struct _KTHREAD *thread = NtCurrentTeb()->Reserved5[1];
|
|
|
|
|
|
|
|
if (!thread)
|
|
|
|
{
|
|
|
|
HANDLE handle = GetCurrentThread();
|
|
|
|
|
|
|
|
/* FIXME: we shouldn't need it, GetCurrentThread() should be client thread already */
|
2019-04-12 15:20:28 +02:00
|
|
|
if (GetCurrentThreadId() == request_thread)
|
|
|
|
handle = OpenThread( THREAD_QUERY_INFORMATION, FALSE, client_tid );
|
2019-04-08 14:04:07 +02:00
|
|
|
|
|
|
|
kernel_object_from_handle( handle, PsThreadType, (void**)&thread );
|
|
|
|
if (handle != GetCurrentThread()) NtClose( handle );
|
|
|
|
|
|
|
|
NtCurrentTeb()->Reserved5[1] = thread;
|
|
|
|
}
|
|
|
|
|
|
|
|
return thread;
|
2009-12-30 11:02:01 +01:00
|
|
|
}
|
2019-04-19 18:24:14 +02:00
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
* PsLookupThreadByThreadId (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI PsLookupThreadByThreadId( HANDLE threadid, PETHREAD *thread )
|
|
|
|
{
|
2019-04-23 16:23:14 +02:00
|
|
|
OBJECT_ATTRIBUTES attr;
|
|
|
|
CLIENT_ID cid;
|
2019-04-19 18:24:14 +02:00
|
|
|
NTSTATUS status;
|
|
|
|
HANDLE handle;
|
|
|
|
|
|
|
|
TRACE( "(%p %p)\n", threadid, thread );
|
|
|
|
|
2019-04-23 16:23:14 +02:00
|
|
|
cid.UniqueProcess = 0;
|
|
|
|
cid.UniqueThread = threadid;
|
|
|
|
InitializeObjectAttributes( &attr, NULL, 0, NULL, NULL );
|
|
|
|
status = NtOpenThread( &handle, THREAD_QUERY_INFORMATION, &attr, &cid );
|
|
|
|
if (status) return status;
|
2019-04-19 18:24:14 +02:00
|
|
|
|
|
|
|
status = ObReferenceObjectByHandle( handle, THREAD_ALL_ACCESS, PsThreadType, KernelMode, (void**)thread, NULL );
|
|
|
|
|
|
|
|
NtClose( handle );
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2019-04-29 16:01:45 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* PsGetThreadId (NTOSKRNL.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI PsGetThreadId(PETHREAD thread)
|
|
|
|
{
|
|
|
|
TRACE( "%p -> %p\n", thread, thread->kthread.id.UniqueThread );
|
|
|
|
return thread->kthread.id.UniqueThread;
|
|
|
|
}
|
2009-12-30 11:02:01 +01:00
|
|
|
|
2019-05-21 12:11:44 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* PsGetThreadProcessId (NTOSKRNL.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI PsGetThreadProcessId( PETHREAD thread )
|
|
|
|
{
|
|
|
|
TRACE( "%p -> %p\n", thread, thread->kthread.id.UniqueProcess );
|
|
|
|
return thread->kthread.id.UniqueProcess;
|
|
|
|
}
|
|
|
|
|
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 )
|
|
|
|
{
|
2020-05-26 12:05:06 +02:00
|
|
|
DWORD_PTR affinity_mask;
|
2008-04-07 21:10:12 +02:00
|
|
|
|
2020-05-26 12:05:06 +02:00
|
|
|
GetProcessAffinityMask( GetCurrentProcess(), NULL, &affinity_mask);
|
|
|
|
return affinity_mask;
|
2008-04-07 21:10:12 +02:00
|
|
|
}
|
|
|
|
|
2020-05-22 19:37:43 +02:00
|
|
|
ULONG WINAPI KeQueryActiveProcessorCountEx(USHORT group_number)
|
|
|
|
{
|
|
|
|
TRACE("group_number %u.\n", group_number);
|
|
|
|
|
|
|
|
return GetActiveProcessorCount(group_number);
|
|
|
|
}
|
2008-04-07 21:10:12 +02:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* KeQueryTimeIncrement (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
ULONG WINAPI KeQueryTimeIncrement(void)
|
|
|
|
{
|
|
|
|
return 10000;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.@)
|
|
|
|
*/
|
2020-05-26 12:05:08 +02:00
|
|
|
VOID WINAPI KeSetSystemAffinityThread(KAFFINITY affinity)
|
2015-01-02 12:44:38 +01:00
|
|
|
{
|
2020-05-26 12:05:08 +02:00
|
|
|
KeSetSystemAffinityThreadEx(affinity);
|
2015-01-02 12:44:38 +01:00
|
|
|
}
|
2009-12-29 10:13:37 +01:00
|
|
|
|
2020-05-26 12:05:07 +02:00
|
|
|
KAFFINITY WINAPI KeSetSystemAffinityThreadEx(KAFFINITY affinity)
|
|
|
|
{
|
|
|
|
DWORD_PTR system_affinity = KeQueryActiveProcessors();
|
2020-05-26 12:05:09 +02:00
|
|
|
PKTHREAD thread = KeGetCurrentThread();
|
2020-05-26 12:05:07 +02:00
|
|
|
GROUP_AFFINITY old, new;
|
|
|
|
|
|
|
|
TRACE("affinity %#lx.\n", affinity);
|
|
|
|
|
|
|
|
affinity &= system_affinity;
|
|
|
|
|
|
|
|
NtQueryInformationThread(GetCurrentThread(), ThreadGroupInformation,
|
|
|
|
&old, sizeof(old), NULL);
|
|
|
|
|
2020-05-26 12:05:09 +02:00
|
|
|
if (old.Mask != system_affinity)
|
|
|
|
thread->user_affinity = old.Mask;
|
|
|
|
|
2020-05-26 12:05:07 +02:00
|
|
|
memset(&new, 0, sizeof(new));
|
|
|
|
new.Mask = affinity;
|
|
|
|
|
|
|
|
return NtSetInformationThread(GetCurrentThread(), ThreadGroupInformation, &new, sizeof(new))
|
2020-05-26 12:05:09 +02:00
|
|
|
? 0 : thread->user_affinity;
|
2020-05-26 12:05:07 +02:00
|
|
|
}
|
|
|
|
|
2019-02-06 23:34:48 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* KeRevertToUserAffinityThread (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI KeRevertToUserAffinityThread(void)
|
|
|
|
{
|
2020-05-26 12:05:10 +02:00
|
|
|
KeRevertToUserAffinityThreadEx(0);
|
2019-02-06 23:34:48 +01:00
|
|
|
}
|
|
|
|
|
2020-05-26 12:05:09 +02:00
|
|
|
void WINAPI KeRevertToUserAffinityThreadEx(KAFFINITY affinity)
|
|
|
|
{
|
|
|
|
DWORD_PTR system_affinity = KeQueryActiveProcessors();
|
|
|
|
PRKTHREAD thread = KeGetCurrentThread();
|
|
|
|
GROUP_AFFINITY new;
|
|
|
|
|
|
|
|
TRACE("affinity %#lx.\n", affinity);
|
|
|
|
|
|
|
|
affinity &= system_affinity;
|
|
|
|
|
|
|
|
memset(&new, 0, sizeof(new));
|
|
|
|
new.Mask = affinity ? affinity
|
|
|
|
: (thread->user_affinity ? thread->user_affinity : system_affinity);
|
|
|
|
|
|
|
|
NtSetInformationThread(GetCurrentThread(), ThreadGroupInformation, &new, sizeof(new));
|
|
|
|
thread->user_affinity = affinity;
|
|
|
|
}
|
2019-02-06 23:34:48 +01:00
|
|
|
|
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
|
|
|
|
2019-02-01 16:28:16 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* KeExpandKernelStackAndCalloutEx (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI KeExpandKernelStackAndCalloutEx(PEXPAND_STACK_CALLOUT callout, void *parameter, SIZE_T size,
|
|
|
|
BOOLEAN wait, void *context)
|
|
|
|
{
|
|
|
|
WARN("(%p %p %lu %x %p) semi-stub: ignoring stack expand\n", callout, parameter, size, wait, context);
|
|
|
|
callout(parameter);
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* KeExpandKernelStackAndCallout (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI KeExpandKernelStackAndCallout(PEXPAND_STACK_CALLOUT callout, void *parameter, SIZE_T size)
|
|
|
|
{
|
|
|
|
return KeExpandKernelStackAndCalloutEx(callout, parameter, size, TRUE, NULL);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2019-03-11 16:56:17 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MmBuildMdlForNonPagedPool (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI MmBuildMdlForNonPagedPool(MDL *mdl)
|
|
|
|
{
|
|
|
|
FIXME("stub: %p\n", mdl);
|
|
|
|
}
|
|
|
|
|
2018-09-06 11:01:20 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MmCreateSection (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI MmCreateSection( HANDLE *handle, ACCESS_MASK access, OBJECT_ATTRIBUTES *attr,
|
|
|
|
LARGE_INTEGER *size, ULONG protect, ULONG alloc_attr,
|
|
|
|
HANDLE file, FILE_OBJECT *file_obj )
|
|
|
|
{
|
|
|
|
FIXME("%p %#x %p %s %#x %#x %p %p: stub\n", handle, access, attr,
|
|
|
|
wine_dbgstr_longlong(size->QuadPart), protect, alloc_attr, file, file_obj);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
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);
|
2018-06-05 17:14:50 +02:00
|
|
|
return !IsBadReadPtr(VirtualAddress, 1);
|
2008-03-21 21:25:40 +01:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-04-23 16:23:25 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MmUnmapLockedPages (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI MmUnmapLockedPages( void *base, MDL *mdl )
|
|
|
|
{
|
|
|
|
FIXME( "(%p %p_\n", base, mdl );
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
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);
|
2019-02-26 13:39:29 +01:00
|
|
|
ObReferenceObject( *Object = &driver->driver_obj );
|
2016-08-04 18:53:57 +02:00
|
|
|
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
|
|
|
|
2020-07-16 17:17:08 +02:00
|
|
|
/********************************************************************
|
|
|
|
* ObOpenObjectByName (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI ObOpenObjectByName(POBJECT_ATTRIBUTES attr, POBJECT_TYPE type,
|
|
|
|
KPROCESSOR_MODE mode, ACCESS_STATE *access_state,
|
|
|
|
ACCESS_MASK access, PVOID ctx, HANDLE *handle)
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
void *object;
|
|
|
|
|
|
|
|
TRACE( "attr(%p %s %x) %p %u %p %u %p %p\n", attr->RootDirectory, debugstr_us(attr->ObjectName),
|
|
|
|
attr->Attributes, type, mode, access_state, access, ctx, handle );
|
|
|
|
|
|
|
|
if (mode != KernelMode)
|
|
|
|
{
|
|
|
|
FIXME( "UserMode access not implemented\n" );
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attr->RootDirectory) FIXME( "RootDirectory unhandled\n" );
|
|
|
|
|
|
|
|
status = ObReferenceObjectByName(attr->ObjectName, attr->Attributes, access_state, access, type, mode, ctx, &object );
|
|
|
|
if (status != STATUS_SUCCESS)
|
|
|
|
return status;
|
|
|
|
|
|
|
|
status = ObOpenObjectByPointer(object, attr->Attributes, access_state, access, type, mode, handle);
|
|
|
|
|
|
|
|
ObDereferenceObject(object);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-12 11:58:30 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ObReferenceObjectByPointer (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI ObReferenceObjectByPointer(void *obj, ACCESS_MASK access,
|
|
|
|
POBJECT_TYPE type,
|
|
|
|
KPROCESSOR_MODE mode)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %x, %p, %d): stub\n", obj, access, type, mode);
|
|
|
|
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-13 09:22:52 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ObfReferenceObject (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2019-02-27 17:14:38 +01:00
|
|
|
DEFINE_FASTCALL1_WRAPPER( ObfReferenceObject )
|
2019-05-16 10:15:26 +02:00
|
|
|
void FASTCALL ObfReferenceObject( void *obj )
|
2016-02-13 09:22:52 +01:00
|
|
|
{
|
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.@)
|
|
|
|
*/
|
2019-02-27 17:14:38 +01:00
|
|
|
DEFINE_FASTCALL1_WRAPPER( ObfDereferenceObject )
|
2019-05-16 10:15:26 +02:00
|
|
|
void FASTCALL ObfDereferenceObject( void *obj )
|
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
|
|
|
}
|
|
|
|
|
2018-03-21 06:40:18 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ObRegisterCallbacks (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2020-05-29 09:53:04 +02:00
|
|
|
NTSTATUS WINAPI ObRegisterCallbacks(POB_CALLBACK_REGISTRATION callback, void **handle)
|
2018-03-21 06:40:18 +01:00
|
|
|
{
|
2020-05-29 09:53:04 +02:00
|
|
|
FIXME( "callback %p, handle %p.\n", callback, handle );
|
2018-03-21 06:40:18 +01:00
|
|
|
|
|
|
|
if(handle)
|
|
|
|
*handle = UlongToHandle(0xdeadbeaf);
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
2008-08-29 00:55:01 +02:00
|
|
|
|
2018-03-21 06:40:20 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ObUnRegisterCallbacks (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI ObUnRegisterCallbacks(void *handle)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p\n", handle );
|
|
|
|
}
|
|
|
|
|
2018-03-21 06:40:22 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ObGetFilterVersion (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
USHORT WINAPI ObGetFilterVersion(void)
|
|
|
|
{
|
|
|
|
FIXME( "stub:\n" );
|
|
|
|
|
|
|
|
return OB_FLT_REGISTRATION_VERSION;
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2019-04-08 14:04:29 +02:00
|
|
|
return KeGetCurrentThread()->id.UniqueProcess;
|
2007-05-17 09:49:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* PsGetCurrentThreadId (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI PsGetCurrentThreadId(void)
|
|
|
|
{
|
2019-04-08 14:04:29 +02:00
|
|
|
return KeGetCurrentThread()->id.UniqueThread;
|
2007-05-17 09:49:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-29 16:01:20 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* PsIsSystemThread (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI PsIsSystemThread(PETHREAD thread)
|
|
|
|
{
|
|
|
|
return thread->kthread.process == PsInitialSystemProcess;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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 */
|
2019-06-17 09:28:35 +02:00
|
|
|
size_t len = min( lstrlenW(info.szCSDVersion)*sizeof(WCHAR), version->MaximumLength );
|
2007-05-17 09:49:28 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-02-06 17:51:43 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* PsRevertToSelf (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI PsRevertToSelf(void)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2018-03-01 23:02:38 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* PsSetCreateProcessNotifyRoutineEx (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI PsSetCreateProcessNotifyRoutineEx( PCREATE_PROCESS_NOTIFY_ROUTINE_EX 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.@)
|
|
|
|
*/
|
2020-05-29 09:53:10 +02:00
|
|
|
NTSTATUS WINAPI PsRemoveLoadImageNotifyRoutine(PLOAD_IMAGE_NOTIFY_ROUTINE routine)
|
2016-04-04 02:56:30 +02:00
|
|
|
{
|
2020-05-29 09:53:10 +02:00
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
TRACE("routine %p.\n", routine);
|
|
|
|
|
|
|
|
for (i = 0; i < load_image_notify_routine_count; ++i)
|
|
|
|
if (load_image_notify_routines[i] == routine)
|
|
|
|
{
|
|
|
|
--load_image_notify_routine_count;
|
|
|
|
memmove(&load_image_notify_routines[i], &load_image_notify_routines[i + 1],
|
|
|
|
sizeof(*load_image_notify_routines) * (load_image_notify_routine_count - i));
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
return STATUS_PROCEDURE_NOT_FOUND;
|
2016-04-04 02:56:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-02-08 17:00:33 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* PsReferenceProcessFilePointer (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI PsReferenceProcessFilePointer(PEPROCESS process, FILE_OBJECT **file)
|
|
|
|
{
|
|
|
|
FIXME("%p %p\n", process, file);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-14 14:19:45 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* PsTerminateSystemThread (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2019-01-25 05:56:24 +01:00
|
|
|
NTSTATUS WINAPI PsTerminateSystemThread(NTSTATUS status)
|
2009-06-14 14:19:45 +02:00
|
|
|
{
|
2019-01-25 05:56:24 +01:00
|
|
|
TRACE("status %#x.\n", status);
|
|
|
|
ExitThread( status );
|
2009-06-14 14:19:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-02-27 14:05:35 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* PsSuspendProcess (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI PsSuspendProcess(PEPROCESS process)
|
|
|
|
{
|
|
|
|
FIXME("stub: %p\n", process);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* PsResumeProcess (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI PsResumeProcess(PEPROCESS process)
|
|
|
|
{
|
|
|
|
FIXME("stub: %p\n", process);
|
|
|
|
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 );
|
2020-05-29 09:53:06 +02:00
|
|
|
|
2008-11-17 11:01:10 +01:00
|
|
|
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
|
|
|
|
2019-08-02 07:49:33 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MmIsThisAnNtAsSystem (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI MmIsThisAnNtAsSystem(void)
|
|
|
|
{
|
|
|
|
TRACE("\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
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.@)
|
|
|
|
*/
|
2020-05-28 11:15:14 +02:00
|
|
|
void WINAPI KeInitializeDpc(KDPC *dpc, PKDEFERRED_ROUTINE deferred_routine, void *deferred_context)
|
2010-09-22 09:06:07 +02:00
|
|
|
{
|
2020-05-28 11:15:14 +02:00
|
|
|
FIXME("dpc %p, deferred_routine %p, deferred_context %p semi-stub.\n",
|
|
|
|
dpc, deferred_routine, deferred_context);
|
|
|
|
|
|
|
|
dpc->DeferredRoutine = deferred_routine;
|
|
|
|
dpc->DeferredContext = deferred_context;
|
2010-09-22 09:06:07 +02:00
|
|
|
}
|
2009-03-01 09:48:51 +01:00
|
|
|
|
2019-12-26 10:18:54 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* KeSetImportanceDpc (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
VOID WINAPI KeSetImportanceDpc(PRKDPC dpc, KDPC_IMPORTANCE importance)
|
|
|
|
{
|
|
|
|
FIXME("%p, %d stub\n", dpc, importance);
|
|
|
|
}
|
|
|
|
|
2018-11-06 13:10:17 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* KeSetTargetProcessorDpc (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
VOID WINAPI KeSetTargetProcessorDpc(PRKDPC dpc, CCHAR number)
|
|
|
|
{
|
|
|
|
FIXME("%p, %d stub\n", dpc, number);
|
|
|
|
}
|
|
|
|
|
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-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;
|
|
|
|
}
|
|
|
|
|
2019-03-21 16:54:00 +01:00
|
|
|
/*****************************************************
|
|
|
|
* IoWMIOpenBlock (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoWMIOpenBlock(LPCGUID guid, ULONG desired_access, PVOID *data_block_obj)
|
|
|
|
{
|
|
|
|
FIXME("(%p %u %p) stub\n", guid, desired_access, data_block_obj);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2011-03-19 10:26:58 +01:00
|
|
|
/*****************************************************
|
|
|
|
* PsSetLoadImageNotifyRoutine (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI PsSetLoadImageNotifyRoutine(PLOAD_IMAGE_NOTIFY_ROUTINE routine)
|
|
|
|
{
|
2020-05-29 09:53:10 +02:00
|
|
|
FIXME("routine %p, semi-stub.\n", routine);
|
|
|
|
|
|
|
|
if (load_image_notify_routine_count == ARRAY_SIZE(load_image_notify_routines))
|
|
|
|
return STATUS_INSUFFICIENT_RESOURCES;
|
|
|
|
|
|
|
|
load_image_notify_routines[load_image_notify_routine_count++] = routine;
|
|
|
|
|
2011-03-19 10:26:58 +01:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-06-05 22:48:37 +02:00
|
|
|
/*****************************************************
|
|
|
|
* IoSetThreadHardErrorMode (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI IoSetThreadHardErrorMode(BOOLEAN EnableHardErrors)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
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.@)
|
|
|
|
*/
|
2019-08-19 03:02:38 +02:00
|
|
|
NTSTATUS WINAPI ObQueryNameString( void *object, OBJECT_NAME_INFORMATION *name, ULONG size, ULONG *ret_size )
|
2014-10-29 18:32:36 +01:00
|
|
|
{
|
2019-08-19 03:02:38 +02:00
|
|
|
HANDLE handle;
|
|
|
|
NTSTATUS ret;
|
|
|
|
|
|
|
|
TRACE("object %p, name %p, size %u, ret_size %p.\n", object, name, size, ret_size);
|
|
|
|
|
|
|
|
if ((ret = ObOpenObjectByPointer( object, 0, NULL, 0, NULL, KernelMode, &handle )))
|
|
|
|
return ret;
|
|
|
|
ret = NtQueryObject( handle, ObjectNameInformation, name, size, ret_size );
|
|
|
|
|
|
|
|
NtClose( handle );
|
|
|
|
return ret;
|
2014-10-29 18:32:36 +01:00
|
|
|
}
|
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
|
|
|
|
2018-06-26 17:05:31 +02:00
|
|
|
/*****************************************************
|
|
|
|
* IoUnregisterPlugPlayNotification (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoUnregisterPlugPlayNotification(PVOID notification)
|
|
|
|
{
|
|
|
|
FIXME("stub: %p\n", 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-09-29 05:03:06 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* KeEnterCriticalRegion (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI KeEnterCriticalRegion(void)
|
|
|
|
{
|
2019-05-30 13:11:42 +02:00
|
|
|
TRACE( "semi-stub\n" );
|
|
|
|
KeGetCurrentThread()->critical_region++;
|
2015-09-29 05:03:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* KeLeaveCriticalRegion (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI KeLeaveCriticalRegion(void)
|
|
|
|
{
|
2019-05-30 13:11:42 +02:00
|
|
|
TRACE( "semi-stub\n" );
|
|
|
|
KeGetCurrentThread()->critical_region--;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* KeAreApcsDisabled (NTOSKRNL.@)
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI KeAreApcsDisabled(void)
|
|
|
|
{
|
|
|
|
unsigned int critical_region = KeGetCurrentThread()->critical_region;
|
|
|
|
TRACE( "%u\n", critical_region );
|
|
|
|
return !!critical_region;
|
2015-09-29 05:03:06 +02:00
|
|
|
}
|
2015-11-13 08:30:26 +01:00
|
|
|
|
2019-06-25 15:36:15 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* KeBugCheck (NTOSKRNL.@)
|
|
|
|
*/
|
|
|
|
void WINAPI KeBugCheck(ULONG code)
|
|
|
|
{
|
|
|
|
KeBugCheckEx(code, 0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* KeBugCheckEx (NTOSKRNL.@)
|
|
|
|
*/
|
|
|
|
void WINAPI KeBugCheckEx(ULONG code, ULONG_PTR param1, ULONG_PTR param2, ULONG_PTR param3, ULONG_PTR param4)
|
|
|
|
{
|
|
|
|
ERR( "%x %lx %lx %lx %lx\n", code, param1, param2, param3, param4 );
|
|
|
|
ExitProcess( code );
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
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;
|
|
|
|
|
2019-06-17 09:28:35 +02:00
|
|
|
if (wcsncmp( name, servicesW, lstrlenW(servicesW) ))
|
2016-08-24 06:11:07 +02:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-06-17 09:28:35 +02:00
|
|
|
*service = OpenServiceW( manager_handle, name + lstrlenW(servicesW),
|
2018-08-25 05:42:58 +02:00
|
|
|
SERVICE_QUERY_CONFIG | SERVICE_SET_STATUS );
|
2016-08-24 06:11:07 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-04-24 03:17:31 +02:00
|
|
|
/* find the LDR_DATA_TABLE_ENTRY corresponding to the driver module */
|
|
|
|
static LDR_DATA_TABLE_ENTRY *find_ldr_module( HMODULE module )
|
2018-08-25 05:42:58 +02:00
|
|
|
{
|
2020-04-24 03:17:31 +02:00
|
|
|
LDR_DATA_TABLE_ENTRY *ldr;
|
2018-08-25 05:42:58 +02:00
|
|
|
ULONG_PTR magic;
|
2016-08-24 06:11:07 +02:00
|
|
|
|
2018-08-25 05:42:58 +02:00
|
|
|
LdrLockLoaderLock( 0, NULL, &magic );
|
|
|
|
if (LdrFindEntryForAddress( module, &ldr ))
|
|
|
|
{
|
|
|
|
WARN( "module not found for %p\n", module );
|
|
|
|
ldr = NULL;
|
|
|
|
}
|
|
|
|
LdrUnlockLoaderLock( 0, magic );
|
|
|
|
|
|
|
|
return ldr;
|
|
|
|
}
|
|
|
|
|
2019-05-04 15:55:53 +02:00
|
|
|
/* convert PE image VirtualAddress to Real Address */
|
|
|
|
static inline void *get_rva( HMODULE module, DWORD va )
|
|
|
|
{
|
|
|
|
return (void *)((char *)module + va);
|
|
|
|
}
|
|
|
|
|
2020-06-09 18:03:14 +02:00
|
|
|
static void WINAPI ldr_notify_callback(ULONG reason, LDR_DLL_NOTIFICATION_DATA *data, void *context)
|
2019-05-04 15:55:53 +02:00
|
|
|
{
|
|
|
|
const IMAGE_DATA_DIRECTORY *relocs;
|
2020-06-09 18:03:14 +02:00
|
|
|
IMAGE_BASE_RELOCATION *rel, *end;
|
|
|
|
SYSTEM_BASIC_INFORMATION info;
|
|
|
|
IMAGE_NT_HEADERS *nt;
|
2019-05-04 15:55:53 +02:00
|
|
|
INT_PTR delta;
|
2020-06-09 18:03:14 +02:00
|
|
|
char *base;
|
|
|
|
HMODULE module;
|
|
|
|
|
|
|
|
if (reason != LDR_DLL_NOTIFICATION_REASON_LOADED) return;
|
|
|
|
TRACE( "loading %s\n", debugstr_us(data->Loaded.BaseDllName));
|
2019-05-04 15:55:53 +02:00
|
|
|
|
2020-06-09 18:03:14 +02:00
|
|
|
module = data->Loaded.DllBase;
|
2019-05-04 15:55:53 +02:00
|
|
|
nt = RtlImageNtHeader( module );
|
|
|
|
base = (char *)nt->OptionalHeader.ImageBase;
|
2020-06-09 18:03:14 +02:00
|
|
|
if (!(delta = (char *)module - base)) return;
|
2019-05-04 15:55:53 +02:00
|
|
|
|
2020-06-09 18:03:14 +02:00
|
|
|
/* the loader does not apply relocations to non page-aligned binaries or executables,
|
|
|
|
* we have to do it ourselves */
|
2019-05-04 15:55:53 +02:00
|
|
|
|
2020-06-09 18:03:14 +02:00
|
|
|
NtQuerySystemInformation( SystemBasicInformation, &info, sizeof(info), NULL );
|
|
|
|
if (nt->OptionalHeader.SectionAlignment >= info.PageSize && (nt->FileHeader.Characteristics & IMAGE_FILE_DLL))
|
|
|
|
return;
|
2019-05-04 15:55:53 +02:00
|
|
|
|
|
|
|
if (nt->FileHeader.Characteristics & IMAGE_FILE_RELOCS_STRIPPED)
|
|
|
|
{
|
2020-06-09 18:03:14 +02:00
|
|
|
WARN( "Need to relocate module from %p to %p, but there are no relocation records\n", base, module );
|
|
|
|
return;
|
2019-05-04 15:55:53 +02:00
|
|
|
}
|
|
|
|
|
2020-06-09 18:03:14 +02:00
|
|
|
relocs = &nt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC];
|
|
|
|
if (!relocs->Size || !relocs->VirtualAddress) return;
|
2019-05-04 15:55:53 +02:00
|
|
|
|
2020-06-09 18:03:14 +02:00
|
|
|
TRACE( "relocating from %p-%p to %p-%p\n", base, base + nt->OptionalHeader.SizeOfImage,
|
|
|
|
module, (char *)module + nt->OptionalHeader.SizeOfImage );
|
2019-05-04 15:55:53 +02:00
|
|
|
|
|
|
|
rel = get_rva( module, relocs->VirtualAddress );
|
|
|
|
end = get_rva( module, relocs->VirtualAddress + relocs->Size );
|
|
|
|
|
|
|
|
while (rel < end - 1 && rel->SizeOfBlock)
|
|
|
|
{
|
2020-05-22 16:52:56 +02:00
|
|
|
char *page = get_rva( module, rel->VirtualAddress );
|
|
|
|
DWORD old_prot1, old_prot2;
|
2020-05-03 03:55:54 +02:00
|
|
|
|
2020-06-09 18:03:14 +02:00
|
|
|
if (rel->VirtualAddress >= nt->OptionalHeader.SizeOfImage)
|
2019-05-04 15:55:53 +02:00
|
|
|
{
|
|
|
|
WARN( "invalid address %p in relocation %p\n", get_rva( module, rel->VirtualAddress ), rel );
|
2020-06-09 18:03:14 +02:00
|
|
|
return;
|
2019-05-04 15:55:53 +02:00
|
|
|
}
|
2020-05-03 03:55:54 +02:00
|
|
|
|
|
|
|
/* Relocation entries may hang over the end of the page, so we need to
|
|
|
|
* protect two pages. */
|
2020-06-09 18:03:14 +02:00
|
|
|
VirtualProtect( page, info.PageSize, PAGE_READWRITE, &old_prot1 );
|
|
|
|
VirtualProtect( page + info.PageSize, info.PageSize, PAGE_READWRITE, &old_prot2 );
|
2020-05-03 03:55:54 +02:00
|
|
|
rel = LdrProcessRelocationBlock( page, (rel->SizeOfBlock - sizeof(*rel)) / sizeof(USHORT),
|
2019-05-04 15:55:53 +02:00
|
|
|
(USHORT *)(rel + 1), delta );
|
2020-06-09 18:03:14 +02:00
|
|
|
VirtualProtect( page, info.PageSize, old_prot1, &old_prot1 );
|
|
|
|
VirtualProtect( page + info.PageSize, info.PageSize, old_prot2, &old_prot2 );
|
|
|
|
if (!rel)
|
2018-08-25 05:42:58 +02:00
|
|
|
{
|
2020-06-09 18:03:14 +02:00
|
|
|
WARN( "LdrProcessRelocationBlock failed\n" );
|
|
|
|
return;
|
2018-08-25 05:42:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* load the .sys module for a device driver */
|
|
|
|
static HMODULE load_driver( const WCHAR *driver_name, const UNICODE_STRING *keyname )
|
|
|
|
{
|
|
|
|
static const WCHAR driversW[] = {'\\','d','r','i','v','e','r','s','\\',0};
|
|
|
|
static const WCHAR systemrootW[] = {'\\','S','y','s','t','e','m','R','o','o','t','\\',0};
|
|
|
|
static const WCHAR postfixW[] = {'.','s','y','s',0};
|
|
|
|
static const WCHAR ntprefixW[] = {'\\','?','?','\\',0};
|
|
|
|
static const WCHAR ImagePathW[] = {'I','m','a','g','e','P','a','t','h',0};
|
|
|
|
HKEY driver_hkey;
|
|
|
|
HMODULE module;
|
|
|
|
LPWSTR path = NULL, str;
|
|
|
|
DWORD type, size;
|
|
|
|
|
|
|
|
if (RegOpenKeyW( HKEY_LOCAL_MACHINE, keyname->Buffer + 18 /* skip \registry\machine */, &driver_hkey ))
|
2016-08-24 06:11:07 +02:00
|
|
|
{
|
2018-12-05 18:57:40 +01:00
|
|
|
ERR( "cannot open key %s, err=%u\n", wine_dbgstr_w(keyname->Buffer), GetLastError() );
|
2018-08-25 05:42:58 +02:00
|
|
|
return NULL;
|
2016-08-24 06:11:07 +02:00
|
|
|
}
|
|
|
|
|
2018-08-25 05:42:58 +02:00
|
|
|
/* read the executable path from memory */
|
|
|
|
size = 0;
|
|
|
|
if (!RegQueryValueExW( driver_hkey, ImagePathW, NULL, &type, NULL, &size ))
|
2016-08-24 06:11:07 +02:00
|
|
|
{
|
2018-08-25 05:42:58 +02:00
|
|
|
str = HeapAlloc( GetProcessHeap(), 0, size );
|
|
|
|
if (!RegQueryValueExW( driver_hkey, ImagePathW, NULL, &type, (LPBYTE)str, &size ))
|
|
|
|
{
|
|
|
|
size = ExpandEnvironmentStringsW(str,NULL,0);
|
|
|
|
path = HeapAlloc(GetProcessHeap(),0,size*sizeof(WCHAR));
|
|
|
|
ExpandEnvironmentStringsW(str,path,size);
|
|
|
|
}
|
|
|
|
HeapFree( GetProcessHeap(), 0, str );
|
|
|
|
if (!path)
|
|
|
|
{
|
|
|
|
RegCloseKey( driver_hkey );
|
|
|
|
return NULL;
|
|
|
|
}
|
2016-08-24 06:11:07 +02:00
|
|
|
|
2019-06-17 09:28:35 +02:00
|
|
|
if (!wcsnicmp( path, systemrootW, 12 ))
|
2018-08-25 05:42:58 +02:00
|
|
|
{
|
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
|
|
|
|
GetWindowsDirectoryW(buffer, MAX_PATH);
|
|
|
|
|
2019-06-17 09:28:35 +02:00
|
|
|
str = HeapAlloc(GetProcessHeap(), 0, (size -11 + lstrlenW(buffer))
|
2018-08-25 05:42:58 +02:00
|
|
|
* sizeof(WCHAR));
|
|
|
|
lstrcpyW(str, buffer);
|
|
|
|
lstrcatW(str, path + 11);
|
|
|
|
HeapFree( GetProcessHeap(), 0, path );
|
|
|
|
path = str;
|
|
|
|
}
|
2019-06-17 09:28:35 +02:00
|
|
|
else if (!wcsncmp( path, ntprefixW, 4 ))
|
2018-08-25 05:42:58 +02:00
|
|
|
str = path + 4;
|
|
|
|
else
|
|
|
|
str = path;
|
2016-08-24 06:11:07 +02:00
|
|
|
}
|
2018-08-25 05:42:58 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* default is to use the driver name + ".sys" */
|
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
GetSystemDirectoryW(buffer, MAX_PATH);
|
|
|
|
path = HeapAlloc(GetProcessHeap(),0,
|
2019-06-17 09:28:35 +02:00
|
|
|
(lstrlenW(buffer) + lstrlenW(driversW) + lstrlenW(driver_name) + lstrlenW(postfixW) + 1)
|
2018-08-25 05:42:58 +02:00
|
|
|
*sizeof(WCHAR));
|
|
|
|
lstrcpyW(path, buffer);
|
|
|
|
lstrcatW(path, driversW);
|
|
|
|
lstrcatW(path, driver_name);
|
|
|
|
lstrcatW(path, postfixW);
|
|
|
|
str = path;
|
|
|
|
}
|
|
|
|
RegCloseKey( driver_hkey );
|
2016-08-24 06:11:07 +02:00
|
|
|
|
2018-12-05 18:57:40 +01:00
|
|
|
TRACE( "loading driver %s\n", wine_dbgstr_w(str) );
|
2018-08-25 05:42:58 +02:00
|
|
|
|
2020-06-09 18:03:14 +02:00
|
|
|
module = LoadLibraryW( str );
|
2020-05-29 09:53:12 +02:00
|
|
|
|
|
|
|
if (module && load_image_notify_routine_count)
|
|
|
|
{
|
|
|
|
UNICODE_STRING module_name;
|
|
|
|
IMAGE_NT_HEADERS *nt;
|
|
|
|
IMAGE_INFO info;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
RtlInitUnicodeString(&module_name, str);
|
|
|
|
nt = RtlImageNtHeader(module);
|
|
|
|
memset(&info, 0, sizeof(info));
|
|
|
|
info.u.s.ImageAddressingMode = IMAGE_ADDRESSING_MODE_32BIT;
|
|
|
|
info.u.s.SystemModeImage = TRUE;
|
|
|
|
info.ImageSize = nt->OptionalHeader.SizeOfImage;
|
|
|
|
info.ImageBase = module;
|
|
|
|
|
|
|
|
for (i = 0; i < load_image_notify_routine_count; ++i)
|
|
|
|
{
|
|
|
|
TRACE("Calling image load notify %p.\n", load_image_notify_routines[i]);
|
|
|
|
load_image_notify_routines[i](&module_name, NULL, &info);
|
|
|
|
TRACE("Called image load notify %p.\n", load_image_notify_routines[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-25 05:42:58 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, path );
|
|
|
|
return module;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* call the driver init entry point */
|
|
|
|
static NTSTATUS WINAPI init_driver( DRIVER_OBJECT *driver_object, UNICODE_STRING *keyname )
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
NTSTATUS status;
|
|
|
|
const IMAGE_NT_HEADERS *nt;
|
|
|
|
const WCHAR *driver_name;
|
|
|
|
HMODULE module;
|
|
|
|
|
|
|
|
/* Retrieve driver name from the keyname */
|
2019-06-17 09:28:35 +02:00
|
|
|
driver_name = wcsrchr( keyname->Buffer, '\\' );
|
2018-08-25 05:42:58 +02:00
|
|
|
driver_name++;
|
|
|
|
|
|
|
|
module = load_driver( driver_name, keyname );
|
|
|
|
if (!module)
|
|
|
|
return STATUS_DLL_INIT_FAILED;
|
|
|
|
|
|
|
|
driver_object->DriverSection = find_ldr_module( module );
|
2020-06-19 20:11:37 +02:00
|
|
|
driver_object->DriverStart = ((LDR_DATA_TABLE_ENTRY *)driver_object->DriverSection)->DllBase;
|
|
|
|
driver_object->DriverSize = ((LDR_DATA_TABLE_ENTRY *)driver_object->DriverSection)->SizeOfImage;
|
2018-08-25 05:42:58 +02:00
|
|
|
|
|
|
|
nt = RtlImageNtHeader( module );
|
|
|
|
if (!nt->OptionalHeader.AddressOfEntryPoint) return STATUS_SUCCESS;
|
|
|
|
driver_object->DriverInit = (PDRIVER_INITIALIZE)((char *)module + nt->OptionalHeader.AddressOfEntryPoint);
|
|
|
|
|
|
|
|
TRACE_(relay)( "\1Call driver init %p (obj=%p,str=%s)\n",
|
|
|
|
driver_object->DriverInit, driver_object, wine_dbgstr_w(keyname->Buffer) );
|
|
|
|
|
|
|
|
status = driver_object->DriverInit( driver_object, keyname );
|
|
|
|
|
|
|
|
TRACE_(relay)( "\1Ret driver init %p (obj=%p,str=%s) retval=%08x\n",
|
|
|
|
driver_object->DriverInit, driver_object, wine_dbgstr_w(keyname->Buffer), status );
|
|
|
|
|
2018-12-05 18:57:40 +01:00
|
|
|
TRACE( "init done for %s obj %p\n", wine_dbgstr_w(driver_name), driver_object );
|
|
|
|
TRACE( "- DriverInit = %p\n", driver_object->DriverInit );
|
|
|
|
TRACE( "- DriverStartIo = %p\n", driver_object->DriverStartIo );
|
|
|
|
TRACE( "- DriverUnload = %p\n", driver_object->DriverUnload );
|
2018-08-25 05:42:58 +02:00
|
|
|
for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
|
2018-12-05 18:57:40 +01:00
|
|
|
TRACE( "- MajorFunction[%d] = %p\n", i, driver_object->MajorFunction[i] );
|
2016-08-24 06:11:07 +02:00
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2018-08-25 05:42:58 +02:00
|
|
|
static BOOLEAN get_drv_name( UNICODE_STRING *drv_name, const UNICODE_STRING *service_name )
|
|
|
|
{
|
|
|
|
static const WCHAR driverW[] = {'\\','D','r','i','v','e','r','\\',0};
|
|
|
|
WCHAR *str;
|
|
|
|
|
2019-06-17 09:28:35 +02:00
|
|
|
if (!(str = heap_alloc( sizeof(driverW) + service_name->Length - lstrlenW(servicesW)*sizeof(WCHAR) )))
|
2018-08-25 05:42:58 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
lstrcpyW( str, driverW );
|
2019-06-17 09:28:35 +02:00
|
|
|
lstrcpynW( str + lstrlenW(driverW), service_name->Buffer + lstrlenW(servicesW),
|
|
|
|
service_name->Length/sizeof(WCHAR) - lstrlenW(servicesW) + 1 );
|
2018-08-25 05:42:58 +02:00
|
|
|
RtlInitUnicodeString( drv_name, str );
|
|
|
|
return TRUE;
|
|
|
|
}
|
2016-08-24 06:11:07 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
2018-08-25 05:42:58 +02:00
|
|
|
* ZwLoadDriver (NTOSKRNL.EXE.@)
|
2016-08-24 06:11:07 +02:00
|
|
|
*/
|
2018-08-25 05:42:58 +02:00
|
|
|
NTSTATUS WINAPI ZwLoadDriver( const UNICODE_STRING *service_name )
|
2016-08-24 06:11:07 +02:00
|
|
|
{
|
2018-08-25 05:42:58 +02:00
|
|
|
SERVICE_STATUS_HANDLE service_handle;
|
|
|
|
struct wine_rb_entry *entry;
|
|
|
|
struct wine_driver *driver;
|
|
|
|
UNICODE_STRING drv_name;
|
2016-08-24 06:11:07 +02:00
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
TRACE( "(%s)\n", debugstr_us(service_name) );
|
|
|
|
|
2018-08-25 05:42:58 +02:00
|
|
|
if ((status = open_driver( service_name, (SC_HANDLE *)&service_handle )) != STATUS_SUCCESS)
|
2016-08-24 06:11:07 +02:00
|
|
|
return status;
|
|
|
|
|
2018-08-25 05:42:58 +02:00
|
|
|
if (!get_drv_name( &drv_name, service_name ))
|
2016-08-24 06:11:07 +02:00
|
|
|
{
|
2018-08-25 05:42:58 +02:00
|
|
|
CloseServiceHandle( (void *)service_handle );
|
|
|
|
return STATUS_NO_MEMORY;
|
2016-08-24 06:11:07 +02:00
|
|
|
}
|
|
|
|
|
2018-12-22 00:28:46 +01:00
|
|
|
if (wine_rb_get( &wine_drivers, &drv_name ))
|
|
|
|
{
|
|
|
|
TRACE( "driver %s already loaded\n", debugstr_us(&drv_name) );
|
|
|
|
RtlFreeUnicodeString( &drv_name );
|
2019-01-08 11:19:20 +01:00
|
|
|
CloseServiceHandle( (void *)service_handle );
|
2018-12-22 00:28:46 +01:00
|
|
|
return STATUS_IMAGE_ALREADY_LOADED;
|
|
|
|
}
|
|
|
|
|
2018-08-25 05:42:58 +02:00
|
|
|
set_service_status( service_handle, SERVICE_START_PENDING, 0 );
|
|
|
|
|
|
|
|
status = IoCreateDriver( &drv_name, init_driver );
|
|
|
|
entry = wine_rb_get( &wine_drivers, &drv_name );
|
|
|
|
RtlFreeUnicodeString( &drv_name );
|
|
|
|
if (status != STATUS_SUCCESS)
|
2016-08-24 06:11:07 +02:00
|
|
|
{
|
2018-08-25 05:42:58 +02:00
|
|
|
ERR( "failed to create driver %s: %08x\n", debugstr_us(service_name), status );
|
|
|
|
goto error;
|
2016-08-24 06:11:07 +02:00
|
|
|
}
|
|
|
|
|
2018-08-25 05:42:58 +02:00
|
|
|
driver = WINE_RB_ENTRY_VALUE( entry, struct wine_driver, entry );
|
|
|
|
driver->service_handle = service_handle;
|
2016-08-24 06:11:07 +02:00
|
|
|
|
2019-06-22 17:12:32 +02:00
|
|
|
pnp_manager_enumerate_root_devices( service_name->Buffer + wcslen( servicesW ) );
|
|
|
|
|
2018-08-25 05:42:58 +02:00
|
|
|
set_service_status( service_handle, SERVICE_RUNNING,
|
|
|
|
SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN );
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
|
|
|
|
error:
|
|
|
|
set_service_status( service_handle, SERVICE_STOPPED, 0 );
|
|
|
|
CloseServiceHandle( (void *)service_handle );
|
2016-08-24 06:11:07 +02:00
|
|
|
return status;
|
|
|
|
}
|
2016-09-01 09:28:00 +02:00
|
|
|
|
2018-08-25 05:42:58 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ZwUnloadDriver (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI ZwUnloadDriver( const UNICODE_STRING *service_name )
|
|
|
|
{
|
|
|
|
struct wine_rb_entry *entry;
|
|
|
|
UNICODE_STRING drv_name;
|
|
|
|
|
|
|
|
TRACE( "(%s)\n", debugstr_us(service_name) );
|
|
|
|
|
|
|
|
if (!get_drv_name( &drv_name, service_name ))
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
|
|
|
|
entry = wine_rb_get( &wine_drivers, &drv_name );
|
|
|
|
RtlFreeUnicodeString( &drv_name );
|
|
|
|
if (!entry)
|
|
|
|
{
|
|
|
|
ERR( "failed to locate driver %s\n", debugstr_us(service_name) );
|
|
|
|
return STATUS_OBJECT_NAME_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
unload_driver( entry, NULL );
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
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;
|
|
|
|
}
|
2018-03-18 07:40:13 +01:00
|
|
|
|
|
|
|
|
2018-03-27 00:58:55 +02:00
|
|
|
#ifdef __x86_64__
|
|
|
|
/**************************************************************************
|
|
|
|
* __chkstk (NTOSKRNL.@)
|
|
|
|
*
|
|
|
|
* Supposed to touch all the stack pages, but we shouldn't need that.
|
|
|
|
*/
|
|
|
|
__ASM_GLOBAL_FUNC( __chkstk, "ret" );
|
|
|
|
|
|
|
|
#elif defined(__i386__)
|
|
|
|
/**************************************************************************
|
|
|
|
* _chkstk (NTOSKRNL.@)
|
|
|
|
*/
|
2020-05-05 16:28:49 +02:00
|
|
|
__ASM_GLOBAL_FUNC( _chkstk,
|
2018-03-27 00:58:55 +02:00
|
|
|
"negl %eax\n\t"
|
|
|
|
"addl %esp,%eax\n\t"
|
|
|
|
"xchgl %esp,%eax\n\t"
|
|
|
|
"movl 0(%eax),%eax\n\t" /* copy return address from old location */
|
|
|
|
"movl %eax,0(%esp)\n\t"
|
|
|
|
"ret" )
|
|
|
|
#elif defined(__arm__)
|
|
|
|
/**************************************************************************
|
|
|
|
* __chkstk (NTDLL.@)
|
|
|
|
*
|
|
|
|
* Incoming r4 contains words to allocate, converting to bytes then return
|
|
|
|
*/
|
|
|
|
__ASM_GLOBAL_FUNC( __chkstk, "lsl r4, r4, #2\n\t"
|
|
|
|
"bx lr" )
|
|
|
|
#endif
|
2018-04-05 01:18:17 +02:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* PsAcquireProcessExitSynchronization (NTOSKRNL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI PsAcquireProcessExitSynchronization(PEPROCESS process)
|
|
|
|
{
|
|
|
|
FIXME("stub: %p\n", process);
|
|
|
|
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* PsReleaseProcessExitSynchronization (NTOSKRNL.@)
|
|
|
|
*/
|
|
|
|
void WINAPI PsReleaseProcessExitSynchronization(PEPROCESS process)
|
|
|
|
{
|
|
|
|
FIXME("stub: %p\n", process);
|
|
|
|
}
|
2018-04-05 01:18:18 +02:00
|
|
|
|
|
|
|
typedef struct _EX_PUSH_LOCK_WAIT_BLOCK *PEX_PUSH_LOCK_WAIT_BLOCK;
|
|
|
|
/*********************************************************************
|
|
|
|
* ExfUnblockPushLock (NTOSKRNL.@)
|
|
|
|
*/
|
2019-02-27 17:14:38 +01:00
|
|
|
DEFINE_FASTCALL_WRAPPER( ExfUnblockPushLock, 8 )
|
2019-05-16 10:15:26 +02:00
|
|
|
void FASTCALL ExfUnblockPushLock( EX_PUSH_LOCK *lock, PEX_PUSH_LOCK_WAIT_BLOCK block )
|
2018-04-05 01:18:18 +02:00
|
|
|
{
|
|
|
|
FIXME( "stub: %p, %p\n", lock, block );
|
|
|
|
}
|
2018-04-05 01:18:19 +02:00
|
|
|
|
2018-04-17 07:09:00 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* FsRtlRegisterFileSystemFilterCallbacks (NTOSKRNL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI FsRtlRegisterFileSystemFilterCallbacks( DRIVER_OBJECT *object, PFS_FILTER_CALLBACKS callbacks)
|
|
|
|
{
|
|
|
|
FIXME("stub: %p %p\n", object, callbacks);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
2018-05-25 07:50:14 +02:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* SeSinglePrivilegeCheck (NTOSKRNL.@)
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI SeSinglePrivilegeCheck(LUID privilege, KPROCESSOR_MODE mode)
|
|
|
|
{
|
2019-10-28 04:59:58 +01:00
|
|
|
static int once;
|
|
|
|
if (!once++) FIXME("stub: %08x%08x %u\n", privilege.HighPart, privilege.LowPart, mode);
|
2018-05-25 07:50:14 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2018-07-14 01:10:04 +02:00
|
|
|
|
2019-08-08 05:42:40 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* SePrivilegeCheck (NTOSKRNL.@)
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI SePrivilegeCheck(PRIVILEGE_SET *privileges, SECURITY_SUBJECT_CONTEXT *context, KPROCESSOR_MODE mode)
|
|
|
|
{
|
|
|
|
FIXME("stub: %p %p %u\n", privileges, context, mode);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-08-08 05:42:41 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* SeLocateProcessImageName (NTOSKRNL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI SeLocateProcessImageName(PEPROCESS process, UNICODE_STRING **image_name)
|
|
|
|
{
|
|
|
|
FIXME("stub: %p %p\n", process, image_name);
|
|
|
|
if (image_name) *image_name = NULL;
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2018-07-16 22:52:32 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* KeFlushQueuedDpcs (NTOSKRNL.@)
|
|
|
|
*/
|
2018-07-14 01:10:04 +02:00
|
|
|
void WINAPI KeFlushQueuedDpcs(void)
|
|
|
|
{
|
|
|
|
FIXME("stub!\n");
|
|
|
|
}
|
2018-07-16 22:52:32 +02:00
|
|
|
|
2018-11-06 08:51:02 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* DbgQueryDebugFilterState (NTOSKRNL.@)
|
|
|
|
*/
|
2018-08-29 03:30:02 +02:00
|
|
|
NTSTATUS WINAPI DbgQueryDebugFilterState(ULONG component, ULONG level)
|
|
|
|
{
|
|
|
|
FIXME("stub: %d %d\n", component, level);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
2018-09-11 04:12:12 +02:00
|
|
|
|
2018-11-06 08:51:02 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* PsGetProcessWow64Process (NTOSKRNL.@)
|
|
|
|
*/
|
|
|
|
PVOID WINAPI PsGetProcessWow64Process(PEPROCESS process)
|
|
|
|
{
|
|
|
|
FIXME("stub: %p\n", process);
|
|
|
|
return NULL;
|
|
|
|
}
|
2018-11-06 08:51:03 +01:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MmCopyVirtualMemory (NTOSKRNL.@)
|
|
|
|
*/
|
2020-05-31 17:26:21 +02:00
|
|
|
NTSTATUS WINAPI MmCopyVirtualMemory(PEPROCESS fromprocess, void *fromaddress, PEPROCESS toprocess,
|
|
|
|
void *toaddress, SIZE_T bufsize, KPROCESSOR_MODE mode,
|
|
|
|
SIZE_T *copied)
|
2018-11-06 08:51:03 +01:00
|
|
|
{
|
2020-05-31 17:26:21 +02:00
|
|
|
FIXME("fromprocess %p, fromaddress %p, toprocess %p, toaddress %p, bufsize %lu, mode %d, copied %p stub.\n",
|
|
|
|
fromprocess, fromaddress, toprocess, toaddress, bufsize, mode, copied);
|
|
|
|
|
|
|
|
*copied = 0;
|
2018-11-06 08:51:03 +01:00
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
2019-01-31 16:12:50 +01:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* KeEnterGuardedRegion (NTOSKRNL.@)
|
|
|
|
*/
|
|
|
|
void WINAPI KeEnterGuardedRegion(void)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* KeLeaveGuardedRegion (NTOSKRNL.@)
|
|
|
|
*/
|
|
|
|
void WINAPI KeLeaveGuardedRegion(void)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
}
|
2019-02-26 13:38:58 +01:00
|
|
|
|
|
|
|
static const WCHAR token_type_name[] = {'T','o','k','e','n',0};
|
|
|
|
|
|
|
|
static struct _OBJECT_TYPE token_type =
|
|
|
|
{
|
|
|
|
token_type_name
|
|
|
|
};
|
|
|
|
|
|
|
|
POBJECT_TYPE SeTokenObjectType = &token_type;
|
2019-02-27 04:08:42 +01:00
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* ExUuidCreate (NTOSKRNL.@)
|
|
|
|
*
|
|
|
|
* Creates a 128bit UUID.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
*
|
|
|
|
* STATUS_SUCCESS if successful.
|
|
|
|
* RPC_NT_UUID_LOCAL_ONLY if UUID is only locally unique.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
*
|
|
|
|
* Follows RFC 4122, section 4.4 (Algorithms for Creating a UUID from
|
|
|
|
* Truly Random or Pseudo-Random Numbers)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI ExUuidCreate(UUID *uuid)
|
|
|
|
{
|
|
|
|
RtlGenRandom(uuid, sizeof(*uuid));
|
|
|
|
/* Clear the version bits and set the version (4) */
|
|
|
|
uuid->Data3 &= 0x0fff;
|
|
|
|
uuid->Data3 |= (4 << 12);
|
|
|
|
/* Set the topmost bits of Data4 (clock_seq_hi_and_reserved) as
|
|
|
|
* specified in RFC 4122, section 4.4.
|
|
|
|
*/
|
|
|
|
uuid->Data4[0] &= 0x3f;
|
|
|
|
uuid->Data4[0] |= 0x80;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_guid(uuid));
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
2019-03-11 16:56:18 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ExSetTimerResolution (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
ULONG WINAPI ExSetTimerResolution(ULONG time, BOOLEAN set_resolution)
|
|
|
|
{
|
|
|
|
FIXME("stub: %u %d\n", time, set_resolution);
|
|
|
|
return KeQueryTimeIncrement();
|
|
|
|
}
|
2019-08-22 06:16:54 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IoGetRequestorProcess (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PEPROCESS WINAPI IoGetRequestorProcess(IRP *irp)
|
|
|
|
{
|
|
|
|
TRACE("irp %p.\n", irp);
|
|
|
|
return irp->Tail.Overlay.Thread->kthread.process;
|
|
|
|
}
|
2020-01-30 12:52:57 +01:00
|
|
|
|
2020-05-03 18:22:02 +02:00
|
|
|
#ifdef _WIN64
|
|
|
|
/***********************************************************************
|
|
|
|
* IoIs32bitProcess (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI IoIs32bitProcess(IRP *irp)
|
|
|
|
{
|
|
|
|
TRACE("irp %p.\n", irp);
|
|
|
|
return irp->Tail.Overlay.Thread->kthread.process->wow64;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-01-30 12:52:57 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* RtlIsNtDdiVersionAvailable (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI RtlIsNtDdiVersionAvailable(ULONG version)
|
|
|
|
{
|
|
|
|
FIXME("stub: %d\n", version);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2020-05-22 19:37:40 +02:00
|
|
|
|
|
|
|
BOOLEAN WINAPI KdRefreshDebuggerNotPresent(void)
|
|
|
|
{
|
|
|
|
TRACE(".\n");
|
|
|
|
|
|
|
|
return !KdDebuggerEnabled;
|
|
|
|
}
|
2020-05-27 11:50:47 +02:00
|
|
|
|
2020-05-27 11:50:48 +02:00
|
|
|
struct generic_call_dpc_context
|
|
|
|
{
|
|
|
|
DEFERRED_REVERSE_BARRIER *reverse_barrier;
|
|
|
|
PKDEFERRED_ROUTINE routine;
|
|
|
|
ULONG *cpu_count_barrier;
|
|
|
|
void *context;
|
|
|
|
ULONG cpu_index;
|
2020-05-27 11:50:49 +02:00
|
|
|
ULONG current_barrier_flag;
|
|
|
|
LONG *barrier_passed_count;
|
2020-05-27 11:50:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static void WINAPI generic_call_dpc_callback(TP_CALLBACK_INSTANCE *instance, void *context)
|
|
|
|
{
|
|
|
|
struct generic_call_dpc_context *c = context;
|
|
|
|
GROUP_AFFINITY old, new;
|
|
|
|
|
|
|
|
TRACE("instance %p, context %p.\n", instance, context);
|
|
|
|
|
|
|
|
NtQueryInformationThread(GetCurrentThread(), ThreadGroupInformation,
|
|
|
|
&old, sizeof(old), NULL);
|
|
|
|
|
|
|
|
memset(&new, 0, sizeof(new));
|
|
|
|
|
|
|
|
new.Mask = 1 << c->cpu_index;
|
|
|
|
NtSetInformationThread(GetCurrentThread(), ThreadGroupInformation, &new, sizeof(new));
|
|
|
|
|
2020-05-27 11:50:49 +02:00
|
|
|
TlsSetValue(dpc_call_tls_index, context);
|
2020-05-27 11:50:48 +02:00
|
|
|
c->routine((PKDPC)0xdeadbeef, c->context, c->cpu_count_barrier, c->reverse_barrier);
|
2020-05-27 11:50:49 +02:00
|
|
|
TlsSetValue(dpc_call_tls_index, NULL);
|
2020-05-27 11:50:48 +02:00
|
|
|
NtSetInformationThread(GetCurrentThread(), ThreadGroupInformation, &old, sizeof(old));
|
|
|
|
}
|
|
|
|
|
|
|
|
void WINAPI KeGenericCallDpc(PKDEFERRED_ROUTINE routine, void *context)
|
|
|
|
{
|
|
|
|
ULONG cpu_count = KeQueryActiveProcessorCountEx(ALL_PROCESSOR_GROUPS);
|
|
|
|
static struct generic_call_dpc_context *contexts;
|
|
|
|
DEFERRED_REVERSE_BARRIER reverse_barrier;
|
|
|
|
static ULONG last_cpu_count;
|
2020-05-27 11:50:49 +02:00
|
|
|
LONG barrier_passed_count;
|
2020-05-27 11:50:48 +02:00
|
|
|
ULONG cpu_count_barrier;
|
|
|
|
ULONG i;
|
|
|
|
|
|
|
|
TRACE("routine %p, context %p.\n", routine, context);
|
|
|
|
|
|
|
|
EnterCriticalSection(&dpc_call_cs);
|
|
|
|
|
|
|
|
if (!dpc_call_tp)
|
|
|
|
{
|
|
|
|
if (!(dpc_call_tp = CreateThreadpool(NULL)))
|
|
|
|
{
|
|
|
|
ERR("Could not create thread pool.\n");
|
|
|
|
LeaveCriticalSection(&dpc_call_cs);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetThreadpoolThreadMinimum(dpc_call_tp, cpu_count);
|
|
|
|
SetThreadpoolThreadMaximum(dpc_call_tp, cpu_count);
|
|
|
|
|
|
|
|
memset(&dpc_call_tpe, 0, sizeof(dpc_call_tpe));
|
|
|
|
dpc_call_tpe.Version = 1;
|
|
|
|
dpc_call_tpe.Pool = dpc_call_tp;
|
|
|
|
}
|
|
|
|
|
|
|
|
reverse_barrier.Barrier = cpu_count;
|
|
|
|
reverse_barrier.TotalProcessors = cpu_count;
|
|
|
|
cpu_count_barrier = cpu_count;
|
|
|
|
|
|
|
|
if (contexts)
|
|
|
|
{
|
|
|
|
if (last_cpu_count < cpu_count)
|
|
|
|
{
|
|
|
|
static struct generic_call_dpc_context *new_contexts;
|
|
|
|
if (!(new_contexts = heap_realloc(contexts, sizeof(*contexts) * cpu_count)))
|
|
|
|
{
|
|
|
|
ERR("No memory.\n");
|
|
|
|
LeaveCriticalSection(&dpc_call_cs);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
contexts = new_contexts;
|
|
|
|
SetThreadpoolThreadMinimum(dpc_call_tp, cpu_count);
|
|
|
|
SetThreadpoolThreadMaximum(dpc_call_tp, cpu_count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!(contexts = heap_alloc(sizeof(*contexts) * cpu_count)))
|
|
|
|
{
|
|
|
|
ERR("No memory.\n");
|
|
|
|
LeaveCriticalSection(&dpc_call_cs);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(contexts, 0, sizeof(*contexts) * cpu_count);
|
|
|
|
last_cpu_count = cpu_count;
|
2020-05-27 11:50:49 +02:00
|
|
|
barrier_passed_count = 0;
|
2020-05-27 11:50:48 +02:00
|
|
|
|
|
|
|
for (i = 0; i < cpu_count; ++i)
|
|
|
|
{
|
|
|
|
contexts[i].reverse_barrier = &reverse_barrier;
|
|
|
|
contexts[i].cpu_count_barrier = &cpu_count_barrier;
|
|
|
|
contexts[i].routine = routine;
|
|
|
|
contexts[i].context = context;
|
|
|
|
contexts[i].cpu_index = i;
|
2020-05-27 11:50:49 +02:00
|
|
|
contexts[i].barrier_passed_count = &barrier_passed_count;
|
2020-05-27 11:50:48 +02:00
|
|
|
|
|
|
|
TrySubmitThreadpoolCallback(generic_call_dpc_callback, &contexts[i], &dpc_call_tpe);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (InterlockedCompareExchange((LONG *)&cpu_count_barrier, 0, 0))
|
|
|
|
SwitchToThread();
|
|
|
|
|
|
|
|
LeaveCriticalSection(&dpc_call_cs);
|
|
|
|
}
|
|
|
|
|
2020-05-27 11:50:49 +02:00
|
|
|
|
|
|
|
BOOLEAN WINAPI KeSignalCallDpcSynchronize(void *barrier)
|
|
|
|
{
|
|
|
|
struct generic_call_dpc_context *context = TlsGetValue(dpc_call_tls_index);
|
|
|
|
DEFERRED_REVERSE_BARRIER *b = barrier;
|
|
|
|
LONG curr_flag, comp, done_value;
|
|
|
|
BOOL first;
|
|
|
|
|
|
|
|
TRACE("barrier %p, context %p.\n", barrier, context);
|
|
|
|
|
|
|
|
if (!context)
|
|
|
|
{
|
|
|
|
WARN("Called outside of DPC context.\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
context->current_barrier_flag ^= 0x80000000;
|
|
|
|
curr_flag = context->current_barrier_flag;
|
|
|
|
|
|
|
|
first = !context->cpu_index;
|
|
|
|
comp = curr_flag + context->cpu_index;
|
|
|
|
done_value = curr_flag + b->TotalProcessors;
|
|
|
|
|
|
|
|
if (first)
|
|
|
|
InterlockedExchange((LONG *)&b->Barrier, comp);
|
|
|
|
|
|
|
|
while (InterlockedCompareExchange((LONG *)&b->Barrier, comp + 1, comp) != done_value)
|
|
|
|
;
|
|
|
|
|
|
|
|
InterlockedIncrement(context->barrier_passed_count);
|
|
|
|
|
|
|
|
while (first && InterlockedCompareExchange(context->barrier_passed_count, 0, b->TotalProcessors))
|
|
|
|
;
|
|
|
|
|
|
|
|
return first;
|
|
|
|
}
|
|
|
|
|
2020-05-27 11:50:47 +02:00
|
|
|
void WINAPI KeSignalCallDpcDone(void *barrier)
|
|
|
|
{
|
|
|
|
InterlockedDecrement((LONG *)barrier);
|
|
|
|
}
|
2020-05-31 17:26:20 +02:00
|
|
|
|
|
|
|
void * WINAPI PsGetProcessSectionBaseAddress(PEPROCESS process)
|
|
|
|
{
|
|
|
|
void *image_base;
|
|
|
|
NTSTATUS status;
|
|
|
|
SIZE_T size;
|
|
|
|
HANDLE h;
|
|
|
|
|
|
|
|
TRACE("process %p.\n", process);
|
|
|
|
|
|
|
|
if ((status = ObOpenObjectByPointer(process, 0, NULL, PROCESS_ALL_ACCESS, NULL, KernelMode, &h)))
|
|
|
|
{
|
|
|
|
WARN("Error opening process object, status %#x.\n", status);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
status = NtReadVirtualMemory(h, &process->info.PebBaseAddress->ImageBaseAddress,
|
|
|
|
&image_base, sizeof(image_base), &size);
|
|
|
|
|
|
|
|
NtClose(h);
|
|
|
|
|
|
|
|
if (status || size != sizeof(image_base))
|
|
|
|
{
|
|
|
|
WARN("Error reading process memory, status %#x, size %lu.\n", status, size);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("returning %p.\n", image_base);
|
|
|
|
return image_base;
|
|
|
|
}
|
2020-05-31 17:26:23 +02:00
|
|
|
|
|
|
|
void WINAPI KeStackAttachProcess(KPROCESS *process, KAPC_STATE *apc_state)
|
|
|
|
{
|
|
|
|
FIXME("process %p, apc_state %p stub.\n", process, apc_state);
|
|
|
|
}
|
2020-05-31 17:26:24 +02:00
|
|
|
|
|
|
|
void WINAPI KeUnstackDetachProcess(KAPC_STATE *apc_state)
|
|
|
|
{
|
|
|
|
FIXME("apc_state %p stub.\n", apc_state);
|
|
|
|
}
|
2020-06-09 18:03:14 +02:00
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
* DllMain
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
|
|
|
|
{
|
|
|
|
static void *handler;
|
|
|
|
LARGE_INTEGER count;
|
|
|
|
|
|
|
|
switch(reason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
DisableThreadLibraryCalls( inst );
|
|
|
|
#if defined(__i386__) || defined(__x86_64__)
|
|
|
|
handler = RtlAddVectoredExceptionHandler( TRUE, vectored_handler );
|
|
|
|
#endif
|
|
|
|
KeQueryTickCount( &count ); /* initialize the global KeTickCount */
|
|
|
|
NtBuildNumber = NtCurrentTeb()->Peb->OSBuildNumber;
|
|
|
|
ntoskrnl_heap = HeapCreate( HEAP_CREATE_ENABLE_EXECUTE, 0, 0 );
|
|
|
|
dpc_call_tls_index = TlsAlloc();
|
|
|
|
LdrRegisterDllNotification( 0, ldr_notify_callback, NULL, &ldr_notify_cookie );
|
|
|
|
break;
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
LdrUnregisterDllNotification( ldr_notify_cookie );
|
|
|
|
|
|
|
|
if (reserved) break;
|
|
|
|
|
|
|
|
if (dpc_call_tp)
|
|
|
|
CloseThreadpool(dpc_call_tp);
|
|
|
|
|
|
|
|
HeapDestroy( ntoskrnl_heap );
|
|
|
|
RtlRemoveVectoredExceptionHandler( handler );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|