NTDLL/csr: some more stubs; code split;

NTDLL/rtl: some more stubs; RtlRaiseStatus() implemented;
Minor changes.

svn path=/trunk/; revision=1977
This commit is contained in:
Emanuele Aliberti 2001-06-17 20:05:10 +00:00
parent c4bb1e256b
commit 1731f27560
14 changed files with 286 additions and 116 deletions

View file

@ -37,6 +37,7 @@ NtCreateSymbolicLinkObject ZwCreateSymbolicLinkObject 16
NtCreateThread ZwCreateThread 32
NtCreateTimer ZwCreateTimer 16
NtCreateToken ZwCreateToken 52
NtCreateWaitablePort ZwCreateWaitablePort 20
NtDelayExecution ZwDelayExecution 8
NtDeleteAtom ZwDeleteAtom 4
NtDeleteFile ZwDeleteFile 4

View file

@ -186,6 +186,16 @@ typedef struct
HANDLE OutputHandle; /* handle to screen buffer to switch to */
} CSRSS_SET_ACTIVE_SCREEN_BUFFER_REQUEST, *PCSRSS_SET_ACTIVE_SCREEN_BUFFER_REQUEST;
typedef struct
{
HANDLE UniqueThread;
} CSRSS_IDENTIFY_ALERTABLE_THREAD_REQUEST, * PCSRSS_IDENTIFY_ALERTABLE_THREAD_REQUEST;
typedef struct
{
CLIENT_ID Cid;
} CSRSS_IDENTIFY_ALERTABLE_THREAD_REPLY, * PCSRSS_IDENTIFY_ALERTABLE_THREAD_REPLY;
#define CSRSS_MAX_WRITE_CONSOLE_REQUEST (MAX_MESSAGE_DATA - sizeof( ULONG ) - sizeof( CSRSS_WRITE_CONSOLE_REQUEST))
#define CSRSS_MAX_WRITE_CONSOLE_OUTPUT_CHAR (MAX_MESSAGE_DATA - sizeof( ULONG ) - sizeof( CSRSS_WRITE_CONSOLE_OUTPUT_CHAR_REQUEST ))

View file

@ -87,7 +87,13 @@ NTSTATUS STDCALL NtCreatePort(PHANDLE PortHandle,
POBJECT_ATTRIBUTES ObjectAttributes,
ULONG MaxConnectInfoLength,
ULONG MaxDataLength,
ULONG Reserved);
ULONG NPMessageQueueSize OPTIONAL);
NTSTATUS STDCALL NtCreateWaitablePort(PHANDLE PortHandle,
POBJECT_ATTRIBUTES ObjectAttributes,
ULONG MaxConnectInfoLength,
ULONG MaxDataLength,
ULONG NPMessageQueueSize OPTIONAL);
NTSTATUS STDCALL NtImpersonateClientOfPort (HANDLE PortHandle,
PLPC_MESSAGE ClientMessage);

View file

@ -1,4 +1,4 @@
/* $Id: csr.h,v 1.5 2001/06/17 09:23:46 ekohl Exp $
/* $Id: csr.h,v 1.6 2001/06/17 20:05:09 ea Exp $
*
*/
@ -7,12 +7,15 @@
#include <csrss/csrss.h>
extern HANDLE WindowsApiPort; /* lpc.c */
NTSTATUS STDCALL CsrClientConnectToServer(VOID);
NTSTATUS STDCALL CsrClientCallServer(PCSRSS_API_REQUEST Request,
PCSRSS_API_REPLY Reply,
PCSRSS_API_REPLY Reply OPTIONAL,
ULONG Length,
ULONG ReplyLength);
VOID STDCALL CsrIdentifyAlertableThread(VOID);
NTSTATUS STDCALL CsrIdentifyAlertableThread(VOID);
NTSTATUS STDCALL CsrNewThread(VOID);
NTSTATUS STDCALL CsrSetPriorityClass(HANDLE Process,
PULONG PriorityClass);

View file

