Jump to content

DevHelp CloseEventSem: Difference between revisions

From EDM2
Created page with "This service closes an event semaphore that was previously opened with OpenEventSem. If this is the last reference to this event, then the event semaphore is destroyed. ==Sy..."
 
No edit summary
Line 1: Line 1:
{{DISPLAYTITLE:DevHelp_CloseEventSem}}
This service closes an event semaphore that was previously opened with OpenEventSem. If this is the last reference to this event, then the event semaphore is destroyed.  
This service closes an event semaphore that was previously opened with OpenEventSem. If this is the last reference to this event, then the event semaphore is destroyed.  



Revision as of 02:31, 4 May 2025

This service closes an event semaphore that was previously opened with OpenEventSem. If this is the last reference to this event, then the event semaphore is destroyed.

Syntax

C

USHORT APIENTRY DevHelp_CloseEventSem( ULONG hEvent );

Assembler

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

CALL  [Device_Help]

Parameters

C

hEvent (ULONG)
Semaphore handle

Assembler

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

CALL  [Device_Help]

Return Code

C

Success Indicator: Clear if successful.

Possible errors: ERROR_INVALID_HANDLE (6)

Assembler

   'C' Clear if successful.

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

Remarks

This function uses the EAX and Flags registers. CloseEventSem 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.

The system semaphores reside in a memory buffer rather than on a disk file. Therefore, when the last process that has a semaphore open exits or closes that semaphore, the semaphore disappears.

The OPEN/CLOSE operations can be nested. A maximum of 65,534 (64KB-1) opens-per-process is allowed for each semaphore at any one time. If this limit is reached, the very next call to OpenEventSem returns ERROR_TOO_MANY_OPENS. In order for a process to intentionally destroy a semaphore prior to termination, the number of calls to CloseEventSem must equal the number of calls to OpenEventSem.

Example Code

C

#include  "dhcalls.h"

USHORT APIENTRY DevHelp_CloseEventSem( ULONG hEvent );

Related Functions