Jump to content

DevHelp_ResetEventSem

From EDM2

This service resets an event semaphore that has been previously opened with OpenEventSem. The number of posts performed on the event before it was reset is returned to the caller in the pulPostCt parameter. If the event was already reset, the ERROR_ALREADY_RESET return code is returned, and zero is returned in the pulPostCt parameter. It is not reset a second time.

Syntax

C

USHORT APIENTRY DevHlp_ResetEventSem( ULONG  hEvent, PULONG pNumPosts );

Assembler

MOV   EAX,SemaphoreHandle        ; DWORD semaphore handle
MOV   EDI,pNumPosts              ; Pointer to variable to receive the number of
                                 ; posts performed on the event before the reset.
MOV   DL,DevHlp_ResetEventSem

CALL  [Device_Help]

Parameters

C

hEvent (ULONG)
Semaphore handle
pNumPosts (PULONG)
Pointer to a variable to receive the number of posts performed on the event before the reset.

Assembler

MOV   EAX,SemaphoreHandle        ; DWORD semaphore handle
MOV   EDI,pNumPosts              ; Pointer to variable to receive the number of
                                 ; posts performed on the event before the reset.

Return Code

C

Success Indicator: 0

Possible errors:

ERROR_INVALID_HANDLE (6)
ERROR_ALREADY_RESET  (300)

Assembler

   'C:' Clear if successful.

   'C' Set if error.
       EAX = Error code.
            Possible errors:
               ERROR_INVALID_HANDLE (6)
               ERROR_ALREADY_RESET  (300)

Remarks

This function uses the EAX, EDI, and Flags registers. ResetEventSem can be called only from a Ring 0 device driver or file system driver. The handle passed in must be a handle to a shared event semaphore. If the handle does not exist or is not a shared event semaphore, or if the semaphore was not previously opened with OpenEventSem, then ERROR_INVALID_HANDLE is returned.

To reverse this operation, call PostEventSem. This posts the event, so that any threads that were waiting for the event semaphore to be posted (with DosWaitEventSem) are allowed to run.

Example Code

C

#include  "dhcalls.h"

USHORT APIENTRY DevHlp_ResetEventSem( ULONG  hEvent,
                                      PULONG pNumPosts );