@ -1,9 +1,9 @@
/* $Id: capture.c,v 1.2 2001/06/17 09:24:04 ekohl Exp $
/* $Id: capture.c,v 1.3 2001/06/17 20:05:09 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: lib/ntdll/csr/capture.c
* PURPOSE: CSRSS Capure API
* PURPOSE: CSRSS Capture API
*/
/* INCLUDES *****************************************************************/
@ -19,7 +19,7 @@
/* GLOBALS *******************************************************************/
static HANDLE hCaptureHeap = INVALID_HANDLE_VALUE;
static HANDLE hCaptureHeap = INVALID_HANDLE_VALUE; /* FIXME: use the general NTDLL heap */
/* FUNCTIONS *****************************************************************/
@ -34,6 +34,15 @@ STDCALL CsrAllocateCaptureBuffer (
return NULL;
}
VOID STDCALL
CsrCaptureMessageString (DWORD Unknown0,
DWORD Unknown1,
DWORD Unknown2,
DWORD Unknown3,
DWORD Unknown4)
{
}
VOID STDCALL
CsrAllocateCapturePointer(ULONG Unknown0,
ULONG Unknown1,
@ -42,6 +51,12 @@ CsrAllocateCapturePointer(ULONG Unknown0,
}
VOID STDCALL CsrAllocateMessagePointer (DWORD Unknown0,
DWORD Unknown1,
DWORD Unknown2)
{
}
VOID STDCALL
CsrCaptureMessageBuffer(ULONG Unknown0,
ULONG Unknown1,
@ -53,6 +68,7 @@ CsrCaptureMessageBuffer(ULONG Unknown0,
BOOLEAN STDCALL CsrFreeCaptureBuffer (PVOID CaptureBuffer)
{
/* FIXME: use NTDLL own heap */
return RtlFreeHeap (hCaptureHeap, 0, CaptureBuffer);
}

View file

@ -1,16 +1,20 @@
/* $Id: api.c,v 1.10 2001/06/17 09:24:04 ekohl Exp $
/* $Id: lpc.c,v 1.1 2001/06/17 20:05:09 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: lib/ntdll/csr/api.c
* PURPOSE: CSRSS API
* FILE: lib/ntdll/csr/lpc.c
* PURPOSE: CSRSS Client/Server LPC API
*
* REVISIONS:
* 2001-06-16 (ea)
* File api.c renamed lpc.c. Process/thread code moved
* in thread.c. Check added on the LPC port.
*/
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
#include <ntdll/csr.h>
#include <ntdll/rtl.h>
#include <string.h>
#include <csrss/csrss.h>
@ -20,27 +24,49 @@
/* GLOBALS *******************************************************************/
static HANDLE WindowsApiPort;
HANDLE WindowsApiPort = INVALID_HANDLE_VALUE;
/* FUNCTIONS *****************************************************************/
/* Possible CsrClientCallServer (the NT one):
NTSTATUS STDCALL
CsrClientCallServer(PCSRSS_XXX_REQUEST Request,
PCSRSS_XXX_REPLY Reply OPTIONAL,
ULONG CsrApiNumber,
ULONG MaxRequestReplyLength)
XXX_REQUEST and XXX_REPLY depend on the CsrApiNumber value and are not LPC
objects (the LPC_REQUEST is built here instead).
If Reply == NULL, use storage of Request to write the reply.
TO BE VERIFIED.
*/
NTSTATUS STDCALL
CsrClientCallServer(PCSRSS_API_REQUEST Request,
PCSRSS_API_REPLY Reply,
PCSRSS_API_REPLY Reply OPTIONAL,
ULONG Length,
ULONG ReplyLength)
{
NTSTATUS Status;
if (INVALID_HANDLE_VALUE == WindowsApiPort)
{
DbgPrint ("NTDLL.%s: client not connected to CSRSS!\n", __FUNCTION__);
return (STATUS_UNSUCCESSFUL);
}
// DbgPrint("CsrClientCallServer(Request %x, Reply %x, Length %d, "
// "ReplyLength %d)\n", Request, Reply, Length, ReplyLength);
Request->Header.DataSize = Length;
Request->Header.MessageSize = sizeof(LPC_MESSAGE_HEADER) + Length;
Status = NtRequestWaitReplyPort(WindowsApiPort,
&Request->Header,
&Reply->Header);
(Reply?&Reply->Header:&Request->Header));
// DbgPrint("Status %x\n", Status);
@ -87,71 +113,4 @@ CsrClientConnectToServer(VOID)
return(STATUS_SUCCESS);
}
VOID STDCALL
CsrIdentifyAlertableThread(VOID)
{
/* FIXME: notify csrss that current thread is alertable */
}
NTSTATUS STDCALL
CsrNewThread(VOID)
{
return (NtRegisterThreadTerminatePort(WindowsApiPort));
}
NTSTATUS STDCALL
CsrSetPriorityClass(HANDLE Process,
PULONG PriorityClass)
{
/* FIXME: call csrss to get hProcess' priority */
*PriorityClass = CSR_PRIORITY_CLASS_NORMAL;
return (STATUS_NOT_IMPLEMENTED);
}
VOID STDCALL
CsrProbeForRead(IN CONST PVOID Address,
IN ULONG Length,
IN ULONG Alignment)
{
PUCHAR Pointer;
UCHAR Data;
if (Length == 0)
return;
if ((ULONG)Address & (Alignment - 1))
RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT);
Pointer = (PUCHAR)Address;
Data = *Pointer;
Pointer = (PUCHAR)((ULONG)Address + Length -1);
Data = *Pointer;
}
VOID STDCALL
CsrProbeForWrite(IN CONST PVOID Address,
IN ULONG Length,
IN ULONG Alignment)
{
PUCHAR Pointer;
UCHAR Data;
if (Length == 0)
return;
if ((ULONG)Address & (Alignment - 1))
RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT);
// if (Address >= MmUserProbeAddress)
// RtlRaiseStatus(STATUS_ACCESS_VIOLATION);
Pointer = (PUCHAR)Address;
Data = *Pointer;
*Pointer = Data;
Pointer = (PUCHAR)((ULONG)Address + Length -1);
Data = *Pointer;
*Pointer = Data;
}
/* EOF */

