[io-layer] Correctly detect a PE32+ assembly as managed when starting process
commit68bcbb4b77477133a1715a63ee1faaa85b600779
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Mon, 10 Oct 2016 11:28:43 +0000 (10 13:28 +0200)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Mon, 10 Oct 2016 12:00:07 +0000 (10 14:00 +0200)
tree756fd62dd47b14efc49b58256cd3457925d4f813
parent7ca51073c638becc090e2c974ecaa739af62e4a3
[io-layer] Correctly detect a PE32+ assembly as managed when starting process

We weren't checking whether a PE file is in PE32 or PE32+ format,
causing us to use the PE32 offsets on the newer format as well.

This means that using Process.Start() on a managed assembly didn't
always work when a PE32+ file was in play. Such a file is created
when targeting x64 e.g. via the -platform:x64 csc.exe/mcs option.

The reason why we probably didn't notice until now is that in an
assembly produced by mcs there happens to be some data at the PE32
CLR header offset even in a PE32+ file, causing the check to "work".

This doesn't apply to csc.exe/roslyn though and so we couldn't
execute those assemblies via Process.Start() even though they're
perfectly managed. Since the .NET Core project.json toolchain
produces x64-targeted assemblies by default more people ran into
the issue trying to run those on Mono: https://github.com/cake-build/cake/issues/1247

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=44937

PE/COFF spec at https://msdn.microsoft.com/en-us/library/windows/desktop/ms680547(v=vs.85).aspx
mono/io-layer/processes.c