Jump to content

DevHelp PostEventSem

From EDM2
Revision as of 19:44, 27 July 2018 by Martini (talk | contribs) (Created page with "This service posts an event semaphore that was previously reset with ResetEventSem. If the event is already posted, the post count is incremented and the ERROR_ALREADY_POSTED ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This service posts an event semaphore that was previously reset with ResetEventSem. If the event is already posted, the post count is incremented and the ERROR_ALREADY_POSTED return code is returned. Otherwise, the event is posted, the post count is set to one, and all threads that called DosWaitEventSem are scheduled to run.

Syntax

C

USHORT APIENTRY DevHelp_PostEventSem( ULONG hEvent );

Assembler

MOV   EAX,SemaphoreHandle     ; DWORD semaphore handle
MOV   DL,DevHlp_PostEventSem

CALL  [Device_Help]

Parameters

C

hEvent (ULONG)
Semaphore handle


Assembler

MOV   EAX,SemaphoreHandle     ; DWORD semaphore handle

Return Code

C

Success Indicator: Clear if successful.

Possible errors:

              ERROR_ALREADY_POSTED    (299)
              ERROR_INVALID_HANDLE    (6)
              ERROR_TOO_MANY_POSTS    (298)

Assembler

   'C' Clear if successful.

   'C' Set if error.
       EAX = Error code.
            Possible errors:
               ERROR_ALREADY_POSTED    (299)
               ERROR_INVALID_HANDLE    (6)
               ERROR_TOO_MANY_POSTS    (298)

Remarks

This function uses the EAX and Flags registers. PostEventSem 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. There is a limit of 65,534 (64KB-1) posts allowed per event semaphore. If this limit is reached, then the ERROR_TOO_MANY_POSTS return code is returned.

To reverse this operation, call ResetEventSem. This resets the event, so that any threads that subsequently wait on the event semaphore (with DosWaitEventSem) will be blocked.

Example Code

C

#include  "dhcalls.h"

USHORT APIENTRY DevHelp_PostEventSem( ULONG hEvent );

Related Functions