View file

@ -0,0 +1,61 @@
/* $Id: probe.c,v 1.1 2001/06/17 20:05:09 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: lib/ntdll/csr/probe.c
* PURPOSE: CSRSS address range access probing API
* AUTHOR: Eric Kohl
* DATE: 2001-06-17
*/
#define NTOS_MODE_USER
#include <ntos.h>
#define NDEBUG
#include <ntdll/rtl.h>
VOID STDCALL
CsrProbeForRead(IN CONST PVOID Address,
IN ULONG Length,
IN ULONG Alignment)
{
PUCHAR Pointer;
UCHAR Data;
if (Length == 0)
return;
if ((ULONG)Address & (Alignment - 1))
RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT);
Pointer = (PUCHAR)Address;
Data = *Pointer;
Pointer = (PUCHAR)((ULONG)Address + Length -1);
Data = *Pointer;
}
VOID STDCALL
CsrProbeForWrite(IN CONST PVOID Address,
IN ULONG Length,
IN ULONG Alignment)
{
PUCHAR Pointer;
UCHAR Data;
if (Length == 0)
return;
if ((ULONG)Address & (Alignment - 1))
RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT);
// if (Address >= MmUserProbeAddress)
// RtlRaiseStatus(STATUS_ACCESS_VIOLATION);
Pointer = (PUCHAR)Address;
Data = *Pointer;
*Pointer = Data;
Pointer = (PUCHAR)((ULONG)Address + Length -1);
Data = *Pointer;
*Pointer = Data;
}
/* EOF */

View file

@ -0,0 +1,57 @@
/* $Id: thread.c,v 1.1 2001/06/17 20:05:09 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: lib/ntdll/csr/propvar.c
* PURPOSE: CSRSS threads API
*/
#define NTOS_MODE_USER
#include <ntos.h>
#include <ntdll/csr.h>
#include <string.h>
#include <csrss/csrss.h>
#define NDEBUG
#include <ntdll/ntdll.h>
NTSTATUS STDCALL
CsrNewThread(VOID)
{
return (NtRegisterThreadTerminatePort(WindowsApiPort));
}
NTSTATUS STDCALL
CsrSetPriorityClass(HANDLE Process,
PULONG PriorityClass)
{
/* FIXME: call csrss to get hProcess' priority */
*PriorityClass = CSR_PRIORITY_CLASS_NORMAL;
return (STATUS_NOT_IMPLEMENTED);
}
NTSTATUS
STDCALL
CsrIdentifyAlertableThread (VOID)
{
/* FIXME: notify csrss that current thread is alertable */
#if 0
CSRSS_IDENTIFY_ALERTABLE_THREAD_REPLY Reply;
CSRSS_IDENTIFY_ALERTABLE_THREAD_REQUEST Request = (PCSRSS_IDENTIFY_ALERTABLE_THREAD_REQUEST) & Reply;
PNT_TEB Teb;
Request->UniqueThread = NtCurrentTeb()->Cid.UniqueThread;
/* FIXME: this is written the NT way, NOT the ROS way! */
return CsrClientCallServer (
Request,
NULL, /* use Request storage for reply */
CSRSS_IDENTIFY_ALERTABLE_THREAD,
sizeof (CSRSS_IDENTIFY_ALERTABLE_THREAD_REPLY)
);
#endif
return (STATUS_NOT_IMPLEMENTED);
}
/* EOF */

