leecher1337 / ntvdmx64

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

LDNTVDM Performance/Speed #196

Closed matead92 closed 2 years ago

matead92 commented 2 years ago

Hi. Why is it when I use LDNTVDM the processing speed is considerably slow? Is there a way to make it faster??

For example, at the moment I run a batch file as administrator and rename 'ldntvdm.dll' in order to get my speed back for GCC compiling. If I have 'ldntvdm.dll' enabled, GCC compiles code very slow.

LDNTVDM.BAT

@ECHO OFF
CLS
ECHO.
ECHO Microsoft Windows 'LDNTVDM' Enabler
ECHO Be sure to 'Run as Administrator'
ECHO.

:start
ECHO ----------------------------------------
ECHO  [1] ENABLE
ECHO  [2] DISABLE
ECHO ----------------------------------------
ECHO.
Choice /C 12 /M "Enable ldntvdm? "
if errorlevel 2 goto disable
if errorlevel 1 goto enable
GOTO end

:disable
ECHO.
ECHO LDNTVDM DISABLED
CD C:\Windows\System32\
RENAME ldntvdm.dll _ldntvdm.dll
ECHO.
GOTO end

:enable
ECHO.
ECHO LDNTVDM ENABLED
CD C:\Windows\System32\
RENAME _ldntvdm.dll ldntvdm.dll
ECHO.
GOTO end

:end
PAUSE

Thanks.

leecher1337 commented 2 years ago

The only reason I could think if would be if gcc spawns lots of processes where loader needs to get injected (i.e. when compiling hundreds of files, hundreds of gcc instances need to get launched sequentially). Maybe the loader was unable to store the Symbol files and has to redownload them on every injection leading to startup delays. Just guessing, I never heard of such issues, use DebugView to check loader output to see if there is something that maybe slows down loader startup.

peter8777555 commented 2 years ago

My PC for 13 years,

Open NEW cmd.exe I know the FIRST run any programs will be delay 2-3 seconds, Ex: winver,mspaint,calc, ..... Second run any programs the processing speed is back.

Open NEW cmd.exe again, I know the FIRST run any programs will be delay 2-3 seconds, Ex: winver,mspaint,calc, ..... Second run any programs the processing speed is back.

Open NEW cmd.exe again again, I know the FIRST run any programs will be delay 2-3 seconds, Ex: winver,mspaint,calc, ..... Second run any programs the processing speed is back.

Why ?

peter8777555 commented 2 years ago

To: matead92

I have the same question and make a batch file to Enable/Disable ldntvdm.dll

matead92 commented 2 years ago

To: matead92

I have the same question and make a batch file to Enable/Disable ldntvdm.dll

I originally made it because if I played Fortnite, the anti-cheat would complain about ldntvdm.dll. Renaming it to something else (in this case, _ldntvdm.dll solved that for me).

It doesn't explain why some 32-bit or 64-bit programs run slow however.

leecher1337 commented 2 years ago

As long as you don't check the DebugView logs, we will never know...

peter8777555 commented 2 years ago

As long as you don't check the DebugView logs, we will never know...

To leecher1337:

My PC for 13 years,

Open NEW cmd.exe I know the FIRST run any programs will be delay 2-3 seconds, Ex: winver,mspaint,calc, ..... Second run any programs the processing speed is back.

Open NEW cmd.exe again, I know the FIRST run any programs will be delay 2-3 seconds, Ex: winver,mspaint,calc, ..... Second run any programs the processing speed is back.

Open NEW cmd.exe again again, I know the FIRST run any programs will be delay 2-3 seconds, Ex: winver,mspaint,calc, ..... Second run any programs the processing speed is back.


OS : Windows 7 X64.

FIRST run ANY programs will be delay 2-3 seconds ?

Open NEW cmd.exe Run "PC Tools R4.30" 3 times.

Run_PC.exe_1st.log --> Delay 3 seconds. Run_PC.exe_2nd.log --> No any Delay. Run_PC.exe_3rd.log --> No any Delay.

Open NEW cmd.exe Run "WinVer" 3 times.

Run_WinVer.exe_1st.log --> Delay 3 seconds. Run_WinVer.exe_2nd.log --> No any Delay. Run_WinVer.exe_3rd.log --> No any Delay.

DebugView_Logs.zip

leecher1337 commented 2 years ago

Thanks for the logs. It seems that Microsoft doesn't provide debug symbols for the verison of C:\Windows\system32\appinfo.dll used on your machine. Thus, ldntvdm loader tries to redownload it everytime and fails (404), thus causing the delay. Seems that they forgot providing debug symbols for your version, what a shame!

The consequence of this is, that "Run as..." with 16bit applications won't work on your system. It's not a real tragedy, if you do not absolutely require it, but of course, it will cause you a delay. Not much I can do about it, if there are no symbols available, there are none. The only thing that I could do is checking for your specific appinfo.dll version and add it to a list of "known" DLLs in the loader and hardcode the offsets to circumvent the problem. If I should try this, you would need to attach your appinfo.dll, so that I can analyze it to find the correct offsets.

matead92 commented 2 years ago

Here is the log when I run make.exe and compile some C code which is very slow (unless I rename ldntvdm.dll to _ldntvdm.dll as explained in my first post).

