Skip to content

Commit

Permalink
cmd/robloxmutexer: check for mutex exist instead of proc
Browse files Browse the repository at this point in the history
  • Loading branch information
apprehensions committed Feb 13, 2024
1 parent 39e1cad commit 0c5a1e9
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions cmd/robloxmutexer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ package main

import (
"log"
"os"
"time"
"errors"
"unsafe"

"golang.org/x/sys/windows"
Expand All @@ -22,23 +22,16 @@ func main() {
}

func lock() error {
ok, err := running(os.Args[0])
if err != nil {
return err
}

if !ok {
log.Println("another robloxmutexer is already running, exiting...")
return nil
}

name, err := windows.UTF16PtrFromString("ROBLOX_singletonMutex")
if err != nil {
return err
}

mutex, err := windows.CreateMutex(nil, false, name)
if err != nil {
if errors.Is(err, windows.ERROR_ALREADY_EXISTS) {
return errors.New("Roblox's Mutex is already locked!")
}
return err
}
defer windows.CloseHandle(mutex)
Expand Down

0 comments on commit 0c5a1e9

Please sign in to comment.