View file

@ -1,19 +1,19 @@
; $Id: ntdll.def,v 1.74 2001/06/17 09:25:03 ekohl Exp $
; $Id: ntdll.def,v 1.75 2001/06/17 20:05:09 ea Exp $
;
; ReactOS Operating System
;
LIBRARY ntdll.dll
EXPORTS
;CsrAllocateCaptureBuffer
;CsrAllocateCapturePointer
;CsrAllocateMessagePointer
;CsrCaptureMessageBuffer
;CsrCaptureMessageString
;CsrCaptureTimeout
CsrAllocateCaptureBuffer@12
CsrAllocateCapturePointer@12
CsrAllocateMessagePointer@12
CsrCaptureMessageBuffer@16
CsrCaptureMessageString@20
CsrCaptureTimeout@8
CsrClientCallServer@16
CsrClientConnectToServer@0
;CsrFreeCaptureBuffer
CsrFreeCaptureBuffer@4
CsrIdentifyAlertableThread@0
CsrNewThread@0
CsrProbeForRead@12
@ -92,6 +92,7 @@ NtCreateSymbolicLinkObject@16
NtCreateThread@32
NtCreateTimer@16
NtCreateToken@52
NtCreateWaitablePort@20
NtDelayExecution@8
NtDeleteAtom@4
NtDeleteFile@4

View file

@ -1,19 +1,19 @@
; $Id: ntdll.edf,v 1.63 2001/06/17 09:25:03 ekohl Exp $
; $Id: ntdll.edf,v 1.64 2001/06/17 20:05:10 ea Exp $
;
; ReactOS Operating System
;
LIBRARY ntdll.dll
EXPORTS
;CsrAllocateCaptureBuffer
;CsrAllocateCapturePointer
;CsrAllocateMessagePointer
;CsrCaptureMessageBuffer
;CsrCaptureMessageString
;CsrCaptureTimeout
CsrAllocateCaptureBuffer=CsrAllocateCaptureBuffer@12
CsrAllocateCapturePointer=CsrAllocateCapturePointer@12
CsrAllocateMessagePointer=CsrAllocateMessagePointer@12
CsrCaptureMessageBuffer=CsrCaptureMessageBuffer@16
CsrCaptureMessageString=CsrCaptureMessageString@20
CsrCaptureTimeout=CsrCaptureTimeout@8
CsrClientCallServer=CsrClientCallServer@16
CsrClientConnectToServer=CsrClientConnectToServer@0
;CsrFreeCaptureBuffer
CsrFreeCaptureBuffer=CsrFreeCaptureBuffer@4
CsrIdentifyAlertableThread=CsrIdentifyAlertableThread@0
CsrNewThread=CsrNewThread@0
CsrProbeForRead=CsrProbeForRead@12
@ -92,6 +92,7 @@ NtCreateSymbolicLinkObject=NtCreateSymbolicLinkObject@16
NtCreateThread=NtCreateThread@32
NtCreateTimer=NtCreateTimer@16
NtCreateToken=NtCreateToken@52
NtCreateWaitablePort=NtCreateWaitablePort@20
NtDelayExecution=NtDelayExecution@8
NtDeleteAtom=NtDeleteAtom@4
NtDeleteFile=NtDeleteFile@4

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.61 2001/05/30 20:02:31 ekohl Exp $
# $Id: makefile,v 1.62 2001/06/17 20:05:09 ea Exp $
#
# ReactOS Operating System
#
@ -15,7 +15,7 @@ DLLMAIN=main/dllmain.o
all: $(DLLTARGET)
CSR_OBJECTS = csr/api.o
CSR_OBJECTS = csr/lpc.o csr/capture.o csr/probe.o csr/thread.o
DBG_OBJECTS = dbg/brkpoint.o dbg/debug.o dbg/print.o
@ -25,7 +25,8 @@ RTL_OBJECTS = rtl/critical.o rtl/error.o rtl/heap.o rtl/largeint.o \
rtl/bitmap.o rtl/time.o rtl/acl.o rtl/sid.o rtl/image.o \
rtl/access.o rtl/apc.o rtl/callback.o rtl/luid.o rtl/misc.o \
rtl/registry.o rtl/exception.o rtl/intrlck.o rtl/resource.o \
rtl/handle.o rtl/atom.o rtl/message.o rtl/timezone.o
rtl/handle.o rtl/atom.o rtl/message.o rtl/timezone.o \
rtl/propvar.o
STDIO_OBJECTS = stdio/sprintf.o stdio/swprintf.o

View file

@ -1,4 +1,4 @@
/* $Id: exception.c,v 1.5 2001/03/18 19:35:12 dwelch Exp $
/* $Id: exception.c,v 1.6 2001/06/17 20:05:10 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -53,7 +53,13 @@ KiUserExceptionDispatcher(PEXCEPTION_RECORD ExceptionRecord,
VOID STDCALL
RtlRaiseStatus(NTSTATUS Status)
{
EXCEPTION_RECORD ExceptionRecord;
ExceptionRecord.ExceptionCode = Status;
ExceptionRecord.ExceptionRecord = NULL;
ExceptionRecord.NumberParameters = 0;
ExceptionRecord.ExceptionFlags = EXCEPTION_NONCONTINUABLE;
RtlRaiseException (& ExceptionRecord);
}

View file

@ -0,0 +1,62 @@
/* $Id: propvar.c,v 1.1 2001/06/17 20:05:10 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: lib/ntdll/csr/propvar.c
* PURPOSE: CSRSS properties and variants API
*/
#define NTOS_MODE_USER
#include <ntos.h>
NTSTATUS
STDCALL
PropertyLengthAsVariant (
DWORD Unknown0,
DWORD Unknown1,
DWORD Unknown2,
DWORD Unknown3
)
{
return (STATUS_NOT_IMPLEMENTED);
}
BOOLEAN
STDCALL
RtlCompareVariants (
DWORD Unknown0,
DWORD Unknown1,
DWORD Unknown2
)
{
return (FALSE);
}
BOOLEAN
STDCALL
RtlConvertPropertyToVariant (
DWORD Unknown0,
DWORD Unknown1,
DWORD Unknown2,
DWORD Unknown3
)
{
return (FALSE);
}
NTSTATUS
STDCALL
RtlConvertVariantToProperty (
DWORD Unknown0,
DWORD Unknown1,
DWORD Unknown2,
DWORD Unknown3,
DWORD Unknown4,
DWORD Unknown5,
DWORD Unknown6
)
{
return (STATUS_NOT_IMPLEMENTED);
}
/* EOF */

View file

@ -8,20 +8,6 @@
// ?Allocate@CBufferAllocator@@UAEPAXK@Z
STUB(PropertyLengthAsVariant)
STUB(RtlCompareVariants)
STUB(RtlConvertPropertyToVariant)
STUB(RtlConvertVariantToProperty)
STUB(CsrAllocateCaptureBuffer)
STUB(CsrAllocateCapturePointer)
STUB(CsrAllocateMessagePointer)
STUB(CsrCaptureMessageBuffer)
STUB(CsrCaptureMessageString)
STUB(CsrCaptureTimeout)
STUB(CsrFreeCaptureBuffer)
STUB(CsrIdentifyAlertableThread)
STUB(CsrProbeForRead)
STUB(CsrProbeForWrite)
STUB(KiRaiseUserExceptionDispatcher)
@ -172,5 +158,5 @@ STUB(_aullrem)
STUB(_aullshr)
//STUB(_chkstk)
STUB(_fltused)
STUB(sscanf)
//STUB(sscanf)