How to detect CPU is x86 or x64 or IA64

And can a x68 CPU system, install 64 bit Windows OS?
Or
How a 32 bit Windows OS running on x64 cpu systesm?

If the processor is an intel or amd 64bit cpu it can install either 32bit
or 64bit versions of windows and run in either 32bit or 64bit mode.

IA64 is dead. Very, very dead. It was actually born dead, but nobody at
Intel, HP, or Microsoft would admit it for like a decade.

Your code is compiled as either 32bit or 64bit. In general you do not have
to worry at all about which width you are running on, if you write your
code correctly. IOCTLs from 32bit processes on a 64bit platform can be an
issue.

Mark Roddy

On Fri, Aug 9, 2013 at 6:23 AM, wrote:

> And can a x68 CPU system, install 64 bit Windows OS?
> Or
> How a 32 bit Windows OS running on x64 cpu systesm?
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

Start reading MSDN articles from
WOW64
GetNativeSystemInfo
IoIs32bitProcess

Your suggestions are technically correct but as Mark points out the real
question is why did the OP think they needed to know> In the kernel a 32
bit driver runs on a 32-bit system and 64-bit is again matched. So there is
little reason for kernel code to know the processor. If you properly
design your IOCTL’s (so they don’t have pointers in the structs and any
length that can be of pointer size are always 64-bit you don’t need to worry
about 32 bit processes on a 64 bit system.

So to ask the question we ask way too often on this list, what is the real
problem the original poster is trying to solve?

Don Burn
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@mail.ru
Sent: Friday, August 09, 2013 9:43 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] How to detect CPU is x86 or x64 or IA64

Start reading MSDN articles from
WOW64
GetNativeSystemInfo
IoIs32bitProcess


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

You can’t run x64 code on x86 CPU since such CPU wouldn’t recognize x64
instructions.

You know if your code running at amd64 or itanium at compile time.

You can detect if your x32 code running on amd64 CPU by means of cpuid
instruction with 0x80000001 in eax and check bit 29 of edx register after
cpuid - if bit is set means that this CPU is amd64.

On Friday, August 9, 2013, wrote:

And can a x68 CPU system, install 64 bit Windows OS?
Or
How a 32 bit Windows OS running on x64 cpu systesm?


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

That CPUID 0x80000001 will tell you the processor is x64 capable, but you
need to rdmsr 0xC0000080 and check bit 10 to know if the CPU is actively in
x64 mode.

But I agree with samael7 that you probably just want to use existing APIs
to get the info rather than checking directly.

JB

On Fri, Aug 9, 2013 at 10:15 AM, Sergey Pisarev wrote:

> You can’t run x64 code on x86 CPU since such CPU wouldn’t recognize x64
> instructions.
>
> You know if your code running at amd64 or itanium at compile time.
>
> You can detect if your x32 code running on amd64 CPU by means of cpuid
> instruction with 0x80000001 in eax and check bit 29 of edx register after
> cpuid - if bit is set means that this CPU is amd64.
>
>
> On Friday, August 9, 2013, wrote:
>
>> And can a x68 CPU system, install 64 bit Windows OS?
>> Or
>> How a 32 bit Windows OS running on x64 cpu systesm?
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
>>
>> OSR is HIRING!! See http://www.osr.com/careers
>>
>> For our schedule of WDF, WDM, debugging and other seminars visit:
>> http://www.osr.com/seminars
>>
>> To unsubscribe, visit the List Server section of OSR Online at
>> http://www.osronline.com/page.cfm?name=ListServer
>>
> — NTDEV is sponsored by OSR Visit the list at:
> http://www.osronline.com/showlists.cfm?list=ntdev OSR is HIRING!! See
> http://www.osr.com/careers For our schedule of WDF, WDM, debugging and
> other seminars visit: http://www.osr.com/seminars To unsubscribe, visit
> the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

No the OP needs to step back and explain why he thinks he need this. Almost
every use I have ever seen in the kernel could have been avoided with a good
design to begin with, and a large number of them were dumped by throwing out
the driver (and in some cases the develoiper).

Don Burn
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Jimbo Bob
Sent: Friday, August 09, 2013 10:48 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] How to detect CPU is x86 or x64 or IA64

That CPUID 0x80000001 will tell you the processor is x64 capable, but you
need to rdmsr 0xC0000080 and check bit 10 to know if the CPU is actively in
x64 mode.

