Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Detection Matrix
- The general idea is to check the following environment variables:
- PROCESSOR_ARCHITECTURE - reports the native processor architecture EXCEPT for WOW64, where it reports x86.
- PROCESSOR_ARCHITEW6432 - not used EXCEPT for WOW64, where it reports the original native processor architecture.
- Visually, it looks like:
- Environment Variable \ Program Bitness ----- 32bit Native ---- 64bit Native ------ WOW64
- PROCESSOR_ARCHITECTURE --------------------- x86 ------------- AMD64 ------------- x86
- PROCESSOR_ARCHITEW6432 --------------------- undefined ------- undefined --------- AMD64
- WOW64 = 32bit Program on 64bit OS
- Replace AMD64 with IA64 for Itaniums
- Detection Logic
- The logic that I use from a program to detect whether the OS is 32bit or 64bit looks like this:
- IF PROCESSOR_ARCHITECTURE == amd64 OR
- PROCESSOR_ARCHITEW6432 == amd64 THEN
- // OS is 64bit
- ELSE
- // OS is 32bit
- END IF
- Another way to test for the same thing is:
- IF PROCESSOR_ARCHITECTURE == x86 AND
- PROCESSOR_ARCHITEW6432 NOT DEFINED THEN
- // OS is 32bit
- ELSE
- // OS is 64bit
- END IF
- While detection for whether a process is in WOW64 mode is to simply check for the presence of the PROCESSOR_ARCHITEW6432 environment variable.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement