source: trunk/src/win32k/k32/k32HandleSystemEvent.cpp@ 10367

Last change on this file since 10367 was 5169, checked in by bird, 25 years ago

Initial coding - not completed.

File size: 5.3 KB
Line 
1/* $Id: k32HandleSystemEvent.cpp,v 1.1 2001-02-18 15:26:38 bird Exp $
2 *
3 * k32HandleSystemEvent - Override system events like Ctrl-Alt-Delete
4 * and Ctrl-Alt-2xNumLock.
5 *
6 * Copyright (c) 2000-2001 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
7 *
8 * Project Odin Software License can be found in LICENSE.TXT
9 *
10 */
11
12
13/*******************************************************************************
14* Defined Constants And Macros *
15*******************************************************************************/
16#define INCL_DOSMEMMGR
17#define INCL_DOSERRORS
18
19#define INCL_OS2KRNL_TK
20#define INCL_OS2KRNL_SEM
21
22#define NO_WIN32K_LIB_FUNCTIONS
23
24/*******************************************************************************
25* Header Files *
26*******************************************************************************/
27#include <os2.h>
28#include "devSegDf.h" /* Win32k segment definitions. */
29#include "OS2Krnl.h"
30#include "win32k.h"
31#include "k32.h"
32#include "options.h"
33#include "dev32.h"
34#include "log.h"
35
36
37/*******************************************************************************
38* Global Variables *
39*******************************************************************************/
40/**
41 * This global array will have an entry for each event. If the entry is
42 * different from NULLHANDLE we should post the the semaphore and not
43 * let the OS handle the event.
44 */
45struct
46{
47 HEV hev; /* NULLHANDLE if the event isn't overridden. */
48 /* Handle to post if overridden. */
49 BOOL fBad; /* Flag which is set if a posting of the hev */
50 /* returned and error code. */
51} aSysEventsOverrides[] =
52{
53 {NULLHANDLE, FALSE}, /* dh SendEvent - Session Manager (mouse - both buttons) */
54 {NULLHANDLE, FALSE}, /* dh SendEvent - Ctrl-Break */
55 {NULLHANDLE, FALSE}, /* dh SendEvent - Ctrl-C */
56 {NULLHANDLE, FALSE}, /* dh SendEvent - Ctrl-ScrollLock */
57 {NULLHANDLE, FALSE}, /* dh SendEvent - Ctrl-PrtSc */
58 {NULLHANDLE, FALSE}, /* dh SendEvent - Shift-PrtSc */
59 {NULLHANDLE, FALSE}, /* dh SendEvent - Session Manager (keyboard - Ctrl-Esc) */
60 {NULLHANDLE, FALSE}, /* dh SendEvent - Ctrl-Alt-Del */
61 {NULLHANDLE, FALSE}, /* dh SendEvent - Keyboard Hot Plug/Reset */
62 {NULLHANDLE, FALSE}, /* dh SendEvent - Power suspend event */
63 {NULLHANDLE, FALSE}, /* dh SendEvent - Power off event */
64 {NULLHANDLE, FALSE} /* VectorSDF - System Dump */
65};
66
67
68/**
69 * Override a system event.
70 * @returns NO_ERROR on success.
71 * ERROR_INVALID_PARAMETER If incorrect parameter specified.
72 * ERROR_ACCESS_DENIED If you tried to unset (fHandle=FALSE) an event specifying the wrong
73 * hev. Or you tried to handle (fHandle=TRUE) and event which is allready
74 * handled by someone else (which is alive and kicking - ie. !fBad).
75 * @param ulEvent Event to override.
76 * In win32k.h the valid events are defined.
77 * @param hev Handle of shared event semaphore which is posted when
78 * the specified system event occures.
79 * If the value 0xFFFFFFFF is specified the system will handle the event.
80 * @param fHandle Action flag. <br>
81 * TRUE: Take control of the event.<br>
82 * FALSE: Give control back to the OS of this event. (hev must match the current handle!)
83 * @status partially implemented.
84 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
85 * @remark Not all events are implemented yet.
86 */
87APIRET k32HandleSystemEvent(ULONG ulEvent, HEV hev, BOOL fHandle)
88{
89 /*
90 * Validate parameters.
91 * Event identifier range.
92 * The event semaphore handle seems ok.
93 */
94 if ( ulEvent > K32_SYSEVENT_LAST
95 || ((ULONG)hev & 0xFFFF0000UL) != 0x80010000UL /* 0x80010000 seems to be the shared event semaphore handle bits. */
96 )
97 return ERROR_INVALID_PARAMETER;
98
99
100 /*
101 * Check if we're trying to override an allready taken event.
102 */
103 if ( (fHandle && aSysEventsOverrides[ulEvent].hev && !aSysEventsOverrides[ulEvent].fBad)
104 || (!fHandle && aSysEventsOverrides[ulEvent].hev != hev && !aSysEventsOverrides[ulEvent].fBad)
105 )
106 return ERROR_ACCESS_DENIED;
107
108
109 /*
110 * Handle action.
111 */
112 if (fHandle)
113 { /* Take controll of an event. */
114 aSysEventsOverrides[ulEvent].fBad = FALSE;
115 aSysEventsOverrides[ulEvent].hev = hev;
116 }
117 else
118 { /* Giveback control. */
119 aSysEventsOverrides[ulEvent].hev = NULLHANDLE;
120 }
121
122 return NO_ERROR;
123}
124
Note: See TracBrowser for help on using the repository browser.