But I agree with samael7 that you probably just want to use existing APIs to
get the info rather than checking directly.

JB

On Fri, Aug 9, 2013 at 10:15 AM, Sergey Pisarev
wrote:

You can’t run x64 code on x86 CPU since such CPU wouldn’t recognize
x64 instructions.

You know if your code running at amd64 or itanium at compile time.

You can detect if your x32 code running on amd64 CPU by means of
cpuid instruction with 0x80000001 in eax and check bit 29 of edx register
after cpuid - if bit is set means that this CPU is amd64.

On Friday, August 9, 2013, wrote:

And can a x68 CPU system, install 64 bit Windows OS?
Or
How a 32 bit Windows OS running on x64 cpu systesm?


NTDEV is sponsored by OSR

Visit the list at:
http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars
visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online
at http://www.osronline.com/page.cfm?name=ListServer

— NTDEV is sponsored by OSR Visit the list at:
http://www.osronline.com/showlists.cfm?list=ntdev OSR is HIRING!! See
http://www.osr.com/careers For our schedule of WDF, WDM, debugging and other
seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List
Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

— NTDEV is sponsored by OSR Visit the list at:
http://www.osronline.com/showlists.cfm?list=ntdev OSR is HIRING!! See
http://www.osr.com/careers For our schedule of WDF, WDM, debugging and other
seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List
Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Hint: it doesn’t matter to you in the slightest whether your CPU is an x86
or x64. What MIGHT matter is if you have very bad driver design that
requires passing in pointers to user space; then you need to know if it is
a 32-bit or 64-bit app running, and it also means you should probably
redesign that interface to not require user-mode addresses be decoded in
your driver.

What problem is it that you think you are solving?
joe

And can a x68 CPU system, install 64 bit Windows OS?
Or
How a 32 bit Windows OS running on x64 cpu systesm?


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

On 09-Aug-2013 17:15, Sergey Pisarev wrote:

You can detect if your x32 code running on amd64 CPU by means of cpuid
> …

Or simply: IsWow64Process()

– pa

This would not be correct. By definition, all drivers in Win64 must run
in 64-bit mode. So if a Win32 app does an I/O operation, by the time your
driver sees it you are going to find the CPU in 64-bit mode, independent
of what mode the app was running in.

There is a DDI call to ask if the calling process was a Win32 process; I
forget its name, but I suspect that it only works when you are in the top
level of a driver, in the context of the calling thread.

But going back to the point of the question, why does it matter? And, if
it matters, how do you redesign the interface so it doesn’t matter?
joe

That CPUID 0x80000001 will tell you the processor is x64 capable, but you
need to rdmsr 0xC0000080 and check bit 10 to know if the CPU is actively
in
x64 mode.

But I agree with samael7 that you probably just want to use existing APIs
to get the info rather than checking directly.

JB

On Fri, Aug 9, 2013 at 10:15 AM, Sergey Pisarev
wrote:
>
>> You can’t run x64 code on x86 CPU since such CPU wouldn’t recognize x64
>> instructions.
>>
>> You know if your code running at amd64 or itanium at compile time.
>>
>> You can detect if your x32 code running on amd64 CPU by means of cpuid
>> instruction with 0x80000001 in eax and check bit 29 of edx register
>> after
>> cpuid - if bit is set means that this CPU is amd64.
>>
>>
>> On Friday, August 9, 2013, wrote:
>>
>>> And can a x68 CPU system, install 64 bit Windows OS?
>>> Or
>>> How a 32 bit Windows OS running on x64 cpu systesm?
>>>
>>> —
>>> NTDEV is sponsored by OSR
>>>
>>> Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
>>>
>>> OSR is HIRING!! See http://www.osr.com/careers
>>>
>>> For our schedule of WDF, WDM, debugging and other seminars visit:
>>> http://www.osr.com/seminars
>>>
>>> To unsubscribe, visit the List Server section of OSR Online at
>>> http://www.osronline.com/page.cfm?name=ListServer
>>>
>> — NTDEV is sponsored by OSR Visit the list at:
>> http://www.osronline.com/showlists.cfm?list=ntdev OSR is HIRING!! See
>> http://www.osr.com/careers For our schedule of WDF, WDM, debugging and
>> other seminars visit: http://www.osr.com/seminars To unsubscribe, visit
>> the List Server section of OSR Online at
>> http://www.osronline.com/page.cfm?name=ListServer
>>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer