From f3541757ddffd46da02f90909922872a694de1fd Mon Sep 17 00:00:00 2001 From: "John Chen (CLR)" Date: Mon, 11 Jan 2016 14:23:52 -0800 Subject: Make CORCOMPILE_HEADER backward compatible Resolve issue #2348 by reordering fields in CORCOMPILE_HEADER, so that PEKind and Machines fields are in the same location as in older versions of this struct. --- src/utilcode/pedecoder.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/utilcode') diff --git a/src/utilcode/pedecoder.cpp b/src/utilcode/pedecoder.cpp index 049276ba5b..2e1a143534 100644 --- a/src/utilcode/pedecoder.cpp +++ b/src/utilcode/pedecoder.cpp @@ -1226,9 +1226,12 @@ IMAGE_DATA_DIRECTORY *PEDecoder::GetMetaDataHelper(METADATA_SECTION_TYPE type) c // Visual Studio took dependency on crossgen /CreatePDB returning COR_E_NI_AND_RUNTIME_VERSION_MISMATCH // when crossgen and the native image come from different runtimes. In order to reach error path that returns - // COR_E_NI_AND_RUNTIME_VERSION_MISMATCH in this case, size of CORCOMPILE_HEADER has to remain constant to pass earlier + // COR_E_NI_AND_RUNTIME_VERSION_MISMATCH in this case, size of CORCOMPILE_HEADER has to remain constant, + // and the offset of PEKind and Machine fields inside CORCOMPILE_HEADER also have to remain constant, to pass earlier // checks that lead to different error codes. See Windows Phone Blue Bug #45406 for details. _ASSERTE(sizeof(CORCOMPILE_HEADER) == 160 + sizeof(TADDR)); + _ASSERTE(offsetof(CORCOMPILE_HEADER, PEKind) == 108 + sizeof(TADDR)); + _ASSERTE(offsetof(CORCOMPILE_HEADER, Machine) == 116 + sizeof(TADDR)); // Handle NGEN format; otherwise, there is only one MetaData section in the // COR_HEADER and so the value of pDirRet is correct -- cgit v1.2.3