mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +00:00
win: Placate more OS versions in the PEImageReader test
The BaseName() was added because system DLLs were being reported by GetFileVersionInfo()/VerQueryValue() as having major file versions of 6.2 instead of 10.0 on Windows 10 when accessed by full path, but not by BaseName(). The PEImageReader gets the correct version from the in-memory images, 10.0. This trick didn't work on Windows XP, where two copies of comctl32.dll were found loaded into the process, one with a major file version of 5.82 and the other with 6.0. Giving GetFileVersionInfo() the BaseName() would result in it returning information from one of these, which would cause the version to not match when the PEImageReader was looking at the other. All of these GetFileVersionInfo() quirks make me glad that we're not using it anymore (outside of the test). Because of the version numbers involved (NT 6.2 = Windows 8, where GetVersion()/GetVersionEx() start behaving differently for non-manifested applications) and the fact that GetFileVersionInfo() and VerQueryValue() seem to report 10.0 even with full paths on Windows 10 in applications manifested to run on that OS, the BaseName() thing is restricted to Windows 8 and higher. TEST=crashpad_snapshot_test PEImageReader.VSFixedFileInfo_AllModules BUG=crashpad:78 R=scottmg@chromium.org Review URL: https://codereview.chromium.org/1493933002 .
This commit is contained in:
parent
894a06070e
commit
47fbac4ae1
@ -93,12 +93,23 @@ void TestVSFixedFileInfo(ProcessReaderWin* process_reader,
|
||||
}
|
||||
}
|
||||
|
||||
base::FilePath module_path(module.name);
|
||||
|
||||
const DWORD version = GetVersion();
|
||||
const int major_version = LOBYTE(LOWORD(version));
|
||||
const int minor_version = HIBYTE(LOWORD(version));
|
||||
if (major_version > 6 || (major_version == 6 && minor_version >= 2)) {
|
||||
// Windows 8 or later.
|
||||
//
|
||||
// Use BaseName() to ensure that GetModuleVersionAndType() finds the
|
||||
// already-loaded module with the specified name. Otherwise, dwFileVersionMS
|
||||
// may not match.
|
||||
// may not match. This appears to be related to the changes made in Windows
|
||||
// 8.1 to GetVersion() and GetVersionEx() for non-manifested applications
|
||||
module_path = module_path.BaseName();
|
||||
}
|
||||
|
||||
VS_FIXEDFILEINFO expected;
|
||||
const bool expected_rv = GetModuleVersionAndType(
|
||||
base::FilePath(module.name).BaseName(), &expected);
|
||||
const bool expected_rv = GetModuleVersionAndType(module_path, &expected);
|
||||
ASSERT_TRUE(expected_rv || !known_dll);
|
||||
|
||||
EXPECT_EQ(expected_rv, observed_rv);
|
||||
|
Loading…
x
Reference in New Issue
Block a user