Was just wondering if the usage of the function 'IsWow64Process' is better than compiling it separately for 64 Bit os. Still need to change offsets of some addresses so the program actually does stay the same.
-
It's unclear what you're trying to achieve here. A 32-bit executable should run on 64-bit Windows without any problems anyway, and a 64-bit one can't *ever* run on 32-bit Windows... – Roddy Oct 07 '13 at 09:04
3 Answers
IsWow64Process()
tells you that you're a 32-bit app running on a 64 bit system. It doesn't make you a 64-bit app.

- 36,172
- 4
- 64
- 79
IsWow64Process()
only makes sense for 32-bit processes because it says whether the said process is being run on a 64-bit system. The process is still completely 32-bit with all the consequences, for example, it can only load 32-bit DLLs and can only use 2 gigabytes of memory.
Note that in many cases making your code 64 bit is not really worth it, especially when you need to ship 32-bit code as well and especially while almost all versions of Windows allow running 32-bit code. See this answer for more details.

- 1
- 1

- 167,383
- 100
- 513
- 979
IsWow64Process
is not platform-independent.
I determine the bit width by looking at the size of std::ptrdiff_t
:
constexpr /*remove if compiler does not support*/ unsigned long GetProcessBits()
{
return sizeof(std::ptrdiff_t) /*size in bytes*/ * 8U;
}
This will return 32 if running in 32 bit mode, and 64 if running in 64 bit mode.

- 231,907
- 34
- 361
- 483
-
THe Question has the "winapi" tag, so I guess the portability is not an issue. – Bojan Hrnkas Oct 07 '13 at 08:56
-
@Bojan Hrnkas; when I sketched the answer out, it only had C++ as the tag. And, besides, it's Windows *for now*. – Bathsheba Oct 07 '13 at 08:57
-
-
@Bathsheba. `sizeof(std::ptrdiff_t)` is unrelated to `IsWow64Process`, which only returns true if you're a 32-bit executable running under 64-bit Windows. So of course it's platform-specific. – Roddy Oct 07 '13 at 09:10
-
@Roddy Indeed; I reinterpreted the OP as his asking whether or not his code is compiled to a 32 or 64 bit target. – Bathsheba Oct 07 '13 at 09:28