Name: MutexDLL (DLL name is ToonInstanceMutex.DLL)
Description: This DLL makes only one instance of a program. So you can only run one and when you try to run another, it is closed already (although the piece of code is still executed before close).
Download Link: http://host-a.net/to...er/MutexDLL.zip
Size: 5kb around (not being precise, just says it when looking at the icon)
DLL made using programming language? ASM (High level syntax form)
Assembled using: MASM32 see DLL resource section (Source Code included in download).
Credit Required? Nope, don't need it.
Hello all, the first paragraph is my little story ignore it if you want;
This is my first ASM DLL for Game Maker (I don't count an example as first that is in my signature). I wanted to try making a ASM DLL for Game Maker and manage to get the basis on making DLLs with it. During the learning, I had no idea how to pass a double type value into the DLL. I tried the tutorial from VitalDragon but he only showed how to load it to the FPU stack. Of course I was stupid to realize you can pop values out of the stack to a variable of some sort to able to pass the right data type through. Even though I got it working, I used high level syntax of ASM like if statements or something easier to call functions.
This DLL will make a Game Run on one instance only. Meaning if you try to open another one of the programs that uses my DLL will be closed automatically. It uses game_end to end the game, so even if I call that the Piece of Code is still run unless I use exit;
It makes the program "One Instance" only by the use of Mutex. I seen this example program that does this so I might make use of it for use. The DLL only has two functions:
- ToonMutexStart(name,[dllpath]); This creates the mutex and sees if the mutex already exists or was already created. We do this by giving it a name (see example). Returns 1 for success (handle is stored in the DLL), -2 for already called it, -1 for already used in another instance.
- ToonMutexEnd(); This frees the DLL and the mutex using the reason parameter in the DLL to see if it has being freed from the process.
As mentioned an example and scripts are there for demonstration. This can be useful if you wanted only one instance of that programmed to be runned.
If you know better then me at this, maybe you can help me with some useful tips. I'll appreciate anything useful. Or maybe bugs?
NOTE: I saw the DLL OneInstance by Roach. It's not meant for competing, it's for a ASM example for people to learn if they wanted too.
The source is included for learning uses. Feel free to use it for your own DLL without my credit. The source is commented at my best. Please read, Readme.txt included in the package for a bit of info on the source. There is also another example in my sig which does add, return a string and MessageBox wrapper of, MessageBoxA function.
DWORD data type is considered a string and REAL8 is the double.
I hope there was some use or interest for learning.
EDIT: Idea from here, http://vcfaq.mvps.org/mfc/2.htm
EDIT2: If you can't get the DLL to work (I know this is a known issue by now), use http://www.toonidyzo...loads/mutex.zip This one is made in C++ and it is also open source. Thanks and sorry about this unexpected failure D:
Here is the new ASM DLL, I fixed the error. I passed the wrong stuff in CreateMutex on the ASM one so sometimes it's bound to be different.
C++ Version: http://www.toonidyzo...loads/mutex.zip
MASM Version: http://host-a.net/to...tance_Mutex.zip
Source code is easier to read too haha. I also avoided some high level syntax ASM :/
See scripts for the new function names, I got rid of "Toon". Again no credit is required.
Idea on Mutex One Instance here: http://vcfaq.mvps.org/mfc/2.htm
I don't know if this DLL will not error like the one on Roach's (apparently).
Edited by Toon-Master, 24 May 2008 - 05:51 AM.