File System Redirector
The %windir%\System32 directory is reserved for 64-bit applications on 64-bit Windows. Most DLL file names were not changed when 64-bit versions of the DLLs were created, so 32-bit versions of the DLLs are stored in a different directory. WOW64 hides this difference by using a file system redirector.
In most cases, whenever a 32-bit application attempts to access %windir%\System32, %windir%\lastgood\system32, or %windir%\regedit.exe, the access is redirected to an architecture-specific path.
These paths are provided for reference only. For compatibility, applications should not use these paths directly. Instead, they should call the APIs described below.
Original Path | Redirected Path for 32-bit x86 Processes | Redirected Path for 32-bit ARM Processes |
%windir%\System32 | %windir%\SysWOW64 | %windir%\SysArm32 |
%windir%\lastgood\system32 | %windir%\lastgood\SysWOW64 | %windir%\lastgood\SysArm32 |
%windir%\regedit.exe | %windir%\SysWOW64\regedit.exe | %windir%\ SysArm32\regedit.exe |
If the access causes the system to display the UAC prompt, redirection does not occur. Instead, the 64-bit version of the requested file is launched. To prevent this problem, either specify the SysWOW64 directory to avoid redirection and ensure access to the 32-bit version of the file, or run the 32-bit application with administrator privileges so the UAC prompt is not displayed.
**Windows ServerВ 2003 and WindowsВ XP:В В ** UAC is not supported.
Certain subdirectories are exempt from redirection. Access to these subdirectories is not redirected to %windir%\SysWOW64: %windir%\system32\catroot
%windir%\system32\catroot2
%windir%\system32\driverstore
%windir%\system32\drivers\etc
%windir%\system32\logfiles
%windir%\system32\spool
**Windows ServerВ 2008, WindowsВ Vista, Windows ServerВ 2003 and WindowsВ XP:В В **%windir%\system32\driverstore is redirected.
To retrieve the name of the 32-bit system directory, 64-bit applications should use the GetSystemWow64Directory2 function (WindowsВ 10, version 1511) or the GetSystemWow64Directory function.
Applications should use the SHGetKnownFolderPath function to determine the %ProgramFiles% directory name.
Windows ServerВ 2003 and WindowsВ XP: Applications should use the SHGetSpecialFolderPath function to determine the %ProgramFiles% directory name.
Applications can control the WOW64 file system redirector using the Wow64DisableWow64FsRedirection, Wow64EnableWow64FsRedirection, and Wow64RevertWow64FsRedirection functions. Disabling file system redirection affects all file operations performed by the calling thread, so it should be disabled only when necessary for a single CreateFile call and re-enabled again immediately after the function returns. Disabling file system redirection for longer periods can prevent 32-bit applications from loading system DLLs, causing the applications to fail.
32-bit applications can access the native system directory by substituting %windir%\Sysnative for %windir%\System32. WOW64 recognizes Sysnative as a special alias used to indicate that the file system should not redirect the access. This mechanism is flexible and easy to use, therefore, it is the recommended mechanism to bypass file system redirection. Note that 64-bit applications cannot use the Sysnative alias as it is a virtual directory not a real one.
Windows ServerВ 2003 and WindowsВ XP: The Sysnative alias was added starting with WindowsВ Vista.
Process Interoperability
You can run Win32-based applications on 64-bit Windows using an emulation layer. WindowsВ 10 on ARM includes an x86-on-ARM64 emulation layer. For more information, see Running 32-bit Applications.
On 64-bit Windows, a 64-bit process cannot load a 32-bit dynamic-link library (DLL). Additionally, a 32-bit process cannot load a 64-bit DLL. However, 64-bit Windows supports remote procedure calls (RPC) between 64-bit and 32-bit processes (both on the same computer and across computers). On 64-bit Windows, an out-of-process 32-bit COM server can communicate with a 64-bit client, and an out-of-process 64-bit COM server can communicate with a 32-bit client. Therefore, if you have a 32-bit DLL that is not COM-aware, you can wrap it in an out-of-process COM server and use COM to marshal calls to and from a 64-bit process.
In-process servers are currently registered using the InprocServer registry entry. On 64-bit Windows, 64- and 32-bit in-process servers should use the InprocServer32 entry.
To port handles, which by their nature are local to the computer and would never be used across the 32-bit to 64-bit boundary, use the HANDLE_PTR type instead of the INT_PTR or DWORD_PTR type. This includes porting RPC interfaces passing such handles as DWORD values. The 64-bit HANDLE_PTR is 64 bits on the wire (not truncated) and thus does not need mapping. (The 32-bit HANDLE_PTR is 32 bits on the wire.)
Windows 7 64 bit «Windows is loading files» reboot loop. This is not a question, but a tutorial of sorts.
I purchased an Asus G73JH laptop at Best Buy two days ago. Let me stress that I was and still am happy with this computer.
- Windows 7 Home 64 bit
- Intel Core i7
- ATI Mobility Radeon 5870 GPU
After uninstalling bloatware, installing Avast 5.0 free edition and updating the virus definitions, I updated my stock device drivers from the Asus site (there are some compatibility issues when updating from the respective hardware provider’s sites) and rebooted. After the reboot I configured Windows to my taste and rebooted to ensure that the settings were saved if the computer should happen to freeze. When Windows started again, I used Windows Update while I began the process of transferring my files from my external hard drive. These files are all clean, and pass deep scans with all search options enabled in Avast 5.0 free and Malwarebytes 1.46 paid version. When the transfer was complete, there were 26 updates waiting to be installed and I chose the option to install before shutting down. When the installation was completed the computer shut down and I hit the power button to turn it back on. I saw a black screen and a status bar that said «windows is loading files» before the standard Windows 7 start screen loaded. After that screen, a very generic background appeared with the busy icon quickly replacing the cursor. It idled for about 10 seconds and rebooted. The loop was infinite. Please note that I did not create backup discs after I got my system where I wanted it. I intended to do so after the updates so that the backup would be complete.
Here is what I found while trying to fix this, in no particular order:
- None of the options given after pressing F8 allowed windows to boot. Safe mode loaded to the safe mode screen in Windows without hanging up on any files and rebooted after idling for a seconds. Disabling the automatic restart after failure only brought the Blue Screen Of Death, notifying me of a memory dump.
- The system repair disc that I made on a different computer after this happened loaded fine, but there were absolutely no errors shown in any of the tests it performed.
- System restore does not fix the problem.
- A Windows XP home with SP3 installation disc will ask to format the partition. This was unacceptable because I needed the data I had moved from my external drive.
- I tried Linux Zorin, Pardus, Ubuntu, and Xubuntu but none of them would allow me to access the Windows file structure. These all loaded off of their respective discs, so I knew it was not a hardware failure or malfunction.
- My recovery partition loaded properly, but again, this was not an option. I just needed to see if it was intact.
- I was able to choose the load drivers option and from there I could access my file structure. I was also able to copy folders to my external hard drive after plugging it in. Note that when doing this it does not give confirmation of the copy and paste. Be patient. Also, it only copies folders and all of their contents. Nothing in the folders will show up using this method and you will not be able to choose specific files.
- Since Windows did not fully load, I was unable to use services.msc.
- Using the repair disc to load a command shell worked, but I was unable to launch the control panel to manually uninstall the updates so I do not know if it would have made a difference. If anyone has a command-line entry within the command shell (not in the RUN command within Windows) that will open Control Panel, please post it here.
- I was able to access the registry through the shell, but I do not know the appropriate values to change so I did not alter it. I’m only saying this in case someone that is familiar with editing the registry has this problem. They might be able to find a fix.
- There are absolutely no forums that have a universal fix to this error.
- I did not think of trying to open Windows Explorer from command until now. Doing this may have allowed my to move files or uninstall. I do not know.
- Microsoft cannot fix this error.
- By using the recovery partition after I dumped my data, I found that it will give the option to make a new partition on the same drive. I did not choose this option because I had what I needed, I did not want a dual installation of windows, and I did not know if the file structure on the first OS would remain intact. I did a full reset and am typing this on the laptop in question. Again, there are no hardware issues. I have updated everything and backed it up, but I am keeping automatic updates off. If you do this, you will want to go to your taskbar and open the Action Center (not the automatic updates window). There is an option to no longer receive notifications about that error. I enabled it.
I finally called Microsoft Technical Support at 800-642-7638 (800-MICROSOFT) to get help. If this happens to you, save yourself some time by asking to be transferred to a Windows 7 specialist. Despite answering the automated system’s questions, I did not get through to the right division when it first rang through. I had to explain the problem twice. When the tech picks up and goes through the formalities, explain the problem. After they confirm what your support question is regarding, tell them what you have tried to fix the issue at hand because it will help speed the process. The tech that I spoke to researched it for a few minutes and his response was that I had already tried everything. My remaining option was to back my files up. If this is happening to you, you might need to cut your losses and reformat or do a full system recovery. The tech taught me how to transfer specific files using the notepad. I will include the entire process for those that are not familiar with it.
- Boot from a Windows 7 repair disc. If you are not given the option to boot from CD or DVD after inserting the repair disc, restart your computer and press F2 when the first screen comes up. This should take you to your BIOS, but the specific key may be different on your unit. If F2 does not work, refer to your computer handbook or user guide. In the BIOS, locate the portion that allows you to change device boot order. When you find it, move your DVD drive to the top of the list. This is usually done by pressing + or minus, but may be F5 and F6 depending on your BIOS. There should be instructions on the screen. After you have done this, choose to save your configuration and exit. When the computer reboots, you should see a message that tells you to press any key to boot from CD or DVD. Do this.
- Inside the repair disc there is an option to load a command prompt. Click this.
- Connect the removable drive you wish to transfer files to.
- Inside the shell, type the word «notepad» without the quotation marks and press Enter. It should load notepad, but if it does not you can try typing: «C:« and pressing Enter. Again, and in any future examples, do not type the quotes. When the directory changes, type «notepad» and press Enter. If notepad does not load, I don’t know what to offer. If it does, go to the File menu, and click Open. When the box pops up, there will be a drop-down menu that has by Text Files» selected by default. Change this to «All Files» and browse to the folder you need to access. If it is in «My Documents», you will find it by going to C:, then going to Users, then choosing whatever folder has your name or profile under it. It will probably not be the Administrator folder. You should now be able to select the files and folders you want to copy.
- Go back to the shell without closing the open window and type «notepad» again, hitting Enter afterward. If you are unable to see the command shell, close the «Open» window, move the notepad to the side, and move the shell to a corner of your screen. Then browse back to the folders you need. Once the second Notepad opens, go to Files > Open again, but this time go to the removable drive and open it. You will want to move and re-size the windows until you are able to able to see both sets of your files at once.
- Left-click the folder you wish to copy over, and drag it to the open window for your removable drive. You will not see confirmation that anything is happening, but you should move your cursor to the folders you are moving files from. It will change to a cursor with a square and a plus-sign (+) below and to the right of the cursor itself. When the cursor changes back to normal, the transfer is done. If you are moving small files, it may be quick enough that you will not get a change in the cursor. If it is normal when hovering over the first window, it is done. Also, you will not be able to switch windows or browse while the transfer is happening. When you are able to affect the windows or folders, your transfer had completed. Once you have transferred a folder or file, right-click on the file/folder and select «Properties». Note the size of the directory or file on the disk. Then do the same in your removable drive to confirm that all of the data has transferred without errors. If the sizes do not match, repeat the process until they done.
I hope this helps. I will be posting it in many forums.
How to load a 32bit DLL in a 64bit windows
I installed Mozilla FireFox x64 in a 64bit windows, now I want to LoadLibrary(mozglue.dll) but I receive error number 193
LoadLibrary(mozglue.dll) works good in a 32bit windows with Mozilla FireFox 86
I use this code:
What is the problem with this code?
Edit:
LoadLibraryExW(L»C:\\Program Files\\Mozilla Firefox\\mozglue.dll», NULL, LOAD_LIBRARY_AS_DATAFILE);
LoadLibraryW(L»C:\\Program Files\\Mozilla Firefox\\mozglue.dll»);
Now GetLastError returns 0 but GetProcAddress fails.
2 Answers 2
You are either trying to load a 32-bit DLL into a 64-bit process, or a 64-bit DLL into a 32-bit process. It can’t be done.
I imagine that if you have ‘Mozilla FireFox x64’ that mozglue.dll is 64-bit — so you need to compile and link your test program as 64-bit.
Your first issue is that 64-bit programs can’t load 32-bit DLLs and 32-bit programs can’t load 64-bit DLLs for the purposes of executing code. This is described in MSDN’s Process Interopability information:
You can run Win32-based applications on 64-bit Windows using an emulation layer. For more information, see Running 32-bit Applications.
On 64-bit Windows, a 64-bit process cannot load a 32-bit dynamic-link library (DLL). Additionally, a 32-bit process cannot load a 64-bit DLL.
If you need to support both 32-bit programs and 64-bit the easiest way is to install the 32-bit version of the Mozilla DLLs (via a 32-bit Mozilla install) and you do the same for 64-bit Mozilla. By default 64-bit Mozilla should be placed in C:\Program Files\Mozilla Firefox\ and 32-bit Mozilla in C:\Program Files (x86)\Mozilla Firefox\ . You’ll need to account for the different directories when building a 64-bit application vs a 32-bit application when loading DLLs like mozglue.dll
You don’t check to see if hndl is NULL or not. You should only have to check GetLastError if the returned handle was NULL, not when it isn’t NULL. Secondly calling LoadLibraryExW with LOAD_LIBRARY_AS_DATAFILE allows you to load DLL resources, but doesn’t allow you to retrieve the function addresses with GetProcAddress . This is documented in the MSDN Documentation for LoadLibraryEx:
If this value is used, the system maps the file into the calling process’s virtual address space as if it were a data file. Nothing is done to execute or prepare to execute the mapped file. Therefore, you cannot call functions like GetModuleFileName, GetModuleHandle or GetProcAddress with this DLL. Using this value causes writes to read-only memory to raise an access violation. Use this flag when you want to load a DLL only to extract messages or resources from it.
Keeping the ideas above in mind I compiled your code with a revised loadfunc and built it as a 64-bit application. When finished your program prints OK in a MessageBox:
For a 32-bit program you’d need to change the path in the code above to the 32-bit Mozilla directory as mentioned earlier and compile as an x86 32-bit application. The default path for the 32-bit code mentioned earlier would be C:\Program Files (x86)\Mozilla Firefox\
I downloaded the 64-bit version of Mozilla from this download link and the 32-bit Mozilla installation from this link.