Author: tfaber
Date: Fri Dec 7 18:00:30 2012
New Revision: 57815
URL: http://svn.reactos.org/svn/reactos?rev=57815&view=rev
Log:
[SPIDER]
- Only dissolve a stack of cards if they're of the same color
- Allow easier recognition of suit in concealed cards
- Patch by Marcel Leyendeckers, m dot leyendeckers at gmx dot de
CORE-6808 #resolve #comment Committed. Thanks!
Modified:
trunk/reactos/base/applications/games/spider/spigame.cpp
Modified: trunk/reactos/base/applications/games/spider/spigame.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/games/sp…
==============================================================================
--- trunk/reactos/base/applications/games/spider/spigame.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/games/spider/spigame.cpp [iso-8859-1] Fri Dec 7 18:00:30 2012
@@ -249,7 +249,8 @@
int i, max = NUM_ONECOLOR_CARDS - dragcards.NumCards() - 1;
/* Dragged cards have been checked to be in order, check stack cards */
- if (stackLookingGood(mystack, max))
+ if (mystack[0].Suit() == dragcard.Suit() &&
+ stackLookingGood(mystack, max))
{
CardStack s = stackobj.GetCardStack();
CardStack f;
@@ -279,8 +280,8 @@
{
int i, pos;
- /* Compute the value for yRowStackCardOffset based on the height of the card, so the card number isn't hidden on larger cards */
- yRowStackCardOffset = (int)(__cardheight / 6.7);
+ /* Compute the value for yRowStackCardOffset based on the height of the card, so the card number and suite isn't hidden on larger cards except Ace */
+ yRowStackCardOffset = (int)(__cardheight / 6.4);
pDeck = SpiderWnd.CreateRegion(0, true, 0, 0, -15, 0);
pDeck->SetFaceDirection(CS_FACE_DOWN, 0);
Author: hbelusca
Date: Thu Dec 6 23:43:31 2012
New Revision: 57810
URL: http://svn.reactos.org/svn/reactos?rev=57810&view=rev
Log:
[CSRSRV/BASESRV/CONSRV/WINSRV]
- Add a useful CHECK_API_MSG_SIZE macro to check whether a server message structure can hold in a CSR_API_MESSAGE structure. These checks are required because LPC will use the generic CSR_API_MESSAGE structure for communicating all the different servers' messages, and thus we avoid possible buffer overflows with this method.
- Effectively use this macro for all the server message structures.
- Remove a hack regarding the maximum data size we can pass through the CSR LPC port.
- Remove the now unused CSRSS_HEADER_SIZE symbol.
Modified:
branches/ros-csrss/include/reactos/subsys/csr/csrmsg.h
branches/ros-csrss/include/reactos/subsys/win/basemsg.h
branches/ros-csrss/include/reactos/subsys/win/conmsg.h
branches/ros-csrss/include/reactos/subsys/win/winmsg.h
branches/ros-csrss/subsystems/win32/csrsrv/api.c
Modified: branches/ros-csrss/include/reactos/subsys/csr/csrmsg.h
URL: http://svn.reactos.org/svn/reactos/branches/ros-csrss/include/reactos/subsy…
==============================================================================
--- branches/ros-csrss/include/reactos/subsys/csr/csrmsg.h [iso-8859-1] (original)
+++ branches/ros-csrss/include/reactos/subsys/csr/csrmsg.h [iso-8859-1] Thu Dec 6 23:43:31 2012
@@ -64,6 +64,10 @@
HANDLE ProcessId;
} CSR_CONNECTION_INFO, *PCSR_CONNECTION_INFO;
+// We must have a size at most equal to the maximum acceptable LPC data size.
+C_ASSERT(sizeof(CSR_CONNECTION_INFO) <= LPC_MAX_DATA_LENGTH);
+
+
typedef struct _CSR_IDENTIFY_ALTERTABLE_THREAD
{
CLIENT_ID Cid;
@@ -97,8 +101,6 @@
ULONG_PTR PointerOffsetsArray[ANYSIZE_ARRAY];
} CSR_CAPTURE_BUFFER, *PCSR_CAPTURE_BUFFER;
-/* Keep in sync with definition below. */
-// #define CSRSS_HEADER_SIZE (sizeof(PORT_MESSAGE) + sizeof(ULONG) + sizeof(NTSTATUS))
typedef struct _CSR_API_MESSAGE
{
@@ -117,11 +119,38 @@
CSR_CLIENT_CONNECT CsrClientConnect;
CSR_SET_PRIORITY_CLASS SetPriorityClass;
CSR_IDENTIFY_ALTERTABLE_THREAD IdentifyAlertableThread;
+
+ //
+ // This padding is used to make the CSR_API_MESSAGE structure
+ // large enough to hold full other API_MESSAGE-type structures
+ // used by other servers. These latter structures's sizes must
+ // be checked against the size of CSR_API_MESSAGE by using the
+ // CHECK_API_MSG_SIZE macro defined below.
+ //
+ // This is required because LPC will use this generic structure
+ // for communicating all the different servers' messages, and
+ // thus we avoid possible buffer overflows with this method.
+ // The problems there are, that we have to manually adjust the
+ // size of the padding to hope that all the servers' messaging
+ // structures will hold in it, or, that we have to be careful
+ // to not define too big messaging structures for the servers.
+ //
+ // Finally, the overall message structure size must be at most
+ // equal to the maximum acceptable LPC message size.
+ //
+ ULONG_PTR Padding[35];
} Data;
};
};
} CSR_API_MESSAGE, *PCSR_API_MESSAGE;
+// We must have a size at most equal to the maximum acceptable LPC message size.
+C_ASSERT(sizeof(CSR_API_MESSAGE) <= LPC_MAX_MESSAGE_LENGTH);
+
+// Macro to check that the total size of servers' message structures
+// are at most equal to the size of the CSR_API_MESSAGE structure.
+#define CHECK_API_MSG_SIZE(type) C_ASSERT(sizeof(type) <= sizeof(CSR_API_MESSAGE))
+
#endif // _CSRMSG_H
/* EOF */
Modified: branches/ros-csrss/include/reactos/subsys/win/basemsg.h
URL: http://svn.reactos.org/svn/reactos/branches/ros-csrss/include/reactos/subsy…
==============================================================================
--- branches/ros-csrss/include/reactos/subsys/win/basemsg.h [iso-8859-1] (original)
+++ branches/ros-csrss/include/reactos/subsys/win/basemsg.h [iso-8859-1] Thu Dec 6 23:43:31 2012
@@ -203,6 +203,9 @@
} Data;
} BASE_API_MESSAGE, *PBASE_API_MESSAGE;
+// Check that a BASE_API_MESSAGE can hold in a CSR_API_MESSAGE.
+CHECK_API_MSG_SIZE(BASE_API_MESSAGE);
+
#endif // _BASEMSG_H
/* EOF */
Modified: branches/ros-csrss/include/reactos/subsys/win/conmsg.h
URL: http://svn.reactos.org/svn/reactos/branches/ros-csrss/include/reactos/subsy…
==============================================================================
--- branches/ros-csrss/include/reactos/subsys/win/conmsg.h [iso-8859-1] (original)
+++ branches/ros-csrss/include/reactos/subsys/win/conmsg.h [iso-8859-1] Thu Dec 6 23:43:31 2012
@@ -618,6 +618,9 @@
} Data;
} CONSOLE_API_MESSAGE, *PCONSOLE_API_MESSAGE;
+// Check that a CONSOLE_API_MESSAGE can hold in a CSR_API_MESSAGE.
+CHECK_API_MSG_SIZE(CONSOLE_API_MESSAGE);
+
#endif // _CONMSG_H
/* EOF */
Modified: branches/ros-csrss/include/reactos/subsys/win/winmsg.h
URL: http://svn.reactos.org/svn/reactos/branches/ros-csrss/include/reactos/subsy…
==============================================================================
--- branches/ros-csrss/include/reactos/subsys/win/winmsg.h [iso-8859-1] (original)
+++ branches/ros-csrss/include/reactos/subsys/win/winmsg.h [iso-8859-1] Thu Dec 6 23:43:31 2012
@@ -83,6 +83,9 @@
} Data;
} USER_API_MESSAGE, *PUSER_API_MESSAGE;
+// Check that a USER_API_MESSAGE can hold in a CSR_API_MESSAGE.
+CHECK_API_MSG_SIZE(USER_API_MESSAGE);
+
#endif // _WINMSG_H
/* EOF */
Modified: branches/ros-csrss/subsystems/win32/csrsrv/api.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-csrss/subsystems/win32/csrs…
==============================================================================
--- branches/ros-csrss/subsystems/win32/csrsrv/api.c [iso-8859-1] (original)
+++ branches/ros-csrss/subsystems/win32/csrsrv/api.c [iso-8859-1] Thu Dec 6 23:43:31 2012
@@ -919,13 +919,13 @@
&CsrApiPortName,
0,
NULL,
- NULL /* FIXME*/);
+ NULL /* FIXME: Use the Security Descriptor */);
/* Create the Port Object */
Status = NtCreatePort(&CsrApiPort,
&ObjectAttributes,
- LPC_MAX_DATA_LENGTH, // HACK: the real value is: sizeof(CSR_CONNECTION_INFO),
- LPC_MAX_MESSAGE_LENGTH, // HACK: the real value is: sizeof(CSR_API_MESSAGE),
+ sizeof(CSR_CONNECTION_INFO),
+ sizeof(CSR_API_MESSAGE),
16 * PAGE_SIZE);
if (NT_SUCCESS(Status))
{
Author: hbelusca
Date: Thu Dec 6 22:24:27 2012
New Revision: 57809
URL: http://svn.reactos.org/svn/reactos?rev=57809&view=rev
Log:
[NTDLL/CSRSRV]
Re-fix part of the capture-buffer offset setting, based on what I understood from all my previous investigations. It reverts a little part of r57673 but fixing some existing bugs there.
Modified:
branches/ros-csrss/dll/ntdll/csr/connect.c
branches/ros-csrss/subsystems/win32/csrsrv/api.c
Modified: branches/ros-csrss/dll/ntdll/csr/connect.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/ntdll/csr/connect…
==============================================================================
--- branches/ros-csrss/dll/ntdll/csr/connect.c [iso-8859-1] (original)
+++ branches/ros-csrss/dll/ntdll/csr/connect.c [iso-8859-1] Thu Dec 6 22:24:27 2012
@@ -51,7 +51,8 @@
IN ULONG DataLength)
{
NTSTATUS Status;
- ULONG i;
+ ULONG PointerCount;
+ PULONG_PTR OffsetPointer;
/* Fill out the Port Message Header. */
ApiMessage->Header.u2.ZeroInit = 0;
@@ -90,13 +91,16 @@
* a server pointer, and each pointer to these message pointers
* is converted into an offset.
*/
- for (i = 0 ; i < CaptureBuffer->PointerCount ; ++i)
+ PointerCount = CaptureBuffer->PointerCount;
+ OffsetPointer = CaptureBuffer->PointerOffsetsArray;
+ while (PointerCount--)
{
- if (CaptureBuffer->PointerOffsetsArray[i] != 0)
+ if (*OffsetPointer != 0)
{
- *(PULONG_PTR)CaptureBuffer->PointerOffsetsArray[i] += CsrPortMemoryDelta;
- CaptureBuffer->PointerOffsetsArray[i] -= (ULONG_PTR)ApiMessage;
+ *(PULONG_PTR)*OffsetPointer += CsrPortMemoryDelta;
+ *OffsetPointer -= (ULONG_PTR)ApiMessage;
}
+ ++OffsetPointer;
}
}
@@ -120,13 +124,16 @@
* pointers, and convert back these message server pointers
* into client pointers.
*/
- for (i = 0 ; i < CaptureBuffer->PointerCount ; ++i)
+ PointerCount = CaptureBuffer->PointerCount;
+ OffsetPointer = CaptureBuffer->PointerOffsetsArray;
+ while (PointerCount--)
{
- if (CaptureBuffer->PointerOffsetsArray[i] != 0)
+ if (*OffsetPointer != 0)
{
- CaptureBuffer->PointerOffsetsArray[i] += (ULONG_PTR)ApiMessage;
- *(PULONG_PTR)CaptureBuffer->PointerOffsetsArray[i] -= CsrPortMemoryDelta;
+ *OffsetPointer += (ULONG_PTR)ApiMessage;
+ *(PULONG_PTR)*OffsetPointer -= CsrPortMemoryDelta;
}
+ ++OffsetPointer;
}
}
Modified: branches/ros-csrss/subsystems/win32/csrsrv/api.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-csrss/subsystems/win32/csrs…
==============================================================================
--- branches/ros-csrss/subsystems/win32/csrsrv/api.c [iso-8859-1] (original)
+++ branches/ros-csrss/subsystems/win32/csrsrv/api.c [iso-8859-1] Thu Dec 6 22:24:27 2012
@@ -1125,7 +1125,9 @@
PCSR_CAPTURE_BUFFER LocalCaptureBuffer = NULL, RemoteCaptureBuffer = NULL;
SIZE_T BufferDistance;
ULONG Length = 0;
- ULONG i;
+ ULONG PointerCount;
+ PULONG_PTR OffsetPointer;
+ ULONG_PTR CurrentOffset;
/* Use SEH to make sure this is valid */
_SEH2_TRY
@@ -1182,19 +1184,23 @@
* All the pointer offsets correspond to pointers which point
* to the remote data buffer instead of the local one.
*/
- for (i = 0 ; i < RemoteCaptureBuffer->PointerCount ; ++i)
- {
- if (RemoteCaptureBuffer->PointerOffsetsArray[i] != 0)
- {
- /* Temporarily transform the offset into a pointer */
- RemoteCaptureBuffer->PointerOffsetsArray[i] += (ULONG_PTR)ApiMessage;
+ PointerCount = RemoteCaptureBuffer->PointerCount;
+ OffsetPointer = RemoteCaptureBuffer->PointerOffsetsArray;
+ while (PointerCount--)
+ {
+ CurrentOffset = *OffsetPointer;
+
+ if (CurrentOffset != 0)
+ {
+ /* Get the pointer corresponding to the offset */
+ CurrentOffset += (ULONG_PTR)ApiMessage;
/* Validate the bounds of the current pointed pointer */
- if ((*(PULONG_PTR)RemoteCaptureBuffer->PointerOffsetsArray[i] >= CsrThread->Process->ClientViewBase) &&
- (*(PULONG_PTR)RemoteCaptureBuffer->PointerOffsetsArray[i] < CsrThread->Process->ClientViewBounds))
+ if ((*(PULONG_PTR)CurrentOffset >= CsrThread->Process->ClientViewBase) &&
+ (*(PULONG_PTR)CurrentOffset < CsrThread->Process->ClientViewBounds))
{
/* Modify the pointed pointer to take into account its new position */
- *(PULONG_PTR)RemoteCaptureBuffer->PointerOffsetsArray[i] += BufferDistance;
+ *(PULONG_PTR)CurrentOffset += BufferDistance;
}
else
{
@@ -1203,10 +1209,9 @@
DbgBreakPoint();
ApiMessage->Status = STATUS_INVALID_PARAMETER;
}
-
- /* Transform back into an offset */
- RemoteCaptureBuffer->PointerOffsetsArray[i] -= (ULONG_PTR)ApiMessage;
- }
+ }
+
+ ++OffsetPointer;
}
/* Check if we got success */
@@ -1249,7 +1254,9 @@
{
PCSR_CAPTURE_BUFFER RemoteCaptureBuffer, LocalCaptureBuffer;
SIZE_T BufferDistance;
- ULONG i;
+ ULONG PointerCount;
+ PULONG_PTR OffsetPointer;
+ ULONG_PTR CurrentOffset;
/* Get the remote capture buffer */
RemoteCaptureBuffer = ApiMessage->CsrCaptureData;
@@ -1272,19 +1279,22 @@
* to the local data buffer instead of the remote one (revert
* the logic of CsrCaptureArguments).
*/
- for (i = 0 ; i < RemoteCaptureBuffer->PointerCount ; ++i)
- {
- if (RemoteCaptureBuffer->PointerOffsetsArray[i] != 0)
- {
- /* Temporarily transform the offset into a pointer */
- RemoteCaptureBuffer->PointerOffsetsArray[i] += (ULONG_PTR)ApiMessage;
+ PointerCount = RemoteCaptureBuffer->PointerCount;
+ OffsetPointer = RemoteCaptureBuffer->PointerOffsetsArray;
+ while (PointerCount--)
+ {
+ CurrentOffset = *OffsetPointer;
+
+ if (CurrentOffset != 0)
+ {
+ /* Get the pointer corresponding to the offset */
+ CurrentOffset += (ULONG_PTR)ApiMessage;
/* Modify the pointed pointer to take into account its new position */
- *(PULONG_PTR)RemoteCaptureBuffer->PointerOffsetsArray[i] -= BufferDistance;
-
- /* Transform back into an offset */
- RemoteCaptureBuffer->PointerOffsetsArray[i] -= (ULONG_PTR)ApiMessage;
- }
+ *(PULONG_PTR)CurrentOffset -= BufferDistance;
+ }
+
+ ++OffsetPointer;
}
/* Copy the data back */
@@ -1328,7 +1338,8 @@
{
PCSR_CAPTURE_BUFFER CaptureBuffer = ApiMessage->CsrCaptureData;
SIZE_T BufferDistance = (ULONG_PTR)Buffer - (ULONG_PTR)ApiMessage;
- ULONG i;
+ ULONG PointerCount;
+ PULONG_PTR OffsetPointer;
/*
* Check whether we have a valid buffer pointer, elements
@@ -1364,16 +1375,20 @@
if ((CaptureBuffer->Size - (ULONG_PTR)*Buffer + (ULONG_PTR)CaptureBuffer) >=
(ElementCount * ElementSize))
{
- for (i = 0 ; i < CaptureBuffer->PointerCount ; ++i)
+ /* Perform the validation test */
+ PointerCount = CaptureBuffer->PointerCount;
+ OffsetPointer = CaptureBuffer->PointerOffsetsArray;
+ while (PointerCount--)
{
/*
* The pointer offset must be equal to the delta between
* the addresses of the buffer and of the API message.
*/
- if (CaptureBuffer->PointerOffsetsArray[i] == BufferDistance)
+ if (*OffsetPointer == BufferDistance)
{
return TRUE;
}
+ ++OffsetPointer;
}
}
}
Author: hbelusca
Date: Thu Dec 6 21:52:09 2012
New Revision: 57808
URL: http://svn.reactos.org/svn/reactos?rev=57808&view=rev
Log:
[NTDLL]
Correct some comments.
Modified:
branches/ros-csrss/dll/ntdll/csr/capture.c
Modified: branches/ros-csrss/dll/ntdll/csr/capture.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/ntdll/csr/capture…
==============================================================================
--- branches/ros-csrss/dll/ntdll/csr/capture.c [iso-8859-1] (original)
+++ branches/ros-csrss/dll/ntdll/csr/capture.c [iso-8859-1] Thu Dec 6 21:52:09 2012
@@ -93,7 +93,7 @@
/* Validate size */
if (BufferSize >= MAXLONG) return NULL;
- /* Add the size of the header and for each pointer to the pointers */
+ /* Add the size of the header and for each offset to the pointers */
BufferSize += FIELD_OFFSET(CSR_CAPTURE_BUFFER, PointerOffsetsArray) + (ArgumentCount * sizeof(ULONG_PTR));
/* Align it to a 4-byte boundary */
@@ -107,7 +107,7 @@
CaptureBuffer->Size = BufferSize;
CaptureBuffer->PointerCount = 0;
- /* Initialize all the pointers */
+ /* Initialize all the offsets */
RtlZeroMemory(CaptureBuffer->PointerOffsetsArray,
ArgumentCount * sizeof(ULONG_PTR));