Note: There are a few cases of duplicates in user autocompletion which are being worked on.

Failure of SystemParametersInfo is not tested

NEW
Unassigned

Status

()

Core
Widget: Win32
7 years ago
7 years ago

People

(Reporter: Jean-Marc Desperrier, Unassigned)

Tracking

Trunk
x86
Other
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [patch in hand])

Comment hidden (empty)
(Reporter)

Comment 1

7 years ago
The call to SystemParametersInfo here has two problems :
http://hg.mozilla.org/mozilla-central/file/tip/widget/src/windows/nsLookAndFeel.cpp#l456
456         HIGHCONTRAST contrastThemeInfo;
457         contrastThemeInfo.cbSize = sizeof(contrastThemeInfo);
458         ::SystemParametersInfo(SPI_GETHIGHCONTRAST, 0, &contrastThemeInfo, 0);
459 
460         aMetric = ((contrastThemeInfo.dwFlags & HCF_HIGHCONTRASTON) != 0);

- The return status of SystemParametersInfo is not tested
- The second argument is set to zero, it should be the size of the contrastThemeInfo structure according to MSDN.
(Reporter)

Comment 2

7 years ago
Documentation for the fact the second argument should not be zero :
http://msdn.microsoft.com/en-us/library/ms724947(VS.85).aspx
SPI_GETHIGHCONTRAST    Set the cbSize member of this structure and the uiParam parameter to sizeof(HIGHCONTRAST).

Proposed fix (by Xeno86, of the KernelEx http://kernelex.sourceforge.net/ project)
456         HIGHCONTRAST contrastThemeInfo;
457         contrastThemeInfo.cbSize = sizeof(contrastThemeInfo);
458         BOOL success = ::SystemParametersInfo(SPI_GETHIGHCONTRAST, sizeof(contrastThemeInfo), &contrastThemeInfo, 0);
459 
460         aMetric = (success && (contrastThemeInfo.dwFlags & HCF_HIGHCONTRASTON) != 0);

The code in it's current state apparently never fails on supported Microsoft OS, first because this call is always successful, second probably because the OS implementation directly uses the size in the structure, and not the one in the argument of the call.

The problem has been identified by the KernelEx project (a set of DLL that allows NT/2000/XP program to run under Windows 98/Me) because it's much easier to make the call fail there (Accessibility Pack is optional under Windows 9x).

Original report by xeno86 on mozilla.dev.builds :
http://groups.google.com/group/mozilla.dev.builds/msg/db0d3b7d07822680
Whiteboard: [patch in hand]
You need to log in before you can comment on or make changes to this bug.