Implemented IoCheckDesiredAccess() and IoGetInitialStack().

svn path=/trunk/; revision=3300
This commit is contained in:
Eric Kohl 2002-07-24 17:49:31 +00:00
parent d6e258cc9e
commit a79a9cbba6
2 changed files with 212 additions and 180 deletions

View file

@ -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
* PROJECT: ReactOS kernel
@ -19,32 +37,32 @@
/* FUNCTIONS *****************************************************************/
PVOID STDCALL
IoGetInitialStack (VOID)
IoGetInitialStack(VOID)
{
UNIMPLEMENTED;
return(PsGetCurrentThread()->Tcb.InitialStack);
}
VOID STDCALL
IoGetStackLimits (PULONG LowLimit,
PULONG HighLimit)
IoGetStackLimits(OUT PULONG LowLimit,
OUT PULONG HighLimit)
{
*LowLimit = (ULONG)NtCurrentTeb ()->Tib.StackLimit;
*HighLimit = (ULONG)NtCurrentTeb ()->Tib.StackBase;
*LowLimit = (ULONG)NtCurrentTeb()->Tib.StackLimit;
*HighLimit = (ULONG)NtCurrentTeb()->Tib.StackBase;
}
PEPROCESS STDCALL
IoThreadToProcess (IN PETHREAD Thread)
IoThreadToProcess(IN PETHREAD Thread)
{
return (Thread->ThreadsProcess);
return(Thread->ThreadsProcess);
}
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.
*/
BOOLEAN STDCALL EXPORTED
IoSetThreadHardErrorMode (IN BOOLEAN HardErrorEnabled)
IoSetThreadHardErrorMode(IN BOOLEAN HardErrorEnabled)
{
BOOLEAN PreviousHEM = NtCurrentTeb ()->HardErrorDisabled;
NtCurrentTeb ()->HardErrorDisabled = (
(TRUE == HardErrorEnabled)
? FALSE
: TRUE
);
return (
(TRUE == PreviousHEM)
? FALSE
: TRUE
);
BOOLEAN PreviousHEM = NtCurrentTeb()->HardErrorDisabled;
NtCurrentTeb()->HardErrorDisabled = ((TRUE == HardErrorEnabled) ? FALSE : TRUE);
return((TRUE == PreviousHEM) ? FALSE : TRUE);
}
/* EOF */

View file

