64bit vc++ program seems to run under 32bit mode
Asked Answered
T

2

10

I created a 64bit c++ project in Visual Studio 2010 (under Windows 7 64bit);

I thought I was running a 64bit application, and the following code returned true:

bool is64bit = (sizeof(void*)==8);

but if I called the function IsWow64Process, it returned FALSE...

More weird things:

  • calling LoadLibrary() to load a dll under c:\windows\system32\some.dll works well
  • loading a dll under c:\windows\sysWow64\some.dll will fail (error code 193: some.dll is not a valid win32 application)

All these failures suggest the application is running under 32bit mode, but this is against the truth the pointer type is 8-byte length

I am confused, any help will be appreciated!

Tamikotamil answered 23/10, 2012 at 17:38 Comment(0)
F
10

calling LoadLibrary() to load a dll under c:\windows\system32\some.dll works well; loading a dll under c:\windows\sysWow64\some.dll will fail

Everything you say suggests that you are running 64 bit.

In Windows 64bit, the System32 folder contains the 64 bit versions of the DLLs, and the SysWow64 folder contains the 32 bit versions. When IsWow64Process returns TRUE, it means that you're a 32bit application on a 64bit OS.

This is the opposite of what the names in the folder suggests, which is likely why this seems confusing. Basically, the SysWow64 folder is the 32 bit versions for use under WoW64, which is "Windows 32-bit on Windows 64-bit" - basically, you use the WoW64 DLLs when you run 32bit, and the normal DLLs when you run 64bit.

Fortuna answered 23/10, 2012 at 17:39 Comment(4)
+1 Everything the OP describes is 100% consistent with a 64-bit application on a 64-bit OS.Kuhn
@DavidSchwartz Yeah - people get confused because using WoW64 means you're running 32bit, which is the opposite of what you'd think given the name ;)Fortuna
Nice answer. Realizing the difference between WoW64 and system32 gave me some time ago solid headache.Donetta
I like to think of "Wow64" as meaning "Win32 on Win64". Well, I don't like to think of it that way, but it helps.Trueblood
M
3

Press Ctrl-Shitf-Esc to run Task Manager application. In the "Processes" tab you'll see *32 label by the name of every 32-bit process. It's a one of the simplest ways of checking bitness of a process.

Mistake answered 23/10, 2012 at 17:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.