2007-05-15 21:41:50 +02:00
|
|
|
/*
|
|
|
|
* ntoskrnl.exe implementation
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Alexandre Julliard
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
|
|
|
|
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winternl.h"
|
2007-05-18 16:37:23 +02:00
|
|
|
#include "excpt.h"
|
2008-08-29 00:31:58 +02:00
|
|
|
#include "ddk/ntddk.h"
|
2007-05-15 21:41:50 +02:00
|
|
|
#include "wine/unicode.h"
|
|
|
|
#include "wine/server.h"
|
2008-10-03 15:51:26 +02:00
|
|
|
#include "wine/list.h"
|
2007-05-15 21:41:50 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
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
|
|
|
|
2007-05-15 21:49:26 +02:00
|
|
|
|
2008-07-21 14:47:55 +02:00
|
|
|
KSYSTEM_TIME KeTickCount = { 0, 0, 0 };
|
2007-05-15 21:49:26 +02:00
|
|
|
|
|
|
|
typedef struct _KSERVICE_TABLE_DESCRIPTOR
|
|
|
|
{
|
|
|
|
PULONG_PTR Base;
|
|
|
|
PULONG Count;
|
|
|
|
ULONG Limit;
|
|
|
|
PUCHAR Number;
|
|
|
|
} KSERVICE_TABLE_DESCRIPTOR, *PKSERVICE_TABLE_DESCRIPTOR;
|
|
|
|
|
2008-07-21 14:47:55 +02:00
|
|
|
KSERVICE_TABLE_DESCRIPTOR KeServiceDescriptorTable[4] = { { 0 } };
|
2007-05-15 21:49:26 +02:00
|
|
|
|
2007-05-17 09:49:28 +02:00
|
|
|
typedef void (WINAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)(HANDLE,HANDLE,BOOLEAN);
|
2008-12-28 14:31:51 +01:00
|
|
|
typedef void (WINAPI *PCREATE_THREAD_NOTIFY_ROUTINE)(HANDLE,HANDLE,BOOLEAN);
|
2007-05-15 21:49:26 +02:00
|
|
|
|
2008-10-03 15:51:26 +02:00
|
|
|
static struct list Irps = LIST_INIT(Irps);
|
|
|
|
|
|
|
|
struct IrpInstance
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
IRP *irp;
|
|
|
|
};
|
|
|
|
|
2007-05-15 21:56:05 +02:00
|
|
|
#ifdef __i386__
|
|
|
|
#define DEFINE_FASTCALL1_ENTRYPOINT( name ) \
|
2009-06-14 15:34:34 +02:00
|
|
|
__ASM_STDCALL_FUNC( name, 4, \
|
2007-05-15 21:56:05 +02:00
|
|
|
"popl %eax\n\t" \
|
|
|
|
"pushl %ecx\n\t" \
|
|
|
|
"pushl %eax\n\t" \
|
2009-06-14 15:34:34 +02:00
|
|
|
"jmp " __ASM_NAME("__regs_") #name __ASM_STDCALL(4))
|
2007-05-15 21:56:05 +02:00
|
|
|
#define DEFINE_FASTCALL2_ENTRYPOINT( name ) \
|
2009-06-14 15:34:34 +02:00
|
|
|
__ASM_STDCALL_FUNC( name, 8, \
|
2007-05-15 21:56:05 +02:00
|
|
|
"popl %eax\n\t" \
|
|
|
|
"pushl %edx\n\t" \
|
|
|
|
"pushl %ecx\n\t" \
|
|
|
|
"pushl %eax\n\t" \
|
2009-06-14 15:34:34 +02:00
|
|
|
"jmp " __ASM_NAME("__regs_") #name __ASM_STDCALL(8))
|
|
|
|
#define DEFINE_FASTCALL3_ENTRYPOINT( name ) \
|
|
|
|
__ASM_STDCALL_FUNC( name, 12, \
|
|
|
|
"popl %eax\n\t" \
|
|
|
|
"pushl %edx\n\t" \
|
|
|
|
"pushl %ecx\n\t" \
|
|
|
|
"pushl %eax\n\t" \
|
|
|
|
"jmp " __ASM_NAME("__regs_") #name __ASM_STDCALL(12))
|
2007-05-15 21:56:05 +02:00
|
|
|
#endif
|
|
|
|
|
2007-05-15 21:41:50 +02:00
|
|
|
static inline LPCSTR debugstr_us( const UNICODE_STRING *us )
|
|
|
|
{
|
|
|
|
if (!us) return "<null>";
|
|
|
|
return debugstr_wn( us->Buffer, us->Length / sizeof(WCHAR) );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HANDLE get_device_manager(void)
|
|
|
|
{
|
|
|
|
static HANDLE device_manager;
|
|
|
|
HANDLE handle = 0, ret = device_manager;
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
SERVER_START_REQ( create_device_manager )
|
|
|
|
{
|
|
|
|
req->access = SYNCHRONIZE;
|
|
|
|
req->attributes = 0;
|
2008-12-08 16:05:17 +01:00
|
|
|
if (!wine_server_call( req )) handle = wine_server_ptr_handle( reply->handle );
|
2007-05-15 21:41:50 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
|
|
|
if (!handle)
|
|
|
|
{
|
|
|
|
ERR( "failed to create the device manager\n" );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (!(ret = InterlockedCompareExchangePointer( &device_manager, handle, 0 )))
|
|
|
|
ret = handle;
|
|
|
|
else
|
|
|
|
NtClose( handle ); /* somebody beat us to it */
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-05-18 16:37:23 +02:00
|
|
|
/* exception handler for emulation of privileged instructions */
|
|
|
|
static LONG CALLBACK vectored_handler( EXCEPTION_POINTERS *ptrs )
|
|
|
|
{
|
|
|
|
EXCEPTION_RECORD *record = ptrs->ExceptionRecord;
|
|
|
|
|
|
|
|
if (record->ExceptionCode == EXCEPTION_ACCESS_VIOLATION ||
|
|
|
|
record->ExceptionCode == EXCEPTION_PRIV_INSTRUCTION)
|
|
|
|
{
|
2009-01-06 20:29:28 +01:00
|
|
|
#ifdef __i386__
|
2009-01-08 17:26:56 +01:00
|
|
|
CONTEXT *context = ptrs->ContextRecord;
|
2009-01-06 20:29:28 +01:00
|
|
|
extern DWORD __wine_emulate_instruction( EXCEPTION_RECORD *rec, CONTEXT *context );
|
|
|
|
|
2007-05-18 16:37:23 +02:00
|
|
|
if (__wine_emulate_instruction( record, context ) == ExceptionContinueExecution)
|
|
|
|
return EXCEPTION_CONTINUE_EXECUTION;
|
2009-01-06 20:29:28 +01:00
|
|
|
#else
|
|
|
|
FIXME( "Privileged instruction emulation not implemented on this CPU\n" );
|
|
|
|
#endif
|
2007-05-18 16:37:23 +02:00
|
|
|
}
|
|
|
|
return EXCEPTION_CONTINUE_SEARCH;
|
|
|
|
}
|
|
|
|
|
2007-05-16 21:13:34 +02:00
|
|
|
/* process an ioctl request for a given device */
|
|
|
|
static NTSTATUS process_ioctl( DEVICE_OBJECT *device, ULONG code, void *in_buff, ULONG in_size,
|
|
|
|
void *out_buff, ULONG *out_size )
|
|
|
|
{
|
|
|
|
IRP irp;
|
|
|
|
MDL mdl;
|
|
|
|
IO_STACK_LOCATION irpsp;
|
|
|
|
PDRIVER_DISPATCH dispatch = device->DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL];
|
|
|
|
NTSTATUS status;
|
2007-05-18 16:48:54 +02:00
|
|
|
LARGE_INTEGER count;
|
2007-05-16 21:13:34 +02:00
|
|
|
|
|
|
|
TRACE( "ioctl %x device %p in_size %u out_size %u\n", code, device, in_size, *out_size );
|
|
|
|
|
|
|
|
/* so we can spot things that we should initialize */
|
|
|
|
memset( &irp, 0x55, sizeof(irp) );
|
|
|
|
memset( &irpsp, 0x66, sizeof(irpsp) );
|
|
|
|
memset( &mdl, 0x77, sizeof(mdl) );
|
|
|
|
|
|
|
|
irp.RequestorMode = UserMode;
|
|
|
|
irp.AssociatedIrp.SystemBuffer = in_buff;
|
|
|
|
irp.UserBuffer = out_buff;
|
|
|
|
irp.MdlAddress = &mdl;
|
|
|
|
irp.Tail.Overlay.s.u.CurrentStackLocation = &irpsp;
|
2008-10-16 10:06:23 +02:00
|
|
|
irp.UserIosb = NULL;
|
2007-05-16 21:13:34 +02:00
|
|
|
|
|
|
|
irpsp.MajorFunction = IRP_MJ_DEVICE_CONTROL;
|
|
|
|
irpsp.Parameters.DeviceIoControl.OutputBufferLength = *out_size;
|
|
|
|
irpsp.Parameters.DeviceIoControl.InputBufferLength = in_size;
|
|
|
|
irpsp.Parameters.DeviceIoControl.IoControlCode = code;
|
|
|
|
irpsp.Parameters.DeviceIoControl.Type3InputBuffer = in_buff;
|
|
|
|
irpsp.DeviceObject = device;
|
2008-10-16 10:06:23 +02:00
|
|
|
irpsp.CompletionRoutine = NULL;
|
2007-05-16 21:13:34 +02:00
|
|
|
|
|
|
|
mdl.Next = NULL;
|
|
|
|
mdl.Size = 0;
|
|
|
|
mdl.StartVa = out_buff;
|
|
|
|
mdl.ByteCount = *out_size;
|
|
|
|
mdl.ByteOffset = 0;
|
|
|
|
|
|
|
|
device->CurrentIrp = &irp;
|
|
|
|
|
2007-05-18 16:48:54 +02:00
|
|
|
KeQueryTickCount( &count ); /* update the global KeTickCount */
|
|
|
|
|
2007-05-16 21:13:34 +02:00
|
|
|
if (TRACE_ON(relay))
|
|
|
|
DPRINTF( "%04x:Call driver dispatch %p (device=%p,irp=%p)\n",
|
|
|
|
GetCurrentThreadId(), dispatch, device, &irp );
|
|
|
|
|
|
|
|
status = dispatch( device, &irp );
|
|
|
|
|
|
|
|
if (TRACE_ON(relay))
|
|
|
|
DPRINTF( "%04x:Ret driver dispatch %p (device=%p,irp=%p) retval=%08x\n",
|
|
|
|
GetCurrentThreadId(), dispatch, device, &irp, status );
|
|
|
|
|
2007-12-18 19:46:39 +01:00
|
|
|
*out_size = (irp.IoStatus.u.Status >= 0) ? irp.IoStatus.Information : 0;
|
2007-05-16 21:13:34 +02:00
|
|
|
return irp.IoStatus.u.Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* 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();
|
2008-12-08 16:05:17 +01:00
|
|
|
obj_handle_t ioctl = 0;
|
2007-05-16 21:13:34 +02:00
|
|
|
NTSTATUS status = STATUS_SUCCESS;
|
|
|
|
ULONG code = 0;
|
|
|
|
void *in_buff, *out_buff = NULL;
|
|
|
|
DEVICE_OBJECT *device = NULL;
|
|
|
|
ULONG in_size = 4096, out_size = 0;
|
|
|
|
HANDLE handles[2];
|
|
|
|
|
|
|
|
if (!(in_buff = HeapAlloc( GetProcessHeap(), 0, in_size )))
|
|
|
|
{
|
|
|
|
ERR( "failed to allocate buffer\n" );
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
handles[0] = stop_event;
|
|
|
|
handles[1] = manager;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
SERVER_START_REQ( get_next_device_request )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->manager = wine_server_obj_handle( manager );
|
2007-05-16 21:13:34 +02:00
|
|
|
req->prev = ioctl;
|
|
|
|
req->status = status;
|
|
|
|
wine_server_add_data( req, out_buff, out_size );
|
|
|
|
wine_server_set_reply( req, in_buff, in_size );
|
|
|
|
if (!(status = wine_server_call( req )))
|
|
|
|
{
|
|
|
|
code = reply->code;
|
|
|
|
ioctl = reply->next;
|
2008-12-29 17:28:40 +01:00
|
|
|
device = wine_server_get_ptr( reply->user_ptr );
|
2007-05-16 21:13:34 +02:00
|
|
|
in_size = reply->in_size;
|
|
|
|
out_size = reply->out_size;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ioctl = 0; /* no previous ioctl */
|
|
|
|
out_size = 0;
|
|
|
|
in_size = reply->in_size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
|
|
|
switch(status)
|
|
|
|
{
|
|
|
|
case STATUS_SUCCESS:
|
|
|
|
HeapFree( GetProcessHeap(), 0, out_buff );
|
|
|
|
if (out_size) out_buff = HeapAlloc( GetProcessHeap(), 0, out_size );
|
|
|
|
else out_buff = NULL;
|
|
|
|
status = process_ioctl( device, code, in_buff, in_size, out_buff, &out_size );
|
|
|
|
break;
|
|
|
|
case STATUS_BUFFER_OVERFLOW:
|
|
|
|
HeapFree( GetProcessHeap(), 0, in_buff );
|
|
|
|
in_buff = HeapAlloc( GetProcessHeap(), 0, in_size );
|
|
|
|
/* restart with larger buffer */
|
|
|
|
break;
|
|
|
|
case STATUS_PENDING:
|
|
|
|
if (WaitForMultipleObjects( 2, handles, FALSE, INFINITE ) == WAIT_OBJECT_0)
|
2009-01-10 21:56:10 +01:00
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, in_buff );
|
|
|
|
HeapFree( GetProcessHeap(), 0, out_buff );
|
2007-05-16 21:13:34 +02:00
|
|
|
return STATUS_SUCCESS;
|
2009-01-10 21:56:10 +01:00
|
|
|
}
|
2007-05-16 21:13:34 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-29 14:52:57 +02:00
|
|
|
|
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;
|
|
|
|
irp->Tail.Overlay.s.u.CurrentStackLocation =
|
|
|
|
(PIO_STACK_LOCATION)(irp + 1) + stack_size;
|
2008-07-29 14:52:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-14 14:01:38 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoInitializeTimer (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoInitializeTimer(PDEVICE_OBJECT DeviceObject,
|
|
|
|
PIO_TIMER_ROUTINE TimerRoutine,
|
|
|
|
PVOID Context)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p, %p, %p\n", DeviceObject, TimerRoutine, Context );
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-14 14:05:54 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoStartTimer (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI IoStartTimer(PDEVICE_OBJECT DeviceObject)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p\n", DeviceObject );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
TRACE( "%d, %d\n", stack_size, charge_quota );
|
|
|
|
|
|
|
|
size = sizeof(IRP) + stack_size * sizeof(IO_STACK_LOCATION);
|
|
|
|
irp = ExAllocatePool( NonPagedPool, size );
|
2008-10-30 21:56:59 +01:00
|
|
|
if (irp == NULL)
|
|
|
|
return NULL;
|
|
|
|
IoInitializeIrp( irp, size, stack_size );
|
2008-10-03 15:51:26 +02:00
|
|
|
irp->AllocationFlags = IRP_ALLOCATED_FIXED_SIZE;
|
|
|
|
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 )
|
|
|
|
{
|
2008-10-03 15:51:26 +02:00
|
|
|
TRACE( "%p\n", irp );
|
|
|
|
|
|
|
|
ExFreePool( irp );
|
2008-07-29 14:52:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-08 22:40:43 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* IoAllocateMdl (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PMDL WINAPI IoAllocateMdl( PVOID VirtualAddress, ULONG Length, BOOLEAN SecondaryBuffer, BOOLEAN ChargeQuota, PIRP Irp )
|
|
|
|
{
|
2007-11-13 09:28:53 +01:00
|
|
|
FIXME( "stub: %p, %u, %i, %i, %p\n", VirtualAddress, Length, SecondaryBuffer, ChargeQuota, Irp );
|
2007-11-08 22:40:43 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-05-15 21:41:50 +02:00
|
|
|
|
2007-11-08 22:09:08 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* IoAllocateWorkItem (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PIO_WORKITEM WINAPI IoAllocateWorkItem( PDEVICE_OBJECT DeviceObject )
|
|
|
|
{
|
2007-11-13 09:28:53 +01:00
|
|
|
FIXME( "stub: %p\n", DeviceObject );
|
2007-11-08 22:09:08 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-10-03 15:51:26 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoAttachDeviceToDeviceStack (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PDEVICE_OBJECT WINAPI IoAttachDeviceToDeviceStack( DEVICE_OBJECT *source,
|
|
|
|
DEVICE_OBJECT *target )
|
|
|
|
{
|
|
|
|
TRACE( "%p, %p\n", source, target );
|
|
|
|
target->AttachedDevice = source;
|
|
|
|
source->StackSize = target->StackSize + 1;
|
|
|
|
return target;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IoBuildDeviceIoControlRequest (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PIRP WINAPI IoBuildDeviceIoControlRequest( ULONG IoControlCode,
|
|
|
|
PDEVICE_OBJECT DeviceObject,
|
|
|
|
PVOID InputBuffer,
|
|
|
|
ULONG InputBufferLength,
|
|
|
|
PVOID OutputBuffer,
|
|
|
|
ULONG OutputBufferLength,
|
|
|
|
BOOLEAN InternalDeviceIoControl,
|
|
|
|
PKEVENT Event,
|
|
|
|
PIO_STATUS_BLOCK IoStatusBlock )
|
|
|
|
{
|
|
|
|
PIRP irp;
|
|
|
|
PIO_STACK_LOCATION irpsp;
|
|
|
|
struct IrpInstance *instance;
|
|
|
|
|
|
|
|
TRACE( "%x, %p, %p, %u, %p, %u, %u, %p, %p\n",
|
|
|
|
IoControlCode, DeviceObject, InputBuffer, InputBufferLength,
|
|
|
|
OutputBuffer, OutputBufferLength, InternalDeviceIoControl,
|
|
|
|
Event, IoStatusBlock );
|
|
|
|
|
|
|
|
if (DeviceObject == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
irp = IoAllocateIrp( DeviceObject->StackSize, FALSE );
|
|
|
|
if (irp == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
instance = HeapAlloc( GetProcessHeap(), 0, sizeof(struct IrpInstance) );
|
|
|
|
if (instance == NULL)
|
|
|
|
{
|
|
|
|
IoFreeIrp( irp );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
instance->irp = irp;
|
|
|
|
list_add_tail( &Irps, &instance->entry );
|
|
|
|
|
|
|
|
irpsp = irp->Tail.Overlay.s.u.CurrentStackLocation - 1;
|
|
|
|
irpsp->MajorFunction = InternalDeviceIoControl ?
|
|
|
|
IRP_MJ_INTERNAL_DEVICE_CONTROL : IRP_MJ_DEVICE_CONTROL;
|
|
|
|
irpsp->Parameters.DeviceIoControl.IoControlCode = IoControlCode;
|
|
|
|
irp->UserIosb = IoStatusBlock;
|
|
|
|
irp->UserEvent = Event;
|
|
|
|
|
|
|
|
return irp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-18 19:46:06 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* IoCreateDriver (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoCreateDriver( UNICODE_STRING *name, PDRIVER_INITIALIZE init )
|
|
|
|
{
|
|
|
|
DRIVER_OBJECT *driver;
|
|
|
|
DRIVER_EXTENSION *extension;
|
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
if (!(driver = RtlAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY,
|
|
|
|
sizeof(*driver) + sizeof(*extension) )))
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
|
|
|
|
if ((status = RtlDuplicateUnicodeString( 1, name, &driver->DriverName )))
|
|
|
|
{
|
|
|
|
RtlFreeHeap( GetProcessHeap(), 0, driver );
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
extension = (DRIVER_EXTENSION *)(driver + 1);
|
|
|
|
driver->Size = sizeof(*driver);
|
|
|
|
driver->DriverInit = init;
|
|
|
|
driver->DriverExtension = extension;
|
|
|
|
extension->DriverObject = driver;
|
|
|
|
extension->ServiceKeyName = driver->DriverName;
|
|
|
|
|
|
|
|
status = driver->DriverInit( driver, name );
|
|
|
|
|
|
|
|
if (status)
|
|
|
|
{
|
|
|
|
RtlFreeUnicodeString( &driver->DriverName );
|
|
|
|
RtlFreeHeap( GetProcessHeap(), 0, driver );
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IoDeleteDriver (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI IoDeleteDriver( DRIVER_OBJECT *driver )
|
|
|
|
{
|
|
|
|
RtlFreeUnicodeString( &driver->DriverName );
|
|
|
|
RtlFreeHeap( GetProcessHeap(), 0, driver );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-15 21:41:50 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoCreateDevice (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoCreateDevice( DRIVER_OBJECT *driver, ULONG ext_size,
|
|
|
|
UNICODE_STRING *name, DEVICE_TYPE type,
|
|
|
|
ULONG characteristics, BOOLEAN exclusive,
|
|
|
|
DEVICE_OBJECT **ret_device )
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
DEVICE_OBJECT *device;
|
|
|
|
HANDLE handle = 0;
|
|
|
|
HANDLE manager = get_device_manager();
|
|
|
|
|
|
|
|
TRACE( "(%p, %u, %s, %u, %x, %u, %p)\n",
|
|
|
|
driver, ext_size, debugstr_us(name), type, characteristics, exclusive, ret_device );
|
|
|
|
|
|
|
|
if (!(device = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*device) + ext_size )))
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
|
|
|
|
SERVER_START_REQ( create_device )
|
|
|
|
{
|
|
|
|
req->access = 0;
|
|
|
|
req->attributes = 0;
|
|
|
|
req->rootdir = 0;
|
2008-12-08 16:05:17 +01:00
|
|
|
req->manager = wine_server_obj_handle( manager );
|
2008-12-29 17:28:40 +01:00
|
|
|
req->user_ptr = wine_server_client_ptr( device );
|
2007-05-15 21:41:50 +02:00
|
|
|
if (name) wine_server_add_data( req, name->Buffer, name->Length );
|
2008-12-08 16:05:17 +01:00
|
|
|
if (!(status = wine_server_call( req ))) handle = wine_server_ptr_handle( reply->handle );
|
2007-05-15 21:41:50 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
|
|
|
if (status == STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
device->DriverObject = driver;
|
|
|
|
device->DeviceExtension = device + 1;
|
|
|
|
device->DeviceType = type;
|
2008-10-03 14:26:25 +02:00
|
|
|
device->StackSize = 1;
|
2007-05-15 21:41:50 +02:00
|
|
|
device->Reserved = handle;
|
|
|
|
|
|
|
|
device->NextDevice = driver->DeviceObject;
|
|
|
|
driver->DeviceObject = device;
|
|
|
|
|
|
|
|
*ret_device = device;
|
|
|
|
}
|
|
|
|
else HeapFree( GetProcessHeap(), 0, device );
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IoDeleteDevice (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI IoDeleteDevice( DEVICE_OBJECT *device )
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
TRACE( "%p\n", device );
|
|
|
|
|
|
|
|
SERVER_START_REQ( delete_device )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( device->Reserved );
|
2007-05-15 21:41:50 +02:00
|
|
|
status = wine_server_call( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
|
|
|
if (status == STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
DEVICE_OBJECT **prev = &device->DriverObject->DeviceObject;
|
|
|
|
while (*prev && *prev != device) prev = &(*prev)->NextDevice;
|
|
|
|
if (*prev) *prev = (*prev)->NextDevice;
|
|
|
|
NtClose( device->Reserved );
|
|
|
|
HeapFree( GetProcessHeap(), 0, device );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-15 21:45:51 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoCreateSymbolicLink (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoCreateSymbolicLink( UNICODE_STRING *name, UNICODE_STRING *target )
|
|
|
|
{
|
|
|
|
HANDLE handle;
|
|
|
|
OBJECT_ATTRIBUTES attr;
|
|
|
|
|
|
|
|
attr.Length = sizeof(attr);
|
|
|
|
attr.RootDirectory = 0;
|
|
|
|
attr.ObjectName = name;
|
|
|
|
attr.Attributes = OBJ_CASE_INSENSITIVE | OBJ_OPENIF;
|
|
|
|
attr.SecurityDescriptor = NULL;
|
|
|
|
attr.SecurityQualityOfService = NULL;
|
|
|
|
|
|
|
|
TRACE( "%s -> %s\n", debugstr_us(name), debugstr_us(target) );
|
|
|
|
/* FIXME: store handle somewhere */
|
|
|
|
return NtCreateSymbolicLinkObject( &handle, SYMBOLIC_LINK_ALL_ACCESS, &attr, target );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-29 15:04:47 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoDeleteSymbolicLink (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoDeleteSymbolicLink( UNICODE_STRING *name )
|
|
|
|
{
|
2008-10-20 16:21:22 +02:00
|
|
|
HANDLE handle;
|
|
|
|
OBJECT_ATTRIBUTES attr;
|
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
attr.Length = sizeof(attr);
|
|
|
|
attr.RootDirectory = 0;
|
|
|
|
attr.ObjectName = name;
|
|
|
|
attr.Attributes = OBJ_CASE_INSENSITIVE;
|
|
|
|
attr.SecurityDescriptor = NULL;
|
|
|
|
attr.SecurityQualityOfService = NULL;
|
|
|
|
|
|
|
|
if (!(status = NtOpenSymbolicLinkObject( &handle, 0, &attr )))
|
|
|
|
{
|
|
|
|
SERVER_START_REQ( unlink_object )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( handle );
|
2008-10-20 16:21:22 +02:00
|
|
|
status = wine_server_call( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
NtClose( handle );
|
|
|
|
}
|
|
|
|
return status;
|
2008-07-29 15:04:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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 )
|
|
|
|
{
|
|
|
|
FIXME( "stub: %s %x %p %p\n", debugstr_us(name), access, file, device );
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2008-08-28 23:46:51 +02:00
|
|
|
|
2008-10-03 15:51:26 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IofCallDriver (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
#ifdef DEFINE_FASTCALL2_ENTRYPOINT
|
|
|
|
DEFINE_FASTCALL2_ENTRYPOINT( IofCallDriver )
|
|
|
|
NTSTATUS WINAPI __regs_IofCallDriver( DEVICE_OBJECT *device, IRP *irp )
|
|
|
|
#else
|
|
|
|
NTSTATUS WINAPI IofCallDriver( DEVICE_OBJECT *device, IRP *irp )
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
PDRIVER_DISPATCH dispatch;
|
|
|
|
IO_STACK_LOCATION *irpsp;
|
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
TRACE( "%p %p\n", device, irp );
|
|
|
|
|
|
|
|
--irp->CurrentLocation;
|
|
|
|
irpsp = --irp->Tail.Overlay.s.u.CurrentStackLocation;
|
|
|
|
dispatch = device->DriverObject->MajorFunction[irpsp->MajorFunction];
|
|
|
|
status = dispatch( device, irp );
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-28 23:46:51 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoGetRelatedDeviceObject (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PDEVICE_OBJECT WINAPI IoGetRelatedDeviceObject( PFILE_OBJECT obj )
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p\n", obj );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-09-08 01:01:55 +02:00
|
|
|
static CONFIGURATION_INFORMATION configuration_information;
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IoGetConfigurationInformation (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PCONFIGURATION_INFORMATION WINAPI IoGetConfigurationInformation(void)
|
|
|
|
{
|
|
|
|
FIXME( "partial stub\n" );
|
|
|
|
/* FIXME: return actual devices on system */
|
|
|
|
return &configuration_information;
|
|
|
|
}
|
|
|
|
|
2008-08-28 23:46:51 +02:00
|
|
|
|
2009-08-14 13:31:57 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoQueryDeviceDescription (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoQueryDeviceDescription(PINTERFACE_TYPE itype, PULONG bus, PCONFIGURATION_TYPE ctype,
|
|
|
|
PULONG cnum, PCONFIGURATION_TYPE ptype, PULONG pnum,
|
|
|
|
PIO_QUERY_DEVICE_ROUTINE callout, PVOID context)
|
|
|
|
{
|
|
|
|
FIXME( "(%p %p %p %p %p %p %p %p)\n", itype, bus, ctype, cnum, ptype, pnum, callout, context);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-29 00:31:58 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoRegisterDriverReinitialization (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI IoRegisterDriverReinitialization( PDRIVER_OBJECT obj, PDRIVER_REINITIALIZE reinit, PVOID context )
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p %p %p\n", obj, reinit, context );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-29 00:36:35 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoRegisterShutdownNotification (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI IoRegisterShutdownNotification( PDEVICE_OBJECT obj )
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p\n", obj );
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-15 21:56:05 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IofCompleteRequest (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
#ifdef DEFINE_FASTCALL2_ENTRYPOINT
|
|
|
|
DEFINE_FASTCALL2_ENTRYPOINT( IofCompleteRequest )
|
|
|
|
void WINAPI __regs_IofCompleteRequest( IRP *irp, UCHAR priority_boost )
|
|
|
|
#else
|
|
|
|
void WINAPI IofCompleteRequest( IRP *irp, UCHAR priority_boost )
|
|
|
|
#endif
|
|
|
|
{
|
2008-10-03 15:51:26 +02:00
|
|
|
IO_STACK_LOCATION *irpsp;
|
|
|
|
PIO_COMPLETION_ROUTINE routine;
|
|
|
|
IO_STATUS_BLOCK *iosb;
|
|
|
|
struct IrpInstance *instance;
|
|
|
|
NTSTATUS status, stat;
|
|
|
|
int call_flag = 0;
|
|
|
|
|
2007-05-15 21:56:05 +02:00
|
|
|
TRACE( "%p %u\n", irp, priority_boost );
|
2008-10-03 15:51:26 +02:00
|
|
|
|
|
|
|
iosb = irp->UserIosb;
|
|
|
|
status = irp->IoStatus.u.Status;
|
|
|
|
while (irp->CurrentLocation <= irp->StackCount)
|
|
|
|
{
|
|
|
|
irpsp = irp->Tail.Overlay.s.u.CurrentStackLocation;
|
|
|
|
routine = irpsp->CompletionRoutine;
|
|
|
|
call_flag = 0;
|
|
|
|
/* FIXME: add SL_INVOKE_ON_CANCEL support */
|
|
|
|
if (routine)
|
|
|
|
{
|
|
|
|
if ((irpsp->Control & SL_INVOKE_ON_SUCCESS) && STATUS_SUCCESS == status)
|
|
|
|
call_flag = 1;
|
|
|
|
if ((irpsp->Control & SL_INVOKE_ON_ERROR) && STATUS_SUCCESS != status)
|
|
|
|
call_flag = 1;
|
|
|
|
}
|
|
|
|
++irp->CurrentLocation;
|
|
|
|
++irp->Tail.Overlay.s.u.CurrentStackLocation;
|
|
|
|
if (call_flag)
|
|
|
|
{
|
|
|
|
TRACE( "calling %p( %p, %p, %p )\n", routine,
|
|
|
|
irpsp->DeviceObject, irp, irpsp->Context );
|
|
|
|
stat = routine( irpsp->DeviceObject, irp, irpsp->Context );
|
2008-10-09 11:00:00 +02:00
|
|
|
TRACE( "CompletionRoutine returned %x\n", stat );
|
2008-10-03 15:51:26 +02:00
|
|
|
if (STATUS_MORE_PROCESSING_REQUIRED == stat)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (iosb && STATUS_SUCCESS == status)
|
|
|
|
{
|
|
|
|
iosb->u.Status = irp->IoStatus.u.Status;
|
|
|
|
iosb->Information = irp->IoStatus.Information;
|
|
|
|
}
|
|
|
|
LIST_FOR_EACH_ENTRY( instance, &Irps, struct IrpInstance, entry )
|
|
|
|
{
|
|
|
|
if (instance->irp == irp)
|
|
|
|
{
|
|
|
|
list_remove( &instance->entry );
|
|
|
|
HeapFree( GetProcessHeap(), 0, instance );
|
|
|
|
IoFreeIrp( irp );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-05-15 21:56:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-25 16:22:24 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedCompareExchange (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2009-06-14 15:34:34 +02:00
|
|
|
#ifdef DEFINE_FASTCALL3_ENTRYPOINT
|
|
|
|
DEFINE_FASTCALL3_ENTRYPOINT( NTOSKRNL_InterlockedCompareExchange )
|
2008-04-25 16:22:24 +02:00
|
|
|
LONG WINAPI __regs_NTOSKRNL_InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare )
|
|
|
|
#else
|
|
|
|
LONG WINAPI NTOSKRNL_InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare )
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
return InterlockedCompareExchange( dest, xchg, compare );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedDecrement (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
#ifdef DEFINE_FASTCALL1_ENTRYPOINT
|
|
|
|
DEFINE_FASTCALL1_ENTRYPOINT( NTOSKRNL_InterlockedDecrement )
|
|
|
|
LONG WINAPI __regs_NTOSKRNL_InterlockedDecrement( LONG volatile *dest )
|
|
|
|
#else
|
|
|
|
LONG WINAPI NTOSKRNL_InterlockedDecrement( LONG volatile *dest )
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
return InterlockedDecrement( dest );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedExchange (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
#ifdef DEFINE_FASTCALL2_ENTRYPOINT
|
|
|
|
DEFINE_FASTCALL2_ENTRYPOINT( NTOSKRNL_InterlockedExchange )
|
|
|
|
LONG WINAPI __regs_NTOSKRNL_InterlockedExchange( LONG volatile *dest, LONG val )
|
|
|
|
#else
|
|
|
|
LONG WINAPI NTOSKRNL_InterlockedExchange( LONG volatile *dest, LONG val )
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
return InterlockedExchange( dest, val );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedExchangeAdd (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
#ifdef DEFINE_FASTCALL2_ENTRYPOINT
|
|
|
|
DEFINE_FASTCALL2_ENTRYPOINT( NTOSKRNL_InterlockedExchangeAdd )
|
|
|
|
LONG WINAPI __regs_NTOSKRNL_InterlockedExchangeAdd( LONG volatile *dest, LONG incr )
|
|
|
|
#else
|
|
|
|
LONG WINAPI NTOSKRNL_InterlockedExchangeAdd( LONG volatile *dest, LONG incr )
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
return InterlockedExchangeAdd( dest, incr );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedIncrement (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
#ifdef DEFINE_FASTCALL1_ENTRYPOINT
|
|
|
|
DEFINE_FASTCALL1_ENTRYPOINT( NTOSKRNL_InterlockedIncrement )
|
|
|
|
LONG WINAPI __regs_NTOSKRNL_InterlockedIncrement( LONG volatile *dest )
|
|
|
|
#else
|
|
|
|
LONG WINAPI NTOSKRNL_InterlockedIncrement( LONG volatile *dest )
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
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 */
|
|
|
|
void *ret = HeapAlloc( GetProcessHeap(), 0, size );
|
|
|
|
TRACE( "%lu pool %u -> %p\n", size, type, ret );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ExAllocatePoolWithQuotaTag (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PVOID WINAPI ExAllocatePoolWithQuotaTag( POOL_TYPE type, SIZE_T size, ULONG tag )
|
|
|
|
{
|
|
|
|
return ExAllocatePoolWithTag( type, size, tag );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ExFreePool (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI ExFreePool( void *ptr )
|
|
|
|
{
|
|
|
|
ExFreePoolWithTag( ptr, 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ExFreePoolWithTag (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI ExFreePoolWithTag( void *ptr, ULONG tag )
|
|
|
|
{
|
|
|
|
TRACE( "%p\n", ptr );
|
|
|
|
HeapFree( GetProcessHeap(), 0, ptr );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-14 14:11:44 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ExInitializeResourceLite (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI ExInitializeResourceLite(PERESOURCE Resource)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p\n", Resource );
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-15 18:23:28 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ExInitializeNPagedLookasideList (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI ExInitializeNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside,
|
|
|
|
PALLOCATE_FUNCTION Allocate,
|
|
|
|
PFREE_FUNCTION Free,
|
|
|
|
ULONG Flags,
|
|
|
|
SIZE_T Size,
|
|
|
|
ULONG Tag,
|
|
|
|
USHORT Depth)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p, %p, %p, %u, %lu, %u, %u\n", Lookaside, Allocate, Free, Flags, Size, Tag, Depth );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-14 14:16:49 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ExInitializeZone (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI ExInitializeZone(PZONE_HEADER Zone,
|
|
|
|
ULONG BlockSize,
|
|
|
|
PVOID InitialSegment,
|
|
|
|
ULONG InitialSegmentSize)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p, %u, %p, %u\n", Zone, BlockSize, InitialSegment, InitialSegmentSize );
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2009-06-17 23:29:33 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* FsRtlRegisterUncProvider (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI FsRtlRegisterUncProvider(PHANDLE MupHandle, PUNICODE_STRING RedirDevName,
|
|
|
|
BOOLEAN MailslotsSupported)
|
|
|
|
{
|
|
|
|
FIXME("(%p %p %d): stub\n", MupHandle, RedirDevName, MailslotsSupported);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
2009-06-14 14:16:49 +02:00
|
|
|
|
2008-12-28 12:55:00 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* KeInitializeEvent (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI KeInitializeEvent( PRKEVENT Event, EVENT_TYPE Type, BOOLEAN State )
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p %d %d\n", Event, Type, State );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-14 13:25:19 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* KeInitializeMutex (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI KeInitializeMutex(PRKMUTEX Mutex, ULONG Level)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p, %u\n", Mutex, Level );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-08 18:45:39 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* KeInitializeSpinLock (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI KeInitializeSpinLock( PKSPIN_LOCK SpinLock )
|
|
|
|
{
|
2008-12-28 12:56:29 +01:00
|
|
|
FIXME( "stub: %p\n", SpinLock );
|
2008-01-08 18:45:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* KeInitializeTimerEx (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI KeInitializeTimerEx( PKTIMER Timer, TIMER_TYPE Type )
|
|
|
|
{
|
2008-12-28 12:56:29 +01:00
|
|
|
FIXME( "stub: %p %d\n", Timer, Type );
|
2008-01-08 18:45:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-18 23:19:09 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* KeInitializeTimer (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI KeInitializeTimer( PKTIMER Timer )
|
|
|
|
{
|
2008-01-08 18:45:39 +01:00
|
|
|
KeInitializeTimerEx(Timer, NotificationTimer);
|
2007-06-18 23:19:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-07 21:10:12 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* KeQueryActiveProcessors (NTOSKRNL.EXE.@)
|
|
|
|
*
|
|
|
|
* Return the active Processors as bitmask
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* active Processors as bitmask
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
KAFFINITY WINAPI KeQueryActiveProcessors( void )
|
|
|
|
{
|
|
|
|
DWORD_PTR AffinityMask;
|
|
|
|
|
|
|
|
GetProcessAffinityMask( GetCurrentProcess(), &AffinityMask, NULL);
|
|
|
|
return AffinityMask;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-07 21:15:46 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* KeQueryInterruptTime (NTOSKRNL.EXE.@)
|
|
|
|
*
|
|
|
|
* Return the interrupt time count
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
ULONGLONG WINAPI KeQueryInterruptTime( void )
|
|
|
|
{
|
|
|
|
LARGE_INTEGER totaltime;
|
|
|
|
|
|
|
|
KeQueryTickCount(&totaltime);
|
|
|
|
return totaltime.QuadPart;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-18 16:48:54 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* KeQuerySystemTime (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI KeQuerySystemTime( LARGE_INTEGER *time )
|
|
|
|
{
|
|
|
|
NtQuerySystemTime( time );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* KeQueryTickCount (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI KeQueryTickCount( LARGE_INTEGER *count )
|
|
|
|
{
|
|
|
|
count->QuadPart = NtGetTickCount();
|
|
|
|
/* update the global variable too */
|
|
|
|
KeTickCount.LowPart = count->u.LowPart;
|
|
|
|
KeTickCount.High1Time = count->u.HighPart;
|
|
|
|
KeTickCount.High2Time = count->u.HighPart;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* KeQueryTimeIncrement (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
ULONG WINAPI KeQueryTimeIncrement(void)
|
|
|
|
{
|
|
|
|
return 10000;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-14 13:49:17 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* KeWaitForSingleObject (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI KeWaitForSingleObject(PVOID Object,
|
|
|
|
KWAIT_REASON WaitReason,
|
|
|
|
KPROCESSOR_MODE WaitMode,
|
|
|
|
BOOLEAN Alertable,
|
|
|
|
PLARGE_INTEGER Timeout)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p, %d, %d, %d, %p\n", Object, WaitReason, WaitMode, Alertable, Timeout );
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2009-06-17 23:25:43 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoRegisterFileSystem (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
VOID WINAPI IoRegisterFileSystem(PDEVICE_OBJECT DeviceObject)
|
|
|
|
{
|
|
|
|
FIXME("(%p): stub\n", DeviceObject);
|
|
|
|
}
|
2009-06-14 13:49:17 +02:00
|
|
|
|
2009-06-17 23:27:42 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IoUnregisterFileSystem (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
VOID WINAPI IoUnregisterFileSystem(PDEVICE_OBJECT DeviceObject)
|
|
|
|
{
|
|
|
|
FIXME("(%p): stub\n", DeviceObject);
|
|
|
|
}
|
|
|
|
|
2007-05-16 17:39:32 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MmAllocateNonCachedMemory (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2007-08-15 14:52:23 +02:00
|
|
|
PVOID WINAPI MmAllocateNonCachedMemory( SIZE_T size )
|
2007-05-16 17:39:32 +02:00
|
|
|
{
|
|
|
|
TRACE( "%lu\n", size );
|
|
|
|
return VirtualAlloc( NULL, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE|PAGE_NOCACHE );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MmFreeNonCachedMemory (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI MmFreeNonCachedMemory( void *addr, SIZE_T size )
|
|
|
|
{
|
|
|
|
TRACE( "%p %lu\n", addr, size );
|
|
|
|
VirtualFree( addr, 0, MEM_RELEASE );
|
|
|
|
}
|
|
|
|
|
2008-03-21 21:25:40 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MmIsAddressValid (NTOSKRNL.EXE.@)
|
|
|
|
*
|
|
|
|
* Check if the process can access the virtual address without a pagefault
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* VirtualAddress [I] Address to check
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Failure: FALSE
|
|
|
|
* Success: TRUE (Accessing the Address works without a Pagefault)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI MmIsAddressValid(PVOID VirtualAddress)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", VirtualAddress);
|
|
|
|
return !IsBadWritePtr(VirtualAddress, 1);
|
|
|
|
}
|
|
|
|
|
2008-02-05 19:19:52 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MmPageEntireDriver (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PVOID WINAPI MmPageEntireDriver(PVOID AddrInSection)
|
|
|
|
{
|
|
|
|
TRACE("%p\n", AddrInSection);
|
|
|
|
return AddrInSection;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MmResetDriverPaging (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
void WINAPI MmResetDriverPaging(PVOID AddrInSection)
|
|
|
|
{
|
|
|
|
TRACE("%p\n", AddrInSection);
|
|
|
|
}
|
|
|
|
|
2009-06-17 23:23:58 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ObfReferenceObject (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
VOID WINAPI ObfReferenceObject(PVOID Object)
|
|
|
|
{
|
|
|
|
FIXME("(%p): stub\n", Object);
|
|
|
|
}
|
2008-08-29 00:45:48 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ObReferenceObjectByHandle (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI ObReferenceObjectByHandle( HANDLE obj, ACCESS_MASK access,
|
|
|
|
POBJECT_TYPE type,
|
|
|
|
KPROCESSOR_MODE mode, PVOID* ptr,
|
|
|
|
POBJECT_HANDLE_INFORMATION info)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p %x %p %d %p %p\n", obj, access, type, mode, ptr, info);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-29 00:55:01 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ObfDereferenceObject (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
2008-12-02 15:38:28 +01:00
|
|
|
#ifdef DEFINE_FASTCALL1_ENTRYPOINT
|
|
|
|
DEFINE_FASTCALL1_ENTRYPOINT( ObfDereferenceObject )
|
|
|
|
void WINAPI __regs_ObfDereferenceObject( VOID *obj )
|
|
|
|
#else
|
2008-08-29 00:55:01 +02:00
|
|
|
void WINAPI ObfDereferenceObject( VOID *obj )
|
2008-12-02 15:38:28 +01:00
|
|
|
#endif
|
2008-08-29 00:55:01 +02:00
|
|
|
{
|
|
|
|
FIXME( "stub: %p\n", obj );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2009-01-08 17:26:56 +01:00
|
|
|
return UlongToHandle(GetCurrentProcessId()); /* FIXME: not quite right... */
|
2007-05-17 09:49:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* PsGetCurrentThreadId (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI PsGetCurrentThreadId(void)
|
|
|
|
{
|
2009-01-08 17:26:56 +01:00
|
|
|
return UlongToHandle(GetCurrentThreadId()); /* FIXME: not quite right... */
|
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;
|
|
|
|
|
|
|
|
RtlGetVersion( &info );
|
|
|
|
if (major) *major = info.dwMajorVersion;
|
|
|
|
if (minor) *minor = info.dwMinorVersion;
|
|
|
|
if (build) *build = info.dwBuildNumber;
|
|
|
|
|
|
|
|
if (version)
|
|
|
|
{
|
|
|
|
#if 0 /* FIXME: GameGuard passes an uninitialized pointer in version->Buffer */
|
|
|
|
size_t len = min( strlenW(info.szCSDVersion)*sizeof(WCHAR), version->MaximumLength );
|
|
|
|
memcpy( version->Buffer, info.szCSDVersion, len );
|
|
|
|
if (len < version->MaximumLength) version->Buffer[len / sizeof(WCHAR)] = 0;
|
|
|
|
version->Length = len;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* PsSetCreateProcessNotifyRoutine (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI PsSetCreateProcessNotifyRoutine( PCREATE_PROCESS_NOTIFY_ROUTINE callback, BOOLEAN remove )
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p %d\n", callback, remove );
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-12-28 14:31:51 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* PsSetCreateThreadNotifyRoutine (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI PsSetCreateThreadNotifyRoutine( PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine )
|
|
|
|
{
|
|
|
|
FIXME( "stub: %p\n", NotifyRoutine );
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-14 14:19:45 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* PsTerminateSystemThread (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI PsTerminateSystemThread(NTSTATUS ExitStatus)
|
|
|
|
{
|
|
|
|
FIXME( "stub: %u\n", ExitStatus );
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-17 11:01:10 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MmGetSystemRoutineAddress (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
PVOID WINAPI MmGetSystemRoutineAddress(PUNICODE_STRING SystemRoutineName)
|
|
|
|
{
|
|
|
|
HMODULE hMod;
|
|
|
|
STRING routineNameA;
|
|
|
|
PVOID pFunc = NULL;
|
|
|
|
|
|
|
|
static const WCHAR ntoskrnlW[] = {'n','t','o','s','k','r','n','l','.','e','x','e',0};
|
|
|
|
static const WCHAR halW[] = {'h','a','l','.','d','l','l',0};
|
|
|
|
|
|
|
|
if (!SystemRoutineName) return NULL;
|
|
|
|
|
|
|
|
if (RtlUnicodeStringToAnsiString( &routineNameA, SystemRoutineName, TRUE ) == STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
/* We only support functions exported from ntoskrnl.exe or hal.dll */
|
|
|
|
hMod = GetModuleHandleW( ntoskrnlW );
|
|
|
|
pFunc = GetProcAddress( hMod, routineNameA.Buffer );
|
|
|
|
if (!pFunc)
|
|
|
|
{
|
|
|
|
hMod = GetModuleHandleW( halW );
|
|
|
|
if (hMod) pFunc = GetProcAddress( hMod, routineNameA.Buffer );
|
|
|
|
}
|
|
|
|
RtlFreeAnsiString( &routineNameA );
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE( "%s -> %p\n", debugstr_us(SystemRoutineName), pFunc );
|
|
|
|
return pFunc;
|
|
|
|
}
|
2007-05-17 09:49:28 +02:00
|
|
|
|
2009-03-01 09:48:51 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MmQuerySystemSize (NTOSKRNL.EXE.@)
|
|
|
|
*/
|
|
|
|
MM_SYSTEMSIZE WINAPI MmQuerySystemSize(void)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return MmLargeSystem;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-15 21:41:50 +02:00
|
|
|
/*****************************************************
|
|
|
|
* DllMain
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
|
|
|
|
{
|
2009-02-02 16:21:25 +01:00
|
|
|
static void *handler;
|
2007-05-18 16:48:54 +02:00
|
|
|
LARGE_INTEGER count;
|
|
|
|
|
2007-05-15 21:41:50 +02:00
|
|
|
switch(reason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
DisableThreadLibraryCalls( inst );
|
2009-02-02 16:21:25 +01:00
|
|
|
handler = RtlAddVectoredExceptionHandler( TRUE, vectored_handler );
|
2007-05-18 16:48:54 +02:00
|
|
|
KeQueryTickCount( &count ); /* initialize the global KeTickCount */
|
2007-05-15 21:41:50 +02:00
|
|
|
break;
|
2009-01-30 11:44:13 +01:00
|
|
|
case DLL_PROCESS_DETACH:
|
2009-02-02 16:21:25 +01:00
|
|
|
RtlRemoveVectoredExceptionHandler( handler );
|
2009-01-30 11:44:13 +01:00
|
|
|
break;
|
2007-05-15 21:41:50 +02:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|