This repository was archived by the owner on Jan 23, 2023. It is now read-only.
File tree 7 files changed +77
-7
lines changed
tests/src/Loader/regressions/GitHub_15544
7 files changed +77
-7
lines changed Original file line number Diff line number Diff line change @@ -720,7 +720,7 @@ NativeImageDumper::DumpNativeImage()
720
720
721
721
for (COUNT_T i = 0 ; i < m_decoder.GetNumberOfSections (); i++)
722
722
{
723
- PTR_IMAGE_SECTION_HEADER section = dptr_add ( m_decoder.FindFirstSection (), i) ;
723
+ PTR_IMAGE_SECTION_HEADER section = m_decoder.FindFirstSection () + i ;
724
724
m_display->Section (reinterpret_cast <char *>(section->Name ),
725
725
section->VirtualAddress ,
726
726
section->SizeOfRawData );
Original file line number Diff line number Diff line change @@ -182,7 +182,7 @@ class PEDecoder
182
182
UINT32 GetWin32VersionValue () const ;
183
183
COUNT_T GetNumberOfRvaAndSizes () const ;
184
184
COUNT_T GetNumberOfSections () const ;
185
- IMAGE_SECTION_HEADER * FindFirstSection () const ;
185
+ PTR_IMAGE_SECTION_HEADER FindFirstSection () const ;
186
186
IMAGE_SECTION_HEADER *FindSection (LPCSTR sectionName) const ;
187
187
188
188
DWORD GetImageIdentity () const ;
Original file line number Diff line number Diff line change @@ -1178,7 +1178,7 @@ inline DWORD PEDecoder::GetImageIdentity() const
1178
1178
}
1179
1179
1180
1180
1181
- inline IMAGE_SECTION_HEADER * PEDecoder::FindFirstSection () const
1181
+ inline PTR_IMAGE_SECTION_HEADER PEDecoder::FindFirstSection () const
1182
1182
{
1183
1183
CONTRACT (IMAGE_SECTION_HEADER *)
1184
1184
{
Original file line number Diff line number Diff line change @@ -445,6 +445,7 @@ BOOL PEDecoder::HasWriteableSections() const
445
445
CONTRACT_CHECK
446
446
{
447
447
INSTANCE_CHECK;
448
+ PRECONDITION (CheckNTHeaders ());
448
449
PRECONDITION (CheckFormat ());
449
450
NOTHROW;
450
451
GC_NOTRIGGER;
@@ -453,7 +454,7 @@ BOOL PEDecoder::HasWriteableSections() const
453
454
}
454
455
CONTRACT_CHECK_END;
455
456
456
- PTR_IMAGE_SECTION_HEADER pSection = FindFirstSection (FindNTHeaders () );
457
+ PTR_IMAGE_SECTION_HEADER pSection = FindFirstSection ();
457
458
_ASSERTE (pSection != NULL );
458
459
459
460
PTR_IMAGE_SECTION_HEADER pSectionEnd = pSection + VAL16 (FindNTHeaders ()->FileHeader .NumberOfSections );
Original file line number Diff line number Diff line change @@ -1029,7 +1029,9 @@ PTR_PEImageLayout PEImage::CreateLayoutFlat(BOOL bPermitWriteableSections)
1029
1029
1030
1030
PTR_PEImageLayout pFlatLayout = PEImageLayout::LoadFlat (GetFileHandle (),this );
1031
1031
1032
- if (!bPermitWriteableSections && pFlatLayout->HasWriteableSections ())
1032
+ if (!bPermitWriteableSections
1033
+ && pFlatLayout->CheckNTHeaders ()
1034
+ && pFlatLayout->HasWriteableSections ())
1033
1035
{
1034
1036
pFlatLayout->Release ();
1035
1037
@@ -1114,8 +1116,7 @@ void PEImage::Load()
1114
1116
1115
1117
#ifdef PLATFORM_UNIX
1116
1118
if (m_pLayouts[IMAGE_FLAT] != NULL
1117
- && m_pLayouts[IMAGE_FLAT]->CheckFormat ()
1118
- && m_pLayouts[IMAGE_FLAT]->IsILOnly ()
1119
+ && m_pLayouts[IMAGE_FLAT]->CheckILOnlyFormat ()
1119
1120
&& !m_pLayouts[IMAGE_FLAT]->HasWriteableSections ())
1120
1121
{
1121
1122
// IL-only images with writeable sections are mapped in general way,
Original file line number Diff line number Diff line change
1
+ // Licensed to the .NET Foundation under one or more agreements.
2
+ // The .NET Foundation licenses this file to you under the MIT license.
3
+ // See the LICENSE file in the project root for more information.
4
+ //
5
+
6
+ using System ;
7
+ using System . IO ;
8
+ using System . Reflection ;
9
+
10
+ public class CMain {
11
+ public static int Main ( String [ ] args ) {
12
+ string tempFileName = Path . GetTempFileName ( ) ;
13
+
14
+ bool isThrown = false ;
15
+
16
+ try
17
+ {
18
+ AssemblyName . GetAssemblyName ( tempFileName ) ;
19
+ }
20
+ catch ( BadImageFormatException )
21
+ {
22
+ isThrown = true ;
23
+ }
24
+
25
+ File . Delete ( tempFileName ) ;
26
+
27
+ if ( isThrown ) {
28
+ Console . WriteLine ( "PASS" ) ;
29
+
30
+ return 100 ;
31
+ } else {
32
+ Console . WriteLine ( "FAIL" ) ;
33
+
34
+ return 101 ;
35
+ }
36
+ }
37
+ }
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" utf-8" ?>
2
+ <Project ToolsVersion =" 12.0" DefaultTargets =" Build" xmlns =" http://schemas.microsoft.com/developer/msbuild/2003" >
3
+ <Import Project =" $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
4
+ <PropertyGroup >
5
+ <Configuration Condition =" '$(Configuration)' == '' " >Debug</Configuration >
6
+ <Platform Condition =" '$(Platform)' == '' " >AnyCPU</Platform >
7
+ <SchemaVersion >2.0</SchemaVersion >
8
+ <ProjectGuid >{AC75380E-F196-4F32-9BCF-F0589AF864E6}</ProjectGuid >
9
+ <OutputType >Exe</OutputType >
10
+ <ProjectTypeGuids >{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids >
11
+ <SolutionDir Condition =" $(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'" >..\..\</SolutionDir >
12
+ <AllowUnsafeBlocks >true</AllowUnsafeBlocks >
13
+ </PropertyGroup >
14
+ <!-- Default configurations to help VS understand the configurations -->
15
+ <PropertyGroup Condition =" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " >
16
+ </PropertyGroup >
17
+ <PropertyGroup Condition =" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " >
18
+ </PropertyGroup >
19
+ <ItemGroup >
20
+ <CodeAnalysisDependentAssemblyPaths Condition =" '$(VS100COMNTOOLS)' != '' " Include =" $(VS100COMNTOOLS)..\IDE\PrivateAssemblies" >
21
+ <Visible >False</Visible >
22
+ </CodeAnalysisDependentAssemblyPaths >
23
+ </ItemGroup >
24
+ <ItemGroup >
25
+ <Compile Include =" main.cs" />
26
+ </ItemGroup >
27
+ <ItemGroup >
28
+ <Service Include =" {82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
29
+ </ItemGroup >
30
+ <Import Project =" $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
31
+ </Project >
You can’t perform that action at this time.
0 commit comments