CppStars / mb-unit

Automatically exported from code.google.com/p/mb-unit
0 stars 0 forks source link

Mixed Mode x86 Assemblies are run AnyCPU #704

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create an unsafe C++ test assembly, compile x86.
2. Attempt to run using Icarus or Echo with IsolatedProcess on a 64bit OS.

What is the expected output? What do you see instead?

I expect the tests to be loaded and run by the Gallio.Host.x86.exe, but it is 
loaded by Gallio.Host.exe which throws a BadImageFormatException.

What version of the product are you using? On what operating system?

3.2.484 nightly build.

Please provide any additional information below.

This is happening because mixed mode assemblies do not have their 32BIT 
corflags set. For mixed mode assemblies, if the PE is PE32, not PE32+ and 
ILONLY is 0, then they are x86, not AnyCPU. The current code just looks at the 
32BIT corflags which is not complete.

For more information, this MSDN blog covers all of the options.

http://blogs.msdn.com/b/slessard/archive/2010/04/09/types-of-managed-code-assemb
lies.aspx

As an example, a C# x86 assembly,

Version   : v4.0.30319
CLR Header: 2.5
PE        : PE32
CorFlags  : 3
ILONLY    : 1
32BIT     : 1
Signed    : 0

And a mixed mode C++ x86 assembly,

Version   : v4.0.30319
CLR Header: 2.5
PE        : PE32
CorFlags  : 3
ILONLY    : 1
32BIT     : 1
Signed    : 0

Attached is a VS2010 solution with 4 test assemblies, two C++, two C#, each 
language compiled x86 and x64.

Original issue reported on code.google.com by rpro...@gmail.com on 11 Aug 2010 at 4:12

Attachments:

GoogleCodeExporter commented 8 years ago
The fix for this turned out to be pretty easy, just a one line modification to 
the AssemblyMetadata.ProcessorArchitecture property to take into account 
assemblies with the ILOnly flag set.

I have attached a patch and tested it against my solution above. The x86 mixed 
mode assembly loads and runs properly.

Original comment by rpro...@gmail.com on 11 Aug 2010 at 7:33

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by Yann.Tre...@gmail.com on 12 Aug 2010 at 1:54

GoogleCodeExporter commented 8 years ago

Original comment by Yann.Tre...@gmail.com on 21 Sep 2010 at 1:46

GoogleCodeExporter commented 8 years ago
This was fixed in 3.2. It was checked in with Revision r2779.

Original comment by rpro...@gmail.com on 25 Sep 2010 at 4:39

GoogleCodeExporter commented 8 years ago

Original comment by Yann.Tre...@gmail.com on 26 Sep 2010 at 5:42