mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
Implemented IoCheckDesiredAccess() and IoGetInitialStack().
svn path=/trunk/; revision=3300
This commit is contained in:
parent
d6e258cc9e
commit
a79a9cbba6
2 changed files with 212 additions and 180 deletions
|
@ -1,4 +1,22 @@
|
||||||
/* $Id: process.c,v 1.11 2000/10/07 13:41:51 dwelch Exp $
|
/*
|
||||||
|
* ReactOS kernel
|
||||||
|
* Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
/* $Id: process.c,v 1.12 2002/07/24 17:49:31 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -19,32 +37,32 @@
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
PVOID STDCALL
|
PVOID STDCALL
|
||||||
IoGetInitialStack (VOID)
|
IoGetInitialStack(VOID)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
return(PsGetCurrentThread()->Tcb.InitialStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID STDCALL
|
VOID STDCALL
|
||||||
IoGetStackLimits (PULONG LowLimit,
|
IoGetStackLimits(OUT PULONG LowLimit,
|
||||||
PULONG HighLimit)
|
OUT PULONG HighLimit)
|
||||||
{
|
{
|
||||||
*LowLimit = (ULONG)NtCurrentTeb ()->Tib.StackLimit;
|
*LowLimit = (ULONG)NtCurrentTeb()->Tib.StackLimit;
|
||||||
*HighLimit = (ULONG)NtCurrentTeb ()->Tib.StackBase;
|
*HighLimit = (ULONG)NtCurrentTeb()->Tib.StackBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PEPROCESS STDCALL
|
PEPROCESS STDCALL
|
||||||
IoThreadToProcess (IN PETHREAD Thread)
|
IoThreadToProcess(IN PETHREAD Thread)
|
||||||
{
|
{
|
||||||
return (Thread->ThreadsProcess);
|
return(Thread->ThreadsProcess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PEPROCESS STDCALL
|
PEPROCESS STDCALL
|
||||||
IoGetRequestorProcess (IN PIRP Irp)
|
IoGetRequestorProcess(IN PIRP Irp)
|
||||||
{
|
{
|
||||||
return (Irp->Tail.Overlay.Thread->ThreadsProcess);
|
return(Irp->Tail.Overlay.Thread->ThreadsProcess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,21 +80,13 @@ IoGetRequestorProcess (IN PIRP Irp)
|
||||||
* processing policy.
|
* processing policy.
|
||||||
*/
|
*/
|
||||||
BOOLEAN STDCALL EXPORTED
|
BOOLEAN STDCALL EXPORTED
|
||||||
IoSetThreadHardErrorMode (IN BOOLEAN HardErrorEnabled)
|
IoSetThreadHardErrorMode(IN BOOLEAN HardErrorEnabled)
|
||||||
{
|
{
|
||||||
BOOLEAN PreviousHEM = NtCurrentTeb ()->HardErrorDisabled;
|
BOOLEAN PreviousHEM = NtCurrentTeb()->HardErrorDisabled;
|
||||||
|
|
||||||
NtCurrentTeb ()->HardErrorDisabled = (
|
NtCurrentTeb()->HardErrorDisabled = ((TRUE == HardErrorEnabled) ? FALSE : TRUE);
|
||||||
(TRUE == HardErrorEnabled)
|
|
||||||
? FALSE
|
return((TRUE == PreviousHEM) ? FALSE : TRUE);
|
||||||
: TRUE
|
|
||||||
);
|
|
||||||
return (
|
|
||||||
(TRUE == PreviousHEM)
|
|
||||||
? FALSE
|
|
||||||
: TRUE
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -1,4 +1,22 @@
|
||||||
/* $Id: share.c,v 1.5 2002/01/21 11:42:04 ekohl Exp $
|
/*
|
||||||
|
* ReactOS kernel
|
||||||
|
* Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
/* $Id: share.c,v 1.6 2002/07/24 17:49:31 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -63,203 +81,203 @@ IoUpdateShareAccess(PFILE_OBJECT FileObject,
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
IoCheckShareAccess(ACCESS_MASK DesiredAccess,
|
IoCheckShareAccess(IN ACCESS_MASK DesiredAccess,
|
||||||
ULONG DesiredShareAccess,
|
IN ULONG DesiredShareAccess,
|
||||||
PFILE_OBJECT FileObject,
|
IN PFILE_OBJECT FileObject,
|
||||||
PSHARE_ACCESS ShareAccess,
|
IN PSHARE_ACCESS ShareAccess,
|
||||||
BOOLEAN Update)
|
IN BOOLEAN Update)
|
||||||
{
|
{
|
||||||
BOOLEAN ReadAccess;
|
BOOLEAN ReadAccess;
|
||||||
BOOLEAN WriteAccess;
|
BOOLEAN WriteAccess;
|
||||||
BOOLEAN DeleteAccess;
|
BOOLEAN DeleteAccess;
|
||||||
BOOLEAN SharedRead;
|
BOOLEAN SharedRead;
|
||||||
BOOLEAN SharedWrite;
|
BOOLEAN SharedWrite;
|
||||||
BOOLEAN SharedDelete;
|
BOOLEAN SharedDelete;
|
||||||
|
|
||||||
ReadAccess = (DesiredAccess & (FILE_READ_DATA | FILE_EXECUTE));
|
ReadAccess = (DesiredAccess & (FILE_READ_DATA | FILE_EXECUTE));
|
||||||
WriteAccess = (DesiredAccess & (FILE_READ_DATA | FILE_APPEND_DATA));
|
WriteAccess = (DesiredAccess & (FILE_READ_DATA | FILE_APPEND_DATA));
|
||||||
DeleteAccess = (DesiredAccess & DELETE);
|
DeleteAccess = (DesiredAccess & DELETE);
|
||||||
|
|
||||||
FileObject->ReadAccess = ReadAccess;
|
FileObject->ReadAccess = ReadAccess;
|
||||||
FileObject->WriteAccess = WriteAccess;
|
FileObject->WriteAccess = WriteAccess;
|
||||||
FileObject->DeleteAccess = DeleteAccess;
|
FileObject->DeleteAccess = DeleteAccess;
|
||||||
|
|
||||||
if (!ReadAccess && !WriteAccess && !DeleteAccess)
|
if (!ReadAccess && !WriteAccess && !DeleteAccess)
|
||||||
{
|
{
|
||||||
return (STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedRead = (DesiredShareAccess & FILE_SHARE_READ);
|
SharedRead = (DesiredShareAccess & FILE_SHARE_READ);
|
||||||
SharedWrite = (DesiredShareAccess & FILE_SHARE_WRITE);
|
SharedWrite = (DesiredShareAccess & FILE_SHARE_WRITE);
|
||||||
SharedDelete = (DesiredShareAccess & FILE_SHARE_DELETE);
|
SharedDelete = (DesiredShareAccess & FILE_SHARE_DELETE);
|
||||||
|
|
||||||
FileObject->SharedRead = SharedRead;
|
FileObject->SharedRead = SharedRead;
|
||||||
FileObject->SharedWrite = SharedWrite;
|
FileObject->SharedWrite = SharedWrite;
|
||||||
FileObject->SharedDelete = SharedDelete;
|
FileObject->SharedDelete = SharedDelete;
|
||||||
|
|
||||||
if (ReadAccess)
|
if (ReadAccess)
|
||||||
{
|
{
|
||||||
if (ShareAccess->SharedRead < ShareAccess->OpenCount)
|
if (ShareAccess->SharedRead < ShareAccess->OpenCount)
|
||||||
return (STATUS_SHARING_VIOLATION);
|
return(STATUS_SHARING_VIOLATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WriteAccess)
|
if (WriteAccess)
|
||||||
{
|
{
|
||||||
if (ShareAccess->SharedWrite < ShareAccess->OpenCount)
|
if (ShareAccess->SharedWrite < ShareAccess->OpenCount)
|
||||||
return (STATUS_SHARING_VIOLATION);
|
return(STATUS_SHARING_VIOLATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DeleteAccess)
|
if (DeleteAccess)
|
||||||
{
|
{
|
||||||
if (ShareAccess->SharedDelete < ShareAccess->OpenCount)
|
if (ShareAccess->SharedDelete < ShareAccess->OpenCount)
|
||||||
return (STATUS_SHARING_VIOLATION);
|
return(STATUS_SHARING_VIOLATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ShareAccess->Readers != 0)
|
if (ShareAccess->Readers != 0)
|
||||||
{
|
{
|
||||||
if (SharedRead == FALSE)
|
if (SharedRead == FALSE)
|
||||||
return (STATUS_SHARING_VIOLATION);
|
return(STATUS_SHARING_VIOLATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ShareAccess->Writers != 0)
|
if (ShareAccess->Writers != 0)
|
||||||
{
|
{
|
||||||
if (SharedWrite == FALSE)
|
if (SharedWrite == FALSE)
|
||||||
return (STATUS_SHARING_VIOLATION);
|
return(STATUS_SHARING_VIOLATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ShareAccess->Deleters != 0)
|
if (ShareAccess->Deleters != 0)
|
||||||
{
|
{
|
||||||
if (SharedDelete == FALSE)
|
if (SharedDelete == FALSE)
|
||||||
return (STATUS_SHARING_VIOLATION);
|
return(STATUS_SHARING_VIOLATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Update == TRUE)
|
if (Update == TRUE)
|
||||||
{
|
{
|
||||||
ShareAccess->OpenCount++;
|
ShareAccess->OpenCount++;
|
||||||
|
|
||||||
if (ReadAccess == TRUE)
|
if (ReadAccess == TRUE)
|
||||||
ShareAccess->Readers++;
|
ShareAccess->Readers++;
|
||||||
|
|
||||||
if (WriteAccess == TRUE)
|
if (WriteAccess == TRUE)
|
||||||
ShareAccess->Writers++;
|
ShareAccess->Writers++;
|
||||||
|
|
||||||
if (DeleteAccess == TRUE)
|
if (DeleteAccess == TRUE)
|
||||||
ShareAccess->Deleters++;
|
ShareAccess->Deleters++;
|
||||||
|
|
||||||
if (SharedRead == TRUE)
|
if (SharedRead == TRUE)
|
||||||
ShareAccess->SharedRead++;
|
ShareAccess->SharedRead++;
|
||||||
|
|
||||||
if (SharedWrite == TRUE)
|
if (SharedWrite == TRUE)
|
||||||
ShareAccess->SharedWrite++;
|
ShareAccess->SharedWrite++;
|
||||||
|
|
||||||
if (SharedDelete == TRUE)
|
if (SharedDelete == TRUE)
|
||||||
ShareAccess->SharedDelete++;
|
ShareAccess->SharedDelete++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID STDCALL
|
VOID STDCALL
|
||||||
IoRemoveShareAccess(PFILE_OBJECT FileObject,
|
IoRemoveShareAccess(IN PFILE_OBJECT FileObject,
|
||||||
PSHARE_ACCESS ShareAccess)
|
IN PSHARE_ACCESS ShareAccess)
|
||||||
{
|
{
|
||||||
if ((FileObject->ReadAccess == FALSE) &&
|
if ((FileObject->ReadAccess == FALSE) &&
|
||||||
(FileObject->WriteAccess == FALSE) &&
|
(FileObject->WriteAccess == FALSE) &&
|
||||||
(FileObject->DeleteAccess == FALSE))
|
(FileObject->DeleteAccess == FALSE))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShareAccess->OpenCount--;
|
ShareAccess->OpenCount--;
|
||||||
|
|
||||||
if (FileObject->ReadAccess == TRUE)
|
if (FileObject->ReadAccess == TRUE)
|
||||||
{
|
{
|
||||||
ShareAccess->Readers--;
|
ShareAccess->Readers--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FileObject->WriteAccess == TRUE)
|
if (FileObject->WriteAccess == TRUE)
|
||||||
{
|
{
|
||||||
ShareAccess->Writers--;
|
ShareAccess->Writers--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FileObject->DeleteAccess == TRUE)
|
if (FileObject->DeleteAccess == TRUE)
|
||||||
{
|
{
|
||||||
ShareAccess->Deleters--;
|
ShareAccess->Deleters--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FileObject->SharedRead == TRUE)
|
if (FileObject->SharedRead == TRUE)
|
||||||
{
|
{
|
||||||
ShareAccess->SharedRead--;
|
ShareAccess->SharedRead--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FileObject->SharedWrite == TRUE)
|
if (FileObject->SharedWrite == TRUE)
|
||||||
{
|
{
|
||||||
ShareAccess->SharedWrite--;
|
ShareAccess->SharedWrite--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FileObject->SharedDelete == TRUE)
|
if (FileObject->SharedDelete == TRUE)
|
||||||
{
|
{
|
||||||
ShareAccess->SharedDelete--;
|
ShareAccess->SharedDelete--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID STDCALL
|
VOID STDCALL
|
||||||
IoSetShareAccess(ACCESS_MASK DesiredAccess,
|
IoSetShareAccess(IN ACCESS_MASK DesiredAccess,
|
||||||
ULONG DesiredShareAccess,
|
IN ULONG DesiredShareAccess,
|
||||||
PFILE_OBJECT FileObject,
|
IN PFILE_OBJECT FileObject,
|
||||||
PSHARE_ACCESS ShareAccess)
|
OUT PSHARE_ACCESS ShareAccess)
|
||||||
{
|
{
|
||||||
BOOLEAN ReadAccess;
|
BOOLEAN ReadAccess;
|
||||||
BOOLEAN WriteAccess;
|
BOOLEAN WriteAccess;
|
||||||
BOOLEAN DeleteAccess;
|
BOOLEAN DeleteAccess;
|
||||||
BOOLEAN SharedRead;
|
BOOLEAN SharedRead;
|
||||||
BOOLEAN SharedWrite;
|
BOOLEAN SharedWrite;
|
||||||
BOOLEAN SharedDelete;
|
BOOLEAN SharedDelete;
|
||||||
|
|
||||||
ReadAccess = (DesiredAccess & (FILE_READ_DATA | FILE_EXECUTE));
|
ReadAccess = (DesiredAccess & (FILE_READ_DATA | FILE_EXECUTE));
|
||||||
WriteAccess = (DesiredAccess & (FILE_READ_DATA | FILE_APPEND_DATA));
|
WriteAccess = (DesiredAccess & (FILE_READ_DATA | FILE_APPEND_DATA));
|
||||||
DeleteAccess = (DesiredAccess & DELETE);
|
DeleteAccess = (DesiredAccess & DELETE);
|
||||||
|
|
||||||
FileObject->ReadAccess = ReadAccess;
|
FileObject->ReadAccess = ReadAccess;
|
||||||
FileObject->WriteAccess = WriteAccess;
|
FileObject->WriteAccess = WriteAccess;
|
||||||
FileObject->DeleteAccess = DeleteAccess;
|
FileObject->DeleteAccess = DeleteAccess;
|
||||||
|
|
||||||
if (!ReadAccess && !WriteAccess && !DeleteAccess)
|
if (!ReadAccess && !WriteAccess && !DeleteAccess)
|
||||||
{
|
{
|
||||||
FileObject->SharedRead = FALSE;
|
FileObject->SharedRead = FALSE;
|
||||||
FileObject->SharedWrite = FALSE;
|
FileObject->SharedWrite = FALSE;
|
||||||
FileObject->SharedDelete = FALSE;
|
FileObject->SharedDelete = FALSE;
|
||||||
|
|
||||||
ShareAccess->OpenCount = 0;
|
ShareAccess->OpenCount = 0;
|
||||||
ShareAccess->Readers = 0;
|
ShareAccess->Readers = 0;
|
||||||
ShareAccess->Writers = 0;
|
ShareAccess->Writers = 0;
|
||||||
ShareAccess->Deleters = 0;
|
ShareAccess->Deleters = 0;
|
||||||
|
|
||||||
ShareAccess->SharedRead = 0;
|
ShareAccess->SharedRead = 0;
|
||||||
ShareAccess->SharedWrite = 0;
|
ShareAccess->SharedWrite = 0;
|
||||||
ShareAccess->SharedDelete = 0;
|
ShareAccess->SharedDelete = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SharedRead = (DesiredShareAccess & FILE_SHARE_READ);
|
SharedRead = (DesiredShareAccess & FILE_SHARE_READ);
|
||||||
SharedWrite = (DesiredShareAccess & FILE_SHARE_WRITE);
|
SharedWrite = (DesiredShareAccess & FILE_SHARE_WRITE);
|
||||||
SharedDelete = (DesiredShareAccess & FILE_SHARE_DELETE);
|
SharedDelete = (DesiredShareAccess & FILE_SHARE_DELETE);
|
||||||
|
|
||||||
FileObject->SharedRead = SharedRead;
|
FileObject->SharedRead = SharedRead;
|
||||||
FileObject->SharedWrite = SharedWrite;
|
FileObject->SharedWrite = SharedWrite;
|
||||||
FileObject->SharedDelete = SharedDelete;
|
FileObject->SharedDelete = SharedDelete;
|
||||||
|
|
||||||
ShareAccess->OpenCount = 1;
|
ShareAccess->OpenCount = 1;
|
||||||
ShareAccess->Readers = (ReadAccess) ? 1 : 0;
|
ShareAccess->Readers = (ReadAccess) ? 1 : 0;
|
||||||
ShareAccess->Writers = (WriteAccess) ? 1 : 0;
|
ShareAccess->Writers = (WriteAccess) ? 1 : 0;
|
||||||
ShareAccess->Deleters = (DeleteAccess) ? 1 : 0;
|
ShareAccess->Deleters = (DeleteAccess) ? 1 : 0;
|
||||||
|
|
||||||
ShareAccess->SharedRead = (SharedRead) ? 1 : 0;
|
ShareAccess->SharedRead = (SharedRead) ? 1 : 0;
|
||||||
ShareAccess->SharedWrite = (SharedWrite) ? 1 : 0;
|
ShareAccess->SharedWrite = (SharedWrite) ? 1 : 0;
|
||||||
ShareAccess->SharedDelete = (SharedDelete) ? 1 : 0;
|
ShareAccess->SharedDelete = (SharedDelete) ? 1 : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -267,8 +285,12 @@ NTSTATUS STDCALL
|
||||||
IoCheckDesiredAccess(IN OUT PACCESS_MASK DesiredAccess,
|
IoCheckDesiredAccess(IN OUT PACCESS_MASK DesiredAccess,
|
||||||
IN ACCESS_MASK GrantedAccess)
|
IN ACCESS_MASK GrantedAccess)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
RtlMapGenericMask(DesiredAccess,
|
||||||
return(STATUS_NOT_IMPLEMENTED);
|
IoFileObjectType->Mapping);
|
||||||
|
if ((*DesiredAccess & GrantedAccess) != GrantedAccess)
|
||||||
|
return(STATUS_ACCESS_DENIED);
|
||||||
|
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue