Jump to content

DevHelp PostEventSem: Difference between revisions

From EDM2
No edit summary
 
Line 15: Line 15:
==Parameters==
==Parameters==
===C===
===C===
; hEvent (ULONG) : Semaphore handle
; ''hEvent'' ([[ULONG]]) - input : Semaphore handle





Latest revision as of 18:42, 23 May 2025

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) - input
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