views:

1422

answers:

8

While it's my understanding that there's no fundamental reason a program written for 32-bit hardware / OSs not to run on 64-bit hardware / OSs, in practice, I've found many programs intended for 32-bit versions of Windows that will not work on 64-bit versions of Windows. Examples include a number of popular security utilities (most products from Norton and Check Point's Zone Alarm) and several games (I've been trying to get Grand Theft Auto 4 to run for a few weeks now, but to no avail - of course, that might be related to any number of other problems related to GTA4, but that's neither here nor there).

I've heard that a program's incompatibility might result from something as simple as not wanting to run from the "Program Files (x86)" folder, but what are some of the other reasons? Why would a virus scanner or firewall written for a 32-bit system not run on a 64-bit system? Why would a game not run when everything is theoretically backwards-compatible?

A: 

If you are using the file system or the registry, make sure that you access the right folders. As a x86 program you will probably want to access "Program Files (x86)", "System32", "WOW6232Node" and such folders instead of the x64 ones.

Products with x86 applications like Norton and Check Point's Zone Alarm fail to run their x86 driver, as the driver needs to x64 to be able to ran by the operating system.

TomWij
Don't try to access those folders directly. Windows already redirects requests involving normal directories to their appropriate 32-bit counterparts.
R. Bemrose
+3  A: 

Drivers are a different story that programs: http://support.microsoft.com/kb/896456

Zone Alarm uses a special 32-bit driver created by Check Point to do the monitoring. This is probably what's creating the issue with that application. As for Grand Theft Auto 4? I have no idea.

Robert Venables
GTA4: For most games anti copy protection measures install drivers and even root kits to ensure your game is 'legit'.
Remus Rusanu
+4  A: 

The best explanation I've found is offered here which basically says 32-bit programs are run on an layer of emulation which doesn't allow the system access you'd get from native programs run in a 64-bit environment:

http://blogs.msdn.com/oldnewthing/archive/2008/12/22/9244582.aspx

I would assume this means that problems with programs like GTA4 come from the layer of emulation not producing the expected results found on a 32-bit native system. This is why you keep seeing Microsoft release compatibility updates all the time.

Here's what the MSDN has to say about the matter:

http://msdn.microsoft.com/en-us/library/bb427430(VS.85).aspx

Joseph
NO! 32-bit Windows programs DO NOT run in an emulator on 64-bit Windows! There is a Wow64 layer which re-interprets system calls, handles the transitions between 32-bit mode and 64-bit mode, redirects some file accesses, but there is no emulator. The problems come when the app installs a driver.
Die in Sente
I've adjusted my answer a tiny bit, but in the MSDN it says "WOW64 is the x86 emulator that allows 32-bit Windows-based applications to run seamlessly on 64-bit Windows." I can see what you are saying though. Simulation would probably fit better but the way emulation is used these days fits too.
Joseph
@Die in Sente WoW does do emulation on IA-64 processors. Just not on x64. So this answer is technically correct, but on x64 machines WoW is more of a redirection layer than an emulation layer.
Eric Haskins
+2  A: 

There can be any number of reasons.

Any application which is programmed ad a low level might be expecting 32 bit register. The Zone Alarm driver posted by novatrust is a good example. GTA4 might be using assembly to improve performance at several points which might result on anything or even simply assuming 32 bits on C++. For example take the following code:

struct GPoint
{
  int x;
  int y;
}

// Array of twenty GPoints
GPoint[] myArr = malloc(20 * sizeof(GPoint);

GPoint* myPointer = myArr;
int index = GetIndexAffectedPoint();

// Invert X and Y for the point
myPointer += 8*index;
swap(myPointer);

I know the example is pretty naive but anyway, in that code you are assuming you're struct is 8 bytes long (4 bytes of the x integer and 4 bytes for the y integer) but in a 64 bit system is actually twice that long so you'll end up swapping the wrong point... things like that happen a lot on low level languages, specially when trying to improve performance...

Jorge Córdoba
This type of thing is a problem when you take 32-bit code and recompile it as 64-bit without fixing these assumptions. However, the question was 32-bit apps running on the 64-bit OS. In that case, the legacy code in your example will work just fine.
Die in Sente
+4  A: 

There is a lot of misinformation on this thread.

When a 32-bit application is run on 64-bit windows:

  • Most of the compatibility problems come when the application tries to install a kernel-mode driver. A 32-bit driver can't be installed on the 64-bit OS. This is amost certainly the problem with a firewall. It's trying to hook into the TCP/IP driver stack.
  • THERE IS NO EMULATOR! The 32-bit object code is executed by the cpu completely natively at full speed.
  • There is no support for old 16-bit code. This broke a lot of installers.
  • Accessing the right folders is generally not a problem. When a 32-bit program opens a file in, say %windir%\system32\, the OS automagically redirects it to %windir%\syswow64. The same for certain parts of the registry. There are a few potential gotchas here, but they're generally along the lines of assuming that various WINAPI Get...Directory() functions return the same strings that they did in Windows 95.
  • Whether it was compiled 10 years ago or just yesterday, then C/C++ pointers are still 32-bits (4 bytes) and all of the code that just assumed that -- including SendMessage()! -- still works. The 8-byte pointer issue doesn't come into the picture until you start converting to 64-bit compilers.
Die in Sente
If there's no emulator, what is Windows On Windows?
biozinc
MSDN says: On the x64 processor, instructions are executed natively by the micro-architecture. Therefore, execution speed under WOW64 on x64 is similar to its speed under 32-bit Windows. On the Intel Itanium processor, more software is involved in the emulation, and performance suffers as a result.
Joseph
@biozinc on x64 processors WoW does NO emulation. x64 processors are capable of running x86 and x64 code simultaneously. It provides 32 to 64 bit windows API call translation, and manages when the processor is in 32 or 64 bit mode. The Wiki article has sources: http://en.wikipedia.org/wiki/WOW64
Eric Haskins
@Joseph beat me to it...
Eric Haskins
I'm starting to think virtualization is a better term to describe how WOW64 works on an x64 processor. The idea seems very similar to how Virtuozzo works.
Joseph
@biozinc. I really don't know what you'd call it, but an "emulator" would imply that the .exe files' code bytes were being interpreted on another architecture or just-in-time translated like Mac on Intel does with PowerPC programs. At least that's the way most people I know think of "emulator".
Die in Sente
+1  A: 

32-bit to 64-bit Migration Considerations

EDIT: Alternative link

Lawand
broken link ?
Ruben Bartelink
+1  A: 

Security applications are a bad example. They all perform unsupported things against undocumented things. Changes between one 32-bit version of Windows to the next are enough to break them, nevermind moving to 64-bit.

That said, there are some compatibility shims that fixup your code on 32-bit that won't when the app is 64-bit. This is because Microsoft assumes you've tested it on 64-bit.

One resulting gotcha is with .NET applications. When running on a 32-bit system, the exe is jitted to 32-bits - where there are compatibility shims to fix your bugs. If your customer happens to be running on a 64-bit system, the executable will be jitted to 64-bits, where those compatibility shims that were protected you from yourself are no longer present.

Chris Jackson had a nice blog entry about this: Shimming Applications on Windows Vista 64-Bit

Ian Boyd
+1  A: 

The problem is probably drivers. With games, it's probably some kind of slimy DRM scheme. Try getting the no-CD crack for the game so you can run it without DRM.

Zan Lynx