[ros-diffs] [tkreuzer] 55993: [WIN32K] - Fix a possible integer overflow in NtGdiCreateBitmap - Don't cast length of LARGE_STRING (ULONG) to USHORT, instead truncate to MAXUSHORT. This is still hacky, but bett...

tkreuzer at svn.reactos.org tkreuzer at svn.reactos.org
Sun Mar 4 11:32:43 UTC 2012


Author: tkreuzer
Date: Sun Mar  4 11:32:43 2012
New Revision: 55993

URL: http://svn.reactos.org/svn/reactos?rev=55993&view=rev
Log:
[WIN32K]
- Fix a possible integer overflow in NtGdiCreateBitmap
- Don't cast length of LARGE_STRING (ULONG) to USHORT, instead truncate to MAXUSHORT. This is still hacky, but better than before.
- Fix MSVC warnings

Modified:
    trunk/reactos/include/reactos/win32k/ntuser.h
    trunk/reactos/subsystems/win32/win32k/include/userfuncs.h
    trunk/reactos/subsystems/win32/win32k/ntuser/class.c
    trunk/reactos/subsystems/win32/win32k/ntuser/defwnd.c
    trunk/reactos/subsystems/win32/win32k/ntuser/display.c
    trunk/reactos/subsystems/win32/win32k/ntuser/input.c
    trunk/reactos/subsystems/win32/win32k/ntuser/kbdlayout.c
    trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c
    trunk/reactos/subsystems/win32/win32k/ntuser/menu.c
    trunk/reactos/subsystems/win32/win32k/ntuser/message.c
    trunk/reactos/subsystems/win32/win32k/ntuser/metric.c
    trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c
    trunk/reactos/subsystems/win32/win32k/ntuser/painting.c
    trunk/reactos/subsystems/win32/win32k/ntuser/scrollbar.c
    trunk/reactos/subsystems/win32/win32k/ntuser/sysparams.c
    trunk/reactos/subsystems/win32/win32k/ntuser/window.c
    trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c
    trunk/reactos/subsystems/win32/win32k/objects/arc.c
    trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c
    trunk/reactos/subsystems/win32/win32k/objects/dibobj.c
    trunk/reactos/subsystems/win32/win32k/objects/drawing.c
    trunk/reactos/subsystems/win32/win32k/objects/fillshap.c
    trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c
    trunk/reactos/subsystems/win32/win32k/objects/line.c
    trunk/reactos/subsystems/win32/win32k/objects/palette.c
    trunk/reactos/subsystems/win32/win32k/objects/path.c
    trunk/reactos/subsystems/win32/win32k/objects/pen.c

Modified: trunk/reactos/include/reactos/win32k/ntuser.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/win32k/ntuser.h?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -2038,7 +2038,7 @@
 UINT
 NTAPI
 NtUserGetKeyboardLayoutList(
-  INT nItems,
+  ULONG nItems,
   HKL *pHklBuff);
 
 BOOL

Modified: trunk/reactos/subsystems/win32/win32k/include/userfuncs.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/include/userfuncs.h?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/userfuncs.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/userfuncs.h [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -62,8 +62,8 @@
 
 /*************** METRIC.C ***************/
 
-BOOL FASTCALL InitMetrics(VOID);
-ULONG FASTCALL UserGetSystemMetrics(ULONG Index);
+BOOL NTAPI InitMetrics(VOID);
+LONG NTAPI UserGetSystemMetrics(ULONG Index);
 
 /*************** KEYBOARD.C ***************/
 

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/class.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/class.c?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/class.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/class.c [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -64,7 +64,7 @@
     NULL,
     FNID_MESSAGEWND,
     ICLS_HWNDMESSAGE
-  }  
+  }
 };
 
 static struct
@@ -82,8 +82,8 @@
  { FNID_BUTTON,     ICLS_BUTTON},
  { FNID_COMBOBOX,   ICLS_COMBOBOX},
  { FNID_COMBOLBOX,  ICLS_COMBOLBOX},
- { FNID_DIALOG,     ICLS_DIALOG},  
- { FNID_EDIT,       ICLS_EDIT}, 
+ { FNID_DIALOG,     ICLS_DIALOG},
+ { FNID_EDIT,       ICLS_EDIT},
  { FNID_LISTBOX,    ICLS_LISTBOX},
  { FNID_MDICLIENT,  ICLS_MDICLIENT},
  { FNID_STATIC,     ICLS_STATIC},
