-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update TPMouse.au3 * Create singleton.au3 * Update TPMouse.au3 * Update keybinds.au3 * Update TPMouse.au3 * Delete keybinds.au3 * Update TPMouse.au3
- Loading branch information
user726687
authored
Jul 25, 2023
1 parent
27ec4f6
commit 3d4c99b
Showing
3 changed files
with
175 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include-once | ||
|
||
; #FUNCTION# ==================================================================================================================== | ||
; Author ........: Valik | ||
; Modified.......: | ||
; =============================================================================================================================== | ||
Func _Singleton($sOccurrenceName, $iFlag = 0) | ||
Local Const $ERROR_ALREADY_EXISTS = 183 | ||
Local Const $SECURITY_DESCRIPTOR_REVISION = 1 | ||
Local $tSecurityAttributes = 0 | ||
|
||
If BitAND($iFlag, 2) Then | ||
; The size of SECURITY_DESCRIPTOR is 20 bytes. We just | ||
; need a block of memory the right size, we aren't going to | ||
; access any members directly so it's not important what | ||
; the members are, just that the total size is correct. | ||
Local $tSecurityDescriptor = DllStructCreate("byte;byte;word;ptr[4]") | ||
; Initialize the security descriptor. | ||
Local $aCall = DllCall("advapi32.dll", "bool", "InitializeSecurityDescriptor", _ | ||
"struct*", $tSecurityDescriptor, "dword", $SECURITY_DESCRIPTOR_REVISION) | ||
If @error Then Return SetError(@error, @extended, 0) | ||
If $aCall[0] Then | ||
; Add the NULL DACL specifying access to everybody. | ||
$aCall = DllCall("advapi32.dll", "bool", "SetSecurityDescriptorDacl", _ | ||
"struct*", $tSecurityDescriptor, "bool", 1, "ptr", 0, "bool", 0) | ||
If @error Then Return SetError(@error, @extended, 0) | ||
If $aCall[0] Then | ||
; Create a SECURITY_ATTRIBUTES structure. | ||
$tSecurityAttributes = DllStructCreate($tagSECURITY_ATTRIBUTES) | ||
; Assign the members. | ||
DllStructSetData($tSecurityAttributes, 1, DllStructGetSize($tSecurityAttributes)) | ||
DllStructSetData($tSecurityAttributes, 2, DllStructGetPtr($tSecurityDescriptor)) | ||
DllStructSetData($tSecurityAttributes, 3, 0) | ||
EndIf | ||
EndIf | ||
EndIf | ||
|
||
Local $aHandle = DllCall("kernel32.dll", "handle", "CreateMutexW", "struct*", $tSecurityAttributes, "bool", 1, "wstr", $sOccurrenceName) | ||
If @error Then Return SetError(@error, @extended, 0) | ||
Local $aLastError = DllCall("kernel32.dll", "dword", "GetLastError") | ||
If @error Then Return SetError(@error, @extended, 0) | ||
If $aLastError[0] = $ERROR_ALREADY_EXISTS Then | ||
If BitAND($iFlag, 1) Then | ||
DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $aHandle[0]) | ||
If @error Then Return SetError(@error, @extended, 0) | ||
Return SetError($aLastError[0], $aLastError[0], 0) | ||
Else | ||
Exit -1 | ||
EndIf | ||
EndIf | ||
Return $aHandle[0] | ||
EndFunc ;==>_Singleton |