To repost this again (for those who haven't seen it):
Frequently Asked Questions about CLI2NOP
- Created by "Stiletto" -
Q. What, exactly, is the "CLI2NOP problem" - a.k.a. the VDM interrupt problem?
A. To quote the README file of SoundFX 2000 (It's called README for a reason):
"Under Windows NT the virtual DOS machine (VDM) maintains a virtual interrupt enable state for each DOS box. Execution of a CLI or STI instruction causes a trap to the VDM, which then updates the virtual interrupt state. Many programs save the interrupt state before disabling them by executing a pushf instruction. Unfortunately, due to a limitation in the Intel architecture when running a process in protected mode at a privilege level above zero, the popf instruction that would normally restore the interrupt state does not cause a trap and hence the virtual interrupt state in the VDM gets out of step with what the program expects and further virtual interrupts such as timer, mouse or sound card are not delivered to the program."
Q. What does CLI2NOP do?
A. To paraphrase SoundFX 2000's manual again:
"SoundFX 2000's solution to this problem is to fix the application by patching the application using CLI2NOP. CLI2NOP is a batch file script and utility that searches for and replaces interrupt disable instructions in an executable file image with no-ops. It does this to avoid the freezes that can occur with some applications as a result of the VDM interrupt problem. This program attempts to work around this problem for several common games."
In summary - it "no-op's" the CLI commands present in the binary code of the executable. This works around the sticking points but changes the code, usually leaving the application with a tendency to freeze, and freeze frequently. So the question is, will you trade freezing at one point with freezing at another?
Q. When do I need to run CLI2NOP?
A. When most compatibility lists of software, such as at [url]http://www.ntcompatible.com,[/url] suggest that you do so. Generally speaking, it is a problem that largely affects BUILD engine based games (Duke Nukem 3D, Blood 3D) and other popular games which use the same engine as DOOM, like DOOM, DOOM2, Hexen, and other games. That is, any game which is a protected-mode application and requires DPMI emulation to be enabled when you attempt to run the game, say, enabled with a utility such as VDMSound Launchpad. So the two factors to pay attention to are: 1.) if it requires DPMI and 2.) it freezes / locks up sometimes at "start-up." ALSO NOTE: the CLI2NOP application is only required under Windows NT 4.0 and Windows 2000. Windows XP includes a "feature" similar to CLI2NOP that is built in to their "virtual DOS machine" (VDM) emulation, which is called on the fly, rather than to be executed preemptively like CLI2NOP. VDMSound now includes the ability to call this feature of Windows XP from within VDMSound. Make sure you get the latest update. If you do not have Windows XP, you must (for now) use CLI2NOP.
Q. Where can I get the program CLI2NOP?
A. By using a search engine such as Google (http://www.google.com), you can find locations on the Internet that carry CLI2NOP in and of itself. This, however, is strictly not permitted under copyright law without the full (trial or otherwise) SoundFX package. Software Systems has a - understandably - dim view of spreading CLI2NOP without the full package. Thus, the only place I can suggest is at the creator's, Software Systems, website: http://www.softsystem.co.uk
SoundFX 2000, itself, is not strictly required in order for CLI2NOP to work. But you must download it in order to use CLI2NOP. That said, VDMSound can be used in place of SoundFX 2000 in order to provide the sound card emulation necessary to run the program that you are trying to run. You can find VDMSound at its website: http://ntvdm.cjb.net
Q. How do I install CLI2NOP?
A. CLI2NOP is not normally installed by the SoundFX 2000 setup program so you should use your favorite Zip file decompression utility (such as WinZip) to extract CLI2NOP.BAT and PATCH.EXE from the "Patch" folder of the SoundFX 2000 distribution archive. You can create a folder that includes PATCH.EXE and CLI2NOP.BAT and list this folder in your path settings. Alternately, you can put CLI2NOP.BAT and PATCH.EXE in the folder that includes the executable for the application that you want to patch. Both files should be placed in the same directory.
Q. How do I use CLI2NOP?
A. CLI2NOP should be run from a Command Prompt window in the directory of the file that is to be patched. At the command prompt enter:
cli2nop [options] file-to-patch [patched file]
The only option is "-2" which enables additional processing using a more aggressive search/replace. (In particular, it replaces "pushfd, cli" combinations with "pushfd, nop", instead of replacing "pushfd, pop eax, cli" combinations with "pushfd, pop eax, nop".) For example, SoundFX 2000 suggests that this setting be used with DOOM and DOOM2, but suggests that it not be used with Duke Nukem 3D.
If no output file is specified then the input file will be modified.
An example of this would be using "cli2nop -2 doom.exe doomnt.exe" for DOOM.
Once you have VDMSound installed, right click on your new executable and choose "Run With VDMS". The game will start, loading VDMS to emulate the sound.
You can also of course use SoundFX 2000 to emulate the sound, since at this time you have it as well on your computer - consult their instructions to install SoundFX 2000.
If you need help setting up the game with its setup program, you're on your own!
Q. Are there any problems in using CLI2NOP to work around the VDM interrupt problem?
A. To quote the SoundFX 2000 manual again: "Removing the interrupt disable sequences can render the application liable to race conditions and contentions that the original programmer had designed to avoid. Consequently the application may be unstable and hence crash more after being patched. Further the patch algorithm is very simple and can possibly replace instructions or data that are essential to normal operation."
When creating PIF settings for applications patched with CLI2NOP you should usually enable the "Compatible timer hardware operation" option after patching. This reduces the frequency of crashes caused by timer interrupt race conditions. It does tend to slow the app slightly so experimentation is worthwhile. A final reminder: if no output file is specified when using CLI2NOP, then the input file (the original game executable) will be modified. You have been warned.
Q. Are there any advanced features you can tell me about?
A. No. Seriously, the definitions of the switches used in executing PATCH.EXE are available by typing "patch.exe -h" while at the Command Prompt, should you wish to use PATCH.EXE for your own purposes.
Software Systems, creators of SoundFX 2000 (http://www.softsystem.co.uk) - your README file, Help file, and CLI2NOP batch file were invaluable in the creation of this FAQ. Thanks also to Lawrence Rust of Software Systems for his quick feedback on the initial version of this FAQ.
Vlad Romascanu, creator of VDMSound (http://ntvdm.cjb.net)
If you must, contact Vlad or I through the VDMSound User's Forum on Bravenet or the messageboards on SourceForge, linked to from the VDMSound website, if you have any further questions regarding CLI2NOP. You can also contact Software Systems at their contact email address: firstname.lastname@example.org. However, this should answer all your questions.
Stiletto - 04/26/02