@@ -97,7 +97,7 @@
 LookupFnIdToiCls(int FnId, int *iCls )
 {
   int i;
-  
+
   for ( i = 0; i < ARRAYSIZE(FnidToiCls); i++)
   {
      if (FnidToiCls[i].FnId == FnId)
@@ -178,7 +178,7 @@
 {
     PCLS Class;
     PPROCESSINFO pi = (PPROCESSINFO)Process;
-     
+
     if (pi != NULL)
     {
         /* Free all local classes */
@@ -413,7 +413,7 @@
       Class->lpfnWndProc = chWndProc;
       Class->Unicode = TRUE;
       Class->CSF_flags &= ~CSF_ANSIPROC;
-      Class->CSF_flags |= CSF_SERVERSIDEPROC;      
+      Class->CSF_flags |= CSF_SERVERSIDEPROC;
    }
    else
    {
@@ -433,7 +433,7 @@
    {
       Class->Unicode = !Ansi;
       Class->lpfnWndProc = chWndProc;
-                                
+
       Class = Class->pclsNext;
    }
 
@@ -936,7 +936,7 @@
                 ANSI_STRING AnsiString;
 
                 Class->lpszClientAnsiMenuName = (PSTR)pszMenuNameBuffer;
-                AnsiString.MaximumLength = RtlUnicodeStringToAnsiSize(MenuName);
+                AnsiString.MaximumLength = (USHORT)RtlUnicodeStringToAnsiSize(MenuName);
                 AnsiString.Buffer = Class->lpszClientAnsiMenuName;
                 Status = RtlUnicodeStringToAnsiString(&AnsiString,
                                                       MenuName,
@@ -1525,7 +1525,7 @@
         ANSI_STRING AnsiString;
         PWSTR strBufW;
 
-        AnsiString.MaximumLength = RtlUnicodeStringToAnsiSize(MenuName);
+        AnsiString.MaximumLength = (USHORT)RtlUnicodeStringToAnsiSize(MenuName);
 
         strBufW = UserHeapAlloc(MenuName->Length + sizeof(UNICODE_NULL) +
                                 AnsiString.MaximumLength);
@@ -1634,8 +1634,8 @@
 
         TRACE("SetClassLong(%d, %x)\n", Index, NewLong);
 
-        if (Index + sizeof(ULONG_PTR) < Index ||
-            Index + sizeof(ULONG_PTR) > Class->cbclsExtra)
+        if ((Index + (INT)sizeof(ULONG_PTR)) < Index ||
+            (Index + (INT)sizeof(ULONG_PTR)) > Class->cbclsExtra)
         {
             EngSetLastError(ERROR_INVALID_PARAMETER);
             return 0;
@@ -1822,7 +1822,7 @@
        lpwcx->style &= ~CS_GLOBALCLASS;
 
     lpwcx->lpfnWndProc = IntGetClassWndProc(Class, Ansi);
-    
+
     lpwcx->cbClsExtra = Class->cbclsExtra;
     lpwcx->cbWndExtra = Class->cbwndExtra;
     lpwcx->hIcon = Class->hIcon;        /* FIXME: Get handle from pointer */
@@ -1840,7 +1840,7 @@
  *  lpszClientXxxMenuName should already be mapped to user space.
  */
     /* Copy string ptr to user. */
-    if ( Class->lpszClientUnicodeMenuName != NULL && 
+    if ( Class->lpszClientUnicodeMenuName != NULL &&
          Class->MenuNameIsString)
     {
        lpwcx->lpszMenuName = UserHeapAddressToUser(Ansi ?
@@ -1897,7 +1897,7 @@
            ClassName.Length = 0;
            ClassName.MaximumLength = 0;
         }
-        
+
         wc.cbSize = sizeof(wc);
         wc.style = DefaultServerClasses[i].Style;
 
@@ -2016,15 +2016,14 @@
 
         CapturedMenuName = ProbeForReadUnicodeString(pClassMenuName->pusMenuName);
 
-        if ( CapturedName.Length & 1 ||
-             CapturedMenuName.Length & 1 ||
-             CapturedClassInfo.cbClsExtra < 0 ||
-             CapturedClassInfo.cbClsExtra +
-                CapturedName.Length +
-                CapturedMenuName.Length +
-                sizeof(CLS) < CapturedClassInfo.cbClsExtra ||
-             CapturedClassInfo.cbWndExtra < 0 ||
-             CapturedClassInfo.hInstance == NULL)
+        if ( (CapturedName.Length & 1) ||
+             (CapturedMenuName.Length & 1) ||
+             (CapturedClassInfo.cbClsExtra < 0) ||
+             ((CapturedClassInfo.cbClsExtra + CapturedName.Length +
+              CapturedMenuName.Length +  sizeof(CLS))
+                < (ULONG)CapturedClassInfo.cbClsExtra) ||
+             (CapturedClassInfo.cbWndExtra < 0) ||
+             (CapturedClassInfo.hInstance == NULL) )
         {
             ERR("NtUserRegisterClassExWOW Invalid Parameter Error!\n");
             goto InvalidParameter;

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/defwnd.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/defwnd.c?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/defwnd.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/defwnd.c [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -59,7 +59,7 @@
                 break;
              }
           }
-          else          
+          else
           {
              co_IntSendMessage(WndChild->head.h, WM_ENDSESSION, KillTimers, lParams);
              if (KillTimers)
@@ -82,7 +82,7 @@
          lResult = MCSR_DONOTSHUTDOWN;
       }
    }
-   else          
+   else
    {
       co_IntSendMessage(pWindow->head.h, WM_ENDSESSION, KillTimers, lParams);
       if (KillTimers)
@@ -141,7 +141,7 @@
    {
       Hook = TRUE;
       lResult = co_HOOK_CallHooks(WH_CBT, HCBT_SYSCOMMAND, wParam, lParam);
-      
+
       if (lResult) return lResult;
    }
 
@@ -218,7 +218,7 @@
            return (LRESULT) DefWndControlColor((HDC)wParam, HIWORD(lParam));
 
       case WM_GETHOTKEY:
-         return DefWndGetHotKey(UserHMGetHandle(Wnd));                
+         return DefWndGetHotKey(UserHMGetHandle(Wnd));
       case WM_SETHOTKEY:
          return DefWndSetHotKey(Wnd, wParam);
 

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/display.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/display.c?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/display.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/display.c [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -102,8 +102,8 @@
 
     /* Initialize the UNICODE_STRING */
     ustrDisplayDrivers.Buffer = awcBuffer;
-    ustrDisplayDrivers.MaximumLength = cbSize;
-    ustrDisplayDrivers.Length = cbSize;
+    ustrDisplayDrivers.MaximumLength = (USHORT)cbSize;
+    ustrDisplayDrivers.Length = (USHORT)cbSize;
 
     /* Set Buffer for description and size of remaining buffer */
     ustrDescription.Buffer = awcBuffer + (cbSize / sizeof(WCHAR));
@@ -117,8 +117,8 @@
                            &cbSize);
     if (NT_SUCCESS(Status))
     {
-        ustrDescription.MaximumLength = cbSize;
-        ustrDescription.Length = cbSize;
+        ustrDescription.MaximumLength = (USHORT)cbSize;
+        ustrDescription.Length = (USHORT)cbSize;
     }
     else
     {

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/input.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/input.c?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/input.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/input.c [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -137,7 +137,7 @@
     ULONG cWaitObjects = 0, cMaxWaitObjects = 1;
     MOUSE_INPUT_DATA MouseInput;
     KEYBOARD_INPUT_DATA KeyInput;
-    
+
     ByteOffset.QuadPart = (LONGLONG)0;
     //WaitTimeout.QuadPart = (LONGLONG)(-10000000);
 
@@ -196,7 +196,7 @@
                                        &ByteOffset,
                                        NULL);
             }
-            
+
             if (MouStatus == STATUS_PENDING)
                 WaitObjects[cWaitObjects++] = &pMouDevice->Event;
         }
@@ -215,7 +215,7 @@
                                        sizeof(KEYBOARD_INPUT_DATA),
                                        &ByteOffset,
                                        NULL);
-                
+
             }
             if (KbdStatus == STATUS_PENDING)
                 WaitObjects[cWaitObjects++] = &pKbdDevice->Event;
@@ -233,7 +233,8 @@
                                               NULL,//&WaitTimeout,
                                               NULL);
 
-            if (Status >= STATUS_WAIT_0 && Status < STATUS_WAIT_0 + cWaitObjects)
+            if ((Status >= STATUS_WAIT_0) &&
+                (Status < (STATUS_WAIT_0 + (LONG)cWaitObjects)))
             {
                 /* Some device has finished reading */
                 pSignaledObject = WaitObjects[Status - STATUS_WAIT_0];

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/kbdlayout.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/kbdlayout.c?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/kbdlayout.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/kbdlayout.c [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -440,7 +440,7 @@
 UINT
 APIENTRY
 NtUserGetKeyboardLayoutList(
-    INT nBuff,
+    ULONG nBuff,
     HKL *pHklBuff)
 {
     UINT uRet = 0;
@@ -600,7 +600,7 @@
             pklLast = gspklBaseLayout->pklPrev;
             while (pklLast != gspklBaseLayout && pklLast->dwKL_Flags & KLF_UNLOAD)
                 pklLast = pklLast->pklPrev;
-            
+
             /* Add new layout to the list */
             pKl->pklNext = pklLast->pklNext;
             pKl->pklPrev = pklLast;

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/keyboard.c [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -876,8 +876,8 @@
                 Msg.lParam |= KF_REPEAT << 16;
             if (!bIsDown)
                 Msg.lParam |= KF_UP << 16;
-            /* FIXME: Set KF_DLGMODE and KF_MENUMODE when needed */ 	 
-            if (pFocusQueue->QF_flags & QF_DIALOGACTIVE) 	 
+            /* FIXME: Set KF_DLGMODE and KF_MENUMODE when needed */
+            if (pFocusQueue->QF_flags & QF_DIALOGACTIVE)
                 Msg.lParam |= KF_DLGMODE << 16;
             if (pFocusQueue->MenuOwner) // pFocusQueue->MenuState) // MenuState needs a start flag...
                 Msg.lParam |= KF_MENUMODE << 16;
@@ -967,7 +967,7 @@
     return ProcessKeyEvent(wVk, wScanCode, pKbdInput->dwFlags, bInjected, dwTime, pKbdInput->dwExtraInfo);
 }
 
-/* 
+/*
  * UserProcessKeyboardInput
  *
  * Process raw keyboard input data
@@ -1045,7 +1045,7 @@
     }
 }
 
-/* 
+/*
  * IntTranslateKbdMessage
  *
  * Addes WM_(SYS)CHAR messages to message queue if message
@@ -1408,8 +1408,8 @@
     if (pKeyName)
     {
         cchKeyName = wcslen(pKeyName);
-        if (cchKeyName > cchSize - 1)
-            cchKeyName = cchSize - 1; // Don't count '\0'
+        if (cchKeyName > (cchSize - 1UL))
+            cchKeyName = cchSize - 1UL; // Don't count '\0'
 
         _SEH2_TRY
         {

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/menu.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/menu.c?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/menu.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/menu.c [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -804,7 +804,7 @@
 IntInsertMenuItem(PMENU_OBJECT MenuObject, UINT uItem, BOOL fByPosition,
                   PROSMENUITEMINFO ItemInfo)
 {
-   int pos = (int)uItem;
+   int pos;
    PMENU_ITEM MenuItem;
    PMENU_OBJECT SubMenu = NULL;
 
@@ -818,7 +818,8 @@
    {
       SubMenu = MenuObject;
       /* calculate position */
-      if(MenuObject->MenuInfo.MenuItemCount < pos)
+      pos = (int)uItem;
+      if(uItem > MenuObject->MenuInfo.MenuItemCount)
       {
          pos = MenuObject->MenuInfo.MenuItemCount;
       }
@@ -1254,7 +1255,7 @@
         bti->rcTitleBar.right  = pWindowObject->rcWindow.right - pWindowObject->rcWindow.left;
         bti->rcTitleBar.bottom = pWindowObject->rcWindow.bottom - pWindowObject->rcWindow.top;
 
-        /* Is it iconiced ? */ 
+        /* Is it iconiced ? */
         if ((dwStyle & WS_ICONIC)!=WS_ICONIC)
         {
             /* Remove frame from rectangle */
@@ -1303,24 +1304,24 @@
             /* FIXME: Note this value should exists in pWindowObject for UserGetSystemMetrics(SM_CYSMCAPTION) */
             bti->rcTitleBar.bottom += UserGetSystemMetrics(SM_CYSMCAPTION);
         }
-        else 
+        else
         {
             /* FIXME: Note this value should exists in pWindowObject for UserGetSystemMetrics(SM_CYCAPTION) and UserGetSystemMetrics(SM_CXSIZE) */
             bti->rcTitleBar.bottom += UserGetSystemMetrics(SM_CYCAPTION);
             bti->rcTitleBar.left += UserGetSystemMetrics(SM_CXSIZE);
         }
 
-        if (dwStyle & WS_CAPTION) 
+        if (dwStyle & WS_CAPTION)
         {
             bti->rgstate[1] = STATE_SYSTEM_INVISIBLE;
-            if (dwStyle & WS_SYSMENU) 
+            if (dwStyle & WS_SYSMENU)
             {
-                if (!(dwStyle & (WS_MINIMIZEBOX|WS_MAXIMIZEBOX))) 
+                if (!(dwStyle & (WS_MINIMIZEBOX|WS_MAXIMIZEBOX)))
                 {
                     bti->rgstate[2] = STATE_SYSTEM_INVISIBLE;
                     bti->rgstate[3] = STATE_SYSTEM_INVISIBLE;
                 }
-                else 
+                else
                 {
                     if (!(dwStyle & WS_MINIMIZEBOX))
                     {
@@ -1341,7 +1342,7 @@
                     bti->rgstate[5] = STATE_SYSTEM_UNAVAILABLE;
                 }
             }
-            else 
+            else
             {
                 bti->rgstate[2] = STATE_SYSTEM_INVISIBLE;
                 bti->rgstate[3] = STATE_SYSTEM_INVISIBLE;
@@ -1609,13 +1610,13 @@
     }
     _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
     {
-        /* Fail copy the data */ 
+        /* Fail copy the data */
         EngSetLastError(ERROR_INVALID_PARAMETER);
         retValue = FALSE;
     }
     _SEH2_END
 
-    /* Get the tile bar info */ 
+    /* Get the tile bar info */
     if (retValue)
     {
         retValue = intGetTitleBarInfo(WindowObject, &bartitleinfo);
@@ -1629,7 +1630,7 @@
             }
             _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
             {
-                /* Fail copy the data */ 
+                /* Fail copy the data */
                 EngSetLastError(ERROR_INVALID_PARAMETER);
                 retValue = FALSE;
             }
@@ -2240,7 +2241,7 @@
    {
       EngSetLastError(ERROR_INVALID_PARAMETER);
 // This will crash menu (line 80) correct_behavior test!
-// "NT4 and below can't handle a bigger MENUITEMINFO struct" 
+// "NT4 and below can't handle a bigger MENUITEMINFO struct"
       //EngSetLastError(ERROR_MENU_ITEM_NOT_FOUND);
       return( FALSE);
    }
@@ -2445,7 +2446,7 @@
          ERR("Failed to capture MenuItem Caption (status 0x%08x)\n",Status);
          SetLastNtError(Status);
          RETURN(FALSE);
-      }       
+      }
    }
 
    if (bInsert) RETURN( UserInsertMenuItem(Menu, uItem, fByPosition, lpmii));

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/message.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/message.c?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/message.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/message.c [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -1844,7 +1844,7 @@
 {
     MSG msg;
     RECT rect;
-    WORD wDragWidth, wDragHeight;
+    ULONG wDragWidth, wDragHeight;
     DECLARE_RETURN(BOOL);
 
     TRACE("Enter NtUserDragDetect(%x)\n", hWnd);

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/metric.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/metric.c?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/metric.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/metric.c [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -15,7 +15,7 @@
 /* FUNCTIONS *****************************************************************/
 
 BOOL
-FASTCALL
+NTAPI
 InitMetrics(VOID)
 {
     INT *piSysMet = gpsi->aiSysMet;
@@ -175,7 +175,8 @@
     return TRUE;
 }
 
-ULONG FASTCALL
+LONG
+NTAPI
 UserGetSystemMetrics(ULONG Index)
 {
     ASSERT(gpsi);

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -94,7 +94,7 @@
         if ((pWnd->style & WS_VISIBLE) && IntPtInWindow(pWnd, x, y))
             return pWnd;
     }
-    
+
     /* Window has not been found */
     return NULL;
 }
@@ -177,10 +177,10 @@
 
     pti = PsGetCurrentThreadWin32Thread();
     MessageQueue = pti->MessageQueue;
-    
+
     /* Update counter */
     MessageQueue->ShowingCursor += bShow ? 1 : -1;
-    
+
     /* Check for trivial cases */
     if ((bShow && MessageQueue->ShowingCursor != 0) ||
         (!bShow && MessageQueue->ShowingCursor != -1))
@@ -189,7 +189,7 @@
           internally to check if cursor is visible */
         return MessageQueue->ShowingCursor;
     }
-    
+
     /* Check if cursor is above window owned by this MessageQueue */
     pWnd = IntTopLevelWindowFromPoint(gpsi->ptCursor.x, gpsi->ptCursor.y);
     if (pWnd && pWnd->head.pti->MessageQueue == MessageQueue)
@@ -206,7 +206,7 @@
             GreMovePointer(hdcScreen, -1, -1);
             TRACE("Removing pointer!\n");
         }
-        
+
         /* Update global info */
         IntGetSysCursorInfo()->ShowingCursor = MessageQueue->ShowingCursor;
     }
@@ -1382,7 +1382,7 @@
            if ((msg->message == clk_msg.message) &&
                (msg->hwnd == clk_msg.hwnd) &&
                (msg->wParam == clk_msg.wParam) &&
-               (msg->time - clk_msg.time < gspv.iDblClickTime) &&
+               ((msg->time - clk_msg.time) < (ULONG)gspv.iDblClickTime) &&
                (abs(msg->pt.x - clk_msg.pt.x) < UserGetSystemMetrics(SM_CXDOUBLECLK)/2) &&
                (abs(msg->pt.y - clk_msg.pt.y) < UserGetSystemMetrics(SM_CYDOUBLECLK)/2))
            {
@@ -1999,7 +1999,7 @@
    MessageQueue->nCntsQBits[QSRosPostMessage] = 0;
    MessageQueue->nCntsQBits[QSRosSendMessage] = 0;
    MessageQueue->nCntsQBits[QSRosHotKey] = 0;
-   
+
    if (MessageQueue->CursorObject)
    {
        PCURICON_OBJECT pCursor = MessageQueue->CursorObject;
@@ -2020,7 +2020,7 @@
 
        UserDereferenceObject(pCursor);
    }
-      
+
 }
 
 PUSER_MESSAGE_QUEUE FASTCALL
@@ -2183,7 +2183,7 @@
 
    UserLeave();
 
-   return Ret;
+   return (SHORT)Ret;
 }
 
 

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/painting.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/painting.c?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/painting.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/painting.c [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -777,7 +777,7 @@
 }
 
 BOOL
-FASTCALL 
+FASTCALL
 IntFlashWindowEx(PWND pWnd, PFLASHWINFO pfwi)
 {
    PPROPERTY pprop;
@@ -1831,9 +1831,9 @@
       else if (pWnd != NULL) // FIXME: Windows does not do that
       {
          UNICODE_STRING ustr;
-         ustr.Buffer = pWnd->strName.Buffer;
-         ustr.Length = pWnd->strName.Length;
-         ustr.MaximumLength = pWnd->strName.MaximumLength;
+         ustr.Buffer = pWnd->strName.Buffer; // FIXME: LARGE_STRING truncated!
+         ustr.Length = (USHORT)min(pWnd->strName.Length, MAXUSHORT);
+         ustr.MaximumLength = (USHORT)min(pWnd->strName.MaximumLength, MAXUSHORT);
          UserDrawCaptionText(hDc, &ustr, &Rect, uFlags, hFont);
       }
    }

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/scrollbar.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/scrollbar.c?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/scrollbar.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/scrollbar.c [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -361,7 +361,7 @@
    /* Make sure the page size is valid */
    if (Info->nPage < 0)
       Info->nPage = 0;
-   else if (Info->nMax - Info->nMin + 1 < Info->nPage)
+   else if ((Info->nMax - Info->nMin + 1UL) < Info->nPage)
    {
       Info->nPage = Info->nMax - Info->nMin + 1;
    }
@@ -371,7 +371,7 @@
    {
       Info->nPos = Info->nMin;
    }
-   else if (Info->nPos > Info->nMax - max(Info->nPage - 1, 0))
+   else if (Info->nPos > (Info->nMax - max((int)Info->nPage - 1, 0)))
    {
       Info->nPos = Info->nMax - max(Info->nPage - 1, 0);
    }
@@ -421,7 +421,7 @@
 
 done:
    if ( action & SA_SSI_HIDE )
-   { 
+   {
       co_UserShowScrollBar(Window, nBar, FALSE, FALSE);
    }
    else
@@ -616,7 +616,7 @@
       case SB_HORZ:
          if (fShowH) set_bits |= WS_HSCROLL;
          else clear_bits |= WS_HSCROLL;
-         if( nBar == SB_HORZ ) break;  
+         if( nBar == SB_HORZ ) break;
       /* Fall through */
       case SB_VERT:
          if (fShowV) set_bits |= WS_VSCROLL;
@@ -701,8 +701,8 @@
 BOOL
 APIENTRY
 NtUserSBGetParms(
-  HWND hWnd, 
-  int fnBar, 
+  HWND hWnd,
+  int fnBar,
   PSBDATA pSBData,
   LPSCROLLINFO lpsi)
 {
@@ -822,11 +822,11 @@
 
    if(InfoH)
       Chg = (IntEnableScrollBar(TRUE, InfoH, wArrows) || Chg);
-     
+
    ERR("FIXME: EnableScrollBar wSBflags %d wArrows %d Chg %d\n",wSBflags,wArrows, Chg);
 // Done in user32:
 //   SCROLL_RefreshScrollBar( hwnd, nBar, TRUE, TRUE );
-   
+
    if (OrigArrows == wArrows) RETURN( FALSE);
    RETURN( TRUE);
 

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/sysparams.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/sysparams.c?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/sysparams.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/sysparams.c [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -727,7 +727,7 @@
         UserRefObjectCo(pwndCurrent, &Ref);
         co_WinPosSetWindowPos(pwndCurrent, 0, pwndCurrent->rcWindow.left,pwndCurrent->rcWindow.top,
                                               pwndCurrent->rcWindow.right-pwndCurrent->rcWindow.left
-                                              ,pwndCurrent->rcWindow.bottom - pwndCurrent->rcWindow.top, 
+                                              ,pwndCurrent->rcWindow.bottom - pwndCurrent->rcWindow.top,
                               SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|
                               SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW);
         UserDerefObjectCo(pwndCurrent);
@@ -800,7 +800,7 @@
             return SpiSetInt(&gspv.uiGridGranularity, uiParam, KEY_DESKTOP, VAL_GRID, fl);
 
         case SPI_GETDESKWALLPAPER:
-            uiParam = min(uiParam, gspv.ustrWallpaper.Length + 1);
+            uiParam = min(uiParam, gspv.ustrWallpaper.Length + 1UL);
             return SpiGet(pvParam, gspv.awcWallpaper, uiParam, fl);
 
         case SPI_SETDESKWALLPAPER:
@@ -1590,7 +1590,7 @@
         }
         ulResult = 1;
     }
-    
+
     return ulResult;
 }
 
@@ -1616,7 +1616,7 @@
 
     TRACE("Leave NtUserSystemParametersInfo, returning %d\n", bResult);
     UserLeave();
-    
+
     return bResult;
 }
 

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/window.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/window.c?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -795,7 +795,7 @@
       Rect->bottom = UserGetSystemMetrics(SM_CYMINIMIZED);
       return;
    }
-   if ( Wnd != UserGetDesktopWindow()) // Wnd->fnid != FNID_DESKTOP ) 
+   if ( Wnd != UserGetDesktopWindow()) // Wnd->fnid != FNID_DESKTOP )
    {
       *Rect = Wnd->rcClient;
       RECTL_vOffsetRect(Rect, -Wnd->rcClient.left, -Wnd->rcClient.top);
@@ -1953,7 +1953,7 @@
          if (Window->state & WNDS_ANSICREATOR)
          {
             ANSI_STRING AnsiString;
-            AnsiString.MaximumLength = RtlUnicodeStringToAnsiSize(ClassName)+sizeof(CHAR);
+            AnsiString.MaximumLength = (USHORT)RtlUnicodeStringToAnsiSize(ClassName)+sizeof(CHAR);
             pszClass = UserHeapAlloc(AnsiString.MaximumLength);
             if (!pszClass)
             {
@@ -1984,13 +1984,13 @@
       {
          UNICODE_STRING Name;
          Name.Buffer = WindowName->Buffer;
-         Name.Length = WindowName->Length;
-         Name.MaximumLength = WindowName->MaximumLength;
+         Name.Length = (USHORT)min(WindowName->Length, MAXUSHORT); // FIXME: LARGE_STRING truncated
+         Name.MaximumLength = (USHORT)min(WindowName->MaximumLength, MAXUSHORT);
 
          if (Window->state & WNDS_ANSICREATOR)
          {
             ANSI_STRING AnsiString;
-            AnsiString.MaximumLength = RtlUnicodeStringToAnsiSize(&Name) + sizeof(CHAR);
+            AnsiString.MaximumLength = (USHORT)RtlUnicodeStringToAnsiSize(&Name) + sizeof(CHAR);
             pszName = UserHeapAlloc(AnsiString.MaximumLength);
             if (!pszName)
             {
@@ -2325,8 +2325,8 @@
 
         /* We pass it on as a UNICODE_STRING */
         ustrClassName.Buffer = lstrClassName.Buffer;
-        ustrClassName.Length = lstrClassName.Length;
-        ustrClassName.MaximumLength = lstrClassName.MaximumLength;
+        ustrClassName.Length = (USHORT)min(lstrClassName.Length, MAXUSHORT); // FIXME: LARGE_STRING truncated
+        ustrClassName.MaximumLength = (USHORT)min(lstrClassName.MaximumLength, MAXUSHORT);
     }
 
     /* Fill the CREATESTRUCTW */
@@ -2593,10 +2593,10 @@
             send WM_GETTEXT messages to windows belonging to its processes */
          if (!ClassAtom || Child->pcls->atomClassName == ClassAtom)
          {
-             // HACK: use UNICODE_STRING instead of LARGE_STRING
+             // FIXME: LARGE_STRING truncated
              CurrentWindowName.Buffer = Child->strName.Buffer;
-             CurrentWindowName.Length = Child->strName.Length;
-             CurrentWindowName.MaximumLength = Child->strName.MaximumLength;
+             CurrentWindowName.Length = (USHORT)min(Child->strName.Length, MAXUSHORT);
+             CurrentWindowName.MaximumLength = (USHORT)min(Child->strName.MaximumLength, MAXUSHORT);
              if(!CheckWindowName ||
                 (Child->strName.Length < 0xFFFF &&
                  !RtlCompareUnicodeString(WindowName, &CurrentWindowName, TRUE)))
@@ -2772,8 +2772,8 @@
                    The user mode version however calls GetWindowText() which will
                    send WM_GETTEXT messages to windows belonging to its processes */
                 ustr.Buffer = TopLevelWindow->strName.Buffer;
-                ustr.Length = TopLevelWindow->strName.Length;
-                ustr.MaximumLength = TopLevelWindow->strName.MaximumLength;
+                ustr.Length = (USHORT)min(TopLevelWindow->strName.Length, MAXUSHORT); // FIXME:LARGE_STRING truncated
+                ustr.MaximumLength = (USHORT)min(TopLevelWindow->strName.MaximumLength, MAXUSHORT);
                 WindowMatches = !CheckWindowName ||
                                 (TopLevelWindow->strName.Length < 0xFFFF &&
                                  !RtlCompareUnicodeString(&WindowName, &ustr, TRUE));
@@ -3158,7 +3158,7 @@
    WinStaObject->ShellListView = hwndListView;
 
    ti = GetW32ThreadInfo();
-   if (ti->pDeskInfo) 
+   if (ti->pDeskInfo)
    {
        ti->pDeskInfo->hShellWindow = hwndShell;
        ti->pDeskInfo->ppiShellProcess = ti->ppi;
@@ -3450,7 +3450,7 @@
       case GWL_ID:
       case GWL_HINSTANCE:
       case GWL_HWNDPARENT:
-         RETURN( co_UserSetWindowLong(Window->head.h, Index, (UINT)NewValue, TRUE));
+         RETURN( (WORD)co_UserSetWindowLong(Window->head.h, Index, (UINT)NewValue, TRUE));
       default:
          if (Index < 0)
          {
@@ -3459,7 +3459,7 @@
          }
    }
 
-   if (Index > Window->cbwndExtra - sizeof(WORD))
+   if ((ULONG)Index > (Window->cbwndExtra - sizeof(WORD)))
    {
       EngSetLastError(ERROR_INVALID_PARAMETER);
       RETURN( 0);

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -173,7 +173,7 @@
 
    TRACE("X:%d Y:%d XS:%d YS:%d\n",x,y,xspacing,yspacing);
 
-   for( i = 0; List[i]; i++)
+   for(i = 0; List[i]; i++)
    {
       PWND Child;
 
@@ -197,7 +197,7 @@
 
          UserDerefObjectCo(Child);
 
-         if (x <= rectParent.right - UserGetSystemMetrics(SM_CXMINSPACING))
+         if (x <= (rectParent.right - UserGetSystemMetrics(SM_CXMINSPACING)))
             x += xspacing;
          else
          {
@@ -228,8 +228,8 @@
    }
 
    IntGetClientRect( pwndParent, &rectParent );
-   if ((Pos->x >= rectParent.left) && (Pos->x + UserGetSystemMetrics(SM_CXICON) < rectParent.right) &&
-       (Pos->y >= rectParent.top) && (Pos->y + UserGetSystemMetrics(SM_CYICON) < rectParent.bottom))
+   if ((Pos->x >= rectParent.left) && ((Pos->x + UserGetSystemMetrics(SM_CXICON)) < rectParent.right) &&
+       (Pos->y >= rectParent.top) && ((Pos->y + UserGetSystemMetrics(SM_CYICON)) < rectParent.bottom))
       return;  /* The icon already has a suitable position */
 
    xspacing = UserGetSystemMetrics(SM_CXICONSPACING);
@@ -318,7 +318,7 @@
          if (Wnd->state & WNDS_MAXIMIZESTOMONITOR)
          {
             Wnd->InternalPos.flags &= ~WPF_MAXINIT;
-            Wnd->InternalPos.MaxPos.x = Wnd->InternalPos.MaxPos.y = -1; 
+            Wnd->InternalPos.MaxPos.x = Wnd->InternalPos.MaxPos.y = -1;
          }
          else
          {
@@ -1893,8 +1893,8 @@
         }
     }
 
-    *HitTest = co_IntSendMessage(ScopeWin->head.h, WM_NCHITTEST, 0,
-                                 MAKELONG(Point->x, Point->y));
+    *HitTest = (USHORT)co_IntSendMessage(ScopeWin->head.h, WM_NCHITTEST, 0,
+                                         MAKELONG(Point->x, Point->y));
     if ((*HitTest) == (USHORT)HTTRANSPARENT)
     {
          UserDereferenceObject(ScopeWin);
@@ -2046,7 +2046,7 @@
         TRACE("hwnd %p, after %p, %d,%d (%dx%d), flags %08x\n",
                winpos->pos.hwnd, winpos->pos.hwndInsertAfter, winpos->pos.x, winpos->pos.y,
                winpos->pos.cx, winpos->pos.cy, winpos->pos.flags);
-        
+
         pwnd = UserGetWindowObject(winpos->pos.hwnd);
         if (!pwnd)
            continue;

Modified: trunk/reactos/subsystems/win32/win32k/objects/arc.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/arc.c?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/arc.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/arc.c [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -126,10 +126,10 @@
     AngleEnd   = atan2((RectSEpts.bottom - CenterY), RectSEpts.right - CenterX)*(360.0/(M_PI*2));
     AngleStart = atan2((RectSEpts.top - CenterY), RectSEpts.left - CenterX)*(360.0/(M_PI*2));
 
-    SfCx = (Rcos(AngleStart) * RadiusX);
-    SfCy = (Rsin(AngleStart) * RadiusY);
-    EfCx = (Rcos(AngleEnd) * RadiusX);
-    EfCy = (Rsin(AngleEnd) * RadiusY);
+    SfCx = (LONG)(Rcos(AngleStart) * RadiusX);
+    SfCy = (LONG)(Rsin(AngleStart) * RadiusY);
+    EfCx = (LONG)(Rcos(AngleEnd) * RadiusX);
+    EfCy = (LONG)(Rsin(AngleEnd) * RadiusY);
 
     if ((arctype == GdiTypePie) || (arctype == GdiTypeChord))
     {

Modified: trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -158,11 +158,11 @@
 
     /* Calculate width and image size in bytes */
     cjWidthBytes = WIDTH_BYTES_ALIGN16(nWidth, cRealBpp);
-    cjSize = cjWidthBytes * nHeight;
-
-    /* Check parameters (possible overflow of cjWidthBytes!) */
-    if (iFormat == 0 || nWidth <= 0 || nWidth >= 0x8000000 || nHeight <= 0 ||
-        cBitsPixel > 32 || cPlanes > 32 || cjSize >= 0x100000000ULL)
+    cjSize = (ULONGLONG)cjWidthBytes * nHeight;
+
+    /* Check parameters (possible overflow of cjSize!) */
+    if ((iFormat == 0) || (nWidth <= 0) || (nWidth >= 0x8000000) || (nHeight <= 0) ||
+        (cBitsPixel > 32) || (cPlanes > 32) || (cjSize >= 0x100000000ULL))
     {
         DPRINT1("Invalid bitmap format! Width=%d, Height=%d, Bpp=%d, Planes=%d\n",
                 nWidth, nHeight, cBitsPixel, cPlanes);
@@ -178,7 +178,7 @@
         PSURFACE psurf = SURFACE_ShareLockSurface(hbmp);
         _SEH2_TRY
         {
-            ProbeForRead(pUnsafeBits, cjSize, 1);
+            ProbeForRead(pUnsafeBits, (SIZE_T)cjSize, 1);
             UnsafeSetBitmapBits(psurf, 0, pUnsafeBits);
         }
         _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)

Modified: trunk/reactos/subsystems/win32/win32k/objects/dibobj.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/dibobj.c?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -141,9 +141,9 @@
     }
 
     biBitCount = BitsPerFormat(psurf->SurfObj.iBitmapFormat);
-    if (biBitCount <= 8 && StartIndex < (1 << biBitCount))
-    {
-        if (StartIndex + Entries > (1 << biBitCount))
+    if ((biBitCount <= 8) && (StartIndex < (1UL << biBitCount)))
+    {
+        if (StartIndex + Entries > (1UL << biBitCount))
             Entries = (1 << biBitCount) - StartIndex;
 
         if (psurf->ppal == NULL)
@@ -537,7 +537,8 @@
     LONG width, height;
     WORD planes, bpp;
     DWORD compr, size ;
-    int i, bitmap_type;
+    USHORT i;
+    int bitmap_type;
     RGBTRIPLE* rgbTriples;
     RGBQUAD* rgbQuads;
     VOID* colorPtr;
@@ -618,10 +619,10 @@
     case 0: /* Only info */
         if(pbmci)
         {
-            pbmci->bmciHeader.bcWidth = psurf->SurfObj.sizlBitmap.cx;
-            pbmci->bmciHeader.bcHeight = (psurf->SurfObj.fjBitmap & BMF_TOPDOWN) ?
+            pbmci->bmciHeader.bcWidth = (WORD)psurf->SurfObj.sizlBitmap.cx;
+            pbmci->bmciHeader.bcHeight = (WORD)((psurf->SurfObj.fjBitmap & BMF_TOPDOWN) ?
                                          -psurf->SurfObj.sizlBitmap.cy :
-                                         psurf->SurfObj.sizlBitmap.cy;
+                                         psurf->SurfObj.sizlBitmap.cy);
             pbmci->bmciHeader.bcPlanes = 1;
             pbmci->bmciHeader.bcBitCount = BitsPerFormat(psurf->SurfObj.iBitmapFormat);
         }
@@ -674,19 +675,19 @@
         {
             if(Usage == DIB_RGB_COLORS)
             {
-                unsigned int colors = min(psurf->ppal->NumColors, 1 << bpp);
+                ULONG colors = min(psurf->ppal->NumColors, 256);
 
                 if(pbmci)
                 {
-                    for(i=0; i < colors; i++)
+                    for(i = 0; i < colors; i++)
                     {
                         rgbTriples[i].rgbtRed = psurf->ppal->IndexedColors[i].peRed;
                         rgbTriples[i].rgbtGreen = psurf->ppal->IndexedColors[i].peGreen;
                         rgbTriples[i].rgbtBlue = psurf->ppal->IndexedColors[i].peBlue;
                     }
                 }
-                if(colors != 1 << bpp) Info->bmiHeader.biClrUsed = colors;
-                for(i=0; i < colors; i++)
+                if(colors != 256) Info->bmiHeader.biClrUsed = colors;
+                for(i = 0; i < colors; i++)
                 {
                     rgbQuads[i].rgbRed = psurf->ppal->IndexedColors[i].peRed;
                     rgbQuads[i].rgbGreen = psurf->ppal->IndexedColors[i].peGreen;
@@ -695,7 +696,7 @@
             }
             else
             {
-                for(i=0; i < 1 << bpp; i++)
+                for(i = 0; i < 256; i++)
                 {
                     if(pbmci) ((WORD*)rgbTriples)[i] = i;
                     ((WORD*)rgbQuads)[i] = i;
@@ -706,7 +707,7 @@
         {
             if(Usage == DIB_PAL_COLORS)
             {
-                for(i=0; i < 1 << bpp; i++)
+                for(i = 0; i < 256; i++)
                 {
                     if(pbmci) ((WORD*)rgbTriples)[i] = i;
                     ((WORD*)rgbQuads)[i] = i;
@@ -877,7 +878,7 @@
         POINTL srcPoint;
         BOOL ret ;
 
-        if (StartScan > psurf->SurfObj.sizlBitmap.cy)
+        if (StartScan > (ULONG)psurf->SurfObj.sizlBitmap.cy)
         {
             ScanLines = 0;
             goto done;
@@ -889,8 +890,8 @@
 
         /* Fixup values */
         Info->bmiHeader.biWidth = psurf->SurfObj.sizlBitmap.cx;
-        Info->bmiHeader.biHeight = height < 0 ?
-                                   -ScanLines : ScanLines;
+        Info->bmiHeader.biHeight = (height < 0) ?
+                                   -(LONG)ScanLines : ScanLines;
         /* Create the DIB */
         hBmpDest = DIB_CreateDIBSection(pDC, Info, Usage, &pDIBits, NULL, 0, 0);
         /* Restore them */
@@ -1379,7 +1380,7 @@
     {
         ProbeForRead(&bmi->bmiHeader.biSize, sizeof(DWORD), 1);
         ProbeForRead(bmi, bmi->bmiHeader.biSize, 1);
-        ProbeForRead(bmi, DIB_BitmapInfoSize(bmi, Usage), 1);
+        ProbeForRead(bmi, DIB_BitmapInfoSize(bmi, (WORD)Usage), 1);
     }
     _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
     {
@@ -1783,7 +1784,7 @@
 FASTCALL
 BuildDIBPalette(CONST BITMAPINFO *bmi)
 {
-    BYTE bits;
+    WORD bits;
     ULONG ColorCount;
     HPALETTE hPal;
     ULONG RedMask = 0, GreenMask = 0, BlueMask = 0;

Modified: trunk/reactos/subsystems/win32/win32k/objects/drawing.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/drawing.c?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/drawing.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/drawing.c [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -1315,14 +1315,14 @@
             INT YLeft,
             INT Width,
             INT Height,
-            double StartArc,
+            double StartArc, // FIXME: don't use floating point!
             double EndArc,
             ARCTYPE arctype)
 {
     PDC_ATTR pdcattr;
     PBRUSH pbrush;
-    int Start = ceil(StartArc);
-    int End   = ceil(EndArc);
+    int Start = (int)ceil(StartArc);
+    int End   = (int)ceil(EndArc);
     BOOL Chord = (arctype == GdiTypeChord), ret;
 
     pdcattr = dc->pdcattr;
@@ -1351,13 +1351,13 @@
             INT YLeft,
             INT Width,
             INT Height,
-            double StartArc,
+            double StartArc, // FIXME: don't use floating point!
             double EndArc,
             ARCTYPE arctype,
             PBRUSH pbrush)
 {
-    int Start = ceil(StartArc);
-    int End   = ceil(EndArc);
+    int Start = (int)ceil(StartArc);
+    int End   = (int)ceil(EndArc);
     BOOL Chord = (arctype == GdiTypeChord);
     // Sort out alignment here.
     return app_draw_arc(dc, rect( XLeft, YLeft, Width, Height),

Modified: trunk/reactos/subsystems/win32/win32k/objects/fillshap.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/fillshap.c?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/fillshap.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/fillshap.c [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -355,7 +355,7 @@
     PULONG SafeCounts;
     NTSTATUS Status = STATUS_SUCCESS;
     BOOL Ret = TRUE;
-    INT nPoints = 0, nMaxPoints = 0, nInvalid = 0, i;
+    ULONG nPoints = 0, nMaxPoints = 0, nInvalid = 0, i;
 
     if (!UnsafePoints || !UnsafeCounts ||
         Count == 0 || iFunc == 0 || iFunc > GdiPolyPolyRgn)

Modified: trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -1227,7 +1227,7 @@
 {
     POBJ pobj;
     FLONG fl = 0;
-    UCHAR objt = ObjectType >> 16;
+    UCHAR objt = (ObjectType >> 16) & 0xFF;
 
     if ((objt == GDIObjType_DC_TYPE && cjSize == sizeof(DC)) ||
         (objt == GDIObjType_PAL_TYPE && cjSize == sizeof(PALETTE)) ||

Modified: trunk/reactos/subsystems/win32/win32k/objects/line.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/line.c?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/line.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/line.c [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -334,7 +334,7 @@
                    PULONG  PolyPoints,
                    DWORD   Count)
 {
-    int i;
+    ULONG i;
     LPPOINT pts;
     PULONG pc;
     BOOL ret = FALSE; // Default to failure
@@ -419,7 +419,7 @@
     PDC dc;
     PDC_ATTR pdcattr;
     POINT *line_pts = NULL, *line_pts_old, *bzr_pts = NULL, bzr[4];
-    INT i, num_pts, num_bzr_pts, space, space_old, size;
+    ULONG i, num_pts, num_bzr_pts, space, space_old, size;
     BOOL result = FALSE;
 
     dc = DC_LockDc(hdc);

Modified: trunk/reactos/subsystems/win32/win32k/objects/palette.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/palette.c?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/palette.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/palette.c [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -404,7 +404,7 @@
 
     if (ppdev->flFlags & PDEV_GAMMARAMP_TABLE)
     {
-        INT i;
+        ULONG i;
         PGAMMARAMP GammaRamp = (PGAMMARAMP)ppdev->pvGammaRamp;
         for ( i = 0; i < Colors; i++)
         {
@@ -980,7 +980,7 @@
     CONST LPPALETTEENTRY pe)
 {
     PPALETTE palGDI;
-    WORD numEntries;
+    ULONG numEntries;
 
     if ((UINT)hpal & GDI_HANDLE_STOCK_MASK)
     {

Modified: trunk/reactos/subsystems/win32/win32k/objects/path.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/path.c?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/path.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/path.c [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -13,6 +13,10 @@
 #define NDEBUG
 #include <debug.h>
 
+#ifdef _MSC_VER
+#pragma warning(disable:4244)
+#endif
+
 #define NUM_ENTRIES_INITIAL 16  /* Initial size of points / flags arrays  */
 #define GROW_FACTOR_NUMER    2  /* Numerator of grow factor for the array */
 #define GROW_FACTOR_DENOM    1  /* Denominator of grow factor             */
@@ -20,7 +24,7 @@
 /***********************************************************************
  * Internal functions
  */
- 
+
 /* PATH_DestroyGdiPath
  *
  * Destroys a GdiPath structure (frees the memory in the arrays).
@@ -71,7 +75,7 @@
 GdiPathDPtoLP(PDC pdc, PPOINT ppt, INT count)
 {
   XFORMOBJ xo;
-   
+
   XFORMOBJ_vInit(&xo, &pdc->dclevel.mxDeviceToWorld);
   return XFORMOBJ_bApplyXform(&xo, XF_LTOL, count, (PPOINTL)ppt, (PPOINTL)ppt);
 }
@@ -738,7 +742,7 @@
 {
   PPATH pPath;
   POINT lastmove, orig_pos;
-  INT i;
+  ULONG i;
   PDC_ATTR pdcattr;
   BOOL State = FALSE, Ret = FALSE;
 
@@ -751,7 +755,7 @@
     return FALSE;
   }
 
-  pdcattr = dc->pdcattr;  
+  pdcattr = dc->pdcattr;
 
   lastmove.x = orig_pos.x = pdcattr->ptlCurrent.x;
   lastmove.y = orig_pos.y = pdcattr->ptlCurrent.y;

Modified: trunk/reactos/subsystems/win32/win32k/objects/pen.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/pen.c?rev=55993&r1=55992&r2=55993&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/pen.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/pen.c [iso-8859-1] Sun Mar  4 11:32:43 2012
@@ -3,7 +3,7 @@
  * PROJECT:           ReactOS kernel
  * PURPOSE:           Pen functiona
  * FILE:              subsys/win32k/objects/pen.c
- * PROGRAMER:         
+ * PROGRAMER:
  */
 
 #include <win32k.h>
@@ -230,7 +230,7 @@
       cbRetCount = sizeof(EXTLOGPEN) - sizeof(DWORD) + pbrushPen->dwStyleCount * sizeof(DWORD);
       if (pBuffer)
       {
-         INT i;
+         ULONG i;
 
          if (cbCount < cbRetCount) return 0;
          pExtLogPen = (PEXTLOGPEN)pBuffer;




More information about the Ros-diffs mailing list