@ -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
* PROJECT: ReactOS kernel
@ -63,203 +81,203 @@ IoUpdateShareAccess(PFILE_OBJECT FileObject,
NTSTATUS STDCALL
IoCheckShareAccess(ACCESS_MASK DesiredAccess,
ULONG DesiredShareAccess,
PFILE_OBJECT FileObject,
PSHARE_ACCESS ShareAccess,
BOOLEAN Update)
IoCheckShareAccess(IN ACCESS_MASK DesiredAccess,
IN ULONG DesiredShareAccess,
IN PFILE_OBJECT FileObject,
IN PSHARE_ACCESS ShareAccess,
IN BOOLEAN Update)
{
BOOLEAN ReadAccess;
BOOLEAN WriteAccess;
BOOLEAN DeleteAccess;
BOOLEAN SharedRead;
BOOLEAN SharedWrite;
BOOLEAN SharedDelete;
BOOLEAN ReadAccess;
BOOLEAN WriteAccess;
BOOLEAN DeleteAccess;
BOOLEAN SharedRead;
BOOLEAN SharedWrite;
BOOLEAN SharedDelete;
ReadAccess = (DesiredAccess & (FILE_READ_DATA | FILE_EXECUTE));
WriteAccess = (DesiredAccess & (FILE_READ_DATA | FILE_APPEND_DATA));
DeleteAccess = (DesiredAccess & DELETE);
ReadAccess = (DesiredAccess & (FILE_READ_DATA | FILE_EXECUTE));
WriteAccess = (DesiredAccess & (FILE_READ_DATA | FILE_APPEND_DATA));
DeleteAccess = (DesiredAccess & DELETE);
FileObject->ReadAccess = ReadAccess;
FileObject->WriteAccess = WriteAccess;
FileObject->DeleteAccess = DeleteAccess;
FileObject->ReadAccess = ReadAccess;
FileObject->WriteAccess = WriteAccess;
FileObject->DeleteAccess = DeleteAccess;
if (!ReadAccess && !WriteAccess && !DeleteAccess)
{
return (STATUS_SUCCESS);
}
if (!ReadAccess && !WriteAccess && !DeleteAccess)
{
return(STATUS_SUCCESS);
}
SharedRead = (DesiredShareAccess & FILE_SHARE_READ);
SharedWrite = (DesiredShareAccess & FILE_SHARE_WRITE);
SharedDelete = (DesiredShareAccess & FILE_SHARE_DELETE);
SharedRead = (DesiredShareAccess & FILE_SHARE_READ);
SharedWrite = (DesiredShareAccess & FILE_SHARE_WRITE);
SharedDelete = (DesiredShareAccess & FILE_SHARE_DELETE);
FileObject->SharedRead = SharedRead;
FileObject->SharedWrite = SharedWrite;
FileObject->SharedDelete = SharedDelete;
FileObject->SharedRead = SharedRead;
FileObject->SharedWrite = SharedWrite;
FileObject->SharedDelete = SharedDelete;
if (ReadAccess)
{
if (ShareAccess->SharedRead < ShareAccess->OpenCount)
return (STATUS_SHARING_VIOLATION);
}
if (ReadAccess)
{
if (ShareAccess->SharedRead < ShareAccess->OpenCount)
return(STATUS_SHARING_VIOLATION);
}
if (WriteAccess)
{
if (ShareAccess->SharedWrite < ShareAccess->OpenCount)
return (STATUS_SHARING_VIOLATION);
}
if (WriteAccess)
{
if (ShareAccess->SharedWrite < ShareAccess->OpenCount)
return(STATUS_SHARING_VIOLATION);
}
if (DeleteAccess)
{
if (ShareAccess->SharedDelete < ShareAccess->OpenCount)
return (STATUS_SHARING_VIOLATION);
}
if (DeleteAccess)
{
if (ShareAccess->SharedDelete < ShareAccess->OpenCount)
return(STATUS_SHARING_VIOLATION);
}
if (ShareAccess->Readers != 0)
{
if (SharedRead == FALSE)
return (STATUS_SHARING_VIOLATION);
}
if (ShareAccess->Readers != 0)
{
if (SharedRead == FALSE)
return(STATUS_SHARING_VIOLATION);
}
if (ShareAccess->Writers != 0)
{
if (SharedWrite == FALSE)
return (STATUS_SHARING_VIOLATION);
}
if (ShareAccess->Writers != 0)
{
if (SharedWrite == FALSE)
return(STATUS_SHARING_VIOLATION);
}
if (ShareAccess->Deleters != 0)
{
if (SharedDelete == FALSE)
return (STATUS_SHARING_VIOLATION);
}
if (ShareAccess->Deleters != 0)
{
if (SharedDelete == FALSE)
return(STATUS_SHARING_VIOLATION);
}
if (Update == TRUE)
{
ShareAccess->OpenCount++;
if (Update == TRUE)
{
ShareAccess->OpenCount++;
if (ReadAccess == TRUE)
ShareAccess->Readers++;
if (ReadAccess == TRUE)
ShareAccess->Readers++;
if (WriteAccess == TRUE)
ShareAccess->Writers++;
if (WriteAccess == TRUE)
ShareAccess->Writers++;
if (DeleteAccess == TRUE)
ShareAccess->Deleters++;
if (DeleteAccess == TRUE)
ShareAccess->Deleters++;
if (SharedRead == TRUE)
ShareAccess->SharedRead++;
if (SharedRead == TRUE)
ShareAccess->SharedRead++;
if (SharedWrite == TRUE)
ShareAccess->SharedWrite++;
if (SharedWrite == TRUE)
ShareAccess->SharedWrite++;
if (SharedDelete == TRUE)
ShareAccess->SharedDelete++;
}
if (SharedDelete == TRUE)
ShareAccess->SharedDelete++;
}
return (STATUS_SUCCESS);
return(STATUS_SUCCESS);
}
VOID STDCALL
IoRemoveShareAccess(PFILE_OBJECT FileObject,
PSHARE_ACCESS ShareAccess)
IoRemoveShareAccess(IN PFILE_OBJECT FileObject,
IN PSHARE_ACCESS ShareAccess)
{
if ((FileObject->ReadAccess == FALSE) &&
(FileObject->WriteAccess == FALSE) &&
(FileObject->DeleteAccess == FALSE))
{
return;
}
if ((FileObject->ReadAccess == FALSE) &&
(FileObject->WriteAccess == FALSE) &&
(FileObject->DeleteAccess == FALSE))
{
return;
}
ShareAccess->OpenCount--;
ShareAccess->OpenCount--;
if (FileObject->ReadAccess == TRUE)
{
ShareAccess->Readers--;
}
if (FileObject->ReadAccess == TRUE)
{
ShareAccess->Readers--;
}
if (FileObject->WriteAccess == TRUE)
{
ShareAccess->Writers--;
}
if (FileObject->WriteAccess == TRUE)
{
ShareAccess->Writers--;
}
if (FileObject->DeleteAccess == TRUE)
{
ShareAccess->Deleters--;
}
if (FileObject->DeleteAccess == TRUE)
{
ShareAccess->Deleters--;
}
if (FileObject->SharedRead == TRUE)
{
ShareAccess->SharedRead--;
}
if (FileObject->SharedRead == TRUE)
{
ShareAccess->SharedRead--;
}
if (FileObject->SharedWrite == TRUE)
{
ShareAccess->SharedWrite--;
}
if (FileObject->SharedWrite == TRUE)
{
ShareAccess->SharedWrite--;
}
if (FileObject->SharedDelete == TRUE)
{
ShareAccess->SharedDelete--;
}
if (FileObject->SharedDelete == TRUE)
{
ShareAccess->SharedDelete--;
}
}
VOID STDCALL
IoSetShareAccess(ACCESS_MASK DesiredAccess,
ULONG DesiredShareAccess,
PFILE_OBJECT FileObject,
PSHARE_ACCESS ShareAccess)
IoSetShareAccess(IN ACCESS_MASK DesiredAccess,
IN ULONG DesiredShareAccess,
IN PFILE_OBJECT FileObject,
OUT PSHARE_ACCESS ShareAccess)
{
BOOLEAN ReadAccess;
BOOLEAN WriteAccess;
BOOLEAN DeleteAccess;
BOOLEAN SharedRead;
BOOLEAN SharedWrite;
BOOLEAN SharedDelete;
BOOLEAN ReadAccess;
BOOLEAN WriteAccess;
BOOLEAN DeleteAccess;
BOOLEAN SharedRead;
BOOLEAN SharedWrite;
BOOLEAN SharedDelete;
ReadAccess = (DesiredAccess & (FILE_READ_DATA | FILE_EXECUTE));
WriteAccess = (DesiredAccess & (FILE_READ_DATA | FILE_APPEND_DATA));
DeleteAccess = (DesiredAccess & DELETE);
ReadAccess = (DesiredAccess & (FILE_READ_DATA | FILE_EXECUTE));
WriteAccess = (DesiredAccess & (FILE_READ_DATA | FILE_APPEND_DATA));
DeleteAccess = (DesiredAccess & DELETE);
FileObject->ReadAccess = ReadAccess;
FileObject->WriteAccess = WriteAccess;
FileObject->DeleteAccess = DeleteAccess;
FileObject->ReadAccess = ReadAccess;
FileObject->WriteAccess = WriteAccess;
FileObject->DeleteAccess = DeleteAccess;
if (!ReadAccess && !WriteAccess && !DeleteAccess)
{
FileObject->SharedRead = FALSE;
FileObject->SharedWrite = FALSE;
FileObject->SharedDelete = FALSE;
if (!ReadAccess && !WriteAccess && !DeleteAccess)
{
FileObject->SharedRead = FALSE;
FileObject->SharedWrite = FALSE;
FileObject->SharedDelete = FALSE;
ShareAccess->OpenCount = 0;
ShareAccess->Readers = 0;
ShareAccess->Writers = 0;
ShareAccess->Deleters = 0;
ShareAccess->OpenCount = 0;
ShareAccess->Readers = 0;
ShareAccess->Writers = 0;
ShareAccess->Deleters = 0;
ShareAccess->SharedRead = 0;
ShareAccess->SharedWrite = 0;
ShareAccess->SharedDelete = 0;
}
else
{
SharedRead = (DesiredShareAccess & FILE_SHARE_READ);
SharedWrite = (DesiredShareAccess & FILE_SHARE_WRITE);
SharedDelete = (DesiredShareAccess & FILE_SHARE_DELETE);
ShareAccess->SharedRead = 0;
ShareAccess->SharedWrite = 0;
ShareAccess->SharedDelete = 0;
}
else
{
SharedRead = (DesiredShareAccess & FILE_SHARE_READ);
SharedWrite = (DesiredShareAccess & FILE_SHARE_WRITE);
SharedDelete = (DesiredShareAccess & FILE_SHARE_DELETE);
FileObject->SharedRead = SharedRead;
FileObject->SharedWrite = SharedWrite;
FileObject->SharedDelete = SharedDelete;
FileObject->SharedRead = SharedRead;
FileObject->SharedWrite = SharedWrite;
FileObject->SharedDelete = SharedDelete;
ShareAccess->OpenCount = 1;
ShareAccess->Readers = (ReadAccess) ? 1 : 0;
ShareAccess->Writers = (WriteAccess) ? 1 : 0;
ShareAccess->Deleters = (DeleteAccess) ? 1 : 0;
ShareAccess->OpenCount = 1;
ShareAccess->Readers = (ReadAccess) ? 1 : 0;
ShareAccess->Writers = (WriteAccess) ? 1 : 0;
ShareAccess->Deleters = (DeleteAccess) ? 1 : 0;
ShareAccess->SharedRead = (SharedRead) ? 1 : 0;
ShareAccess->SharedWrite = (SharedWrite) ? 1 : 0;
ShareAccess->SharedDelete = (SharedDelete) ? 1 : 0;
}
ShareAccess->SharedRead = (SharedRead) ? 1 : 0;
ShareAccess->SharedWrite = (SharedWrite) ? 1 : 0;
ShareAccess->SharedDelete = (SharedDelete) ? 1 : 0;
}
}
@ -267,8 +285,12 @@ NTSTATUS STDCALL
IoCheckDesiredAccess(IN OUT PACCESS_MASK DesiredAccess,
IN ACCESS_MASK GrantedAccess)
{
UNIMPLEMENTED;
return(STATUS_NOT_IMPLEMENTED);
RtlMapGenericMask(DesiredAccess,
IoFileObjectType->Mapping);
if ((*DesiredAccess & GrantedAccess) != GrantedAccess)
return(STATUS_ACCESS_DENIED);
return(STATUS_SUCCESS);
}