Author: akhaldi
Date: Wed Nov 26 16:49:31 2014
New Revision: 65492

URL: http://svn.reactos.org/svn/reactos?rev=65492&view=rev
Log:
* Sync up to trunk head (r65491).

Modified:
    branches/shell-experiments/   (props changed)
    branches/shell-experiments/base/shell/explorer/globals.h
    branches/shell-experiments/base/shell/explorer/taskbar/desktopbar.cpp
    branches/shell-experiments/base/system/lsass/lsass.c
    branches/shell-experiments/base/system/services/services.c
    branches/shell-experiments/base/system/winlogon/winlogon.c
    branches/shell-experiments/boot/freeldr/freeldr/include/arch/pc/x86common.h
    branches/shell-experiments/drivers/filesystems/ntfs/mft.c
    branches/shell-experiments/win32ss/gdi/eng/floatobj.h
    branches/shell-experiments/win32ss/gdi/ntgdi/freetype.c
    branches/shell-experiments/win32ss/gdi/ntgdi/xformobj.c
    branches/shell-experiments/win32ss/user/ntuser/msgqueue.c
    branches/shell-experiments/win32ss/user/ntuser/winpos.c

Propchange: branches/shell-experiments/
------------------------------------------------------------------------------
--- svn:mergeinfo       (original)
+++ svn:mergeinfo       Wed Nov 26 16:49:31 2014
@@ -19,4 +19,4 @@
 
/branches/usb-bringup:51335,51337,51341-51343,51348,51350,51353,51355,51365-51369,51372,51384-54388,54396-54398,54736-54737,54752-54754,54756-54760,54762,54764-54765,54767-54768,54772,54774-54777,54781,54787,54790-54792,54797-54798,54806,54808,54834-54838,54843,54850,54852,54856,54858-54859
 /branches/usb-bringup-trunk:55019-55543,55548-55554,55556-55567
 /branches/wlan-bringup:54809-54998
-/trunk/reactos:61927-65481
+/trunk/reactos:61927-65491

Modified: branches/shell-experiments/base/shell/explorer/globals.h
URL: 
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/explorer/globals.h?rev=65492&r1=65491&r2=65492&view=diff
==============================================================================
--- branches/shell-experiments/base/shell/explorer/globals.h    [iso-8859-1] 
(original)
+++ branches/shell-experiments/base/shell/explorer/globals.h    [iso-8859-1] 
Wed Nov 26 16:49:31 2014
@@ -235,7 +235,7 @@
 #endif
 
 
