13

Suppose some author has enforced his Windows application to be single instance. Is there any way to make multiple instance of this application (aside from running inside a virtual machine or requesting the author to rewrite the app)?

If there is a readymade tool, I would like to know it. (I have tried sandboxie and Altiris SVS without luck).

If there is nothing out there, I want to program a tool/hack that will let me do this. I am looking for pointers where to start - what will be involved, what skills would be needed. I have moderate programming skills in C and Java.

If this cannot be done, please explain why.

EDIT: I know its a bad idea but I still need to do it (for various reasons). I want a generic way that works for any application and does not introduce errors.

Jus12
  • 919

7 Answers7

4

There is no generic way because different applications use different methods. Many of the methods involve trying to get some machine-wide (or, at least, user-wide) resource (e.g., a named synchronization object, a file with a well-known name and location, or a registry value). If the app succeeds, then it holds that resource as long as it runs. If it fails because another instance already holds the resource, then it might try to signal the original instance so that it can respond.

In 16-bit Windows, when a program started, the OS passed it a unique handle called an HINSTANCE. It would also be passed the HINSTANCE of a currently running process using the same executable (if any). In those days, that was probably the most common way for the program to know if a copy was already running. In 32-bit Windows, with protected memory, process-specific address spaces, and the end of cooperative multitasking, the HINSTANCEs no longer carried the same meaning.

A small number of apps do this simply for "usability", but for many others, there may be a good reason to enforce singletons. Bypassing that could lead to data corruption or simply failing to run.

3

Many applications check the global list of processes (with EnumProcesses, OpenProcess, GetModuleBaseName, and similar functions) or list of windows (with EnumWindows, EnumChildWindows).

You may try to set hook (see samples SetWindowsHookEx, CallNextHookEx, etc) to hook those specific API function calls from that application and replace requested data in response with yours to fool the application.

3

You can run application on different users accounts and instance checking will not work anymore.

Tomas
  • 141
3

It is possible!

Here is an image of me running half-life 1 4x in 4 windows all connected to the same LAN server, the only problem is the controllers not being independently linked to each window.

https://web.archive.org/web/20150315150158if_/http://img29.imageshack.us/img29/5642/yc0y.jpg

To do this, you need 'Process Explorer' - a program that allows you to do what is known as 'Close Handle' on the '\BaseNamedObjects\ValveHalfLifeLauncherMutex' sub-process or something. its not that hard. go here for detailed instructions - http://am.half-lifecreations.com/forums/index.php?topic=479.0

But yeah that's for half-life but get Process Explorer and im sure you'll be able to find which handle/process you need to close in order to get the programs u want running multi times.

I dont see why windows doesn't implement running games multi times in splits/snaps as a feature anyway! its clearly because people wouldn't buy as many PC's... also check out SoftXSpand really awesome, allows u to run multiple instances of windows as independent users

Tonton
  • 31
2

In Windows 8 and newer, you hold the Shift key and click the programs' icon/button on taskbar. This will launch the executable again. If the app does not self check for clones, you will have a new window.

This will ofcourse potentially create conflicts with the app internal files if it opens for example an internal sqlite file, so you must really know what you are doing or don't care if something breaks.

2

Windows 10 provides sandbox feature to run a program in isolation. Sandbox Docs.

You can also use Sandboxie, now free!

GTodorov
  • 133
  • 1
  • 8
2

Lock files, named pipes and synchronisation events are some of the common ways applications use to check they're the only running instance. To work around lock files you'd either have to virtualise the file system, hook into it or do a carefully timed delete (and that may not work if it locks the file open too). Named pipes and synchronisation events will be much more difficult because you don't have the same control from outside the application that you do with files.