Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

64bit vc++ program seems to run under 32bit mode

Tags:

c++

win64

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!

like image 992
A.Y.N. Avatar asked Oct 23 '12 17:10

A.Y.N.


People also ask

Why are all my programs in 32-bit?

This is perfectly normal and nothing has changed. Many programs are designed to be 32-bit because 64-bit simply isn't necessary and it allows for greater compatibility for anyone that may still need it.

Is my Visual Studio 64-bit or 32-bit?

Visual Studio remains a 32 bit application, though certain components (e.g., diagnostics/debuggers, MSBuild, compilers, designers) will take advantage of 64-bit processors if available. We've updated our download pages to clarify this.

Can a 64-bit computer run 32-bit programs?

Can I run 32-bit programs on a 64-bit computer? Most programs made for the 32-bit version of Windows will work on the 64-bit version of Windows except for most Antivirus programs. Device drivers that are made for the 32-bit version of Windows will not work correctly on a computer running a 64-bit version of Windows.

Will Windows 10 64-bit run 32-bit programs?

In general, yes, you can . the fact that they are 32-bit is irrelevant. Both 64-bit Windows 10 and 32-bit Windows 10 can run 32-bit programs.


2 Answers

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.

like image 163
Reed Copsey Avatar answered Sep 22 '22 15:09

Reed Copsey


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.

like image 42
qehgt Avatar answered Sep 23 '22 15:09

qehgt