title: How to completely sandbox registry and file system for Windows app?
body: <p>We have a legacy Windows application which does its job very well. The problem is, it stores and manipulates registry values and files in both AppData and ProgramData Windows folders during runtime, and no source code is available to change it. We need to run multiple copies (they have different settings) of this application simultaneously, which is currently not possible, because they conflict with each other and crash. Creating a separate Windows VM for each copy is not possible (the machines are low-end and simply do not handle it; besides, some users do not have the knowledge for setting up a VM).</p>
  
  <p>How can we completely isolate each copy of the app in its own directory? I thought about intercepting WinAPI calls and replacing calls to the file system and registry with our own database, but I am not sure how to implement this. A brief search gave me <a href="https://github.com/nektra/Deviare-InProc" rel="nofollow noreferrer">Deviare</a> (open-source) and <a href="https://www.microsoft.com/en-us/research/project/detours/" rel="nofollow noreferrer">Detours</a> (proprietary). Are these the right tools for the job? If so, which WinAPI functions should be intercepted?</p>