leecher1337 / ntvdmx64

Run Microsoft Windows NTVDM (DOS) on 64bit Editions
812 stars 81 forks source link

Installing and running breaks MinTTY bash #21

Closed Danfun64 closed 6 years ago

Danfun64 commented 6 years ago

I don't know how do diagnose this issue, but I imagine the installation of this software changes how software is loaded. For whatever reason, installing this software breaks MinTTY's Bash, whether it's run in Cygwin, MSYS2, or Git for Windows. Uninstalling this software doesn't make things normal again, the only way to fix it appears to be reinstalling the OS (refreshing works too)

leecher1337 commented 6 years ago

Hi, I think Cygwin seems to react very sensitive to Hooks like ldntvdm.dll does (by hooking CreateProcess functions in order to propagate between processes): https://cygwin.com/faq/faq.html#faq.using.bloda The problem is that the proper DLL injection via AppInit_DLLs only affects processes loading USER32.DLL and thus, console applications wouldn't get the ldntvdm.dll loader injected, therefore the ugly CreateProcess hook was needed. If someone has a better, less invasive method of injecting the loader into all (new) processes, I'm wiling to change the loader to not hook CreateProcess APIs, if this is the cause for some problems.

Patching the system DLLs directly on the harddisk in order to not need a loader DLL in every process address space doesn't seem a viable solution to me, because these files are unfortunately protected by the nasty PatchGuard and additionally, they tend to change very often on system updates, so a loader that does in-memory-patching like ldntvdm seems a more solid solution to me.

However I don't believe that you have to re-install the OS in order to get rid of ldntvdm.dll (which - as said - only modifies processes in memory, not on disk, so it's not persistant). It could be that the uninstaller is unable to remove the AppInit-Hook for ldntvdm.dll from registry or the file from disk on next reboot, but in this case, just rename ldntvdm.dll in both System32 and SysWOW64 - Directories to a different name and it won't be loaded again on next reboot, because the file cannot be found then.

leecher1337 commented 6 years ago

Hi, I updated the loader so that it hopefully doesn't interfere with CreateProcess() API anymore, please update your loader and try again, I hope that this helps with the problem described.

Danfun64 commented 6 years ago

Confirmed that MSYS2 works now. WSLTTY doesn't work, however, because of #22 and Windows Defender closing WSLTTY due to not liking how ntvdmx64 uses APPINIT. As the original issue is solved, i'll close this for now.