0

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.

Jonathan Potter
  • 36,172
  • 4
  • 64
  • 79
  • 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 Answers3

1

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.

Jonathan Potter
  • 36,172
  • 4
  • 64
  • 79
1

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.

Community
  • 1
  • 1
sharptooth
  • 167,383
  • 100
  • 513
  • 979
0

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.

Bathsheba
  • 231,907
  • 34
  • 361
  • 483