Why doesn't the corflags utility warn when marking x64 assemblies as x86?
Asked Answered
D

2

2

If I set the platform flags of MyApp.exe to be x64 I still can run the corflags utilty like this:
corflags /32bit+ MyApp.exe
corflags will happily set the 32bit flag to 1. Of course when I'll try to run the application I'll get an error: 0xC000007B = STATUS_INVALID_IMAGE_FORMAT

My question is: Is there a way that an assembly which is built to x64 can run as x86 or it is just that corflags utility doesn't 'care'?

Delubrum answered 22/11, 2008 at 9:52 Comment(3)
I noticed that the user mdb edited this post and removed the x64 tag. Can anyone tell me why? (I would expect to find this kind of questions with x64 tag)Delubrum
This is definitely a x64 question. This should be tagged x64.Chalk
Thanks Jerome. I don't want to start editing wars ala wikipedia. I wish there was a way to talk directly to the mdbDelubrum
S
2

Compiling your binary by setting the "Platform Type" to x64 also changes the image PE header to make it 64 bits only. You can see this by using the Dependency Walker, for instance.

Having a 64Bits PE header does seem to take precedence over the 32 bits only corflags. The win32 bootstrapper for .NET seems to see that the PE header is not compatible with the current system (64 bits on a 32 bits system). That prevents the native image from loading, and incidentally also the .NET assembly part of the image.

I don't know any tool capable of updating the PE header this way, though. This does not seem to be just a matter of changing a flag to set the image to 32 bits. (See this blog post)

Series answered 22/11, 2008 at 19:46 Comment(0)
F
0

Because if you don't load a native DLL, there's no reason that you couldn't remark it as 32-bit. If it's pure MSIL, the decision doesn't mean as much.

Fleece answered 22/11, 2008 at 18:7 Comment(1)
Hmm not true Paul. Try a simple test: Create a console application with nothing inside. Build it as x64 application than use corflags to set it to x86. Now try to run the application - You'll get the 0xC000007B error.Delubrum

© 2022 - 2024 — McMap. All rights reserved.