-#define        DESKTOP_COUNT   2
+#define        DESKTOP_COUNT   4
 
 struct Desktops : public vector<DesktopRef>
 {

Modified: branches/shell-experiments/base/shell/explorer/taskbar/desktopbar.cpp
URL: 
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/explorer/taskbar/desktopbar.cpp?rev=65492&r1=65491&r2=65492&view=diff
==============================================================================
--- branches/shell-experiments/base/shell/explorer/taskbar/desktopbar.cpp       
[iso-8859-1] (original)
+++ branches/shell-experiments/base/shell/explorer/taskbar/desktopbar.cpp       
[iso-8859-1] Wed Nov 26 16:49:31 2014
@@ -145,8 +145,8 @@
        TCHAR QuickLaunchBand[] = _T("Quicklaunch");
        rbBand.lpText = QuickLaunchBand;
        rbBand.hwndChild = _hwndQuickLaunch;
-       rbBand.cx = 100;
-       rbBand.cxMinChild = 100;
+       rbBand.cx = 150;
+       rbBand.cxMinChild = 150;
        rbBand.wID = IDW_QUICKLAUNCHBAR;
        SendMessage(_hwndrebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand);
 
@@ -451,7 +451,9 @@
                break;
 
          case ID_SWITCH_DESKTOP_1:
-         case ID_SWITCH_DESKTOP_1+1: {
+          case ID_SWITCH_DESKTOP_1+1:
+         case ID_SWITCH_DESKTOP_1+2:
+         case ID_SWITCH_DESKTOP_1+3: {
                int desktop_idx = id - ID_SWITCH_DESKTOP_1;
 
                g_Globals._desktops.SwitchToDesktop(desktop_idx);

Modified: branches/shell-experiments/base/system/lsass/lsass.c
URL: 
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/system/lsass/lsass.c?rev=65492&r1=65491&r2=65492&view=diff
==============================================================================
--- branches/shell-experiments/base/system/lsass/lsass.c        [iso-8859-1] 
(original)
+++ branches/shell-experiments/base/system/lsass/lsass.c        [iso-8859-1] 
Wed Nov 26 16:49:31 2014
@@ -28,6 +28,7 @@
 #define NTOS_MODE_USER
 
 #include <ndk/psfuncs.h>
+#include <ndk/rtlfuncs.h>
 
 #include <lsass/lsasrv.h>
 #include <samsrv/samsrv.h>
@@ -45,6 +46,9 @@
 
     DPRINT("Local Security Authority Subsystem\n");
     DPRINT("  Initializing...\n");
+
+    /* Make us critical */
+    RtlSetProcessIsCritical(TRUE, NULL, TRUE);
 
     /* Initialize the LSA server DLL. */
     Status = LsapInitLsa();

Modified: branches/shell-experiments/base/system/services/services.c
URL: 
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/system/services/services.c?rev=65492&r1=65491&r2=65492&view=diff
==============================================================================
--- branches/shell-experiments/base/system/services/services.c  [iso-8859-1] 
(original)
+++ branches/shell-experiments/base/system/services/services.c  [iso-8859-1] 
Wed Nov 26 16:49:31 2014
@@ -316,6 +316,9 @@
 
     DPRINT("SERVICES: Service Control Manager\n");
 
+    /* Make us critical */
+    RtlSetProcessIsCritical(TRUE, NULL, TRUE);
+
     /* We are initializing ourselves */
     ScmInitialize = TRUE;
 

Modified: branches/shell-experiments/base/system/winlogon/winlogon.c
URL: 
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/system/winlogon/winlogon.c?rev=65492&r1=65491&r2=65492&view=diff
==============================================================================
--- branches/shell-experiments/base/system/winlogon/winlogon.c  [iso-8859-1] 
(original)
+++ branches/shell-experiments/base/system/winlogon/winlogon.c  [iso-8859-1] 
Wed Nov 26 16:49:31 2014
@@ -318,6 +318,10 @@
 
     hAppInstance = hInstance;
 
+    /* Make us critical */
+    RtlSetProcessIsCritical(TRUE, NULL, FALSE);
+    RtlSetThreadIsCritical(TRUE, NULL, FALSE);
+
     if (!RegisterLogonProcess(GetCurrentProcessId(), TRUE))
     {
         ERR("WL: Could not register logon process\n");

Modified: 
branches/shell-experiments/boot/freeldr/freeldr/include/arch/pc/x86common.h
URL: 
http://svn.reactos.org/svn/reactos/branches/shell-experiments/boot/freeldr/freeldr/include/arch/pc/x86common.h?rev=65492&r1=65491&r2=65492&view=diff
==============================================================================
--- branches/shell-experiments/boot/freeldr/freeldr/include/arch/pc/x86common.h 
[iso-8859-1] (original)
+++ branches/shell-experiments/boot/freeldr/freeldr/include/arch/pc/x86common.h 
[iso-8859-1] Wed Nov 26 16:49:31 2014
@@ -17,7 +17,7 @@
 #define FREELDR_BASE        HEX(F800)
 #define FREELDR_PE_BASE    HEX(10000)
 #define DISKREADBUFFER     HEX(8E000) /* Buffer to store data read in from the 
disk via the BIOS */
-#define MEMORY_MARGIN      HEX(9C000) /* Highest usable address */
+#define MEMORY_MARGIN      HEX(9A000) /* Highest usable address */
 /* 9F000- 9FFFF is reserved for the EBDA */
 
 #define BIOSCALLBUFSEGMENT (BIOSCALLBUFFER/16) /* Buffer to store temporary 
data for any Int386() call */

Modified: branches/shell-experiments/drivers/filesystems/ntfs/mft.c
URL: 
http://svn.reactos.org/svn/reactos/branches/shell-experiments/drivers/filesystems/ntfs/mft.c?rev=65492&r1=65491&r2=65492&view=diff
==============================================================================
--- branches/shell-experiments/drivers/filesystems/ntfs/mft.c   [iso-8859-1] 
(original)
+++ branches/shell-experiments/drivers/filesystems/ntfs/mft.c   [iso-8859-1] 
Wed Nov 26 16:49:31 2014
@@ -558,7 +558,7 @@
         IndexRoot = (PINDEX_ROOT_ATTRIBUTE)IndexRecord;
         IndexEntry = (PINDEX_ENTRY_ATTRIBUTE)((PCHAR)&IndexRoot->Header + 
IndexRoot->Header.FirstEntryOffset);
         /* Index root is always resident. */
-        IndexEntryEnd = (PINDEX_ENTRY_ATTRIBUTE)(IndexRecord + 
IndexRootCtx->Record.Resident.ValueLength);
+        IndexEntryEnd = (PINDEX_ENTRY_ATTRIBUTE)(IndexRecord + 
IndexRoot->Header.TotalSizeOfEntries);
         ReleaseAttributeContext(IndexRootCtx);
 
         DPRINT("IndexRecordSize: %x IndexBlockSize: %x\n", 
Vcb->NtfsInfo.BytesPerIndexRecord, IndexRoot->SizeOfEntry);

Modified: branches/shell-experiments/win32ss/gdi/eng/floatobj.h
URL: 
http://svn.reactos.org/svn/reactos/branches/shell-experiments/win32ss/gdi/eng/floatobj.h?rev=65492&r1=65491&r2=65492&view=diff
==============================================================================
--- branches/shell-experiments/win32ss/gdi/eng/floatobj.h       [iso-8859-1] 
(original)
+++ branches/shell-experiments/win32ss/gdi/eng/floatobj.h       [iso-8859-1] 
Wed Nov 26 16:49:31 2014
@@ -1,4 +1,8 @@
 #pragma once
+
+C_ASSERT(sizeof(FIX) == sizeof(LONG));
+#define FIX2LONG(x) (((x) + 8) >> 4)
+#define LONG2FIX(x) ((x) << 4)
 
 #if defined(_M_IX86)
 
@@ -10,6 +14,7 @@
     EFLOAT_S *pef2 = (EFLOAT_S*)pf2;
     return (pef1->lMant == pef2->lMant && pef1->lExp == pef2->lExp);
 }
+#define FLOATOBJ_Equal _FLOATOBJ_Equal
 
 FORCEINLINE
 LONG
@@ -18,10 +23,36 @@
     EFLOAT_S *pef = (EFLOAT_S*)pf;
     return pef->lMant >> (32 - pef->lExp);
 }
+#define FLOATOBJ_GetLong _FLOATOBJ_GetLong
+
+/*!
+ * \brief Converts a FLOATOBJ into a LONG by truncating the value to integer
+ *
+ * \param pf - Pointer to a FLOATOBJ containing the value to convert
+ *
+ * \param pl - Pointer to a variable that receives the result
+ *
+ * \return TRUE if the function succeeded, FALSE if the result would overflow
+ *         a LONG.
+ */
+FORCEINLINE
+BOOL
+FASTCALL
+FLOATOBJ_bConvertToLong(FLOATOBJ *pf, PLONG pl)
+{
+    EFLOAT_S *pef = (EFLOAT_S*)pf;
+    LONG lShift = 32 - pef->lExp;
+    if (lShift < 0)
+    {
+        return FALSE;
+    }
+    *pl = pef->lMant >> lShift;
+    return TRUE;
+}
 
 FORCEINLINE
 LONG
-_FLOATOBJ_GetFix(FLOATOBJ *pf)
+FLOATOBJ_GetFix(FLOATOBJ *pf)
 {
     EFLOAT_S *pef = (EFLOAT_S*)pf;
     LONG Shift = (28 - pef->lExp);
@@ -30,7 +61,7 @@
 
 FORCEINLINE
 BOOL
-_FLOATOBJ_IsLong(FLOATOBJ *pf)
+FLOATOBJ_IsLong(FLOATOBJ *pf)
 {
     EFLOAT_S *pef = (EFLOAT_S*)pf;
     ULONG ulShift = pef->lExp;
@@ -42,7 +73,7 @@
 
 FORCEINLINE
 BOOL
-_FLOATOBJ_Equal0(FLOATOBJ *pf)
+FLOATOBJ_Equal0(FLOATOBJ *pf)
 {
     EFLOAT_S *pef = (EFLOAT_S*)pf;
     return (pef->lMant == 0 && pef->lExp == 0);
@@ -50,7 +81,7 @@
 
 FORCEINLINE
 BOOL
-_FLOATOBJ_Equal1(FLOATOBJ *pf)
+FLOATOBJ_Equal1(FLOATOBJ *pf)
 {
     EFLOAT_S *pef = (EFLOAT_S*)pf;
     return (pef->lMant == 0x40000000 && pef->lExp == 2);
@@ -70,12 +101,11 @@
 
 #else
 
-#define _FLOATOBJ_Equal(pf,pf1) (*(pf) == *(pf1))
-#define _FLOATOBJ_GetLong(pf) ((LONG)*(pf))
-#define _FLOATOBJ_IsLong(pf) ((FLOAT)((LONG)*(pf)) == *(pf))
-#define _FLOATOBJ_Equal0(pf) (*(pf) == 0.)
-#define _FLOATOBJ_Equal1(pf) (*(pf) == 1.)
-#define _FLOATOBJ_GetFix(pf) ((LONG)(*(pf) * 16.))
+#define FLOATOBJ_bConvertToLong(pf, pl) (*pl = (LONG)*pf, TRUE)
+#define FLOATOBJ_IsLong(pf) ((FLOAT)((LONG)*(pf)) == *(pf))
+#define FLOATOBJ_Equal0(pf) (*(pf) == 0.)
+#define FLOATOBJ_Equal1(pf) (*(pf) == 1.)
+#define FLOATOBJ_GetFix(pf) ((LONG)(*(pf) * 16.))
 
 #define FLOATOBJ_0 0.
 #define FLOATOBJ_1 1.

Modified: branches/shell-experiments/win32ss/gdi/ntgdi/freetype.c
URL: 
http://svn.reactos.org/svn/reactos/branches/shell-experiments/win32ss/gdi/ntgdi/freetype.c?rev=65492&r1=65491&r2=65492&view=diff
==============================================================================
--- branches/shell-experiments/win32ss/gdi/ntgdi/freetype.c     [iso-8859-1] 
(original)
+++ branches/shell-experiments/win32ss/gdi/ntgdi/freetype.c     [iso-8859-1] 
Wed Nov 26 16:49:31 2014
@@ -1105,7 +1105,7 @@
         }
         if (fs.fsCsb[0] == 0)
         { /* Let's see if we can find any interesting cmaps */
-            for (i = 0; i < FontGDI->face->num_charmaps; i++)
+            for (i = 0; i < (UINT)FontGDI->face->num_charmaps; i++)
             {
                 switch (FontGDI->face->charmaps[i]->encoding)
                 {
@@ -1501,7 +1501,7 @@
 {
     TTPOLYGONHEADER *pph;
     TTPOLYCURVE *ppc;
-    unsigned int needed = 0, point = 0, contour, first_pt;
+    int needed = 0, point = 0, contour, first_pt;
     unsigned int pph_start, cpfx;
     DWORD type;
 
@@ -2073,7 +2073,7 @@
             INT x;
             while (h--)
             {
-                for (x = 0; x < pitch; x++)
+                for (x = 0; (UINT)x < pitch; x++)
                 {
                     if (x < ft_face->glyph->bitmap.width)
                         dst[x] = (src[x / 8] & (1 << ( (7 - (x % 8))))) ? 0xff 
: 0;
@@ -2346,7 +2346,8 @@
     DWORD dwFlags)
 {
     PDC_ATTR pdcattr;
-    UINT Ret = DEFAULT_CHARSET, i;
+    UINT Ret = DEFAULT_CHARSET;
+    INT i;
     HFONT hFont;
     PTEXTOBJ TextObj;
     PFONTGDI FontGdi;
@@ -3752,7 +3753,7 @@
         {
             // FIXME this should probably be a matrix transform with TextTop 
as well.
             Scale = pdcattr->mxWorldToDevice.efM11;
-            if (_FLOATOBJ_Equal0(&Scale))
+            if (FLOATOBJ_Equal0(&Scale))
                 FLOATOBJ_Set1(&Scale);
 
             FLOATOBJ_MulLong(&Scale, Dx[i<<DxShift] << 6); // do the shift 
before multiplying to preserve precision
@@ -4029,7 +4030,7 @@
     face = FontGDI->face;
     if (face->charmap == NULL)
     {
-        for (i = 0; i < face->num_charmaps; i++)
+        for (i = 0; i < (UINT)face->num_charmaps; i++)
         {
             charmap = face->charmaps[i];
             if (charmap->encoding != 0)
@@ -4227,7 +4228,7 @@
     face = FontGDI->face;
     if (face->charmap == NULL)
     {
-        for (i = 0; i < face->num_charmaps; i++)
+        for (i = 0; i < (UINT)face->num_charmaps; i++)
         {
             charmap = face->charmaps[i];
             if (charmap->encoding != 0)

Modified: branches/shell-experiments/win32ss/gdi/ntgdi/xformobj.c
URL: 
http://svn.reactos.org/svn/reactos/branches/shell-experiments/win32ss/gdi/ntgdi/xformobj.c?rev=65492&r1=65491&r2=65492&view=diff
==============================================================================
--- branches/shell-experiments/win32ss/gdi/ntgdi/xformobj.c     [iso-8859-1] 
(original)
+++ branches/shell-experiments/win32ss/gdi/ntgdi/xformobj.c     [iso-8859-1] 
Wed Nov 26 16:49:31 2014
@@ -12,16 +12,8 @@
 #define NDEBUG
 #include <debug.h>
 
-C_ASSERT(sizeof(FIX) == sizeof(LONG));
-#define FIX2LONG(x) (((x) + 8) >> 4)
-#define LONG2FIX(x) ((x) << 4)
-
-#define FLOATOBJ_Equal _FLOATOBJ_Equal
-#define FLOATOBJ_GetLong _FLOATOBJ_GetLong
-#define FLOATOBJ_GetFix _FLOATOBJ_GetFix
-#define FLOATOBJ_IsLong _FLOATOBJ_IsLong
-#define FLOATOBJ_Equal0 _FLOATOBJ_Equal0
-#define FLOATOBJ_Equal1 _FLOATOBJ_Equal1
+#define DOES_VALUE_OVERFLOW_LONG(x) \
+    (((__int64)((long)(x))) != (x))
 
 /** Inline helper functions 
***************************************************/
 
@@ -297,76 +289,153 @@
     return XFORMOBJ_UpdateAccel(pxoDst);
 }
 
+
+/*!
+ * \brief Transforms fix-point coordinates in an array of POINTL structures 
using
+ *        the transformation matrix from the XFORMOBJ.
+ *
+ * \param pxo - Pointer to the XFORMOBJ
+ *
+ * \param cPoints - Number of coordinates to transform
+ *
+ * \param pptIn - Pointer to an array of POINTL structures containing the
+ *        source coordinates.
+ *
+ * \param pptOut - Pointer to an array of POINTL structures, receiving the
+ *        transformed coordinates. Can be the same as pptIn.
+ *
+ * \return TRUE if the operation was successful, FALSE if any of the 
calculations
+ *         caused an integer overflow.
+ *
+ * \note If the function returns FALSE, it might still have written to the
+ *       output buffer. If pptIn and pptOut are equal, the source coordinates
+ *       might have been partly overwritten!
+ */
 static
-VOID
+BOOL
 NTAPI
-XFORMOBJ_vXformFixPoints(
-    IN XFORMOBJ  *pxo,
-    IN ULONG  cPoints,
-    IN PPOINTL  pptIn,
-    OUT PPOINTL  pptOut)
+XFORMOBJ_bXformFixPoints(
+    _In_ XFORMOBJ *pxo,
+    _In_ ULONG cPoints,
+    _In_reads_(cPoints) PPOINTL pptIn,
+    _Out_writes_(cPoints) PPOINTL pptOut)
 {
     PMATRIX pmx;
     INT i;
     FLOATOBJ fo1, fo2;
     FLONG flAccel;
+    LONG lM11, lM12, lM21, lM22, lTemp;
+    register LONGLONG llx, lly;
 
     pmx = XFORMOBJ_pmx(pxo);
     flAccel = pmx->flAccel;
 
     if ((flAccel & (XFORM_SCALE|XFORM_UNITY)) == (XFORM_SCALE|XFORM_UNITY))
     {
-        /* Identity transformation, nothing todo */
+        /* Identity transformation, nothing to do */
     }
     else if (flAccel & XFORM_INTEGER)
     {
         if (flAccel & XFORM_UNITY)
         {
-            /* 1-scale integer transform */
-            LONG lM12 = FLOATOBJ_GetLong(&pmx->efM12);
-            LONG lM21 = FLOATOBJ_GetLong(&pmx->efM21);
+            /* 1-scale integer transform, get the off-diagonal elements */
+            if (!FLOATOBJ_bConvertToLong(&pmx->efM12, &lM12) ||
+                !FLOATOBJ_bConvertToLong(&pmx->efM21, &lM21))
+            {
+                NT_ASSERT(FALSE);
+                return FALSE;
+            }
 
             i = cPoints - 1;
             do
             {
-                LONG x = pptIn[i].x + pptIn[i].y * lM21;
-                LONG y = pptIn[i].y + pptIn[i].x * lM12;
-                pptOut[i].y = y;
-                pptOut[i].x = x;
+                /* Calculate x in 64 bit and check for overflow */
+                llx = Int32x32To64(pptIn[i].y, lM21) + pptIn[i].x;
+                if (DOES_VALUE_OVERFLOW_LONG(llx))
+                {
+                    return FALSE;
+                }
+
+                /* Calculate y in 64 bit and check for overflow */
+                lly = Int32x32To64(pptIn[i].x, lM12) + pptIn[i].y;
+                if (DOES_VALUE_OVERFLOW_LONG(lly))
+                {
+                    return FALSE;
+                }
+
+                /* Write back the results */
+                pptOut[i].x = (LONG)llx;
+                pptOut[i].y = (LONG)lly;
             }
             while (--i >= 0);
         }
         else if (flAccel & XFORM_SCALE)
         {
-            /* Diagonal integer transform */
-            LONG lM11 = FLOATOBJ_GetLong(&pmx->efM11);
-            LONG lM22 = FLOATOBJ_GetLong(&pmx->efM22);
+            /* Diagonal integer transform, get the diagonal elements */
+            if (!FLOATOBJ_bConvertToLong(&pmx->efM11, &lM11) ||
+                !FLOATOBJ_bConvertToLong(&pmx->efM22, &lM22))
+            {
+                NT_ASSERT(FALSE);
+                return FALSE;
+            }
 
             i = cPoints - 1;
             do
             {
-                pptOut[i].x = pptIn[i].x * lM11;
-                pptOut[i].y = pptIn[i].y * lM22;
+                /* Calculate x in 64 bit and check for overflow */
+                llx = Int32x32To64(pptIn[i].x, lM11);
+                if (DOES_VALUE_OVERFLOW_LONG(llx))
+                {
+                    return FALSE;
+                }
+
+                /* Calculate y in 64 bit and check for overflow */
+                lly = Int32x32To64(pptIn[i].y, lM22);
+                if (DOES_VALUE_OVERFLOW_LONG(lly))
+                {
+                    return FALSE;
+                }
+
+                /* Write back the results */
+                pptOut[i].x = (LONG)llx;
+                pptOut[i].y = (LONG)lly;
             }
             while (--i >= 0);
         }
         else
         {
             /* Full integer transform */
-            LONG lM11 = FLOATOBJ_GetLong(&pmx->efM11);
-            LONG lM12 = FLOATOBJ_GetLong(&pmx->efM12);
-            LONG lM21 = FLOATOBJ_GetLong(&pmx->efM21);
-            LONG lM22 = FLOATOBJ_GetLong(&pmx->efM22);
+            if (!FLOATOBJ_bConvertToLong(&pmx->efM11, &lM11) ||
+                !FLOATOBJ_bConvertToLong(&pmx->efM12, &lM12) ||
+                !FLOATOBJ_bConvertToLong(&pmx->efM21, &lM21) ||
+                !FLOATOBJ_bConvertToLong(&pmx->efM22, &lM22))
+            {
+                NT_ASSERT(FALSE);
+                return FALSE;
+            }
 
             i = cPoints - 1;
             do
             {
-                LONG x;
-                x  = pptIn[i].x * lM11;
-                x += pptIn[i].y * lM21;
-                pptOut[i].y  = pptIn[i].y * lM22;
-                pptOut[i].y += pptIn[i].x * lM12;
-                pptOut[i].x = x;
+                /* Calculate x in 64 bit and check for overflow */
+                llx  = Int32x32To64(pptIn[i].x, lM11);
+                llx += Int32x32To64(pptIn[i].y, lM21);
+                if (DOES_VALUE_OVERFLOW_LONG(llx))
+                {
+                    return FALSE;
+                }
+
+                /* Calculate y in 64 bit and check for overflow */
+                lly  = Int32x32To64(pptIn[i].y, lM22);
+                lly += Int32x32To64(pptIn[i].x, lM12);
+                if (DOES_VALUE_OVERFLOW_LONG(lly))
+                {
+                    return FALSE;
+                }
+
+                /* Write back the results */
+                pptOut[i].x = (LONG)llx;
+                pptOut[i].y = (LONG)lly;
             }
             while (--i >= 0);
         }
@@ -377,12 +446,35 @@
         i = cPoints - 1;
         do
         {
+            /* Calculate x in 64 bit and check for overflow */
             fo1 = pmx->efM21;
             FLOATOBJ_MulLong(&fo1, pptIn[i].y);
+            if (!FLOATOBJ_bConvertToLong(&fo1, &lTemp))
+            {
+                return FALSE;
+            }
+            llx = (LONGLONG)pptIn[i].x + lTemp;
+            if (DOES_VALUE_OVERFLOW_LONG(llx))
+            {
+                return FALSE;
+            }
+
+            /* Calculate y in 64 bit and check for overflow */
             fo2 = pmx->efM12;
             FLOATOBJ_MulLong(&fo2, pptIn[i].x);
-            pptOut[i].x = pptIn[i].x + FLOATOBJ_GetLong(&fo1);
-            pptOut[i].y = pptIn[i].y + FLOATOBJ_GetLong(&fo2);
+            if (!FLOATOBJ_bConvertToLong(&fo2, &lTemp))
+            {
+                return FALSE;
+            }
+            lly = (LONGLONG)pptIn[i].y + lTemp;
+            if (DOES_VALUE_OVERFLOW_LONG(lly))
+            {
+                return FALSE;
+            }
+
+            /* Write back the results */
+            pptOut[i].x = (LONG)llx;
+            pptOut[i].y = (LONG)lly;
         }
         while (--i >= 0);
     }
@@ -394,10 +486,17 @@
         {
             fo1 = pmx->efM11;
             FLOATOBJ_MulLong(&fo1, pptIn[i].x);
-            pptOut[i].x = FLOATOBJ_GetLong(&fo1);
+            if (!FLOATOBJ_bConvertToLong(&fo1, &pptOut[i].x))
+            {
+                return FALSE;
+            }
+
             fo2 = pmx->efM22;
             FLOATOBJ_MulLong(&fo2, pptIn[i].y);
-            pptOut[i].y = FLOATOBJ_GetLong(&fo2);
+            if (!FLOATOBJ_bConvertToLong(&fo2, &pptOut[i].y))
+            {
+                return FALSE;
+            }
         }
         while (--i >= 0);
     }
@@ -407,10 +506,21 @@
         i = cPoints - 1;
         do
         {
+            /* Calculate x as FLOATOBJ */
             MulAddLong(&fo1, &pmx->efM11, pptIn[i].x, &pmx->efM21, pptIn[i].y);
+
+            /* Calculate y as FLOATOBJ */
             MulAddLong(&fo2, &pmx->efM12, pptIn[i].x, &pmx->efM22, pptIn[i].y);
-            pptOut[i].x = FLOATOBJ_GetLong(&fo1);
-            pptOut[i].y = FLOATOBJ_GetLong(&fo2);
+
+            if (!FLOATOBJ_bConvertToLong(&fo1, &pptOut[i].x))
+            {
+                return FALSE;
+            }
+
+            if (!FLOATOBJ_bConvertToLong(&fo2, &pptOut[i].y))
+            {
+                return FALSE;
+            }
         }
         while (--i >= 0);
     }
@@ -421,11 +531,24 @@
         i = cPoints - 1;
         do
         {
-            pptOut[i].x += pmx->fxDx;
-            pptOut[i].y += pmx->fxDy;
+            llx = (LONGLONG)pptOut[i].x + pmx->fxDx;
+            if (DOES_VALUE_OVERFLOW_LONG(llx))
+            {
+                return FALSE;
+            }
+            pptOut[i].x = (LONG)llx;
+
+            lly = (LONGLONG)pptOut[i].y + pmx->fxDy;
+            if (DOES_VALUE_OVERFLOW_LONG(lly))
+            {
+                return FALSE;
+            }
+            pptOut[i].y = (LONG)lly;
         }
         while (--i >= 0);
     }
+
+    return TRUE;
 }
 
 /** Public functions 
**********************************************************/
@@ -534,7 +657,10 @@
     }
 
     /* Do the actual fixpoint transformation */
-    XFORMOBJ_vXformFixPoints(pxo, cPoints, pvIn, pvOut);
+    if (!XFORMOBJ_bXformFixPoints(pxo, cPoints, pvIn, pvOut))
+    {
+        return FALSE;
+    }
 
     /* Convert POINTFIX to POINTL? */
     if (iMode == XF_INV_FXTOL || iMode == XF_INV_LTOL || iMode == XF_LTOL)

Modified: branches/shell-experiments/win32ss/user/ntuser/msgqueue.c
URL: 
http://svn.reactos.org/svn/reactos/branches/shell-experiments/win32ss/user/ntuser/msgqueue.c?rev=65492&r1=65491&r2=65492&view=diff
==============================================================================
--- branches/shell-experiments/win32ss/user/ntuser/msgqueue.c   [iso-8859-1] 
(original)
+++ branches/shell-experiments/win32ss/user/ntuser/msgqueue.c   [iso-8859-1] 
Wed Nov 26 16:49:31 2014
@@ -1450,7 +1450,10 @@
     }
     else
     {
-        pwndMsg = co_WinPosWindowFromPoint(pwndMsg, &msg->pt, &hittest, FALSE);
+        /*
+           Start with null window. See wine win.c:test_mouse_input:WM_COMMAND 
tests.
+        */
+        pwndMsg = co_WinPosWindowFromPoint( NULL, &msg->pt, &hittest, FALSE);
     }
 
     TRACE("Got mouse message for %p, hittest: 0x%x\n", msg->hwnd, hittest);

Modified: branches/shell-experiments/win32ss/user/ntuser/winpos.c
URL: 
http://svn.reactos.org/svn/reactos/branches/shell-experiments/win32ss/user/ntuser/winpos.c?rev=65492&r1=65491&r2=65492&view=diff
==============================================================================
--- branches/shell-experiments/win32ss/user/ntuser/winpos.c     [iso-8859-1] 
(original)
+++ branches/shell-experiments/win32ss/user/ntuser/winpos.c     [iso-8859-1] 
Wed Nov 26 16:49:31 2014
@@ -327,6 +327,7 @@
    /* If this is popup window, try to activate the owner first. */
    if ((Wnd->style & WS_POPUP) && (WndTo = Wnd->spwndOwner))
    {
+      ERR("WPAOW Popup with Owner\n");
       WndTo = UserGetAncestor( WndTo, GA_ROOT );
       if (can_activate_window(WndTo)) goto done;
    }
@@ -336,18 +337,41 @@
    WndTo = Wnd;
    for (;;)
    {
-      if (!(WndTo = WndTo->spwndNext)) break;
-      if (can_activate_window( WndTo )) break;
+      if (!(WndTo = WndTo->spwndNext))  break;
+      if (can_activate_window( WndTo )) goto done;
+   }
+
+   /*
+      Fixes wine win.c:test_SetParent last ShowWindow test after popup dies.
+      Check for previous active window to bring to top.
+   */
+   if (Wnd) 
+   {
+      WndTo = Wnd->head.pti->MessageQueue->spwndActivePrev;
+      if (can_activate_window( WndTo )) goto done;
+   }
+
+   // Find any window to bring to top. Works Okay for wine.
+   WndTo = UserGetDesktopWindow();
+   WndTo = WndTo->spwndChild;
+   for (;;)
+   {
+      if (WndTo == Wnd)
+      {
+         WndTo = NULL;
+         break;
+      }
+      if (can_activate_window( WndTo )) goto done;
+      if (!(WndTo = WndTo->spwndNext))  break;
    }
 
 done:
-
    if (WndTo) UserRefObjectCo(WndTo, &Ref);
 
-   if (!gpqForeground || Wnd == gpqForeground->spwndActive)
+   if ((gpqForeground && !gpqForeground->spwndActive) || Wnd == 
gpqForeground->spwndActive)
    {
       /* ReactOS can pass WndTo = NULL to co_IntSetForegroundWindow and 
returns FALSE. */
-      //ERR("WinPosActivateOtherWindow Set FG 0x%p\n",WndTo);
+      //ERR("WinPosActivateOtherWindow Set FG 0x%p hWnd %p\n",WndTo, WndTo ? 
WndTo->head.h : 0);
       if (co_IntSetForegroundWindow(WndTo))
       {
          if (WndTo) UserDerefObjectCo(WndTo);


Reply via email to