https://pastebin.com/FTFhmuvD

peter8777555 commented 2 years ago

Thanks for the logs. It seems that Microsoft doesn't provide debug symbols for the verison of C:\Windows\system32\appinfo.dll used on your machine. Thus, ldntvdm loader tries to redownload it everytime and fails (404), thus causing the delay. Seems that they forgot providing debug symbols for your version, what a shame!

The consequence of this is, that "Run as..." with 16bit applications won't work on your system. It's not a real tragedy, if you do not absolutely require it, but of course, it will cause you a delay. Not much I can do about it, if there are no symbols available, there are none. The only thing that I could do is checking for your specific appinfo.dll version and add it to a list of "known" DLLs in the loader and hardcode the offsets to circumvent the problem. If I should try this, you would need to attach your appinfo.dll, so that I can analyze it to find the correct offsets.

1. Debug symbols for the verison of C:\Windows\system32\appinfo.dll is important ? NTVDMX64 can set a registry or environment var to Enable/Disable download the debug symbols ? I test DOS programs WORK,just delay 3 seconds for 1st running.

2. I have a OLD debug symbols backup for appinfo.dll, I copy to C:\Temp\SymbolCache\appinfo.pdb but delay 3 seconds for 1st running AGAIN. (PS: I have updated Windows 7 X64 on 11/04/2022.)

I attach files to you.

appinfo.dll

appinfo.pdb\9DAB25FEC28B4C5DBB47D89984B443092\appinfo.pdb appinfo.pdb\956EB2DE808A4996AC49F41C295F5E162\appinfo.pdb

appinfo.zip

peter8777555 commented 2 years ago

leecher1337>appinfo.dll Symbols are often missing on Microsoft Symbol Server whic

I have build the NEW version and no more delay 3 seconds. All DOS programs work well and very fast running.

Thank you leecher1337.

matead92 commented 2 years ago

How about my issue? I attached the logs before.

leecher1337 commented 2 years ago

@matead92 Your log looks OK to me. So maybe it's just the short delay that the loader causes upon start (110ms according to the log?) that slows the process down a bit. Theoretically, I could add a blacklist function in registry where you can put the name of the .exe where the loader should not inject into (and therefore also not into its child processes, so i.e. to blacklist make.exe). The loader startup process - according to the log - just takes a few milliseconds per process, so I'm not really sure if the shortcut of blacklisting executables really gives a lot of advantage, but that's the only reason that comes to my mind when seeing the logs. Do you think a blacklist function for processes is benificial?

matead92 commented 2 years ago

@matead92 Your log looks OK to me. So maybe it's just the short delay that the loader causes upon start (110ms according to the log?) that slows the process down a bit. Theoretically, I could add a blacklist function in registry where you can put the name of the .exe where the loader should not inject into (and therefore also not into its child processes, so i.e. to blacklist make.exe). The loader startup process - according to the log - just takes a few milliseconds per process, so I'm not really sure if the shortcut of blacklisting executables really gives a lot of advantage, but that's the only reason that comes to my mind when seeing the logs. Do you think a blacklist function for processes is benificial?

A blacklist function would be amazing! That way I can disable it from running certain programs under 16-bit mode. What a clever idea @leecher1337.

Perhaps instead of a registry entry though, a text file in C:\Windows\System32 called ldntvdm.txt will be better because it'll be easier to edit.

If you prefer to use the registry though, that's fine. I can make a C# program which users can install and run which will help edit the file disallow list by a nice GUI because no body would want to keep navigating to the registry location and manually edit DWORD and STRING values.

Please get started on this straight away if you can. I'm looking forward to it because it'll assist with a huge increase in speed during compilation of my code but also I've noticed some programs have issues with ldntvdm. For example, Visual Studio Code will not close and update if ldntvdm is enabled. The game Fortnite will see ldntvdm.dll as a hacking tool and the anti-mod code triggers which results in the game not booting. So adding all these as well to the block/disallow list will be very nice.

leecher1337 commented 2 years ago

Not sure if the feature will help against anti-mod code detection, as the moduel still gets loiaded into the target process and checks if it should install its hook there, but possibly it works when checking code only monitors for API hooking. To create a whiltelist, create a file c:\windows\ldntvdm.ini with the following contents:

[blacklist]
make.exe

This may prevent injection into make.exe and all its descendant child processes, possibly speeding up your compilation process. Results can be checked with DebugView

matead92 commented 2 years ago

Rebuilt the project and tried it now. I got this error. Any ideas?

Screenshot 2022-07-03 215107

leecher1337 commented 2 years ago

https://github.com/leecher1337/ntvdmx64/issues/197#issuecomment-1173070350

matead92 commented 2 years ago

Thanks, that fixed it and the ldntvdm.ini file is working great. I now have my speed back in my programs.

theliz12x commented 9 months ago

@leecher1337 i've a speed performance issue with an old turbopascal compiler, it takes around 13 seconds on a "new" I7 7th serie machine with win10 and also win7 (i've tested both) compiling 1milions lines of code that requires atleast 1 second on an old I7 2nd series i were tring to install the HAXM version thinking that i could improve the situation but i was not able to install it

leecher1337 commented 9 months ago

Please check if recent rollback to old HAXM driver (requiring test signed mode) helps you to install HAXM build.