CreateWaitableTimer

From aldeid
Jump to navigation Jump to search

Description

Creates or opens a waitable timer object.

To specify an access mask for the object, use the CreateWaitableTimerEx function.

Syntax

HANDLE WINAPI CreateWaitableTimer(
  _In_opt_  LPSECURITY_ATTRIBUTES lpTimerAttributes,
  _In_      BOOL bManualReset,
  _In_opt_  LPCTSTR lpTimerName
);

Parameters

lpTimerAttributes [in, optional]
A pointer to a SECURITY_ATTRIBUTES structure that specifies a security descriptor for the new timer object and determines whether child processes can inherit the returned handle.
If lpTimerAttributes is NULL, the timer object gets a default security descriptor and the handle cannot be inherited. The ACLs in the default security descriptor for a timer come from the primary or impersonation token of the creator.
bManualReset [in]
If this parameter is TRUE, the timer is a manual-reset notification timer. Otherwise, the timer is a synchronization timer.
lpTimerName [in, optional]
The name of the timer object. The name is limited to MAX_PATH characters. Name comparison is case sensitive.
If lpTimerName is NULL, the timer object is created without a name.
If lpTimerName matches the name of an existing event, semaphore, mutex, job, or file-mapping object, the function fails and GetLastError returns ERROR_INVALID_HANDLE. This occurs because these objects share the same namespace.

Return value

If the function succeeds, the return value is a handle to the timer object. If the named timer object exists before the function call, the function returns a handle to the existing object and GetLastError returns ERROR_ALREADY_EXISTS.

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

Example

.text:004010C2                 xor     edx, edx
.text:004010C4                 lea     eax, [esp+404h+FileTime]
.text:004010C8                 mov     dword ptr [esp+404h+SystemTime.wYear], edx
.text:004010CC                 lea     ecx, [esp+404h+SystemTime]
.text:004010D0                 mov     dword ptr [esp+404h+SystemTime.wDayOfWeek], edx
.text:004010D4                 push    eax             ; lpFileTime
.text:004010D5                 mov     dword ptr [esp+408h+SystemTime.wHour], edx
.text:004010D9                 push    ecx             ; lpSystemTime
.text:004010DA                 mov     dword ptr [esp+40Ch+SystemTime.wSecond], edx
.text:004010DE                 mov     [esp+40Ch+SystemTime.wYear], 834h
.text:004010E5                 call    ds:SystemTimeToFileTime
.text:004010EB                 push    0               ; lpTimerName
.text:004010ED                 push    0               ; bManualReset
.text:004010EF                 push    0               ; lpTimerAttributes
.text:004010F1                 call    ds:CreateWaitableTimerA
.text:004010F7                 push    0               ; fResume
.text:004010F9                 push    0               ; lpArgToCompletionRoutine
.text:004010FB                 push    0               ; pfnCompletionRoutine