Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

share.c File Reference

#include "precomp.h"

Go to the source code of this file.

Functions

NTSTATUS ConsoleAddShare (IN ACCESS_MASK DesiredAccess, IN ULONG DesiredShareAccess, IN OUT PCONSOLE_SHARE_ACCESS ShareAccess, IN OUT PHANDLE_DATA HandleData)
NTSTATUS ConsoleDupShare (IN ACCESS_MASK DesiredAccess, IN ULONG DesiredShareAccess, IN OUT PCONSOLE_SHARE_ACCESS ShareAccess, IN OUT PHANDLE_DATA TargetHandleData)
NTSTATUS ConsoleRemoveShare (IN ULONG DesiredAccess, IN ULONG DesiredShareAccess, IN OUT PCONSOLE_SHARE_ACCESS ShareAccess)


Function Documentation

NTSTATUS ConsoleAddShare IN ACCESS_MASK  DesiredAccess,
IN ULONG  DesiredShareAccess,
IN OUT PCONSOLE_SHARE_ACCESS  ShareAccess,
IN OUT PHANDLE_DATA  HandleData
 

Definition at line 25 of file share.c.

Referenced by InitializeIoHandleTable(), ReadChars(), SrvCreateConsoleScreenBuffer(), and SrvOpenConsole().

00032 { 00033 ULONG Ocount; 00034 ULONG ReadAccess; 00035 ULONG WriteAccess; 00036 ULONG SharedRead; 00037 ULONG SharedWrite; 00038 00039 // 00040 // Set the access type in the file object for the current accessor. 00041 // 00042 00043 ReadAccess = (DesiredAccess & GENERIC_READ) != 0; 00044 WriteAccess = (DesiredAccess & GENERIC_WRITE) != 0; 00045 00046 SharedRead = (DesiredShareAccess & FILE_SHARE_READ) != 0; 00047 SharedWrite = (DesiredShareAccess & FILE_SHARE_WRITE) != 0; 00048 00049 // 00050 // Now check to see whether or not the desired accesses are compatible 00051 // with the way that the file is currently open. 00052 // 00053 00054 Ocount = ShareAccess->OpenCount; 00055 00056 if ( (ReadAccess && (ShareAccess->SharedRead < Ocount)) 00057 || 00058 (WriteAccess && (ShareAccess->SharedWrite < Ocount)) 00059 || 00060 ((ShareAccess->Readers != 0) && !SharedRead) 00061 || 00062 ((ShareAccess->Writers != 0) && !SharedWrite) 00063 ) { 00064 00065 // 00066 // The check failed. Simply return to the caller indicating that the 00067 // current open cannot access the file. 00068 // 00069 00070 return STATUS_SHARING_VIOLATION; 00071 00072 } else { 00073 00074 // 00075 // The check was successful. Update the counter information in the 00076 // shared access structure for this open request if the caller 00077 // specified that it should be updated. 00078 // 00079 00080 ShareAccess->OpenCount++; 00081 00082 ShareAccess->Readers += ReadAccess; 00083 ShareAccess->Writers += WriteAccess; 00084 00085 ShareAccess->SharedRead += SharedRead; 00086 ShareAccess->SharedWrite += SharedWrite; 00087 HandleData->Access = DesiredAccess; 00088 HandleData->ShareAccess = DesiredShareAccess; 00089 00090 return STATUS_SUCCESS; 00091 } 00092 }

NTSTATUS ConsoleDupShare IN ACCESS_MASK  DesiredAccess,
IN ULONG  DesiredShareAccess,
IN OUT PCONSOLE_SHARE_ACCESS  ShareAccess,
IN OUT PHANDLE_DATA  TargetHandleData
 

Definition at line 95 of file share.c.

References ASSERT, and FALSE.

Referenced by InheritIoHandleTable(), and SrvDuplicateHandle().

00102 { 00103 ULONG ReadAccess; 00104 ULONG WriteAccess; 00105 ULONG SharedRead; 00106 ULONG SharedWrite; 00107 00108 // 00109 // Set the access type in the file object for the current accessor. 00110 // 00111 00112 ReadAccess = (DesiredAccess & GENERIC_READ) != 0; 00113 WriteAccess = (DesiredAccess & GENERIC_WRITE) != 0; 00114 00115 SharedRead = (DesiredShareAccess & FILE_SHARE_READ) != 0; 00116 SharedWrite = (DesiredShareAccess & FILE_SHARE_WRITE) != 0; 00117 00118 if (ShareAccess->OpenCount == 0) { 00119 ASSERT (FALSE); 00120 return STATUS_SHARING_VIOLATION; 00121 } 00122 00123 ShareAccess->OpenCount++; 00124 00125 ShareAccess->Readers += ReadAccess; 00126 ShareAccess->Writers += WriteAccess; 00127 00128 ShareAccess->SharedRead += SharedRead; 00129 ShareAccess->SharedWrite += SharedWrite; 00130 00131 TargetHandleData->Access = DesiredAccess; 00132 TargetHandleData->ShareAccess = DesiredShareAccess; 00133 00134 return STATUS_SUCCESS; 00135 }

NTSTATUS ConsoleRemoveShare IN ULONG  DesiredAccess,
IN ULONG  DesiredShareAccess,
IN OUT PCONSOLE_SHARE_ACCESS  ShareAccess
 

Definition at line 138 of file share.c.

References ASSERT, and FALSE.

Referenced by CloseInputHandle(), and CloseOutputHandle().

00144 { 00145 ULONG ReadAccess; 00146 ULONG WriteAccess; 00147 ULONG SharedRead; 00148 ULONG SharedWrite; 00149 00150 // 00151 // Set the access type in the file object for the current accessor. 00152 // 00153 00154 ReadAccess = (DesiredAccess & GENERIC_READ) != 0; 00155 WriteAccess = (DesiredAccess & GENERIC_WRITE) != 0; 00156 00157 SharedRead = (DesiredShareAccess & FILE_SHARE_READ) != 0; 00158 SharedWrite = (DesiredShareAccess & FILE_SHARE_WRITE) != 0; 00159 00160 if (ShareAccess->OpenCount == 0) { 00161 ASSERT (FALSE); 00162 return STATUS_UNSUCCESSFUL; 00163 } 00164 00165 ShareAccess->OpenCount--; 00166 00167 ShareAccess->Readers -= ReadAccess; 00168 ShareAccess->Writers -= WriteAccess; 00169 00170 ShareAccess->SharedRead -= SharedRead; 00171 ShareAccess->SharedWrite -= SharedWrite; 00172 00173 return STATUS_SUCCESS; 00174 }


Generated on Sat May 15 19:45:39 2004 for test by doxygen 1.3.7