Author: dchapyshev
Date: Sun Sep 11 16:13:46 2016
New Revision: 72655

URL: http://svn.reactos.org/svn/reactos?rev=72655&view=rev
Log:
[NtUser] Try to fix tests for user32:EnumDisplaySettings

Modified:
    trunk/reactos/win32ss/user/ntuser/display.c

Modified: trunk/reactos/win32ss/user/ntuser/display.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/display.c?rev=72655&r1=72654&r2=72655&view=diff
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/display.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/display.c [iso-8859-1] Sun Sep 11 
16:13:46 2016
@@ -443,7 +443,7 @@
     {
         /* No device found */
         ERR("No PDEV found!\n");
-        return STATUS_UNSUCCESSFUL;
+        return STATUS_INVALID_PARAMETER_1;
     }
 
     *ppdm = ppdev->pdmwDev;
@@ -474,7 +474,7 @@
     {
         /* No device found */
         ERR("No device found!\n");
-        return STATUS_UNSUCCESSFUL;
+        return STATUS_INVALID_PARAMETER_1;
     }
 
     iFoundMode = 0;
@@ -571,13 +571,18 @@
 
     _SEH2_TRY
     {
-        ProbeForWrite(lpDevMode, sizeof(DEVMODEW), 1);
+        ProbeForRead(lpDevMode, sizeof(DEVMODEW), 1);
+
+        cbSize = lpDevMode->dmSize;
+        cbExtra = lpDevMode->dmDriverExtra;
+
+        ProbeForWrite(lpDevMode, cbSize + cbExtra, 1);
     }
     _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
     {
         _SEH2_YIELD(return _SEH2_GetExceptionCode());
     }
-    _SEH2_END
+    _SEH2_END;
 
     if (lpDevMode->dmSize != sizeof(DEVMODEW))
     {
@@ -586,31 +591,30 @@
 
     if (pustrDevice)
     {
-       if (pustrDevice->Buffer == NULL || pustrDevice->Length == 0)
-       {
-           Status = STATUS_INVALID_PARAMETER_1;
-       }
-
         /* Initialize destination string */
         RtlInitEmptyUnicodeString(&ustrDevice, awcDevice, sizeof(awcDevice));
 
         _SEH2_TRY
         {
             /* Probe the UNICODE_STRING and the buffer */
-            ProbeForRead(pustrDevice, sizeof(UNICODE_STRING), 1);
-            ProbeForRead(pustrDevice->Buffer, pustrDevice->Length, 1);
+            ProbeForReadUnicodeString(pustrDevice);
+
+            if (!pustrDevice->Length || !pustrDevice->Buffer)
+                ExRaiseStatus(STATUS_NO_MEMORY);
+
+            ProbeForRead(pustrDevice->Buffer, pustrDevice->Length, 
sizeof(UCHAR));
 
             /* Copy the string */
             RtlCopyUnicodeString(&ustrDevice, pustrDevice);
         }
         _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
         {
-            _SEH2_YIELD(return _SEH2_GetExceptionCode());
-        }
-        _SEH2_END
+            _SEH2_YIELD(return STATUS_INVALID_PARAMETER_1);
+        }
+        _SEH2_END;
 
         pustrDevice = &ustrDevice;
-   }
+    }
 
     /* Acquire global USER lock */
     UserEnterShared();
@@ -642,11 +646,6 @@
         /* Copy some information back */
         _SEH2_TRY
         {
-            ProbeForRead(lpDevMode, sizeof(DEVMODEW), 1);
-            cbSize = lpDevMode->dmSize;
-            cbExtra = lpDevMode->dmDriverExtra;
-
-            ProbeForWrite(lpDevMode, cbSize + cbExtra, 1);
             /* Output what we got */
             RtlCopyMemory(lpDevMode, pdm, min(cbSize, pdm->dmSize));
 
@@ -663,13 +662,6 @@
             Status = _SEH2_GetExceptionCode();
         }
         _SEH2_END;
-    }
-    else
-    {
-        if (Status == STATUS_UNSUCCESSFUL)
-        {
-            Status = STATUS_INVALID_PARAMETER_1;
-        }
     }
 
     return Status;


Reply via email to