Skip to content

Commit 10c7e5c

Browse files
author
Dmitry Chapyshev
committed
[NtUser] Try to fix tests for user32:EnumDisplaySettings
svn path=/trunk/; revision=72655
1 parent db1b0cb commit 10c7e5c

File tree

1 file changed

+18
-26
lines changed

1 file changed

+18
-26
lines changed

reactos/win32ss/user/ntuser/display.c

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ UserEnumCurrentDisplaySettings(
443443
{
444444
/* No device found */
445445
ERR("No PDEV found!\n");
446-
return STATUS_UNSUCCESSFUL;
446+
return STATUS_INVALID_PARAMETER_1;
447447
}
448448

449449
*ppdm = ppdev->pdmwDev;
@@ -474,7 +474,7 @@ UserEnumDisplaySettings(
474474
{
475475
/* No device found */
476476
ERR("No device found!\n");
477-
return STATUS_UNSUCCESSFUL;
477+
return STATUS_INVALID_PARAMETER_1;
478478
}
479479

480480
iFoundMode = 0;
@@ -571,13 +571,18 @@ NtUserEnumDisplaySettings(
571571

572572
_SEH2_TRY
573573
{
574-
ProbeForWrite(lpDevMode, sizeof(DEVMODEW), 1);
574+
ProbeForRead(lpDevMode, sizeof(DEVMODEW), 1);
575+
576+
cbSize = lpDevMode->dmSize;
577+
cbExtra = lpDevMode->dmDriverExtra;
578+
579+
ProbeForWrite(lpDevMode, cbSize + cbExtra, 1);
575580
}
576581
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
577582
{
578583
_SEH2_YIELD(return _SEH2_GetExceptionCode());
579584
}
580-
_SEH2_END
585+
_SEH2_END;
581586

582587
if (lpDevMode->dmSize != sizeof(DEVMODEW))
583588
{
@@ -586,31 +591,30 @@ NtUserEnumDisplaySettings(
586591

587592
if (pustrDevice)
588593
{
589-
if (pustrDevice->Buffer == NULL || pustrDevice->Length == 0)
590-
{
591-
Status = STATUS_INVALID_PARAMETER_1;
592-
}
593-
594594
/* Initialize destination string */
595595
RtlInitEmptyUnicodeString(&ustrDevice, awcDevice, sizeof(awcDevice));
596596

597597
_SEH2_TRY
598598
{
599599
/* Probe the UNICODE_STRING and the buffer */
600-
ProbeForRead(pustrDevice, sizeof(UNICODE_STRING), 1);
601-
ProbeForRead(pustrDevice->Buffer, pustrDevice->Length, 1);
600+
ProbeForReadUnicodeString(pustrDevice);
601+
602+
if (!pustrDevice->Length || !pustrDevice->Buffer)
603+
ExRaiseStatus(STATUS_NO_MEMORY);
604+
605+
ProbeForRead(pustrDevice->Buffer, pustrDevice->Length, sizeof(UCHAR));
602606

603607
/* Copy the string */
604608
RtlCopyUnicodeString(&ustrDevice, pustrDevice);
605609
}
606610
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
607611
{
608-
_SEH2_YIELD(return _SEH2_GetExceptionCode());
612+
_SEH2_YIELD(return STATUS_INVALID_PARAMETER_1);
609613
}
610-
_SEH2_END
614+
_SEH2_END;
611615

612616
pustrDevice = &ustrDevice;
613-
}
617+
}
614618

615619
/* Acquire global USER lock */
616620
UserEnterShared();
@@ -642,11 +646,6 @@ NtUserEnumDisplaySettings(
642646
/* Copy some information back */
643647
_SEH2_TRY
644648
{
645-
ProbeForRead(lpDevMode, sizeof(DEVMODEW), 1);
646-
cbSize = lpDevMode->dmSize;
647-
cbExtra = lpDevMode->dmDriverExtra;
648-
649-
ProbeForWrite(lpDevMode, cbSize + cbExtra, 1);
650649
/* Output what we got */
651650
RtlCopyMemory(lpDevMode, pdm, min(cbSize, pdm->dmSize));
652651

@@ -664,13 +663,6 @@ NtUserEnumDisplaySettings(
664663
}
665664
_SEH2_END;
666665
}
667-
else
668-
{
669-
if (Status == STATUS_UNSUCCESSFUL)
670-
{
671-
Status = STATUS_INVALID_PARAMETER_1;
672-
}
673-
}
674666

675667
return Status;
676668
}

0 commit comments

Comments
 (0)