mirror of
https://github.com/reactos/reactos.git
synced 2024-12-26 00:54:40 +00:00
- Fixed the buffer handling for ioctl requests and direct access
input buffers (METHODE_IN_DIRECT, output buffer from caller). svn path=/trunk/; revision=4388
This commit is contained in:
parent
99146c71b3
commit
a9b1cd3b93
7 changed files with 57 additions and 50 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $Id: blue.c,v 1.36 2003/03/09 21:43:37 hbirr Exp $
|
||||
/* $Id: blue.c,v 1.37 2003/03/21 21:09:40 hbirr Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -454,7 +454,7 @@ ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
|||
offset = (Buf->dwCoord.Y * DeviceExtension->Columns * 2) +
|
||||
(Buf->dwCoord.X * 2) + 1;
|
||||
|
||||
for (dwCount = 0; dwCount < stk->Parameters.Write.Length; dwCount++, pAttr++)
|
||||
for (dwCount = 0; dwCount < stk->Parameters.DeviceIoControl.OutputBufferLength; dwCount++, pAttr++)
|
||||
{
|
||||
(char) *pAttr = vidmem[offset + (dwCount * 2)];
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
|||
offset = (pCoord->Y * DeviceExtension->Columns * 2) +
|
||||
(pCoord->X * 2) + 1;
|
||||
|
||||
for (dwCount = 0; dwCount < (stk->Parameters.Write.Length - sizeof( COORD )); dwCount++, pAttr++)
|
||||
for (dwCount = 0; dwCount < (stk->Parameters.DeviceIoControl.InputBufferLength - sizeof( COORD )); dwCount++, pAttr++)
|
||||
{
|
||||
vidmem[offset + (dwCount * 2)] = *pAttr;
|
||||
}
|
||||
|
@ -531,7 +531,7 @@ ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
|||
offset = (Buf->dwCoord.Y * DeviceExtension->Columns * 2) +
|
||||
(Buf->dwCoord.X * 2);
|
||||
|
||||
for (dwCount = 0; dwCount < stk->Parameters.Write.Length; dwCount++, pChar++)
|
||||
for (dwCount = 0; dwCount < stk->Parameters.DeviceIoControl.OutputBufferLength; dwCount++, pChar++)
|
||||
{
|
||||
*pChar = vidmem[offset + (dwCount * 2)];
|
||||
}
|
||||
|
@ -556,7 +556,7 @@ ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
|||
offset = (pCoord->Y * DeviceExtension->Columns * 2) +
|
||||
(pCoord->X * 2);
|
||||
|
||||
for (dwCount = 0; dwCount < (stk->Parameters.Write.Length - sizeof( COORD )); dwCount++, pChar++)
|
||||
for (dwCount = 0; dwCount < (stk->Parameters.DeviceIoControl.InputBufferLength - sizeof( COORD )); dwCount++, pChar++)
|
||||
{
|
||||
vidmem[offset + (dwCount * 2)] = *pChar;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: class2.c,v 1.31 2003/01/28 17:33:18 hbirr Exp $
|
||||
/* $Id: class2.c,v 1.32 2003/03/21 21:09:41 hbirr Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -1245,12 +1245,12 @@ ScsiClassSendSrbSynchronous(PDEVICE_OBJECT DeviceObject,
|
|||
{
|
||||
if (WriteToDevice == TRUE)
|
||||
{
|
||||
RequestType = IOCTL_SCSI_EXECUTE_OUT;
|
||||
Srb->SrbFlags = SRB_FLAGS_DATA_OUT;
|
||||
RequestType = IOCTL_SCSI_EXECUTE_IN; // needs _in_ to the device
|
||||
Srb->SrbFlags = SRB_FLAGS_DATA_OUT; // needs _out_ from the caller
|
||||
}
|
||||
else
|
||||
{
|
||||
RequestType = IOCTL_SCSI_EXECUTE_IN;
|
||||
RequestType = IOCTL_SCSI_EXECUTE_OUT;
|
||||
Srb->SrbFlags = SRB_FLAGS_DATA_IN;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,17 +12,17 @@
|
|||
|
||||
|
||||
#define IOCTL_CONSOLE_FILL_OUTPUT_ATTRIBUTE CTL_CODE(FILE_DEVICE_SCREEN, 0x810, METHOD_BUFFERED, FILE_WRITE_ACCESS)
|
||||
#define IOCTL_CONSOLE_READ_OUTPUT_ATTRIBUTE CTL_CODE(FILE_DEVICE_SCREEN, 0x811, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
|
||||
#define IOCTL_CONSOLE_WRITE_OUTPUT_ATTRIBUTE CTL_CODE(FILE_DEVICE_SCREEN, 0x812, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
|
||||
#define IOCTL_CONSOLE_READ_OUTPUT_ATTRIBUTE CTL_CODE(FILE_DEVICE_SCREEN, 0x811, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
|
||||
#define IOCTL_CONSOLE_WRITE_OUTPUT_ATTRIBUTE CTL_CODE(FILE_DEVICE_SCREEN, 0x812, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
|
||||
#define IOCTL_CONSOLE_SET_TEXT_ATTRIBUTE CTL_CODE(FILE_DEVICE_SCREEN, 0x813, METHOD_BUFFERED, FILE_WRITE_ACCESS)
|
||||
|
||||
|
||||
#define IOCTL_CONSOLE_FILL_OUTPUT_CHARACTER CTL_CODE(FILE_DEVICE_SCREEN, 0x820, METHOD_BUFFERED, FILE_WRITE_ACCESS)
|
||||
#define IOCTL_CONSOLE_READ_OUTPUT_CHARACTER CTL_CODE(FILE_DEVICE_SCREEN, 0x821, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
|
||||
#define IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER CTL_CODE(FILE_DEVICE_SCREEN, 0x822, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
|
||||
#define IOCTL_CONSOLE_READ_OUTPUT_CHARACTER CTL_CODE(FILE_DEVICE_SCREEN, 0x821, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
|
||||
#define IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER CTL_CODE(FILE_DEVICE_SCREEN, 0x822, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
|
||||
|
||||
|
||||
#define IOCTL_CONSOLE_DRAW CTL_CODE(FILE_DEVICE_SCREEN, 0x830, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
|
||||
#define IOCTL_CONSOLE_DRAW CTL_CODE(FILE_DEVICE_SCREEN, 0x830, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
|
||||
|
||||
|
||||
/* TYPEDEFS **************************************************************/
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: buildirp.c,v 1.30 2002/09/08 10:23:24 chorns Exp $
|
||||
/* $Id: buildirp.c,v 1.31 2003/03/21 21:09:40 hbirr Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -260,29 +260,27 @@ IoBuildDeviceIoControlRequest(ULONG IoControlCode,
|
|||
case METHOD_IN_DIRECT:
|
||||
DPRINT("Using METHOD_IN_DIRECT!\n");
|
||||
|
||||
/* build input buffer (control buffer) */
|
||||
if (InputBuffer && InputBufferLength)
|
||||
/* build output buffer (control buffer) */
|
||||
if (OutputBuffer && OutputBufferLength)
|
||||
{
|
||||
Irp->AssociatedIrp.SystemBuffer = (PVOID)
|
||||
ExAllocatePoolWithTag(NonPagedPool,InputBufferLength,
|
||||
ExAllocatePoolWithTag(NonPagedPool,OutputBufferLength,
|
||||
TAG_SYS_BUF);
|
||||
|
||||
|
||||
if (Irp->AssociatedIrp.SystemBuffer == NULL)
|
||||
{
|
||||
IoFreeIrp(Irp);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
|
||||
InputBuffer,
|
||||
InputBufferLength);
|
||||
Irp->UserBuffer = OutputBuffer;
|
||||
}
|
||||
|
||||
/* build output buffer (data transfer buffer) */
|
||||
if (OutputBuffer && OutputBufferLength)
|
||||
/* build input buffer (data transfer buffer) */
|
||||
if (InputBuffer && InputBufferLength)
|
||||
{
|
||||
Irp->MdlAddress = IoAllocateMdl(OutputBuffer,
|
||||
OutputBufferLength,
|
||||
Irp->MdlAddress = IoAllocateMdl(InputBuffer,
|
||||
InputBufferLength,
|
||||
FALSE,
|
||||
FALSE,
|
||||
Irp);
|
||||
|
|
|
@ -99,12 +99,21 @@ VOID IoDeviceControlCompletion(PDEVICE_OBJECT DeviceObject,
|
|||
|
||||
case METHOD_IN_DIRECT:
|
||||
DPRINT ("Using METHOD_IN_DIRECT!\n");
|
||||
|
||||
/* copy output buffer back and free it */
|
||||
if (Irp->AssociatedIrp.SystemBuffer)
|
||||
{
|
||||
if (IoStack->Parameters.DeviceIoControl.OutputBufferLength)
|
||||
{
|
||||
RtlCopyMemory(Irp->UserBuffer,
|
||||
Irp->AssociatedIrp.SystemBuffer,
|
||||
IoStack->Parameters.DeviceIoControl.
|
||||
OutputBufferLength);
|
||||
}
|
||||
ExFreePool (Irp->AssociatedIrp.SystemBuffer);
|
||||
}
|
||||
|
||||
/* free input buffer (control buffer) */
|
||||
if (Irp->AssociatedIrp.SystemBuffer)
|
||||
ExFreePool (Irp->AssociatedIrp.SystemBuffer);
|
||||
|
||||
/* free output buffer (data transfer buffer) */
|
||||
/* free input buffer (data transfer buffer) */
|
||||
if (Irp->MdlAddress)
|
||||
IoFreeMdl (Irp->MdlAddress);
|
||||
break;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: conio.c,v 1.45 2003/03/21 20:17:55 hbirr Exp $
|
||||
/* $Id: conio.c,v 1.46 2003/03/21 21:09:41 hbirr Exp $
|
||||
*
|
||||
* reactos/subsys/csrss/api/conio.c
|
||||
*
|
||||
|
@ -984,10 +984,10 @@ VOID Console_Api( DWORD RefreshEvent )
|
|||
NULL,
|
||||
&Iosb,
|
||||
IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER,
|
||||
0,
|
||||
0,
|
||||
Buffer,
|
||||
sizeof (COORD) + Title.Length);
|
||||
sizeof (COORD) + Title.Length,
|
||||
NULL,
|
||||
0);
|
||||
if( !NT_SUCCESS( Status ) )
|
||||
{
|
||||
DPRINT1( "Error writing to console\n" );
|
||||
|
@ -1282,10 +1282,10 @@ CSR_API(CsrWriteConsoleOutputChar)
|
|||
NULL,
|
||||
&Iosb,
|
||||
IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER,
|
||||
0,
|
||||
0,
|
||||
&Request->Data.WriteConsoleOutputCharRequest.Coord,
|
||||
sizeof (COORD) + Request->Data.WriteConsoleOutputCharRequest.Length );
|
||||
sizeof (COORD) + Request->Data.WriteConsoleOutputCharRequest.Length,
|
||||
NULL,
|
||||
0);
|
||||
if( !NT_SUCCESS( Status ) )
|
||||
DPRINT1( "Failed to write output chars: %x\n", Status );
|
||||
}
|
||||
|
@ -1476,11 +1476,11 @@ CSR_API(CsrWriteConsoleOutputAttrib)
|
|||
NULL,
|
||||
&Iosb,
|
||||
IOCTL_CONSOLE_WRITE_OUTPUT_ATTRIBUTE,
|
||||
0,
|
||||
0,
|
||||
&Request->Data.WriteConsoleOutputAttribRequest.Coord,
|
||||
Request->Data.WriteConsoleOutputAttribRequest.Length +
|
||||
sizeof (COORD) );
|
||||
sizeof (COORD),
|
||||
NULL,
|
||||
0 );
|
||||
if( !NT_SUCCESS( Status ) )
|
||||
DPRINT1( "Failed to write output attributes to console\n" );
|
||||
}
|
||||
|
|
|
@ -346,10 +346,10 @@ WriteConsoleOutputCharacters(LPCSTR lpCharacter,
|
|||
NULL,
|
||||
&IoStatusBlock,
|
||||
IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER,
|
||||
NULL,
|
||||
0,
|
||||
Buffer,
|
||||
nLength + sizeof(COORD));
|
||||
nLength + sizeof(COORD),
|
||||
NULL,
|
||||
0);
|
||||
if (Status == STATUS_PENDING)
|
||||
{
|
||||
NtWaitForSingleObject(StdOutput,
|
||||
|
@ -397,10 +397,10 @@ WriteConsoleOutputCharactersW(LPCWSTR lpCharacter,
|
|||
NULL,
|
||||
&IoStatusBlock,
|
||||
IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER,
|
||||
NULL,
|
||||
0,
|
||||
Buffer,
|
||||
nLength + sizeof(COORD));
|
||||
nLength + sizeof(COORD),
|
||||
NULL,
|
||||
0);
|
||||
if (Status == STATUS_PENDING)
|
||||
{
|
||||
NtWaitForSingleObject(StdOutput,
|
||||
|
@ -444,10 +444,10 @@ WriteConsoleOutputAttributes(CONST USHORT *lpAttribute,
|
|||
NULL,
|
||||
&IoStatusBlock,
|
||||
IOCTL_CONSOLE_WRITE_OUTPUT_ATTRIBUTE,
|
||||
NULL,
|
||||
0,
|
||||
Buffer,
|
||||
nLength * sizeof(USHORT) + sizeof(COORD));
|
||||
nLength * sizeof(USHORT) + sizeof(COORD),
|
||||
NULL,
|
||||
0);
|
||||
if (Status == STATUS_PENDING)
|
||||
{
|
||||
NtWaitForSingleObject(StdOutput,
|
||||
|
|
Loading…
Reference in a new issue