This is a migrated thread and some comments may be shown as answers.

Bug: Platform architecture does not report bitness correctly

6 Answers 36 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tom
Top achievements
Rank 1
Tom asked on 20 Feb 2012, 11:04 AM
Hello,

Platform architecture reports x86 even when its running in 64bit (compiled with VS for anyCPU and running on a 64bit machine)

I confirmed this with taks manager and should be easy to reproduce

Kind Regards, Tom

6 Answers, 1 is accepted

Sort by
0
Kaloyan
Telerik team
answered on 22 Feb 2012, 01:26 PM
Hello Tom,

Building application with an "Any CPU" platform target specified doesn't necessary mean that it is x64. First and foremost this is only determined after the JIT compilation when dll is loaded into the application domain. 

Regards,
Kaloyan
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Tom
Top achievements
Rank 1
answered on 22 Feb 2012, 03:18 PM
Hi,

I understand that but I did not explain myself well. If you compile to x86 or anyCPU the only difference is that a flag is set in the header of the assembly. A 64bit runtime will switch to WOW64 (32bit compat mode) if this flag is set as x86.

What I then expect ist hat if I compile to AnyCPU that JustDecompile would give this information. If I tested at work correctly (I cannot access it currently) it will show up as x86 while I expect AnyCPU.

Kind Regards, Tom
0
Kaloyan
Telerik team
answered on 23 Feb 2012, 12:08 PM
Hi Tom,

You are absolutely right. What is interesting here is that according to the IL Dasm tool an assembly build on Any CPU and x86 has an exactly the same Machine value == 0x014c in COFF header. Just like you, we are more than interested to catch the difference in those cases, so we will investigate it deeper. Any related info will be more then appreciated.

Kind regards,
Kaloyan
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Chris
Top achievements
Rank 1
answered on 03 Mar 2012, 04:56 PM
Hi,

Hopefully I can be of some help with the bitness, as you have seen the machine flag for Any CPU and x86 are the same, the difference is in the CLR Header. If you use DumpBin to inspect the header you will see that the CLR Header flags for Any CPU will have the IL Only flag set, while a x86 will have the "32-Bit Required" flag set as well.

dumpbin /clrheader CPUTargetTest.exe

ANY CPU:
 clr Header:

              48 cb
            2.05 runtime version
            205C [     604] RVA [size] of MetaData Directory
               1 flags
                   IL Only

x86:

  clr Header:

              48 cb
            2.05 runtime version
            205C [     604] RVA [size] of MetaData Directory
               3 flags
                   IL Only
                   32-Bit Required


You can also check this with corflags.exe

corflags CPUTargetsTest.exe

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

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

Best Regards,

Chris
0
Tom
Top achievements
Rank 1
answered on 05 Mar 2012, 09:59 AM
Hi Chris,

Good analysis. That's what I was about to post once I had the time

Kind Regards, Tom
0
Kaloyan
Telerik team
answered on 06 Mar 2012, 09:29 AM
Hi Chris,

That is exactly what we came up with when discussing the problem. It is included in the latest internal build so give it a try and please let us know if any problem pops up. 

Kind regards,
Kaloyan
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
General Discussions
Asked by
Tom
Top achievements
Rank 1
Answers by
Kaloyan
Telerik team
Tom
Top achievements
Rank 1
Chris
Top achievements
Rank 1
Share this question
or