Categories:

Getting Processor architecture in x86 and x64 bit platform.

GetSystemInfo provides the basic system information and processor architecture of the underlying platform. This API can be used successfully in both x64 and x86 platform. But, under 64-bit WIndows, we can run 32 bit Applications( WOW64). If a WOW64 process call GetSystemInfo API, it will return the

GetSystemInfo provides the basic system information and processor architecture of the underlying platform. This API can be used successfully in both x64 and x86 platform. But, under 64-bit WIndows, we can run 32 bit Applications( WOW64). If a WOW64 process call GetSystemInfo API, it will return the processor architecture as x86. Of course it should be the way, this API act otherwise there could compatibility problems may arise and application could act weird and show undefined behavior.

If the WOW64 process want to know the original platform it’s running, it must call

GetNativeSystemInfo. When we’ve to use this? I’ve a realworld example. When we spawn process explorer (procexp.exe, it realize the underlying platform and create another exe procexp64.exe (64bit version) to iterate all process information in the system. Note that the GetNativeSystemInfo need to be called only if you 32bit application wants to run under 64 bit platform and need to care about the true underlying platform. In all other cases, call GetSystemInfo, which works across platforms uniquely. See the snippet below

Alternatively, you can check the size of a pointer to determine whether you're running in 64-bit or 32-bit platform. But this method works similar to GetSystemInfo. If the process WOW64 process (32 bit on 64 bit OS, it will return the pointer size 4). It's not possible to detect the underlying platform using this method. For that we must call GetNativeSystemInfo API

Source: www.codeproject.com
Category: Architecture

Similar articles: