2005-01-06 13:58:04 +00:00
|
|
|
/* $Id$
|
2005-05-08 04:07:56 +00:00
|
|
|
*
|
2000-02-29 23:57:47 +00:00
|
|
|
* reactos/subsys/csrss/api/wapi.c
|
1999-12-22 14:48:30 +00:00
|
|
|
*
|
2005-02-26 15:06:19 +00:00
|
|
|
* CSRSS port message processing
|
1999-12-22 14:48:30 +00:00
|
|
|
*
|
|
|
|
* ReactOS Operating System
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
2005-07-26 08:55:25 +00:00
|
|
|
#include <csrss.h>
|
2005-03-20 22:55:05 +00:00
|
|
|
|
2005-12-01 22:38:03 +00:00
|
|
|
#define NDEBUG
|
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
#define NDEBUG
|
2002-09-07 15:13:13 +00:00
|
|
|
#include <debug.h>
|
|
|
|
|
1999-12-30 01:51:42 +00:00
|
|
|
/* GLOBALS *******************************************************************/
|
|
|
|
|
2007-06-14 19:09:32 +00:00
|
|
|
extern HANDLE hApiPort;
|
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
HANDLE CsrssApiHeap = (HANDLE) 0;
|
1999-12-30 01:51:42 +00:00
|
|
|
|
2003-12-02 11:38:47 +00:00
|
|
|
static unsigned ApiDefinitionsCount = 0;
|
|
|
|
static PCSRSS_API_DEFINITION ApiDefinitions = NULL;
|
|
|
|
|
1999-12-22 14:48:30 +00:00
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
2003-12-02 11:38:47 +00:00
|
|
|
NTSTATUS FASTCALL
|
|
|
|
CsrApiRegisterDefinitions(PCSRSS_API_DEFINITION NewDefinitions)
|
1999-12-22 14:48:30 +00:00
|
|
|
{
|
2003-12-02 11:38:47 +00:00
|
|
|
unsigned NewCount;
|
|
|
|
PCSRSS_API_DEFINITION Scan;
|
|
|
|
PCSRSS_API_DEFINITION New;
|
|
|
|
|
2007-06-14 16:47:24 +00:00
|
|
|
DPRINT("CSR: %s called\n", __FUNCTION__);
|
2005-03-20 22:55:05 +00:00
|
|
|
|
2003-12-02 11:38:47 +00:00
|
|
|
NewCount = 0;
|
|
|
|
for (Scan = NewDefinitions; 0 != Scan->Handler; Scan++)
|
|
|
|
{
|
|
|
|
NewCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
New = RtlAllocateHeap(CsrssApiHeap, 0,
|
|
|
|
(ApiDefinitionsCount + NewCount)
|
|
|
|
* sizeof(CSRSS_API_DEFINITION));
|
|
|
|
if (NULL == New)
|
|
|
|
{
|
|
|
|
DPRINT1("Unable to allocate memory\n");
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
}
|
|
|
|
if (0 != ApiDefinitionsCount)
|
|
|
|
{
|
|
|
|
RtlCopyMemory(New, ApiDefinitions,
|
|
|
|
ApiDefinitionsCount * sizeof(CSRSS_API_DEFINITION));
|
|
|
|
RtlFreeHeap(CsrssApiHeap, 0, ApiDefinitions);
|
|
|
|
}
|
|
|
|
RtlCopyMemory(New + ApiDefinitionsCount, NewDefinitions,
|
|
|
|
NewCount * sizeof(CSRSS_API_DEFINITION));
|
|
|
|
ApiDefinitions = New;
|
|
|
|
ApiDefinitionsCount += NewCount;
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
VOID
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
FASTCALL
|
2003-12-02 11:38:47 +00:00
|
|
|
CsrApiCallHandler(PCSRSS_PROCESS_DATA ProcessData,
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
PCSR_API_MESSAGE Request)
|
2003-12-02 11:38:47 +00:00
|
|
|
{
|
|
|
|
unsigned DefIndex;
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
ULONG Type;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
- Fix SleepEx.
- Put volatile statements in EX_RUNDOWN_REF, IRP, DEVICE_OBJECT, ERESOURCE, FILE_OBJECT, IO_REMOVE_LOCK, WORK_QUEUE_ITEM where required (thanks to Microsoft's changes in the WDK to mark the fields properly).
- Update FILE_OBJECT definition.
- Add some asserts to some I/O functions.
- Add stub support for File Objects created by XP+ Drivers which have File Object Extensions.
- Add some fixes to IopDeleteFile, including proper reference counting for the DO and VPB, as well as cleanup when the file is closed without a handle.
- Fix a bug in IopSecurityFile.
- Queue and unqueue IRPs in all I/O functions.
- Fully support IRP cancellation now.
- Fix critical bugs in NtDeviceIoControlFile and NtDeviceFsControlFile which were causing double queueing of IRPs and freeing of invalid memory, as well as invalid paramter checking for user-mode buffers.
- Add exhaustive validation checks to IoCreateFile, add more failure cases, and validate the EA buffer. Also support IO_ATTACH_DEVICE_API flag.
- Implement IoCreateStreamFileObjectEx and IoCreateStreamFileObjectLite and fix several bugs in the original implementation of IoCreateStreamFileObject.
- Fix a bug in RtlRaiseException.
- Update Io*ShareAccess routines to support XP+ style semantics related to special File Object flags which disable their use.
- Add validation to all Query/Set routines so that information clasess, lengths, buffers and alignment are properly checked.
- Also add an array for the proper acess rights that each query/set operation requires.
- Check backup/restore privileges during I/O File operations.
- Check traverse access during I/O File Operations.
- Check access privileges to the device during I/O file operations.
- Rename IopReferenceDeviceObject and also verify if an exclusive DO is trying to be invalidly opened.
- Support various extra security checks during I/O File/Device Parse Routine.
- Fix a bug during IopCleanupIrp so that we don't dereference the File OBject if this was a create operation.
- Fix some bogus asserts in IofCompleteRequest, and save the IRP Flags before signalling it's event, since the driver might've freed it behind our back.
- Fix a large bug in ObInsertObject which affected the insert of unnamed objects with forced security options (Such as process/threads).
- Fix the creation of the Process/Thread/Job Obejct Types to that security information is forced.
- Remove "Fix PS!!!" messages since the bug is now fixed and these objects now get proper security descriptors.
- Fix another bug in ObInsertObjet which wasn't properly validating user-mode objects and always assumed kernel mode.
- Silence multiple trace/checkpoint messages that have accumulated throughout time for various debugging purposes.
svn path=/trunk/; revision=25118
2006-12-10 18:40:30 +00:00
|
|
|
DPRINT("CSR: Calling handler for type: %x.\n", Request->Type);
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
Type = Request->Type & 0xFFFF; /* FIXME: USE MACRO */
|
- Fix SleepEx.
- Put volatile statements in EX_RUNDOWN_REF, IRP, DEVICE_OBJECT, ERESOURCE, FILE_OBJECT, IO_REMOVE_LOCK, WORK_QUEUE_ITEM where required (thanks to Microsoft's changes in the WDK to mark the fields properly).
- Update FILE_OBJECT definition.
- Add some asserts to some I/O functions.
- Add stub support for File Objects created by XP+ Drivers which have File Object Extensions.
- Add some fixes to IopDeleteFile, including proper reference counting for the DO and VPB, as well as cleanup when the file is closed without a handle.
- Fix a bug in IopSecurityFile.
- Queue and unqueue IRPs in all I/O functions.
- Fully support IRP cancellation now.
- Fix critical bugs in NtDeviceIoControlFile and NtDeviceFsControlFile which were causing double queueing of IRPs and freeing of invalid memory, as well as invalid paramter checking for user-mode buffers.
- Add exhaustive validation checks to IoCreateFile, add more failure cases, and validate the EA buffer. Also support IO_ATTACH_DEVICE_API flag.
- Implement IoCreateStreamFileObjectEx and IoCreateStreamFileObjectLite and fix several bugs in the original implementation of IoCreateStreamFileObject.
- Fix a bug in RtlRaiseException.
- Update Io*ShareAccess routines to support XP+ style semantics related to special File Object flags which disable their use.
- Add validation to all Query/Set routines so that information clasess, lengths, buffers and alignment are properly checked.
- Also add an array for the proper acess rights that each query/set operation requires.
- Check backup/restore privileges during I/O File operations.
- Check traverse access during I/O File Operations.
- Check access privileges to the device during I/O file operations.
- Rename IopReferenceDeviceObject and also verify if an exclusive DO is trying to be invalidly opened.
- Support various extra security checks during I/O File/Device Parse Routine.
- Fix a bug during IopCleanupIrp so that we don't dereference the File OBject if this was a create operation.
- Fix some bogus asserts in IofCompleteRequest, and save the IRP Flags before signalling it's event, since the driver might've freed it behind our back.
- Fix a large bug in ObInsertObject which affected the insert of unnamed objects with forced security options (Such as process/threads).
- Fix the creation of the Process/Thread/Job Obejct Types to that security information is forced.
- Remove "Fix PS!!!" messages since the bug is now fixed and these objects now get proper security descriptors.
- Fix another bug in ObInsertObjet which wasn't properly validating user-mode objects and always assumed kernel mode.
- Silence multiple trace/checkpoint messages that have accumulated throughout time for various debugging purposes.
svn path=/trunk/; revision=25118
2006-12-10 18:40:30 +00:00
|
|
|
DPRINT("CSR: API Number: %x ServerID: %x\n",Type, Request->Type >> 16);
|
2003-12-02 11:38:47 +00:00
|
|
|
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
/* FIXME: Extract DefIndex instead of looping */
|
2008-08-02 22:09:22 +00:00
|
|
|
for (DefIndex = 0; DefIndex < ApiDefinitionsCount; DefIndex++)
|
2003-12-02 11:38:47 +00:00
|
|
|
{
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
if (ApiDefinitions[DefIndex].Type == Type)
|
2003-12-02 11:38:47 +00:00
|
|
|
{
|
2005-08-11 02:58:54 +00:00
|
|
|
if (Request->Header.u1.s1.DataLength < ApiDefinitions[DefIndex].MinRequestSize)
|
2003-12-02 11:38:47 +00:00
|
|
|
{
|
|
|
|
DPRINT1("Request type %d min request size %d actual %d\n",
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
Type, ApiDefinitions[DefIndex].MinRequestSize,
|
2005-08-11 02:58:54 +00:00
|
|
|
Request->Header.u1.s1.DataLength);
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
Request->Status = STATUS_INVALID_PARAMETER;
|
2003-12-02 11:38:47 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-02 22:09:22 +00:00
|
|
|
Request->Status = (ApiDefinitions[DefIndex].Handler)(ProcessData, Request);
|
2003-12-02 11:38:47 +00:00
|
|
|
}
|
2008-08-02 22:09:22 +00:00
|
|
|
return;
|
2003-12-02 11:38:47 +00:00
|
|
|
}
|
|
|
|
}
|
2008-08-02 22:09:22 +00:00
|
|
|
DPRINT1("CSR: Unknown request type 0x%x\n", Request->Type);
|
|
|
|
Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
|
|
|
|
Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
|
|
|
|
Request->Status = STATUS_INVALID_SYSTEM_SERVICE;
|
2003-12-02 11:38:47 +00:00
|
|
|
}
|
|
|
|
|
2007-12-22 17:18:32 +00:00
|
|
|
BOOL
|
|
|
|
CallHardError(IN PCSRSS_PROCESS_DATA ProcessData,
|
|
|
|
IN PHARDERROR_MSG HardErrorMessage);
|
2006-10-30 14:20:45 +00:00
|
|
|
|
|
|
|
static
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
CsrHandleHardError(IN PCSRSS_PROCESS_DATA ProcessData,
|
|
|
|
IN OUT PHARDERROR_MSG Message)
|
|
|
|
{
|
|
|
|
DPRINT1("CSR: received hard error %lx\n", Message->Status);
|
|
|
|
|
|
|
|
/* Call the hard error handler in win32csr */
|
2007-12-22 17:18:32 +00:00
|
|
|
(VOID)CallHardError(ProcessData, Message);
|
2006-10-30 14:20:45 +00:00
|
|
|
}
|
|
|
|
|
2006-10-30 18:45:22 +00:00
|
|
|
NTSTATUS STDCALL
|
|
|
|
CsrpHandleConnectionRequest (PPORT_MESSAGE Request,
|
|
|
|
IN HANDLE hApiListenPort)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
HANDLE ServerPort = (HANDLE) 0;
|
|
|
|
PCSRSS_PROCESS_DATA ProcessData = NULL;
|
|
|
|
REMOTE_PORT_VIEW LpcRead;
|
|
|
|
LpcRead.Length = sizeof(LpcRead);
|
|
|
|
ServerPort = NULL;
|
|
|
|
|
- Fix SleepEx.
- Put volatile statements in EX_RUNDOWN_REF, IRP, DEVICE_OBJECT, ERESOURCE, FILE_OBJECT, IO_REMOVE_LOCK, WORK_QUEUE_ITEM where required (thanks to Microsoft's changes in the WDK to mark the fields properly).
- Update FILE_OBJECT definition.
- Add some asserts to some I/O functions.
- Add stub support for File Objects created by XP+ Drivers which have File Object Extensions.
- Add some fixes to IopDeleteFile, including proper reference counting for the DO and VPB, as well as cleanup when the file is closed without a handle.
- Fix a bug in IopSecurityFile.
- Queue and unqueue IRPs in all I/O functions.
- Fully support IRP cancellation now.
- Fix critical bugs in NtDeviceIoControlFile and NtDeviceFsControlFile which were causing double queueing of IRPs and freeing of invalid memory, as well as invalid paramter checking for user-mode buffers.
- Add exhaustive validation checks to IoCreateFile, add more failure cases, and validate the EA buffer. Also support IO_ATTACH_DEVICE_API flag.
- Implement IoCreateStreamFileObjectEx and IoCreateStreamFileObjectLite and fix several bugs in the original implementation of IoCreateStreamFileObject.
- Fix a bug in RtlRaiseException.
- Update Io*ShareAccess routines to support XP+ style semantics related to special File Object flags which disable their use.
- Add validation to all Query/Set routines so that information clasess, lengths, buffers and alignment are properly checked.
- Also add an array for the proper acess rights that each query/set operation requires.
- Check backup/restore privileges during I/O File operations.
- Check traverse access during I/O File Operations.
- Check access privileges to the device during I/O file operations.
- Rename IopReferenceDeviceObject and also verify if an exclusive DO is trying to be invalidly opened.
- Support various extra security checks during I/O File/Device Parse Routine.
- Fix a bug during IopCleanupIrp so that we don't dereference the File OBject if this was a create operation.
- Fix some bogus asserts in IofCompleteRequest, and save the IRP Flags before signalling it's event, since the driver might've freed it behind our back.
- Fix a large bug in ObInsertObject which affected the insert of unnamed objects with forced security options (Such as process/threads).
- Fix the creation of the Process/Thread/Job Obejct Types to that security information is forced.
- Remove "Fix PS!!!" messages since the bug is now fixed and these objects now get proper security descriptors.
- Fix another bug in ObInsertObjet which wasn't properly validating user-mode objects and always assumed kernel mode.
- Silence multiple trace/checkpoint messages that have accumulated throughout time for various debugging purposes.
svn path=/trunk/; revision=25118
2006-12-10 18:40:30 +00:00
|
|
|
DPRINT("CSR: %s: Handling: %p\n", __FUNCTION__, Request);
|
2006-10-30 18:45:22 +00:00
|
|
|
|
|
|
|
Status = NtAcceptConnectPort(&ServerPort,
|
|
|
|
NULL,
|
|
|
|
Request,
|
|
|
|
TRUE,
|
|
|
|
0,
|
|
|
|
& LpcRead);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("CSR: NtAcceptConnectPort() failed\n");
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2007-06-14 16:47:24 +00:00
|
|
|
ProcessData = CsrGetProcessData(Request->ClientId.UniqueProcess);
|
2006-10-30 18:45:22 +00:00
|
|
|
if (ProcessData == NULL)
|
|
|
|
{
|
2007-06-14 16:47:24 +00:00
|
|
|
ProcessData = CsrCreateProcessData(Request->ClientId.UniqueProcess);
|
|
|
|
if (ProcessData == NULL)
|
|
|
|
{
|
|
|
|
DPRINT1("Unable to allocate or find data for process 0x%x\n",
|
|
|
|
Request->ClientId.UniqueProcess);
|
|
|
|
Status = STATUS_UNSUCCESSFUL;
|
|
|
|
return Status;
|
|
|
|
}
|
2006-10-30 18:45:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ProcessData->CsrSectionViewBase = LpcRead.ViewBase;
|
|
|
|
ProcessData->CsrSectionViewSize = LpcRead.ViewSize;
|
2007-06-14 19:09:32 +00:00
|
|
|
ProcessData->ServerCommunicationPort = ServerPort;
|
2006-10-30 18:45:22 +00:00
|
|
|
|
|
|
|
Status = NtCompleteConnectPort(ServerPort);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("CSR: NtCompleteConnectPort() failed\n");
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
HANDLE ServerThread = (HANDLE) 0;
|
|
|
|
Status = RtlCreateUserThread(NtCurrentProcess(),
|
|
|
|
NULL,
|
|
|
|
FALSE,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
(PTHREAD_START_ROUTINE)ClientConnectionThread,
|
|
|
|
ServerPort,
|
|
|
|
& ServerThread,
|
|
|
|
NULL);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("CSR: Unable to create server thread\n");
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
NtClose(ServerThread);
|
|
|
|
|
|
|
|
Status = STATUS_SUCCESS;
|
- Fix SleepEx.
- Put volatile statements in EX_RUNDOWN_REF, IRP, DEVICE_OBJECT, ERESOURCE, FILE_OBJECT, IO_REMOVE_LOCK, WORK_QUEUE_ITEM where required (thanks to Microsoft's changes in the WDK to mark the fields properly).
- Update FILE_OBJECT definition.
- Add some asserts to some I/O functions.
- Add stub support for File Objects created by XP+ Drivers which have File Object Extensions.
- Add some fixes to IopDeleteFile, including proper reference counting for the DO and VPB, as well as cleanup when the file is closed without a handle.
- Fix a bug in IopSecurityFile.
- Queue and unqueue IRPs in all I/O functions.
- Fully support IRP cancellation now.
- Fix critical bugs in NtDeviceIoControlFile and NtDeviceFsControlFile which were causing double queueing of IRPs and freeing of invalid memory, as well as invalid paramter checking for user-mode buffers.
- Add exhaustive validation checks to IoCreateFile, add more failure cases, and validate the EA buffer. Also support IO_ATTACH_DEVICE_API flag.
- Implement IoCreateStreamFileObjectEx and IoCreateStreamFileObjectLite and fix several bugs in the original implementation of IoCreateStreamFileObject.
- Fix a bug in RtlRaiseException.
- Update Io*ShareAccess routines to support XP+ style semantics related to special File Object flags which disable their use.
- Add validation to all Query/Set routines so that information clasess, lengths, buffers and alignment are properly checked.
- Also add an array for the proper acess rights that each query/set operation requires.
- Check backup/restore privileges during I/O File operations.
- Check traverse access during I/O File Operations.
- Check access privileges to the device during I/O file operations.
- Rename IopReferenceDeviceObject and also verify if an exclusive DO is trying to be invalidly opened.
- Support various extra security checks during I/O File/Device Parse Routine.
- Fix a bug during IopCleanupIrp so that we don't dereference the File OBject if this was a create operation.
- Fix some bogus asserts in IofCompleteRequest, and save the IRP Flags before signalling it's event, since the driver might've freed it behind our back.
- Fix a large bug in ObInsertObject which affected the insert of unnamed objects with forced security options (Such as process/threads).
- Fix the creation of the Process/Thread/Job Obejct Types to that security information is forced.
- Remove "Fix PS!!!" messages since the bug is now fixed and these objects now get proper security descriptors.
- Fix another bug in ObInsertObjet which wasn't properly validating user-mode objects and always assumed kernel mode.
- Silence multiple trace/checkpoint messages that have accumulated throughout time for various debugging purposes.
svn path=/trunk/; revision=25118
2006-12-10 18:40:30 +00:00
|
|
|
DPRINT("CSR: %s done\n", __FUNCTION__);
|
2006-10-30 18:45:22 +00:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
VOID
|
|
|
|
STDCALL
|
2004-07-03 17:15:02 +00:00
|
|
|
ClientConnectionThread(HANDLE ServerPort)
|
2003-12-02 11:38:47 +00:00
|
|
|
{
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
NTSTATUS Status;
|
2005-08-28 12:03:25 +00:00
|
|
|
BYTE RawRequest[LPC_MAX_DATA_LENGTH];
|
|
|
|
PCSR_API_MESSAGE Request = (PCSR_API_MESSAGE)RawRequest;
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
PCSR_API_MESSAGE Reply;
|
|
|
|
PCSRSS_PROCESS_DATA ProcessData;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2007-06-14 16:47:24 +00:00
|
|
|
DPRINT("CSR: %s called\n", __FUNCTION__);
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
|
2005-06-22 17:43:59 +00:00
|
|
|
/* Reply must be NULL at the first call to NtReplyWaitReceivePort */
|
2007-10-19 23:21:45 +00:00
|
|
|
Reply = NULL;
|
2005-06-22 17:43:59 +00:00
|
|
|
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
/* Loop and reply/wait for a new message */
|
|
|
|
for (;;)
|
2003-12-02 11:38:47 +00:00
|
|
|
{
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
/* Send the reply and wait for a new request */
|
2007-06-14 19:09:32 +00:00
|
|
|
Status = NtReplyWaitReceivePort(hApiPort,
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
0,
|
|
|
|
&Reply->Header,
|
2005-08-28 12:03:25 +00:00
|
|
|
&Request->Header);
|
2007-06-15 19:14:15 +00:00
|
|
|
/* Client died, continue */
|
|
|
|
if (Status == STATUS_INVALID_CID)
|
|
|
|
{
|
|
|
|
Reply = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
2003-12-02 11:38:47 +00:00
|
|
|
{
|
2006-11-05 20:31:35 +00:00
|
|
|
DPRINT1("NtReplyWaitReceivePort failed: %lx\n", Status);
|
|
|
|
break;
|
2003-12-02 11:38:47 +00:00
|
|
|
}
|
2006-10-30 14:20:45 +00:00
|
|
|
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
/* If the connection was closed, handle that */
|
2005-08-28 12:03:25 +00:00
|
|
|
if (Request->Header.u2.s2.Type == LPC_PORT_CLOSED)
|
2003-12-02 11:38:47 +00:00
|
|
|
{
|
2007-01-15 07:33:42 +00:00
|
|
|
DPRINT("Port died, oh well\n");
|
2005-08-28 12:03:25 +00:00
|
|
|
CsrFreeProcessData( Request->Header.ClientId.UniqueProcess );
|
2007-06-14 19:09:32 +00:00
|
|
|
break;
|
2003-12-02 11:38:47 +00:00
|
|
|
}
|
2005-08-16 23:05:33 +00:00
|
|
|
|
2006-10-30 18:45:22 +00:00
|
|
|
if (Request->Header.u2.s2.Type == LPC_CONNECTION_REQUEST)
|
|
|
|
{
|
|
|
|
CsrpHandleConnectionRequest((PPORT_MESSAGE)Request, ServerPort);
|
|
|
|
Reply = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2006-11-05 20:31:35 +00:00
|
|
|
if (Request->Header.u2.s2.Type == LPC_CLIENT_DIED)
|
|
|
|
{
|
2007-06-14 16:47:24 +00:00
|
|
|
DPRINT("Client died, oh well\n");
|
|
|
|
Reply = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((Request->Header.u2.s2.Type != LPC_ERROR_EVENT) &&
|
|
|
|
(Request->Header.u2.s2.Type != LPC_REQUEST))
|
|
|
|
{
|
|
|
|
DPRINT1("CSR: received message %d\n", Request->Header.u2.s2.Type);
|
2006-11-05 20:31:35 +00:00
|
|
|
Reply = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
DPRINT("CSR: Got CSR API: %x [Message Origin: %x]\n",
|
2006-11-05 20:31:35 +00:00
|
|
|
Request->Type,
|
|
|
|
Request->Header.ClientId.UniqueThread);
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
|
|
|
|
/* Get the Process Data */
|
2005-08-28 12:03:25 +00:00
|
|
|
ProcessData = CsrGetProcessData(Request->Header.ClientId.UniqueProcess);
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
if (ProcessData == NULL)
|
2004-07-03 17:15:02 +00:00
|
|
|
{
|
2005-12-01 22:38:03 +00:00
|
|
|
DPRINT1("Message %d: Unable to find data for process 0x%x\n",
|
2005-08-28 12:03:25 +00:00
|
|
|
Request->Header.u2.s2.Type,
|
|
|
|
Request->Header.ClientId.UniqueProcess);
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
break;
|
2005-05-08 04:07:56 +00:00
|
|
|
}
|
2005-12-01 22:38:03 +00:00
|
|
|
if (ProcessData->Terminated)
|
|
|
|
{
|
|
|
|
DPRINT1("Message %d: process %d already terminated\n",
|
2006-11-05 20:31:35 +00:00
|
|
|
Request->Type, (ULONG)Request->Header.ClientId.UniqueProcess);
|
2005-12-01 22:38:03 +00:00
|
|
|
continue;
|
|
|
|
}
|
2004-07-03 17:15:02 +00:00
|
|
|
|
2006-10-30 14:20:45 +00:00
|
|
|
/* Check if we got a hard error */
|
|
|
|
if (Request->Header.u2.s2.Type == LPC_ERROR_EVENT)
|
|
|
|
{
|
|
|
|
/* Call the Handler */
|
|
|
|
CsrHandleHardError(ProcessData, (PHARDERROR_MSG)Request);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Call the Handler */
|
|
|
|
CsrApiCallHandler(ProcessData, Request);
|
|
|
|
}
|
|
|
|
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
/* Send back the reply */
|
2005-08-28 12:03:25 +00:00
|
|
|
Reply = Request;
|
2003-12-02 11:38:47 +00:00
|
|
|
}
|
2006-11-05 20:31:35 +00:00
|
|
|
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
/* Close the port and exit the thread */
|
2007-06-14 19:09:32 +00:00
|
|
|
// NtClose(ServerPort);
|
2007-06-14 16:47:24 +00:00
|
|
|
|
|
|
|
DPRINT("CSR: %s done\n", __FUNCTION__);
|
2005-07-02 13:45:23 +00:00
|
|
|
RtlExitUserThread(STATUS_SUCCESS);
|
1999-12-22 14:48:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* NAME
|
2005-02-26 15:06:19 +00:00
|
|
|
* ServerApiPortThread/1
|
1999-12-22 14:48:30 +00:00
|
|
|
*
|
|
|
|
* DESCRIPTION
|
|
|
|
* Handle connection requests from clients to the port
|
|
|
|
* "\Windows\ApiPort".
|
|
|
|
*/
|
2007-06-14 19:09:32 +00:00
|
|
|
#if 0
|
2005-03-20 22:55:05 +00:00
|
|
|
DWORD STDCALL
|
2006-10-30 18:45:22 +00:00
|
|
|
ServerApiPortThread (HANDLE hApiListenPort)
|
1999-12-22 14:48:30 +00:00
|
|
|
{
|
2006-10-30 18:45:22 +00:00
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
BYTE RawRequest[sizeof(PORT_MESSAGE) + sizeof(CSR_CONNECTION_INFO)];
|
|
|
|
PPORT_MESSAGE Request = (PPORT_MESSAGE)RawRequest;
|
|
|
|
|
- Fix SleepEx.
- Put volatile statements in EX_RUNDOWN_REF, IRP, DEVICE_OBJECT, ERESOURCE, FILE_OBJECT, IO_REMOVE_LOCK, WORK_QUEUE_ITEM where required (thanks to Microsoft's changes in the WDK to mark the fields properly).
- Update FILE_OBJECT definition.
- Add some asserts to some I/O functions.
- Add stub support for File Objects created by XP+ Drivers which have File Object Extensions.
- Add some fixes to IopDeleteFile, including proper reference counting for the DO and VPB, as well as cleanup when the file is closed without a handle.
- Fix a bug in IopSecurityFile.
- Queue and unqueue IRPs in all I/O functions.
- Fully support IRP cancellation now.
- Fix critical bugs in NtDeviceIoControlFile and NtDeviceFsControlFile which were causing double queueing of IRPs and freeing of invalid memory, as well as invalid paramter checking for user-mode buffers.
- Add exhaustive validation checks to IoCreateFile, add more failure cases, and validate the EA buffer. Also support IO_ATTACH_DEVICE_API flag.
- Implement IoCreateStreamFileObjectEx and IoCreateStreamFileObjectLite and fix several bugs in the original implementation of IoCreateStreamFileObject.
- Fix a bug in RtlRaiseException.
- Update Io*ShareAccess routines to support XP+ style semantics related to special File Object flags which disable their use.
- Add validation to all Query/Set routines so that information clasess, lengths, buffers and alignment are properly checked.
- Also add an array for the proper acess rights that each query/set operation requires.
- Check backup/restore privileges during I/O File operations.
- Check traverse access during I/O File Operations.
- Check access privileges to the device during I/O file operations.
- Rename IopReferenceDeviceObject and also verify if an exclusive DO is trying to be invalidly opened.
- Support various extra security checks during I/O File/Device Parse Routine.
- Fix a bug during IopCleanupIrp so that we don't dereference the File OBject if this was a create operation.
- Fix some bogus asserts in IofCompleteRequest, and save the IRP Flags before signalling it's event, since the driver might've freed it behind our back.
- Fix a large bug in ObInsertObject which affected the insert of unnamed objects with forced security options (Such as process/threads).
- Fix the creation of the Process/Thread/Job Obejct Types to that security information is forced.
- Remove "Fix PS!!!" messages since the bug is now fixed and these objects now get proper security descriptors.
- Fix another bug in ObInsertObjet which wasn't properly validating user-mode objects and always assumed kernel mode.
- Silence multiple trace/checkpoint messages that have accumulated throughout time for various debugging purposes.
svn path=/trunk/; revision=25118
2006-12-10 18:40:30 +00:00
|
|
|
DPRINT("CSR: %s called", __FUNCTION__);
|
2006-10-30 18:45:22 +00:00
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
REMOTE_PORT_VIEW LpcRead;
|
|
|
|
LpcRead.Length = sizeof(LpcRead);
|
|
|
|
|
|
|
|
Status = NtListenPort (hApiListenPort, Request);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("CSR: NtListenPort() failed, status=%x\n", Status);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = CsrpHandleConnectionRequest(Request, hApiListenPort);
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("CSR: %s: SmpHandleConnectionRequest failed (Status=0x%08lx)\n",
|
|
|
|
__FUNCTION__, Status);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NtClose(hApiListenPort);
|
|
|
|
NtTerminateThread(NtCurrentThread(), Status);
|
|
|
|
return 0;
|
1999-12-22 14:48:30 +00:00
|
|
|
}
|
2007-06-14 19:09:32 +00:00
|
|
|
#endif
|
2000-02-27 02:12:07 +00:00
|
|
|
|
2005-02-26 15:06:19 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* NAME
|
|
|
|
* ServerSbApiPortThread/1
|
|
|
|
*
|
|
|
|
* DESCRIPTION
|
|
|
|
* Handle connection requests from SM to the port
|
2005-03-20 22:55:05 +00:00
|
|
|
* "\Windows\SbApiPort". We will accept only one
|
|
|
|
* connection request (from the SM).
|
2005-02-26 15:06:19 +00:00
|
|
|
*/
|
2005-03-20 22:55:05 +00:00
|
|
|
DWORD STDCALL
|
2006-10-30 18:45:22 +00:00
|
|
|
ServerSbApiPortThread (HANDLE hSbApiPortListen)
|
2005-02-26 15:06:19 +00:00
|
|
|
{
|
2007-06-14 19:09:32 +00:00
|
|
|
HANDLE hConnectedPort = (HANDLE) 0;
|
|
|
|
PORT_MESSAGE Request;
|
|
|
|
PVOID Context = NULL;
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
2006-01-08 09:00:02 +00:00
|
|
|
PPORT_MESSAGE Reply = NULL;
|
2005-02-26 15:06:19 +00:00
|
|
|
|
2007-06-14 19:09:32 +00:00
|
|
|
DPRINT("CSR: %s called\n", __FUNCTION__);
|
2005-03-20 22:55:05 +00:00
|
|
|
|
2005-08-16 23:05:33 +00:00
|
|
|
RtlZeroMemory(&Request, sizeof(PORT_MESSAGE));
|
2007-06-14 19:09:32 +00:00
|
|
|
Status = NtListenPort (hSbApiPortListen, & Request);
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("CSR: %s: NtListenPort(SB) failed (Status=0x%08lx)\n",
|
|
|
|
__FUNCTION__, Status);
|
|
|
|
} else {
|
|
|
|
DPRINT("-- 1\n");
|
|
|
|
Status = NtAcceptConnectPort(&hConnectedPort,
|
|
|
|
NULL,
|
|
|
|
&Request,
|
|
|
|
TRUE,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("CSR: %s: NtAcceptConnectPort() failed (Status=0x%08lx)\n",
|
|
|
|
__FUNCTION__, Status);
|
|
|
|
} else {
|
|
|
|
DPRINT("-- 2\n");
|
|
|
|
Status = NtCompleteConnectPort (hConnectedPort);
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("CSR: %s: NtCompleteConnectPort() failed (Status=0x%08lx)\n",
|
|
|
|
__FUNCTION__, Status);
|
|
|
|
} else {
|
|
|
|
DPRINT("-- 3\n");
|
|
|
|
/*
|
|
|
|
* Tell the init thread the SM gave the
|
|
|
|
* green light for boostrapping.
|
|
|
|
*/
|
|
|
|
Status = NtSetEvent (hBootstrapOk, NULL);
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("CSR: %s: NtSetEvent failed (Status=0x%08lx)\n",
|
|
|
|
__FUNCTION__, Status);
|
|
|
|
}
|
|
|
|
/* Wait for messages from the SM */
|
|
|
|
DPRINT("-- 4\n");
|
|
|
|
while (TRUE)
|
|
|
|
{
|
|
|
|
Status = NtReplyWaitReceivePort(hConnectedPort,
|
|
|
|
Context,
|
|
|
|
Reply,
|
|
|
|
&Request);
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("CSR: %s: NtReplyWaitReceivePort failed (Status=0x%08lx)\n",
|
|
|
|
__FUNCTION__, Status);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (Request.u2.s2.Type) //fix .h PORT_MESSAGE_TYPE(Request))
|
|
|
|
{
|
|
|
|
/* TODO */
|
|
|
|
default:
|
|
|
|
DPRINT1("CSR: %s received message (type=%d)\n",
|
|
|
|
__FUNCTION__, Request.u2.s2.Type);
|
|
|
|
}
|
|
|
|
DPRINT("-- 5\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DPRINT("CSR: %s: terminating!\n", __FUNCTION__);
|
|
|
|
if(hConnectedPort) NtClose (hConnectedPort);
|
|
|
|
NtClose (hSbApiPortListen);
|
|
|
|
NtTerminateThread (NtCurrentThread(), Status);
|
|
|
|
return 0;
|
2005-02-26 15:06:19 +00:00
|
|
|
}
|
|
|
|
|
2001-08-14 12:57:16 +00:00
|
|
|
/* EOF */
|