Call Win32 / NT-Native API from Windows Subsystem for Linux?

How can I call the Windows API functions from the Linux binary inside the Windows Subsystem for Linux (WSL)? I am sure there is no documented way to do this, but it may still be interesting to try.

I am interested in calling Win32 functions, or if this is not possible, at least for the Windows NT API (Nt *, Zw *). Native APIs should be at least accessible, since the component that runs Linux processes (lxss) depends on these APIs.

You may need to create a custom LoadLibrary function to load Windows DLLs. Another idea would be to search for process memory for known parts of the kernel functions (that is, their user mode entry points).

Has anyone experimented with this and would like to share a solution?

+7
windows-kernel windows-subsystem-for-linux
source share
1 answer

In short, you cannot.

The actual processes in which the Linux processes run are not Win32 processes and cannot load and execute Win32 user mode code, and they cannot call standard Win32 NT kernel entry points.

For more information on the PicoProcess infrastructure used by WSL, read this blog and / or watch the accompanying video .

If you want to "call" Windows code from code running inside WSL, you may need to use some form of socket / messaging / RPC / REST calling technology in which these or both ends of the relationship can listen and respond to messages sent over the network / socket / pipe.

+5
source share

All Articles