C:\Program Files (x86)

Community Forums/General Help/C:\Program Files (x86)

H&K(Posted 2011) [#1]
When a program installs that used to go into C:\Program Files, how does it know to go to C:\Program Files (x86)?

That is, does windows grab the dir info and change it?
Does the Program ask windows where it should go? If so how?

It there some "protocol" that programs follow? If so how come they ALL do?


Gabriel(Posted 2011) [#2]
Well you can do it by grabbing the environment variables.

"ProgramFiles(x86)"
"ProgramFiles"

The former won't be available on 32 bit installations, but in that instance the latter will still return the (x86) folder.

I don't know if that's what everyone does, but that's what you could do. Bear in mind, however, that there are a limited number of installers, so you only really need those installers to take a standard approach and everyone is doing the same thing.

Last edited 2011


Doggie(Posted 2011) [#3]
Under Windows 7 / Vista 64, 32-bit applications run on top of an emulation of a 32 bit operating system that is called Windows on Windows 64, or WOW64 for short. WOW64 intercepts all operating system calls made by a 32 bit application.

For each operating system call made, WOW64 generates native 64 bit system calls, converting 32 bit data structures into 64 bit aligned structures. The appropriate native 64 bit system call is passed to the operating system kernel, and any output data from the 64 bit system call is converted into a format appropriate for the calling application before being passed back.

Like 32 bit applications, WOW64 runs in user mode so any errors that occur in translating an operating system call will only occur at that level. The 64 bit operating system kernel cannot be affected.

Since WOW64 runs in user mode, all 32 bit application code must also run in user mode. This explains why 32 bit kernel mode device drivers and applications that rely on them, will not work under Windows 7 / Vista 64.

The WOW64 emulator consists of the following DLLs:

Wow64.dll. This provides the core emulation infrastructure and the links to the Ntoskrnl.exe entry-point functions.

Wow64Win.dll provides links to the Win32k.sys entry-point functions.

Along with the 64-bit version of Ntdll.dll, these are the only 64-bit binaries that can be loaded into a 32-bit process.

At startup, Wow64.dll loads the 32 bit version of Ntdll.dll and runs its initialization code, which loads all necessary 32 bit DLLs. Almost all 32 bit DLLs are unmodified copies of the original 32 bit Windows binaries. However, some of these DLLs have been modified to behave differently on WOW64 than they do on 32 bit Windows. This is usually because they share memory with 64 bit system components.

In addition to handling operating system calls, the WOW64 interface needs to ensure that files and registry settings for 32 bit applications are kept apart from those for 64 bit applications. To achieve this two mechanisms are used, File and Registry Redirection.


Yasha(Posted 2011) [#4]
.

(better answers)

Last edited 2011


xlsior(Posted 2011) [#5]
And in the same line:

c:\windows\system32 is for 64-bit programs, while c:\windows\syswow64 is used by 32-bit.

(Seems kind of counter-intuitive, but sticking the 64-bit stuff in c:\windows\system32 is done for backwards compatibility reasons, since in 64 bit mode the locations are not intercepted by the OS)