CreateMutex

From aldeid
Jump to navigation Jump to search

Description

Creates or opens a named or unnamed mutex object.

Parameters

HANDLE WINAPI CreateMutex(
  _In_opt_  LPSECURITY_ATTRIBUTES lpMutexAttributes,
  _In_      BOOL bInitialOwner,
  _In_opt_  LPCTSTR lpName
);

Return value

If the function succeeds, the return value is a handle to the newly created mutex object.

If the function fails, the return value is NULL. To get extended error information, call GetLastError.

If the mutex is a named mutex and the object existed before this function call, the return value is a handle to the existing object, GetLastError returns ERROR_ALREADY_EXISTS, bInitialOwner is ignored, and the calling thread is not granted ownership. However, if the caller has limited access rights, the function will fail with ERROR_ACCESS_DENIED and the caller should use the OpenMutex function.

Example

.text:00401065                 push    offset Name     ; "HGL345"
.text:0040106A                 push    0               ; bInitialOwner
.text:0040106C                 push    0               ; lpMutexAttributes
.text:0040106E                 call    ds:CreateMutexA

Comments