Run 64bit program from 32bit shell

1

I switched from Cygwin to WSL recently and have a problem with Sourcetree and commithooks.

Sourcetree uses it's own version of Cygwin (32 bit) to run git. My development environment runs on WSL (which is 64 bit only).

So what I want to do is call WSL bash from Sourcetrees Cygwin Bash and execute the commithook checks. But this does not work, since Cygwin Bash is a 32bit program and thus cannot execute WSL bash, which is 64bit only. So Cygwin Bash sees the WSL bash as a non-executable file.

Is there a way to break out of the 32bit sandbox on Windows 10 to call a 64bit program?

Dakkaron

Posted 2017-06-14T09:43:19.757

Reputation: 139

1since Cygwin Bash is a 32bit program and thus cannot execute WSL bash, which is 64bit only -- huh? to the best of my knowledge, there's nothing stopping you form making that call either way, apart from maybe not being able to find the 64-bit executable (cause of WoW filesystem redirection, which only applies to Program Files and System32). If that's your issue, there's ways around it: https://stackoverflow.com/questions/39812882/python-subprocess-call-cannot-find-windows-bash-exe – Bob – 2017-06-14T09:46:07.630

1@Bob a 32-bit Win32 program can run a 64-bit Windows app without problem. However WSL only supports 64-bit ELF executables and you can't run 32-bit Linux apps – phuclv – 2017-06-14T09:49:57.540

Your W10 is 32 or 64-bit ? – Overmind – 2017-06-14T09:52:15.360

@LưuVĩnhPhúc I took this question as 32-bit Windows PE program calling a 64-bit Windows PE program (bash.exe, as the invoker for WSL). At no point is a 32-bit ELF involved. – Bob – 2017-06-14T10:00:16.683

@Overmind WSL is 64-bit only – phuclv – 2017-06-14T16:55:49.863

Answers

1

What you've encountered here is WOW64 filesystem redirection. Because bash.exe lives in the 64-bit System32 directory, but 32-bit programs see the 32-bit SysWOW64 when they ask for System32. It's not a matter of being unable to run 64-bit from 32-bit, but rather not being able to find the executable you're trying to run in the first place.

You do have a way around it. Quoting from that link:

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.

So simply call the explicit path via sysnative: %windir%\Sysnative\bash.exe (or $WINDIR/Sysnative/bash.exe within cygwin).

Bob

Posted 2017-06-14T09:43:19.757

Reputation: 51 526

Thanks, I got confused with SysWOW64 not containing 64-bit executables, but the 32-bit executables. – Dakkaron – 2017-06-14T14:06:08.460

0

No, not directly if your OS is 32-bit, but for that you can make a 64-bit VM session if you have a 64-bit processor but have installed a 32-bit host OS.

Overmind

Posted 2017-06-14T09:43:19.757

Reputation: 8 562

Read the question again. OP doesn't have a 32 bit OS. – DavidPostill – 2017-06-14T12:17:40.790

It was not specified for the OS. – Overmind – 2017-06-15T07:17:53.693

"My development environment runs on WSL (which is 64 bit only)." – DavidPostill – 2017-06-15T08:06:05.713