Last Comment Bug 599311 - Failure of SystemParametersInfo is not tested
: Failure of SystemParametersInfo is not tested
Status: NEW
[patch in hand]
:
Product: Core
Classification: Components
Component: Widget: Win32 (show other bugs)
: Trunk
: x86 Other
: -- normal (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
:
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-09-24 05:44 PDT by Jean-Marc Desperrier
Modified: 2010-09-24 06:10 PDT (History)
0 users
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments

Description Jean-Marc Desperrier 2010-09-24 05:44:51 PDT

    
Comment 1 Jean-Marc Desperrier 2010-09-24 05:48:25 PDT
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.
Comment 2 Jean-Marc Desperrier 2010-09-24 06:10:42 PDT
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

Note You need to log in before you can comment on or make changes to this bug.