Changeset 1305


Ignore:
Timestamp:
11/13/09 09:34:10 (5 years ago)
Author:
lowjoel
Message:

Make the Eraser DLL create a global mutex so that when the installer is executed and if Eraser is running the user will be asked to quit. This isn't foolproof -- but helps prevent improper upgrades.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser5/EraserDll/Common.h

    r1110 r1305  
    5858GLOBALVAR E_UINT16 uReferenceCount GLOBALINIT1(0); 
    5959GLOBALVAR CEvent evLibraryInitialized GLOBALINIT2(FALSE, TRUE); 
     60const LPTSTR strEraserMutex = _T("Eraser-D309F296-B70C-473d-B2DE-2A1F9C7C9FB1"); 
    6061 
    6162// helpers 
     
    6768    csReferenceCount.Lock(); \ 
    6869    uReferenceCount++; \ 
     70    if (uReferenceCount == 1) \ 
     71    { \ 
     72        SECURITY_DESCRIPTOR sc; \ 
     73        InitializeSecurityDescriptor(&sc, SECURITY_DESCRIPTOR_REVISION); \ 
     74        SetSecurityDescriptorDacl(&sc, TRUE, NULL, FALSE); \ 
     75        \ 
     76        SECURITY_ATTRIBUTES attr; \ 
     77        attr.nLength = sizeof(attr); \ 
     78        attr.lpSecurityDescriptor = ≻ \ 
     79        attr.bInheritHandle = FALSE; \ 
     80        \ 
     81        CreateMutex(&attr, TRUE, strEraserMutex); \ 
     82        CreateMutex(&attr, TRUE, CString(_T("Global\\")) + strEraserMutex); \ 
     83    } \ 
    6984    csReferenceCount.Unlock() 
    7085 
     
    7590    } \ 
    7691    if (uReferenceCount == 0) { \ 
     92        CMutex localMutex(FALSE, _T("Eraser-D309F296-B70C-473d-B2DE-2A1F9C7C9FB1")); \ 
     93        CMutex globalMutex(FALSE, _T("Global\\Eraser-D309F296-B70C-473d-B2DE-2A1F9C7C9FB1")); \ 
     94        localMutex.Unlock(); \ 
     95        globalMutex.Unlock(); \ 
    7796        evLibraryInitialized.ResetEvent(); \ 
    7897    } \ 
Note: See TracChangeset for help on using the changeset viewer.