Why is SysWOW64 reported as System32?
Asked Answered
C

1

0

I am testing a Windows service. The service code fails when it tries to delete a read only file I created in %windir%\SysWOW64, but the exception that is logged is:

Access to the path 'C:\Windows\system32\CanvasImages\62230.jpg' is denied.

I know 64 bit Windows has a whole lot of tricks up its sleeve concerning these two folders, and understand a little of it, but some accurate exception info would be nice.

Cabbageworm answered 9/3, 2015 at 13:15 Comment(5)
"a file I created in %windir%\SysWOW64" - why? Why are you writing in %windir%? Why are you writing in SysWOW64? What code exactly throws that exception? What other exception would you like to see? See MSDN: File System Redirector for more info on what is happening.Bremer
It is because the emulator that supports running 32-bit code on a 64-bit operating system is rather good at emulating a 32-bit operating system. Down to the names of directories. Both the names of c:\windows\syswow64 and c:\program files (x86) are mapped by the file system redirector. If you want to see "syswow64" in that message then you'll have to remove the jitter forcing in the project's Properties + Build tab.Astylar
@Bremer Thanks for the link. My service writes and reads files from its current directory. In order to test exception handling, I create a read only file in that directory in order to force an exception. The exception I would rather have seen is: Access to the path 'C:\Windows\SysWOW64\CanvasImages\62230.jpg' is denied. I have since added code to set the service's current directory to its codebase directory, i.e. where the service exe that I compile resides.Cabbageworm
@Cabbageworm - you should not be installing your service to SysWOW64. You should be installing it to Program Files or Program Files (x86). In fact, almost nothing should ever go in any System folder anymore.Hypoderma
@ErikFunkenbusch The service isn't installed to SysWOW64, but by default it has its current directory set to that folder. The service executable is sitting right where I want it now, in the project's output folder, i.e. bin\Debug.Cabbageworm
H
3

It's a bit confusing, but SysWOW64 is actually the 32 bit emulator for 64 bit systems.

WOW stands for "Windows on Windows", and the original SysWOW was the 16 bit emulator for 32 Bit Windows (and should have been called SysWOW32). So SysWOW64 is the 32 bit emulator for 64 bit Windows.

So, when you run 32 bit applications, it uses SysWOW64 to emulate the 32 bit registry, and 32 bit redirection (to Program Files (x86) for instance).

Hypoderma answered 9/3, 2015 at 15:51 Comment(1)
And the redirection 'back' to 32 bit results in the folder name in the exception message, I assume?Cabbageworm

© 2022 - 2024 — McMap. All rights reserved.