ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
July 2011
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
24 participants
517 discussions
Start a n
N
ew thread
[cgutman] 52563: [AFD] - Fix a desired access bug that totally broke event select - FILE_ALL_ACCESS is NOT equal to EVENT_ALL_ACCESS
by cgutman@svn.reactos.org
Author: cgutman Date: Thu Jul 7 23:17:23 2011 New Revision: 52563 URL:
http://svn.reactos.org/svn/reactos?rev=52563&view=rev
Log: [AFD] - Fix a desired access bug that totally broke event select - FILE_ALL_ACCESS is NOT equal to EVENT_ALL_ACCESS Modified: trunk/reactos/drivers/network/afd/afd/select.c Modified: trunk/reactos/drivers/network/afd/afd/select.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/se…
============================================================================== --- trunk/reactos/drivers/network/afd/afd/select.c [iso-8859-1] (original) +++ trunk/reactos/drivers/network/afd/afd/select.c [iso-8859-1] Thu Jul 7 23:17:23 2011 @@ -286,7 +286,7 @@ if( EventSelectInfo->EventObject && EventSelectInfo->Events ) { Status = ObReferenceObjectByHandle( (PVOID)EventSelectInfo-> EventObject, - FILE_ALL_ACCESS, + EVENT_ALL_ACCESS, ExEventObjectType, UserMode, (PVOID *)&FCB->EventSelect,
13 years, 5 months
1
0
0
0
[cgutman] 52562: [AFD] - Signal the event immediately if the select triggers have already been satisfied - This fixes hangs with applications that wait on the select event before performing any soc...
by cgutman@svn.reactos.org
Author: cgutman Date: Thu Jul 7 22:43:35 2011 New Revision: 52562 URL:
http://svn.reactos.org/svn/reactos?rev=52562&view=rev
Log: [AFD] - Signal the event immediately if the select triggers have already been satisfied - This fixes hangs with applications that wait on the select event before performing any socket operations Modified: trunk/reactos/drivers/network/afd/afd/select.c Modified: trunk/reactos/drivers/network/afd/afd/select.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/se…
============================================================================== --- trunk/reactos/drivers/network/afd/afd/select.c [iso-8859-1] (original) +++ trunk/reactos/drivers/network/afd/afd/select.c [iso-8859-1] Thu Jul 7 22:43:35 2011 @@ -302,6 +302,11 @@ Status = STATUS_SUCCESS; } + if( FCB->EventSelect && (FCB->PollState & FCB->EventSelectTriggers) ) { + AFD_DbgPrint(MID_TRACE,("Setting event %x\n", FCB->EventSelect)); + KeSetEvent( FCB->EventSelect, IO_NETWORK_INCREMENT, FALSE ); + } + AFD_DbgPrint(MID_TRACE,("Returning %x\n", Status)); return UnlockAndMaybeComplete( FCB, Status, Irp,
13 years, 5 months
1
0
0
0
[cgutman] 52561: [AFD] - Implement IOCTL_AFD_RECV for connection-less sockets - Fix a parameter check - Fixes recv() on datagram sockets
by cgutman@svn.reactos.org
Author: cgutman Date: Thu Jul 7 20:44:47 2011 New Revision: 52561 URL:
http://svn.reactos.org/svn/reactos?rev=52561&view=rev
Log: [AFD] - Implement IOCTL_AFD_RECV for connection-less sockets - Fix a parameter check - Fixes recv() on datagram sockets Modified: trunk/reactos/drivers/network/afd/afd/read.c Modified: trunk/reactos/drivers/network/afd/afd/read.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/re…
============================================================================== --- trunk/reactos/drivers/network/afd/afd/read.c [iso-8859-1] (original) +++ trunk/reactos/drivers/network/afd/afd/read.c [iso-8859-1] Thu Jul 7 20:44:47 2011 @@ -44,6 +44,48 @@ return !BytesAvailable && (FCB->PollState & (AFD_EVENT_CLOSE | AFD_EVENT_ABORT)); +} + +static BOOLEAN CheckUnlockExtraBuffers(PAFD_FCB FCB, PIO_STACK_LOCATION IrpSp) +{ + if (FCB->Flags & AFD_ENDPOINT_CONNECTIONLESS) + { + if (IrpSp->MajorFunction == IRP_MJ_READ) + { + /* read() call - no extra buffers */ + return FALSE; + } + else if (IrpSp->MajorFunction == IRP_MJ_DEVICE_CONTROL) + { + if (IrpSp->Parameters.DeviceIoControl.IoControlCode == IOCTL_AFD_RECV_DATAGRAM) + { + /* recvfrom() call - extra buffers */ + return TRUE; + } + else if (IrpSp->Parameters.DeviceIoControl.IoControlCode == IOCTL_AFD_RECV) + { + /* recv() call - no extra buffers */ + return FALSE; + } + else + { + /* Unknown IOCTL */ + ASSERT(FALSE); + return FALSE; + } + } + else + { + /* Unknown IRP_MJ code */ + ASSERT(FALSE); + return FALSE; + } + } + else + { + /* Connection-oriented never has extra buffers */ + return FALSE; + } } static VOID RefillSocketBuffer( PAFD_FCB FCB ) { @@ -292,6 +334,97 @@ return STATUS_SUCCESS; } +static NTSTATUS NTAPI +SatisfyPacketRecvRequest( PAFD_FCB FCB, PIRP Irp, + PAFD_STORED_DATAGRAM DatagramRecv, + PUINT TotalBytesCopied ) { + NTSTATUS Status = STATUS_SUCCESS; + PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation( Irp ); + PAFD_RECV_INFO RecvReq = + GetLockedData(Irp, IrpSp); + UINT BytesToCopy = 0, BytesAvailable = DatagramRecv->Len, AddrLen = 0; + PAFD_MAPBUF Map; + + Map = (PAFD_MAPBUF)(RecvReq->BufferArray + + RecvReq->BufferCount + + EXTRA_LOCK_BUFFERS); + + BytesToCopy = + MIN( RecvReq->BufferArray[0].len, BytesAvailable ); + + AFD_DbgPrint(MID_TRACE,("BytesToCopy: %d len %d\n", BytesToCopy, + RecvReq->BufferArray[0].len)); + + if( Map[0].Mdl ) { + /* Copy the address */ + if( Map[1].Mdl && Map[2].Mdl ) { + AFD_DbgPrint(MID_TRACE,("Checking TAAddressCount\n")); + + if( DatagramRecv->Address->TAAddressCount != 1 ) { + AFD_DbgPrint + (MID_TRACE, + ("Wierd address count %d\n", + DatagramRecv->Address->TAAddressCount)); + } + + AFD_DbgPrint(MID_TRACE,("Computing addr len\n")); + + AddrLen = MIN(DatagramRecv->Address->Address->AddressLength + + sizeof(USHORT), + RecvReq->BufferArray[1].len); + + AFD_DbgPrint(MID_TRACE,("Copying %d bytes of address\n", AddrLen)); + + Map[1].BufferAddress = MmMapLockedPages( Map[1].Mdl, KernelMode ); + + AFD_DbgPrint(MID_TRACE,("Done mapping, copying address\n")); + + RtlCopyMemory( Map[1].BufferAddress, + &DatagramRecv->Address->Address->AddressType, + AddrLen ); + + MmUnmapLockedPages( Map[1].BufferAddress, Map[1].Mdl ); + + AFD_DbgPrint(MID_TRACE,("Copying address len\n")); + + Map[2].BufferAddress = MmMapLockedPages( Map[2].Mdl, KernelMode ); + *((PINT)Map[2].BufferAddress) = AddrLen; + MmUnmapLockedPages( Map[2].BufferAddress, Map[2].Mdl ); + } + + AFD_DbgPrint(MID_TRACE,("Mapping data buffer pages\n")); + + Map[0].BufferAddress = MmMapLockedPages( Map[0].Mdl, KernelMode ); + + AFD_DbgPrint(MID_TRACE,("Buffer %d: %x:%d\n", + 0, + Map[0].BufferAddress, + BytesToCopy)); + + RtlCopyMemory( Map[0].BufferAddress, + DatagramRecv->Buffer, + BytesToCopy ); + + MmUnmapLockedPages( Map[0].BufferAddress, Map[0].Mdl ); + + *TotalBytesCopied = BytesToCopy; + } + + Status = Irp->IoStatus.Status = STATUS_SUCCESS; + Irp->IoStatus.Information = BytesToCopy; + + if (!(RecvReq->TdiFlags & TDI_RECEIVE_PEEK)) + { + FCB->Recv.Content -= *TotalBytesCopied; + ExFreePool( DatagramRecv->Address ); + ExFreePool( DatagramRecv ); + } + + AFD_DbgPrint(MID_TRACE,("Done\n")); + + return Status; +} + NTSTATUS NTAPI AfdConnectedSocketReadData(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp, BOOLEAN Short) { @@ -300,40 +433,95 @@ PAFD_FCB FCB = FileObject->FsContext; PAFD_RECV_INFO RecvReq; UINT TotalBytesCopied = 0; + PAFD_STORED_DATAGRAM DatagramRecv; + PLIST_ENTRY ListEntry; AFD_DbgPrint(MID_TRACE,("Called on %x\n", FCB)); if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp ); - if( FCB->State != SOCKET_STATE_CONNECTED && + if( !(FCB->Flags & AFD_ENDPOINT_CONNECTIONLESS) && + FCB->State != SOCKET_STATE_CONNECTED && FCB->State != SOCKET_STATE_CONNECTING ) { AFD_DbgPrint(MID_TRACE,("Called recv on wrong kind of socket (s%x)\n", FCB->State)); return UnlockAndMaybeComplete( FCB, STATUS_INVALID_PARAMETER, Irp, 0 ); } + + if( !(RecvReq = LockRequest( Irp, IrpSp )) ) + return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY, + Irp, 0 ); + + AFD_DbgPrint(MID_TRACE,("Recv flags %x\n", RecvReq->AfdFlags)); + + RecvReq->BufferArray = LockBuffers( RecvReq->BufferArray, + RecvReq->BufferCount, + NULL, NULL, + TRUE, FALSE ); + + if( !RecvReq->BufferArray ) { + return UnlockAndMaybeComplete( FCB, STATUS_ACCESS_VIOLATION, + Irp, 0 ); + } if( FCB->Flags & AFD_ENDPOINT_CONNECTIONLESS ) { - AFD_DbgPrint(MID_TRACE,("Receive on connection-less sockets not implemented\n")); - return UnlockAndMaybeComplete( FCB, STATUS_NOT_IMPLEMENTED, - Irp, 0 ); - } - - if( !(RecvReq = LockRequest( Irp, IrpSp )) ) - return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY, - Irp, 0 ); - - AFD_DbgPrint(MID_TRACE,("Recv flags %x\n", RecvReq->AfdFlags)); - - RecvReq->BufferArray = LockBuffers( RecvReq->BufferArray, - RecvReq->BufferCount, - NULL, NULL, - TRUE, FALSE ); - - if( !RecvReq->BufferArray ) { - return UnlockAndMaybeComplete( FCB, STATUS_ACCESS_VIOLATION, - Irp, 0 ); + if( !IsListEmpty( &FCB->DatagramList ) ) { + ListEntry = RemoveHeadList( &FCB->DatagramList ); + DatagramRecv = CONTAINING_RECORD + ( ListEntry, AFD_STORED_DATAGRAM, ListEntry ); + if( DatagramRecv->Len > RecvReq->BufferArray[0].len && + !(RecvReq->TdiFlags & TDI_RECEIVE_PARTIAL) ) { + InsertHeadList( &FCB->DatagramList, + &DatagramRecv->ListEntry ); + Status = Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL; + Irp->IoStatus.Information = DatagramRecv->Len; + + if( !IsListEmpty( &FCB->DatagramList ) ) { + FCB->PollState |= AFD_EVENT_RECEIVE; + FCB->PollStatus[FD_READ_BIT] = STATUS_SUCCESS; + PollReeval( FCB->DeviceExt, FCB->FileObject ); + } else + FCB->PollState &= ~AFD_EVENT_RECEIVE; + + UnlockBuffers( RecvReq->BufferArray, RecvReq->BufferCount, FALSE ); + + return UnlockAndMaybeComplete + ( FCB, Status, Irp, Irp->IoStatus.Information ); + } else { + Status = SatisfyPacketRecvRequest + ( FCB, Irp, DatagramRecv, + (PUINT)&Irp->IoStatus.Information ); + + if (RecvReq->TdiFlags & TDI_RECEIVE_PEEK) + { + InsertHeadList(&FCB->DatagramList, + &DatagramRecv->ListEntry); + } + + if( !IsListEmpty( &FCB->DatagramList ) ) { + FCB->PollState |= AFD_EVENT_RECEIVE; + FCB->PollStatus[FD_READ_BIT] = STATUS_SUCCESS; + PollReeval( FCB->DeviceExt, FCB->FileObject ); + } else + FCB->PollState &= ~AFD_EVENT_RECEIVE; + + UnlockBuffers( RecvReq->BufferArray, RecvReq->BufferCount, FALSE ); + + return UnlockAndMaybeComplete + ( FCB, Status, Irp, Irp->IoStatus.Information ); + } + } else if( (RecvReq->AfdFlags & AFD_IMMEDIATE) || (FCB->NonBlocking) ) { + AFD_DbgPrint(MID_TRACE,("Nonblocking\n")); + Status = STATUS_CANT_WAIT; + FCB->PollState &= ~AFD_EVENT_RECEIVE; + UnlockBuffers( RecvReq->BufferArray, RecvReq->BufferCount, FALSE ); + return UnlockAndMaybeComplete( FCB, Status, Irp, 0 ); + } else { + FCB->PollState &= ~AFD_EVENT_RECEIVE; + return LeaveIrpUntilLater( FCB, Irp, FUNCTION_RECV ); + } } Irp->IoStatus.Status = STATUS_PENDING; @@ -367,98 +555,6 @@ return Status; } - -static NTSTATUS NTAPI -SatisfyPacketRecvRequest( PAFD_FCB FCB, PIRP Irp, - PAFD_STORED_DATAGRAM DatagramRecv, - PUINT TotalBytesCopied ) { - NTSTATUS Status = STATUS_SUCCESS; - PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation( Irp ); - PAFD_RECV_INFO RecvReq = - GetLockedData(Irp, IrpSp); - UINT BytesToCopy = 0, BytesAvailable = DatagramRecv->Len, AddrLen = 0; - PAFD_MAPBUF Map; - - Map = (PAFD_MAPBUF)(RecvReq->BufferArray + - RecvReq->BufferCount + - EXTRA_LOCK_BUFFERS); - - BytesToCopy = - MIN( RecvReq->BufferArray[0].len, BytesAvailable ); - - AFD_DbgPrint(MID_TRACE,("BytesToCopy: %d len %d\n", BytesToCopy, - RecvReq->BufferArray[0].len)); - - if( Map[0].Mdl ) { - /* Copy the address */ - if( Map[1].Mdl && Map[2].Mdl ) { - AFD_DbgPrint(MID_TRACE,("Checking TAAddressCount\n")); - - if( DatagramRecv->Address->TAAddressCount != 1 ) { - AFD_DbgPrint - (MID_TRACE, - ("Wierd address count %d\n", - DatagramRecv->Address->TAAddressCount)); - } - - AFD_DbgPrint(MID_TRACE,("Computing addr len\n")); - - AddrLen = MIN(DatagramRecv->Address->Address->AddressLength + - sizeof(USHORT), - RecvReq->BufferArray[1].len); - - AFD_DbgPrint(MID_TRACE,("Copying %d bytes of address\n", AddrLen)); - - Map[1].BufferAddress = MmMapLockedPages( Map[1].Mdl, KernelMode ); - - AFD_DbgPrint(MID_TRACE,("Done mapping, copying address\n")); - - RtlCopyMemory( Map[1].BufferAddress, - &DatagramRecv->Address->Address->AddressType, - AddrLen ); - - MmUnmapLockedPages( Map[1].BufferAddress, Map[1].Mdl ); - - AFD_DbgPrint(MID_TRACE,("Copying address len\n")); - - Map[2].BufferAddress = MmMapLockedPages( Map[2].Mdl, KernelMode ); - *((PINT)Map[2].BufferAddress) = AddrLen; - MmUnmapLockedPages( Map[2].BufferAddress, Map[2].Mdl ); - } - - AFD_DbgPrint(MID_TRACE,("Mapping data buffer pages\n")); - - Map[0].BufferAddress = MmMapLockedPages( Map[0].Mdl, KernelMode ); - - AFD_DbgPrint(MID_TRACE,("Buffer %d: %x:%d\n", - 0, - Map[0].BufferAddress, - BytesToCopy)); - - RtlCopyMemory( Map[0].BufferAddress, - DatagramRecv->Buffer, - BytesToCopy ); - - MmUnmapLockedPages( Map[0].BufferAddress, Map[0].Mdl ); - - *TotalBytesCopied = BytesToCopy; - } - - Status = Irp->IoStatus.Status = STATUS_SUCCESS; - Irp->IoStatus.Information = BytesToCopy; - - if (!(RecvReq->TdiFlags & TDI_RECEIVE_PEEK)) - { - FCB->Recv.Content -= *TotalBytesCopied; - ExFreePool( DatagramRecv->Address ); - ExFreePool( DatagramRecv ); - } - - AFD_DbgPrint(MID_TRACE,("Done\n")); - - return Status; -} - NTSTATUS NTAPI PacketSocketRecvComplete( PDEVICE_OBJECT DeviceObject, @@ -491,7 +587,7 @@ RecvReq = GetLockedData(NextIrp, NextIrpSp); NextIrp->IoStatus.Status = STATUS_FILE_CLOSED; NextIrp->IoStatus.Information = 0; - UnlockBuffers(RecvReq->BufferArray, RecvReq->BufferCount, FALSE); + UnlockBuffers(RecvReq->BufferArray, RecvReq->BufferCount, CheckUnlockExtraBuffers(FCB, NextIrpSp)); if( NextIrp->MdlAddress ) UnlockRequest( NextIrp, IoGetCurrentIrpStackLocation( NextIrp ) ); (void)IoSetCancelRoutine(NextIrp, NULL); IoCompleteRequest( NextIrp, IO_NETWORK_INCREMENT ); @@ -561,7 +657,7 @@ &DatagramRecv->ListEntry ); Status = NextIrp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL; NextIrp->IoStatus.Information = DatagramRecv->Len; - UnlockBuffers( RecvReq->BufferArray, RecvReq->BufferCount, TRUE ); + UnlockBuffers( RecvReq->BufferArray, RecvReq->BufferCount, CheckUnlockExtraBuffers(FCB, NextIrpSp) ); if ( NextIrp->MdlAddress ) UnlockRequest( NextIrp, IoGetCurrentIrpStackLocation( NextIrp ) ); (void)IoSetCancelRoutine(NextIrp, NULL); IoCompleteRequest( NextIrp, IO_NETWORK_INCREMENT ); @@ -576,7 +672,7 @@ &DatagramRecv->ListEntry); } AFD_DbgPrint(MID_TRACE,("Unlocking\n")); - UnlockBuffers( RecvReq->BufferArray, RecvReq->BufferCount, TRUE ); + UnlockBuffers( RecvReq->BufferArray, RecvReq->BufferCount, CheckUnlockExtraBuffers(FCB, NextIrpSp) ); if ( NextIrp->MdlAddress ) UnlockRequest( NextIrp, IoGetCurrentIrpStackLocation( NextIrp ) ); AFD_DbgPrint(MID_TRACE,("Completing\n")); (void)IoSetCancelRoutine(NextIrp, NULL);
13 years, 5 months
1
0
0
0
[cgutman] 52560: [MSAFD] - Let WSPSend handle WSPSendTo on a non-datagram socket (mswsock_new does this) - Fixes sendto on connection-oriented sockets
by cgutman@svn.reactos.org
Author: cgutman Date: Thu Jul 7 20:16:28 2011 New Revision: 52560 URL:
http://svn.reactos.org/svn/reactos?rev=52560&view=rev
Log: [MSAFD] - Let WSPSend handle WSPSendTo on a non-datagram socket (mswsock_new does this) - Fixes sendto on connection-oriented sockets Modified: trunk/reactos/dll/win32/msafd/misc/sndrcv.c Modified: trunk/reactos/dll/win32/msafd/misc/sndrcv.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/misc/sndrc…
============================================================================== --- trunk/reactos/dll/win32/msafd/misc/sndrcv.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msafd/misc/sndrcv.c [iso-8859-1] Thu Jul 7 20:16:28 2011 @@ -573,6 +573,20 @@ *lpErrno = WSAENOTSOCK; return SOCKET_ERROR; } + + if (!(Socket->SharedData.ServiceFlags1 & XP1_CONNECTIONLESS)) + { + /* Use WSPSend for connection-oriented sockets */ + return WSPSend(Handle, + lpBuffers, + dwBufferCount, + lpNumberOfBytesSent, + iFlags, + lpOverlapped, + lpCompletionRoutine, + lpThreadId, + lpErrno); + } /* Bind us First */ if (Socket->SharedData.State == SocketOpen)
13 years, 5 months
1
0
0
0
[cgutman] 52559: [IP] - Return the amount of data sent in XXXSendDatagram() functions - Fixes send() and sendto() return values for datagram sockets (bug exposed by the AFD send user-mode IRP rewrite)
by cgutman@svn.reactos.org
Author: cgutman Date: Thu Jul 7 20:02:52 2011 New Revision: 52559 URL:
http://svn.reactos.org/svn/reactos?rev=52559&view=rev
Log: [IP] - Return the amount of data sent in XXXSendDatagram() functions - Fixes send() and sendto() return values for datagram sockets (bug exposed by the AFD send user-mode IRP rewrite) Modified: trunk/reactos/lib/drivers/ip/network/icmp.c trunk/reactos/lib/drivers/ip/transport/rawip/rawip.c trunk/reactos/lib/drivers/ip/transport/udp/udp.c Modified: trunk/reactos/lib/drivers/ip/network/icmp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/icm…
============================================================================== --- trunk/reactos/lib/drivers/ip/network/icmp.c [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/ip/network/icmp.c [iso-8859-1] Thu Jul 7 20:02:52 2011 @@ -228,6 +228,8 @@ FreeNdisPacket(Packet.NdisPacket); return Status; } + + *DataUsed = DataSize; TI_DbgPrint(MID_TRACE,("Leaving\n")); Modified: trunk/reactos/lib/drivers/ip/transport/rawip/rawip.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/r…
============================================================================== --- trunk/reactos/lib/drivers/ip/transport/rawip/rawip.c [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/ip/transport/rawip/rawip.c [iso-8859-1] Thu Jul 7 20:02:52 2011 @@ -261,6 +261,8 @@ FreeNdisPacket(Packet.NdisPacket); return Status; } + + *DataUsed = DataSize; TI_DbgPrint(MID_TRACE,("Leaving\n")); Modified: trunk/reactos/lib/drivers/ip/transport/udp/udp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/u…
============================================================================== --- trunk/reactos/lib/drivers/ip/transport/udp/udp.c [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/ip/transport/udp/udp.c [iso-8859-1] Thu Jul 7 20:02:52 2011 @@ -234,6 +234,8 @@ FreeNdisPacket(Packet.NdisPacket); return Status; } + + *DataUsed = DataSize; return STATUS_SUCCESS; }
13 years, 5 months
1
0
0
0
[dgorbachev] 52558: Fix failed rel build.
by dgorbachev@svn.reactos.org
Author: dgorbachev Date: Thu Jul 7 19:50:52 2011 New Revision: 52558 URL:
http://svn.reactos.org/svn/reactos?rev=52558&view=rev
Log: Fix failed rel build. Modified: trunk/reactos/ntoskrnl/kd/kdio.c trunk/reactos/ntoskrnl/kdbg/kdb_cli.c Modified: trunk/reactos/ntoskrnl/kd/kdio.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd/kdio.c?rev=525…
============================================================================== --- trunk/reactos/ntoskrnl/kd/kdio.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/kd/kdio.c [iso-8859-1] Thu Jul 7 19:50:52 2011 @@ -39,7 +39,7 @@ volatile ULONG KdpDmesgFreeBytes = 0; volatile ULONG KdbDmesgTotalWritten = 0; KSPIN_LOCK KdpDmesgLogSpinLock; -extern volatile BOOLEAN KdbpIsInDmesgMode; +volatile BOOLEAN KdbpIsInDmesgMode = FALSE; /* FILE DEBUG LOG FUNCTIONS **************************************************/ Modified: trunk/reactos/ntoskrnl/kdbg/kdb_cli.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kdbg/kdb_cli.c?re…
============================================================================== --- trunk/reactos/ntoskrnl/kdbg/kdb_cli.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/kdbg/kdb_cli.c [iso-8859-1] Thu Jul 7 19:50:52 2011 @@ -110,10 +110,8 @@ BOOLEAN KdbpBugCheckRequested = FALSE; /* Vars for dmesg */ -/* defined here, used in ../kd/kdio.c: */ -volatile BOOLEAN KdbpIsInDmesgMode = FALSE; - /* defined in ../kd/kdio.c, declare here: */ +extern volatile BOOLEAN KdbpIsInDmesgMode; extern const ULONG KdpDmesgBufferSize; extern PCHAR KdpDmesgBuffer; extern volatile ULONG KdpDmesgCurrentPosition;
13 years, 5 months
1
0
0
0
[dgorbachev] 52557: [FREELDR] - Move read-only data into data section (allows to boot with GRUB again). - Discard .drectve sections. - Silence "set but not used" warnings.
by dgorbachev@svn.reactos.org
Author: dgorbachev Date: Thu Jul 7 19:19:44 2011 New Revision: 52557 URL:
http://svn.reactos.org/svn/reactos?rev=52557&view=rev
Log: [FREELDR] - Move read-only data into data section (allows to boot with GRUB again). - Discard .drectve sections. - Silence "set but not used" warnings. Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/xboxhw.c trunk/reactos/boot/freeldr/freeldr/freeldr_i386.lnk trunk/reactos/boot/freeldr/freeldr/fs/ext2.c trunk/reactos/boot/freeldr/freeldr/fs/ntfs.c trunk/reactos/boot/freeldr/freeldr/inifile/parse.c trunk/reactos/boot/freeldr/freeldr/ui/ui.c trunk/reactos/boot/freeldr/freeldr/windows/i386/ntsetup.c trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/xboxhw.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/i386/xboxhw.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/xboxhw.c [iso-8859-1] Thu Jul 7 19:19:44 2011 @@ -34,7 +34,7 @@ { PCM_PARTIAL_RESOURCE_LIST PartialResourceList; PCM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry; - EXTENDED_GEOMETRY ExtGeometry; + //EXTENDED_GEOMETRY ExtGeometry; GEOMETRY Geometry; ULONG Size; @@ -69,7 +69,7 @@ DiskGeometry = (PVOID)(((ULONG_PTR)PartialResourceList) + sizeof(CM_PARTIAL_RESOURCE_LIST)); /* Get the disk geometry */ - ExtGeometry.Size = sizeof(EXTENDED_GEOMETRY); + //ExtGeometry.Size = sizeof(EXTENDED_GEOMETRY); if(MachDiskGetDriveGeometry(DriveNumber, &Geometry)) { Modified: trunk/reactos/boot/freeldr/freeldr/freeldr_i386.lnk URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/freel…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/freeldr_i386.lnk [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/freeldr_i386.lnk [iso-8859-1] Thu Jul 7 19:19:44 2011 @@ -32,17 +32,18 @@ *(.data) *(.data2) *(SORT(.data$*)) + *(.rdata) + *(SORT(.rdata$*)) + *(.eh_frame) __data_end__ = . ; __bss_start__ = . ; *(.bss) *(COMMON) __bss_end__ = . ; } - .rdata BLOCK(__section_alignment__) : + /DISCARD/ : { - *(.rdata) - *(SORT(.rdata$*)) - *(.eh_frame) + *(.drectve) } .stab BLOCK(__section_alignment__) (NOLOAD) : { Modified: trunk/reactos/boot/freeldr/freeldr/fs/ext2.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/fs/ex…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/fs/ext2.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/fs/ext2.c [iso-8859-1] Thu Jul 7 19:19:44 2011 @@ -1196,12 +1196,12 @@ LONG Ext2Open(CHAR* Path, OPENMODE OpenMode, ULONG* FileId) { PEXT2_FILE_INFO FileHandle; - ULONG DeviceId; + //ULONG DeviceId; if (OpenMode != OpenReadOnly) return EACCES; - DeviceId = FsGetDeviceId(*FileId); + //DeviceId = FsGetDeviceId(*FileId); DPRINTM(DPRINT_FILESYSTEM, "Ext2Open() FileName = %s\n", Path); Modified: trunk/reactos/boot/freeldr/freeldr/fs/ntfs.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/fs/nt…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/fs/ntfs.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/fs/ntfs.c [iso-8859-1] Thu Jul 7 19:19:44 2011 @@ -536,7 +536,7 @@ static BOOLEAN NtfsFindMftRecord(PNTFS_VOLUME_INFO Volume, ULONGLONG MFTIndex, PCHAR FileName, ULONGLONG *OutMFTIndex) { PNTFS_MFT_RECORD MftRecord; - ULONG Magic; + //ULONG Magic; PNTFS_ATTR_CONTEXT IndexRootCtx; PNTFS_ATTR_CONTEXT IndexBitmapCtx; PNTFS_ATTR_CONTEXT IndexAllocationCtx; @@ -557,7 +557,7 @@ if (NtfsReadMftRecord(Volume, MFTIndex, MftRecord)) { - Magic = MftRecord->Magic; + //Magic = MftRecord->Magic; IndexRootCtx = NtfsFindAttribute(Volume, MftRecord, NTFS_ATTR_TYPE_INDEX_ROOT, L"$I30"); if (IndexRootCtx == NULL) Modified: trunk/reactos/boot/freeldr/freeldr/inifile/parse.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inifi…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/inifile/parse.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/inifile/parse.c [iso-8859-1] Thu Jul 7 19:19:44 2011 @@ -180,12 +180,11 @@ ULONG IniGetNextLineSize(PCHAR IniFileData, ULONG IniFileSize, ULONG CurrentOffset) { - ULONG Idx; ULONG LineCharCount = 0; // Loop through counting chars until we hit the end of the // file or we encounter a new line char - for (Idx=0; (CurrentOffset < IniFileSize); CurrentOffset++) + for (; (CurrentOffset < IniFileSize); CurrentOffset++) { // Increment the line character count LineCharCount++; @@ -193,7 +192,6 @@ // Check for new line char if (IniFileData[CurrentOffset] == '\n') { - CurrentOffset++; break; } } Modified: trunk/reactos/boot/freeldr/freeldr/ui/ui.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/ui/ui…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/ui/ui.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/ui/ui.c [iso-8859-1] Thu Jul 7 19:19:44 2011 @@ -225,14 +225,13 @@ BOOLEAN SetupUiInitialize(VOID) { - VIDEODISPLAYMODE UiDisplayMode; CHAR DisplayModeText[260]; ULONG Depth, Length; DisplayModeText[0] = '\0'; - UiDisplayMode = MachVideoSetDisplayMode(DisplayModeText, TRUE); + MachVideoSetDisplayMode(DisplayModeText, TRUE); MachVideoGetDisplaySize(&UiScreenWidth, &UiScreenHeight, &Depth); UiVtbl = TuiVtbl; Modified: trunk/reactos/boot/freeldr/freeldr/windows/i386/ntsetup.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/windows/i386/ntsetup.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/windows/i386/ntsetup.c [iso-8859-1] Thu Jul 7 19:19:44 2011 @@ -41,7 +41,7 @@ ULONG *TssBasePage) { ULONG TssSize; - ULONG TssPages; + //ULONG TssPages; ULONG_PTR Pcr = 0; ULONG_PTR Tss = 0; ULONG BlockSize, NumPages; @@ -61,7 +61,7 @@ /* Allocate TSS */ TssSize = (sizeof(KTSS) + MM_PAGE_SIZE) & ~(MM_PAGE_SIZE - 1); - TssPages = TssSize / MM_PAGE_SIZE; + //TssPages = TssSize / MM_PAGE_SIZE; Tss = (ULONG_PTR)MmAllocateMemoryWithType(TssSize, LoaderMemoryData); Modified: trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c [iso-8859-1] Thu Jul 7 19:19:44 2011 @@ -224,7 +224,7 @@ ULONG LastPageIndex, LastPageType, MemoryMapStartPage; PPAGE_LOOKUP_TABLE_ITEM MemoryMap; ULONG NoEntries; - PKTSS Tss; + //PKTSS Tss; BOOLEAN Status; // @@ -353,7 +353,7 @@ /* Map stuff like PCR, KI_USER_SHARED_DATA and Apic */ WinLdrMapSpecialPages(PcrBasePage); - Tss = (PKTSS)(KSEG0_BASE | (TssBasePage << MM_PAGE_SHIFT)); + //Tss = (PKTSS)(KSEG0_BASE | (TssBasePage << MM_PAGE_SHIFT)); // Unmap what is not needed from kernel page table MempDisablePages();
13 years, 5 months
1
0
0
0
[dgorbachev] 52556: [NTOSKRNL] Minas Abrahamyan (minas \dot/ subs \at/ gmail \dot/ com): - Allow to view already shown, logged debug messages on the screen (bug #6018).
by dgorbachev@svn.reactos.org
Author: dgorbachev Date: Thu Jul 7 19:18:16 2011 New Revision: 52556 URL:
http://svn.reactos.org/svn/reactos?rev=52556&view=rev
Log: [NTOSKRNL] Minas Abrahamyan (minas \dot/ subs \at/ gmail \dot/ com): - Allow to view already shown, logged debug messages on the screen (bug #6018). Modified: trunk/reactos/ntoskrnl/kd/kdio.c trunk/reactos/ntoskrnl/kdbg/kdb_cli.c Modified: trunk/reactos/ntoskrnl/kd/kdio.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd/kdio.c?rev=525…
============================================================================== --- trunk/reactos/ntoskrnl/kd/kdio.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/kd/kdio.c [iso-8859-1] Thu Jul 7 19:18:16 2011 @@ -33,7 +33,15 @@ CHAR KdpScreenLineBuffer[KdpScreenLineLenght + 1] = ""; ULONG KdpScreenLineBufferPos = 0, KdpScreenLineLength = 0; -/* DEBUG LOG FUNCTIONS *******************************************************/ +const ULONG KdpDmesgBufferSize = 128 * 1024; // 512*1024; // 5*1024*1024; +PCHAR KdpDmesgBuffer = NULL; +volatile ULONG KdpDmesgCurrentPosition = 0; +volatile ULONG KdpDmesgFreeBytes = 0; +volatile ULONG KdbDmesgTotalWritten = 0; +KSPIN_LOCK KdpDmesgLogSpinLock; +extern volatile BOOLEAN KdbpIsInDmesgMode; + +/* FILE DEBUG LOG FUNCTIONS **************************************************/ VOID NTAPI @@ -49,8 +57,14 @@ KeWaitForSingleObject(&KdpLoggerThreadEvent, 0, KernelMode, FALSE, NULL); /* Bug */ + /* Keep KdpCurrentPosition and KdpFreeBytes values in local + * variables to avoid their possible change from Producer part, + * KdpPrintToLogFile function + */ end = KdpCurrentPosition; num = KdpFreeBytes; + + /* Now securely calculate values, based on local variables */ beg = (end + num) % KdpBufferSize; num = KdpBufferSize - num; @@ -148,6 +162,7 @@ IO_STATUS_BLOCK Iosb; HANDLE ThreadHandle; KPRIORITY Priority; + SIZE_T MemSizeMBs; if (!KdpDebugMode.File) return; @@ -175,6 +190,8 @@ /* Display separator + ReactOS version at start of the debug log */ DPRINT1("---------------------------------------------------------------\n"); DPRINT1("ReactOS "KERNEL_VERSION_STR" (Build "KERNEL_VERSION_BUILD_STR")\n"); + MemSizeMBs = MmNumberOfPhysicalPages * PAGE_SIZE / 1024 / 1024; + DPRINT1("%u System Processor [%u MB Memory]\n", KeNumberProcessors, MemSizeMBs); } else if (BootPhase == 2) { @@ -276,6 +293,7 @@ KdpSerialInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase) { + SIZE_T MemSizeMBs; if (!KdpDebugMode.Serial) return; if (BootPhase == 0) @@ -301,6 +319,8 @@ /* Display separator + ReactOS version at start of the debug log */ DPRINT1("-----------------------------------------------------\n"); DPRINT1("ReactOS "KERNEL_VERSION_STR" (Build "KERNEL_VERSION_BUILD_STR")\n"); + MemSizeMBs = MmNumberOfPhysicalPages * PAGE_SIZE / 1024 / 1024; + DPRINT1("%u System Processor [%u MB Memory]\n", KeNumberProcessors, MemSizeMBs); DPRINT1("Command Line: %s\n", KeLoaderBlock->LoadOptions); DPRINT1("ARC Paths: %s %s %s %s\n", KeLoaderBlock->ArcBootDeviceName, KeLoaderBlock->NtHalPathName, @@ -315,11 +335,19 @@ /* SCREEN FUNCTIONS **********************************************************/ +/* + * Screen debug logger function KdpScreenPrint() writes text messages into + * KdpDmesgBuffer, using it as a circular buffer. KdpDmesgBuffer contents could + * be later (re)viewed using dmesg command of kdbg. KdpScreenPrint() protects + * KdpDmesgBuffer from simultaneous writes by use of KdpDmesgLogSpinLock. + */ VOID NTAPI KdpScreenPrint(LPSTR Message, ULONG Length) { + ULONG beg, end, num; + KIRQL OldIrql; PCHAR pch = (PCHAR) Message; while (*pch) @@ -354,16 +382,74 @@ KdpScreenLineBuffer[0] = '\0'; KdpScreenLineLength = KdpScreenLineBufferPos = 0; } - + ++pch; } - + /* Print buffered characters */ if(KdpScreenLineBufferPos != KdpScreenLineLength) { HalDisplayString(KdpScreenLineBuffer + KdpScreenLineBufferPos); KdpScreenLineBufferPos = KdpScreenLineLength; } + + /* Dmesg: store Message in the buffer to show it later */ + if (KdbpIsInDmesgMode) + return; + + if (KdpDmesgBuffer == NULL) + return; + + /* Acquire the printing spinlock without waiting at raised IRQL */ + while (TRUE) + { + /* Wait when the spinlock becomes available */ + while (!KeTestSpinLock(&KdpDmesgLogSpinLock)); + + /* Spinlock was free, raise IRQL */ + KeRaiseIrql(HIGH_LEVEL, &OldIrql); + + /* Try to get the spinlock */ + if (KeTryToAcquireSpinLockAtDpcLevel(&KdpDmesgLogSpinLock)) + break; + + /* Someone else got the spinlock, lower IRQL back */ + KeLowerIrql(OldIrql); + } + + /* Invariant: always_true(KdpDmesgFreeBytes == KdpDmesgBufferSize); + * set num to min(KdpDmesgFreeBytes, Length). + */ + num = (Length < KdpDmesgFreeBytes) ? Length : KdpDmesgFreeBytes; + beg = KdpDmesgCurrentPosition; + if (num != 0) + { + end = (beg + num) % KdpDmesgBufferSize; + if (end > beg) + { + RtlCopyMemory(KdpDmesgBuffer + beg, Message, Length); + } + else + { + RtlCopyMemory(KdpDmesgBuffer + beg, Message, KdpDmesgBufferSize - beg); + RtlCopyMemory(KdpDmesgBuffer, Message + (KdpDmesgBufferSize - beg), end); + } + KdpDmesgCurrentPosition = end; + + /* Counting the total bytes written */ + KdbDmesgTotalWritten += num; + } + + /* Release spinlock */ + KiReleaseSpinLock(&KdpDmesgLogSpinLock); + + /* Lower IRQL */ + KeLowerIrql(OldIrql); + + /* Optional step(?): find out a way to notify about buffer exhaustion, + * and possibly fall into kbd to use dmesg command: user will read + * debug messages before they will be wiped over by next writes. + */ } VOID @@ -371,6 +457,7 @@ KdpScreenInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase) { + SIZE_T MemSizeMBs; if (!KdpDebugMode.Screen) return; if (BootPhase == 0) @@ -381,6 +468,30 @@ /* Register as a Provider */ InsertTailList(&KdProviders, &DispatchTable->KdProvidersList); + } + else if (BootPhase == 1) + { + /* Allocate a buffer for dmesg log buffer. +1 for terminating null, + * see kdbp_cli.c:KdbpCmdDmesg()/2 + */ + KdpDmesgBuffer = ExAllocatePool(NonPagedPool, KdpDmesgBufferSize + 1); + RtlZeroMemory(KdpDmesgBuffer, KdpDmesgBufferSize + 1); + KdpDmesgFreeBytes = KdpDmesgBufferSize; + KdbDmesgTotalWritten = 0; + + /* Initialize spinlock */ + KeInitializeSpinLock(&KdpDmesgLogSpinLock); + + /* Display separator + ReactOS version at start of the debug log */ + DPRINT1("-----------------------------------------------------\n"); + DPRINT1("ReactOS "KERNEL_VERSION_STR" (Build "KERNEL_VERSION_BUILD_STR")\n"); + MemSizeMBs = MmNumberOfPhysicalPages * PAGE_SIZE / 1024 / 1024; + DPRINT1("%u System Processor [%u MB Memory]\n", KeNumberProcessors, MemSizeMBs); + DPRINT1("Command Line: %s\n", KeLoaderBlock->LoadOptions); + DPRINT1("ARC Paths: %s %s %s %s\n", KeLoaderBlock->ArcBootDeviceName, + KeLoaderBlock->NtHalPathName, + KeLoaderBlock->ArcHalDeviceName, + KeLoaderBlock->NtBootPathName); } else if (BootPhase == 2) { Modified: trunk/reactos/ntoskrnl/kdbg/kdb_cli.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kdbg/kdb_cli.c?re…
============================================================================== --- trunk/reactos/ntoskrnl/kdbg/kdb_cli.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/kdbg/kdb_cli.c [iso-8859-1] Thu Jul 7 19:18:16 2011 @@ -42,6 +42,13 @@ #define KEY_SCAN_UP 72 #define KEY_SCAN_DOWN 80 +/* Scan codes of keyboard keys: */ +#define KEYSC_END 0x004f +#define KEYSC_PAGEUP 0x0049 +#define KEYSC_PAGEDOWN 0x0051 +#define KEYSC_HOME 0x0047 +#define KEYSC_ARROWUP 0x0048 + #define KDB_ENTER_CONDITION_TO_STRING(cond) \ ((cond) == KdbDoNotEnter ? "never" : \ ((cond) == KdbEnterAlways ? "always" : \ @@ -81,6 +88,7 @@ static BOOLEAN KdbpCmdFilter(ULONG Argc, PCHAR Argv[]); static BOOLEAN KdbpCmdSet(ULONG Argc, PCHAR Argv[]); static BOOLEAN KdbpCmdHelp(ULONG Argc, PCHAR Argv[]); +static BOOLEAN KdbpCmdDmesg(ULONG Argc, PCHAR Argv[]); /* GLOBALS *******************************************************************/ @@ -100,6 +108,17 @@ PCHAR KdbInitFileBuffer = NULL; /* Buffer where KDBinit file is loaded into during initialization */ BOOLEAN KdbpBugCheckRequested = FALSE; + +/* Vars for dmesg */ +/* defined here, used in ../kd/kdio.c: */ +volatile BOOLEAN KdbpIsInDmesgMode = FALSE; + +/* defined in ../kd/kdio.c, declare here: */ +extern const ULONG KdpDmesgBufferSize; +extern PCHAR KdpDmesgBuffer; +extern volatile ULONG KdpDmesgCurrentPosition; +extern volatile ULONG KdpDmesgFreeBytes; +extern volatile ULONG KdbDmesgTotalWritten; static const struct { @@ -150,6 +169,8 @@ { "bugcheck", "bugcheck", "Bugchecks the system.", KdbpCmdBugCheck }, { "filter", "filter [error|warning|trace|info|level]+|-[componentname|default]", "Enable/disable debug channels", KdbpCmdFilter }, { "set", "set [var] [value]", "Sets var to value or displays value of var.", KdbpCmdSet }, + { "dmesg", "dmesg", "Display debug messages on screen, with navigation on pages.", KdbpCmdDmesg }, + { "kmsg", "kmsg", "Kernel dmesg. Alias for dmesg.", KdbpCmdDmesg }, { "help", "help", "Display help screen.", KdbpCmdHelp } }; @@ -1895,6 +1916,58 @@ return FALSE; } +VOID +KdbpPager( + IN PCHAR Buffer, + IN ULONG BufLength); + +/*!\brief Display debug messages on screen, with paging. + * + * Keys for per-page view: Home, End, PageUp, Arrow Up, PageDown, + * all others are as PageDown. + */ +static BOOLEAN +KdbpCmdDmesg( + ULONG Argc, + PCHAR Argv[]) +{ + ULONG beg, end; + + KdbpIsInDmesgMode = TRUE; /* Toggle logging flag */ + if (!KdpDmesgBuffer) + { + KdbpPrint("Dmesg: error, buffer is not allocated! /DEBUGPORT=SCREEN kernel param required for dmesg.\n"); + return TRUE; + } + + KdbpPrint("*** Dmesg *** TotalWritten=%lu, BufferSize=%lu, CurrentPosition=%lu\n", + KdbDmesgTotalWritten, KdpDmesgBufferSize, KdpDmesgCurrentPosition); + + // Pass data to the pager: + end = KdpDmesgCurrentPosition; + beg = (end + KdpDmesgFreeBytes) % KdpDmesgBufferSize; + + // no roll-overs, and overwritten=lost bytes + if (KdbDmesgTotalWritten <= KdpDmesgBufferSize) + { + // show buffer (KdpDmesgBuffer + beg, num) + KdbpPager(KdpDmesgBuffer, KdpDmesgCurrentPosition); + } + else + { + // show 2 buffers: (KdpDmesgBuffer + beg, KdpDmesgBufferSize - beg) + // and: (KdpDmesgBuffer, end) + KdbpPager(KdpDmesgBuffer + beg, KdpDmesgBufferSize - beg); + KdbpPrint("*** Dmesg: buffer rollup ***\n"); + KdbpPager(KdpDmesgBuffer, end); + } + KdbpPrint("*** Dmesg: end of output ***\n"); + + KdbpIsInDmesgMode = FALSE; /* Toggle logging flag */ + + return TRUE; +} + /*!\brief Sets or displays a config variables value. */ static BOOLEAN @@ -2110,6 +2183,7 @@ * * \note Doesn't correctly handle \\t and terminal escape sequences when calculating the * number of lines required to print a single line from the Buffer in the terminal. + * Prints maximum 4096 chars, because of its buffer size. */ VOID KdbpPrint( @@ -2215,12 +2289,12 @@ if (KdbNumberOfRowsTerminal <= 0) { /* Set number of rows to the default. */ - KdbNumberOfRowsTerminal = 24; + KdbNumberOfRowsTerminal = 23; //24; //Mna.: 23 for SCREEN debugport } else if (KdbNumberOfColsTerminal <= 0) { /* Set number of cols to the default. */ - KdbNumberOfColsTerminal = 80; + KdbNumberOfColsTerminal = 75; //80; //Mna.: 75 for SCREEN debugport } } @@ -2256,6 +2330,7 @@ DbgPrint("\n"); DbgPrint("--- Press q to abort, any other key to continue ---"); + RowsPrintedByTerminal++; /* added by Mna. */ if (KdbDebugState & KD_DEBUG_KDSERIAL) c = KdbpGetCharSerial(); @@ -2315,6 +2390,350 @@ DbgPrint("%s", p); + if (c != '\0') + p[i + 1] = c; + + /* Set p to the start of the next line and + * remember the number of rows/cols printed + */ + p += i; + if (p[0] == '\n') + { + p++; + KdbNumberOfColsPrinted = 0; + } + else + { + ASSERT(p[0] == '\0'); + KdbNumberOfColsPrinted += i; + } + + KdbNumberOfRowsPrinted += RowsPrintedByTerminal; + } +} + +/** memrchr(), explicitly defined, since was absent in MinGW of RosBE. */ +/* + * Reverse memchr() + * Find the last occurrence of 'c' in the buffer 's' of size 'n'. + */ +void * +memrchr(const void *s, int c, size_t n) +{ + const unsigned char *cp; + + if (n != 0) + { + cp = (unsigned char *)s + n; + do + { + if (*(--cp) == (unsigned char)c) + return (void *)cp; + } while (--n != 0); + } + return NULL; +} + +/*!\brief Calculate pointer position for N lines upper of current position. + * + * \param Buffer Characters buffer to operate on. + * \param BufLength Buffer size. + * + * \note Calculate pointer position for N lines upper of current displaying + * position within the given buffer. + * + * Used by KdbpPager(). + * Now N lines count is hardcoded to KdbNumberOfRowsTerminal. + */ +PCHAR +CountOnePageUp(PCHAR Buffer, ULONG BufLength, PCHAR pCurPos) +{ + PCHAR p; + // p0 is initial guess of Page Start + ULONG p0len = KdbNumberOfRowsTerminal * KdbNumberOfColsTerminal; + PCHAR p0 = pCurPos - p0len; + PCHAR prev_p = p0, p1; + ULONG j; + + if (pCurPos < Buffer) + pCurPos = Buffer; + ASSERT(pCurPos <= Buffer + BufLength); + + p = memrchr(p0, '\n', p0len); + if (NULL == p) + p = p0; + for (j = KdbNumberOfRowsTerminal; j--; ) + { + p1 = memrchr(p0, '\n', p-p0); + prev_p = p; + p = p1; + if (NULL == p) + { + p = prev_p; + if (NULL == p) + p = p0; + break; + } + int linesCnt = (KdbNumberOfColsTerminal+prev_p-p-2) / KdbNumberOfColsTerminal; + if (linesCnt > 1) + j -= linesCnt-1; + } + + ASSERT(p != 0); + ++p; + return p; +} + +/*!\brief Prints the given string with, page by page. + * + * \param Buffer Characters buffer to print. + * \param BufferLen Buffer size. + * + * \note Doesn't correctly handle \\t and terminal escape sequences when calculating the + * number of lines required to print a single line from the Buffer in the terminal. + * Maximum length of buffer is limited only by memory size. + * + * Note: BufLength should be greater then (KdbNumberOfRowsTerminal * KdbNumberOfColsTerminal). + * + */ +VOID +KdbpPager( + IN PCHAR Buffer, + IN ULONG BufLength) +{ + static CHAR InBuffer[4096]; + static BOOLEAN TerminalInitialized = FALSE; + static BOOLEAN TerminalConnected = FALSE; + static BOOLEAN TerminalReportsSize = TRUE; + CHAR c = '\0'; + PCHAR p, p2; + ULONG Length; + ULONG i, j; + LONG RowsPrintedByTerminal; + ULONG ScanCode; + + if( BufLength == 0) + return; + + /* Check if the user has aborted output of the current command */ + if (KdbOutputAborted) + return; + + /* Initialize the terminal */ + if (!TerminalInitialized) + { + DbgPrint("\x1b[7h"); /* Enable linewrap */ + + /* Query terminal type */ + /*DbgPrint("\x1b[Z");*/ + DbgPrint("\x05"); + + TerminalInitialized = TRUE; + Length = 0; + KeStallExecutionProcessor(100000); + + for (;;) + { + c = KdbpTryGetCharSerial(5000); + if (c == -1) + break; + + InBuffer[Length++] = c; + if (Length >= (sizeof (InBuffer) - 1)) + break; + } + + InBuffer[Length] = '\0'; + if (Length > 0) + TerminalConnected = TRUE; + } + + /* Get number of rows and columns in terminal */ + if ((KdbNumberOfRowsTerminal < 0) || (KdbNumberOfColsTerminal < 0) || + (KdbNumberOfRowsPrinted) == 0) /* Refresh terminal size each time when number of rows printed is 0 */ + { + if ((KdbDebugState & KD_DEBUG_KDSERIAL) && TerminalConnected && TerminalReportsSize) + { + /* Try to query number of rows from terminal. A reply looks like "\x1b[8;24;80t" */ + TerminalReportsSize = FALSE; + KeStallExecutionProcessor(100000); + DbgPrint("\x1b[18t"); + c = KdbpTryGetCharSerial(5000); + + if (c == KEY_ESC) + { + c = KdbpTryGetCharSerial(5000); + if (c == '[') + { + Length = 0; + + for (;;) + { + c = KdbpTryGetCharSerial(5000); + if (c == -1) + break; + + InBuffer[Length++] = c; + if (isalpha(c) || Length >= (sizeof (InBuffer) - 1)) + break; + } + + InBuffer[Length] = '\0'; + if (InBuffer[0] == '8' && InBuffer[1] == ';') + { + for (i = 2; (i < Length) && (InBuffer[i] != ';'); i++); + + if (Buffer[i] == ';') + { + Buffer[i++] = '\0'; + + /* Number of rows is now at Buffer + 2 and number of cols at Buffer + i */ + KdbNumberOfRowsTerminal = strtoul(InBuffer + 2, NULL, 0); + KdbNumberOfColsTerminal = strtoul(InBuffer + i, NULL, 0); + TerminalReportsSize = TRUE; + } + } + } + /* Clear further characters */ + while ((c = KdbpTryGetCharSerial(5000)) != -1); + } + } + + if (KdbNumberOfRowsTerminal <= 0) + { + /* Set number of rows to the default. */ + KdbNumberOfRowsTerminal = 24; + } + else if (KdbNumberOfColsTerminal <= 0) + { + /* Set number of cols to the default. */ + KdbNumberOfColsTerminal = 80; + } + } + + /* Get the string */ + p = Buffer; + + while (p[0] != '\0') + { + if ( p > Buffer+BufLength) + { + DbgPrint("Dmesg: error, p > Buffer+BufLength,d=%d", p - (Buffer+BufLength)); + return; + } + i = strcspn(p, "\n"); + + // Are we out of buffer? + if (p + i > Buffer + BufLength) + // Leaving pager function: + break; + + /* Calculate the number of lines which will be printed in the terminal + * when outputting the current line + */ + if (i > 0) + RowsPrintedByTerminal = (i + KdbNumberOfColsPrinted - 1) / KdbNumberOfColsTerminal; + else + RowsPrintedByTerminal = 0; + + if (p[i] == '\n') + RowsPrintedByTerminal++; + + /*DbgPrint("!%d!%d!%d!%d!", KdbNumberOfRowsPrinted, KdbNumberOfColsPrinted, i, RowsPrintedByTerminal);*/ + + /* Display a prompt if we printed one screen full of text */ + if (KdbNumberOfRowsTerminal > 0 && + (LONG)(KdbNumberOfRowsPrinted + RowsPrintedByTerminal) >= KdbNumberOfRowsTerminal) + { + if (KdbNumberOfColsPrinted > 0) + DbgPrint("\n"); + + DbgPrint("--- Press q to abort, e/End,h/Home,u/PgUp, other key/PgDn ---"); + RowsPrintedByTerminal++; + + if (KdbDebugState & KD_DEBUG_KDSERIAL) + c = KdbpGetCharSerial(); + else + c = KdbpGetCharKeyboard(&ScanCode); + + if (c == '\r') + { + /* Try to read '\n' which might follow '\r' - if \n is not received here + * it will be interpreted as "return" when the next command should be read. + */ + if (KdbDebugState & KD_DEBUG_KDSERIAL) + c = KdbpTryGetCharSerial(5); + else + c = KdbpTryGetCharKeyboard(&ScanCode, 5); + } + + //DbgPrint("\n"); //Consize version: don't show pressed key + DbgPrint(" '%c'/scan=%04x\n", c, ScanCode); // Shows pressed key + + if (c == 'q') + { + KdbOutputAborted = TRUE; + return; + } + if ( ScanCode == KEYSC_END || c=='e') + { + PCHAR pBufEnd = Buffer + BufLength; + p = CountOnePageUp(Buffer, BufLength, pBufEnd); + i = strcspn(p, "\n"); + } + else if (ScanCode == KEYSC_PAGEUP || c=='u') + { + p = CountOnePageUp(Buffer, BufLength, p); + i = strcspn(p, "\n"); + } + else if (ScanCode == KEYSC_HOME || c=='h') + { + p = Buffer; + i = strcspn(p, "\n"); + } + else if (ScanCode == KEYSC_ARROWUP) + { + p = CountOnePageUp(Buffer, BufLength, p); + i = strcspn(p, "\n"); + } + + KdbNumberOfRowsPrinted = 0; + KdbNumberOfColsPrinted = 0; + } + + /* Insert a NUL after the line and print only the current line. */ + if (p[i] == '\n' && p[i + 1] != '\0') + { + c = p[i + 1]; + p[i + 1] = '\0'; + } + else + { + c = '\0'; + } + + /* Remove escape sequences from the line if there's no terminal connected */ + if (!TerminalConnected) + { + while ((p2 = strrchr(p, '\x1b'))) /* Look for escape character */ + { + if (p2[1] == '[') + { + j = 2; + while (!isalpha(p2[j++])); + strcpy(p2, p2 + j); + } + else + { + strcpy(p2, p2 + 1); + } + } + } + + // The main printing of the current line: + DbgPrint(p); + + // restore not null char with saved: if (c != '\0') p[i + 1] = c;
13 years, 5 months
1
0
0
0
[sir_richard] 52555: Patch by Anton Yarotsky: [SACDRV]: Implement the SAC Channel Input/Output Interface and Getters/Setters.
by sir_richard@svn.reactos.org
Author: sir_richard Date: Thu Jul 7 12:03:56 2011 New Revision: 52555 URL:
http://svn.reactos.org/svn/reactos?rev=52555&view=rev
Log: Patch by Anton Yarotsky: [SACDRV]: Implement the SAC Channel Input/Output Interface and Getters/Setters. Modified: trunk/reactos/drivers/sac/driver/channel.c Modified: trunk/reactos/drivers/sac/driver/channel.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/sac/driver/channel…
============================================================================== --- trunk/reactos/drivers/sac/driver/channel.c [iso-8859-1] (original) +++ trunk/reactos/drivers/sac/driver/channel.c [iso-8859-1] Thu Jul 7 12:03:56 2011 @@ -19,7 +19,7 @@ IN SAC_CHANNEL_TYPE ChannelType ) { - return FALSE; + return ((ChannelType >= VtUtf8) && (ChannelType <= Raw)); } BOOLEAN @@ -28,7 +28,9 @@ IN PSAC_CHANNEL_ID ChannelId ) { - return FALSE; + return IsEqualGUIDAligned( + &Channel->ChannelId.ChannelGuid, + &ChannelId->ChannelGuid); } NTSTATUS @@ -52,7 +54,9 @@ IN PSAC_CHANNEL Channel ) { - return STATUS_NOT_IMPLEMENTED; + CHECK_PARAMETER(Channel); + + return ChannelDereferenceHandles(Channel); } NTSTATUS @@ -62,7 +66,17 @@ IN ULONG BufferSize ) { - return STATUS_NOT_IMPLEMENTED; + NTSTATUS Status; + + CHECK_PARAMETER3(BufferSize < SAC_OBUFFER_SIZE); + + ChannelLockOBuffer(Channel); + + Status = Channel->OBufferWrite(Channel, Buffer, BufferSize); + + ChannelUnlockOBuffer(Channel); + + return Status; } NTSTATUS @@ -70,7 +84,15 @@ IN PSAC_CHANNEL Channel ) { - return STATUS_NOT_IMPLEMENTED; + NTSTATUS Status; + + ChannelLockOBuffer(Channel); + + Status = Channel->OBufferFlush(Channel); + + ChannelUnlockOBuffer(Channel); + + return Status; } NTSTATUS @@ -80,7 +102,15 @@ IN ULONG BufferSize ) { - return STATUS_NOT_IMPLEMENTED; + NTSTATUS Status; + + ChannelLockIBuffer(Channel); + + Status = Channel->IBufferWrite(Channel, Buffer, BufferSize); + + ChannelUnlockIBuffer(Channel); + + return Status; } ULONG @@ -91,7 +121,15 @@ OUT PULONG ResultBufferSize ) { - return STATUS_NOT_IMPLEMENTED; + NTSTATUS Status; + + ChannelLockIBuffer(Channel); + + Status = Channel->IBufferRead(Channel, Buffer, BufferSize, ResultBufferSize); + + ChannelUnlockIBuffer(Channel); + + return Status; } NTSTATUS @@ -99,7 +137,15 @@ IN PSAC_CHANNEL Channel ) { - return STATUS_NOT_IMPLEMENTED; + NTSTATUS Status; + + ChannelLockIBuffer(Channel); + + Status = Channel->IBufferReadLast(Channel); + + ChannelUnlockIBuffer(Channel); + + return Status; } ULONG @@ -107,7 +153,15 @@ IN PSAC_CHANNEL Channel ) { - return STATUS_NOT_IMPLEMENTED; + NTSTATUS Length; + + ChannelLockOBuffer(Channel); + + Length = Channel->IBufferLength(Channel); + + ChannelUnlockOBuffer(Channel); + + return Length; } NTSTATUS @@ -179,7 +233,11 @@ IN PSAC_CHANNEL Channel ) { - return STATUS_NOT_IMPLEMENTED; + NTSTATUS Status; + + ChannelSetEvent(Channel, LockEvent); + + return Status; } NTSTATUS @@ -188,7 +246,11 @@ IN PSAC_CHANNEL Channel ) { - return STATUS_NOT_IMPLEMENTED; + NTSTATUS Status; + + ChannelSetEvent(Channel, RedrawEvent); + + return Status; } NTSTATUS @@ -196,7 +258,11 @@ IN PSAC_CHANNEL Channel ) { - return STATUS_NOT_IMPLEMENTED; + NTSTATUS Status; + + ChannelClearEvent(Channel, RedrawEvent); + + return Status; } NTSTATUS @@ -205,7 +271,12 @@ OUT PBOOLEAN Present ) { - return STATUS_NOT_IMPLEMENTED; + CHECK_PARAMETER1(Channel); + CHECK_PARAMETER2(Present); + + *Present = Channel->Flags & SAC_CHANNEL_FLAG_REDRAW_EVENT; + + return STATUS_SUCCESS; } BOOLEAN @@ -213,7 +284,11 @@ IN PSAC_CHANNEL Channel ) { - return FALSE; + SAC_CHANNEL_STATUS ChannelStatus; + + if (!NT_SUCCESS(ChannelGetStatus(Channel, &ChannelStatus))) return FALSE; + + return (ChannelStatus == Active); } BOOLEAN
13 years, 5 months
1
0
0
0
[sir_richard] 52554: Patch by Anton Yarotsky: [SACDRV]: Add type definitions for channel VTABLE. [SACDRV]: Add channel event macros and flags. [SACDRV]: Add channal lock macros. [SACDRV]: Add macro...
by sir_richard@svn.reactos.org
Author: sir_richard Date: Thu Jul 7 12:02:32 2011 New Revision: 52554 URL:
http://svn.reactos.org/svn/reactos?rev=52554&view=rev
Log: Patch by Anton Yarotsky: [SACDRV]: Add type definitions for channel VTABLE. [SACDRV]: Add channel event macros and flags. [SACDRV]: Add channal lock macros. [SACDRV]: Add macros for parameter validation. [SACDRV]: Add macro for pool allocation. [SACDRV]: Misc fixes. Modified: trunk/reactos/drivers/sac/driver/sacdrv.h Modified: trunk/reactos/drivers/sac/driver/sacdrv.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/sac/driver/sacdrv.…
============================================================================== --- trunk/reactos/drivers/sac/driver/sacdrv.h [iso-8859-1] (original) +++ trunk/reactos/drivers/sac/driver/sacdrv.h [iso-8859-1] Thu Jul 7 12:02:32 2011 @@ -20,6 +20,105 @@ DbgPrint("SAC %s: ", __FUNCTION__); \ DbgPrint(__VA_ARGS__); \ } + +#define CHECK_PARAMETER_WITH_STATUS(Parameter, Status) \ +{ \ + ASSERT((Parameter)); \ + if (!Parameter) \ + { \ + return Status; \ + } \ +} +#define CHECK_PARAMETER(x) \ + CHECK_PARAMETER_WITH_STATUS(x, STATUS_INVALID_PARAMETER) +#define CHECK_PARAMETER1(x) \ + CHECK_PARAMETER_WITH_STATUS(x, STATUS_INVALID_PARAMETER_1) +#define CHECK_PARAMETER2(x) \ + CHECK_PARAMETER_WITH_STATUS(x, STATUS_INVALID_PARAMETER_2) +#define CHECK_PARAMETER3(x) \ + CHECK_PARAMETER_WITH_STATUS(x, STATUS_INVALID_PARAMETER_3) +#define CHECK_ALLOCATION(x) \ + CHECK_PARAMETER_WITH_STATUS(x, STATUS_OUT_OF_MEMORY) + +#define SacAllocatePool(Length, Tag) \ + MyAllocatePool(Length, Tag, __FILE__, __LINE__) + +#define ChannelLock(Channel, x) \ +{ \ + KeWaitForSingleObject( \ + &(Channel)->x.Lock, \ + Executive, \ + KernelMode, \ + FALSE, \ + NULL); \ + ASSERT((Channel)->x.RefCount == 0); \ + InterlockedIncrement(&(Channel)->x.RefCount); \ +} + +#define ChannelUnlock(Channel, x) \ +{ \ + ASSERT((Channel)->x.RefCount == 1); \ + InterlockedDecrement(&(Channel)->x.RefCount); \ + KeReleaseSemaphore( \ + &(Channel)->x.Lock, \ + SEMAPHORE_INCREMENT, \ + 1, \ + FALSE); \ +} + +#define ChannelLockOBuffer(Channel) ChannelLock(Channel, ChannelOBufferLock); +#define ChannelUnlockOBuffer(Channel) ChannelUnlock(Channel, ChannelOBufferLock); +#define ChannelLockIBuffer(Channel) ChannelLock(Channel, ChannelIBufferLock); +#define ChannelUnlockIBuffer(Channel) ChannelUnlock(Channel, ChannelIBufferLock); +#define ChannelLockAttributes(Channel) ChannelLock(Channel, ChannelAttributesLock); +#define ChannelUnlockAttributes(Channel) ChannelUnlock(Channel, ChannelAttributesLock); + +#define ChannelInitializeEvent(Channel, Attributes, x) \ +{ \ + PVOID Object, WaitObject; \ + if (Attributes->x) \ + { \ + if (!VerifyEventWaitable(Attributes->x, &Object, &WaitObject)) \ + { \ + goto FailChannel; \ + } \ + Channel->x = Attributes->x; \ + Channel->x##ObjectBody = Object; \ + Channel->x##WaitObjectBody = WaitObject; \ + } \ +} + +#define ChannelSetEvent(Channel, x) \ +{ \ + ASSERT(Channel->x); \ + ASSERT(Channel->x##ObjectBody); \ + ASSERT(Channel->x##WaitObjectBody); \ + if (Channel->x) \ + { \ + KeSetEvent(Channel->x, EVENT_INCREMENT, FALSE); \ + Status = STATUS_SUCCESS; \ + } \ + else \ + { \ + Status = STATUS_UNSUCCESSFUL; \ + } \ +} + +#define ChannelClearEvent(Channel, x) \ +{ \ + ASSERT(Channel->x); \ + ASSERT(Channel->x##ObjectBody); \ + ASSERT(Channel->x##WaitObjectBody); \ + if (Channel->x) \ + { \ + KeClearEvent(Channel->x); \ + Status = STATUS_SUCCESS; \ + } \ + else \ + { \ + Status = STATUS_UNSUCCESSFUL; \ + } \ +} //Rcp? - sacdrv.sys - SAC Driver (Headless) //RcpA - sacdrv.sys - Internal memory mgr alloc block @@ -36,6 +135,13 @@ #define SAC_MEMORY_LIST_SIZE (1 * 1024 * 1024) +#define SAC_OBUFFER_SIZE (2 * 1024) + +#define SAC_CHANNEL_FLAG_CLOSE_EVENT 0x2 +#define SAC_CHANNEL_FLAG_HAS_NEW_DATA_EVENT 0x4 +#define SAC_CHANNEL_FLAG_LOCK_EVENT 0x8 +#define SAC_CHANNEL_FLAG_REDRAW_EVENT 0x10 + typedef struct _SAC_MEMORY_ENTRY { ULONG Signature; @@ -73,8 +179,89 @@ typedef struct _SAC_CHANNEL_LOCK { LONG RefCount; - KSEMAPHORE Semaphore; + KSEMAPHORE Lock; } SAC_CHANNEL_LOCK, *PSAC_CHANNEL_LOCK; + +struct _SAC_CHANNEL; + +typedef +NTSTATUS +(*PSAC_CHANNEL_CREATE)( + IN struct _SAC_CHANNEL* Channel + ); + +typedef +NTSTATUS +(*PSAC_CHANNEL_DESTROY)( + IN struct _SAC_CHANNEL* Channel + ); + +typedef +NTSTATUS +(*PSAC_CHANNEL_OREAD)( + IN struct _SAC_CHANNEL* Channel, + IN PCHAR Buffer, + IN ULONG BufferSize, + OUT PULONG ByteCount + ); + +typedef +NTSTATUS +(*PSAC_CHANNEL_OECHO)( + IN struct _SAC_CHANNEL* Channel, + IN PWCHAR String, + IN ULONG Length + ); + +typedef +NTSTATUS +(*PSAC_CHANNEL_OFLUSH)( + IN struct _SAC_CHANNEL* Channel + ); + +typedef +NTSTATUS +(*PSAC_CHANNEL_OWRITE)( + IN struct _SAC_CHANNEL* Channel, + IN PWCHAR String, + IN ULONG Length + ); + +typedef +NTSTATUS +(*PSAC_CHANNEL_IREAD)( + IN struct _SAC_CHANNEL* Channel, + IN PWCHAR Buffer, + IN ULONG BufferSize, + IN PULONG ReturnBufferSize + ); + +typedef +NTSTATUS +(*PSAC_CHANNEL_IBUFFER_FULL)( + IN struct _SAC_CHANNEL* Channel, + OUT PBOOLEAN BufferStatus + ); + +typedef +NTSTATUS +(*PSAC_CHANNEL_IBUFFER_LENGTH)( + IN struct _SAC_CHANNEL* Channel + ); + +typedef +CHAR +(*PSAC_CHANNEL_IREAD_LAST)( + IN struct _SAC_CHANNEL* Channel + ); + +typedef +NTSTATUS +(*PSAC_CHANNEL_IWRITE)( + IN struct _SAC_CHANNEL* Channel, + IN PCHAR Buffer, + IN ULONG BufferSize + ); typedef struct _SAC_CHANNEL { @@ -112,20 +299,20 @@ ULONG OBufferIndex; ULONG OBufferFirstGoodIndex; BOOLEAN ChannelHasNewOBufferData; - //PSAC_CHANNEL_CREATE ChannelCreate; - //PSAC_CHANNEL_DESTROY ChannelDestroy; - //PSAC_CHANNEL_OFLUSH ChannelOutputFlush; - //PSAC_CHANNEL_OECHO ChannelOutputEcho; - //PSAC_CHANNEL_OWRITE ChannelOutputWrite; - //PSAC_CHANNEL_OREAD ChannelOutputRead; - //PSAC_CHANNEL_OWRITE ChannelInputWrite; - //PSAC_CHANNEL_IREAD ChannelInputRead; - //PSAC_CHANNEL_IREAD_LAST ChannelInputReadLast; - //PSAC_CHANNEL_IBUFFER_FULL ChannelInputBufferIsFull; - //PSAC_CHANNEL_IBUFFER_LENGTH IBufferLength; + PSAC_CHANNEL_CREATE ChannelCreate; + PSAC_CHANNEL_DESTROY ChannelDestroy; + PSAC_CHANNEL_OFLUSH OBufferFlush; + PSAC_CHANNEL_OECHO OBufferEcho; + PSAC_CHANNEL_OWRITE OBufferWrite; + PSAC_CHANNEL_OREAD OBufferRead; + PSAC_CHANNEL_OWRITE IBufferWrite; + PSAC_CHANNEL_IREAD IBufferRead; + PSAC_CHANNEL_IREAD_LAST IBufferReadLast; + PSAC_CHANNEL_IBUFFER_FULL IBufferIsFull; + PSAC_CHANNEL_IBUFFER_LENGTH IBufferLength; SAC_CHANNEL_LOCK ChannelAttributeLock; SAC_CHANNEL_LOCK ChannelOBufferLock; - SAC_CHANNEL_LOCK ChannelBufferLock; + SAC_CHANNEL_LOCK ChannelIBufferLock; } SAC_CHANNEL, *PSAC_CHANNEL; typedef struct _SAC_DEVICE_EXTENSION
13 years, 5 months
1
0
0
0
← Newer
1
...
43
44
45
46
47
48
49
...
52
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Results per page:
10
25
50
100
200