source: trunk/src/win32k/lib/libInit.c

Last change on this file was 6560, checked in by bird, 24 years ago

Added OPEN_FLAGS_NOINHERIT to prevent children inheriting the win32k handle.

File size: 2.8 KB
Line 
1/* $Id: libInit.c,v 1.5 2001-08-19 01:21:13 bird Exp $
2 *
3 * Inits the Win32k library functions.
4 *
5 * Copyright (c) 2000-2001 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
6 *
7 * Project Odin Software License can be found in LICENSE.TXT
8 *
9 */
10
11
12/*******************************************************************************
13* Header Files *
14*******************************************************************************/
15#define INCL_DOSERRORS
16#define INCL_DOSFILEMGR
17#define INCL_DOSDEVICES
18
19
20/*******************************************************************************
21* Internal Functions *
22*******************************************************************************/
23#include <os2.h>
24
25#include "win32k.h"
26#include "libPrivate.h"
27
28/*******************************************************************************
29* Global Variables *
30*******************************************************************************/
31BOOL fInited = FALSE;
32HFILE hWin32k = NULLHANDLE;
33
34
35/**
36 * Initiates the library.
37 * @returns OS/2 return code.
38 * @status
39 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
40 * @remark
41 */
42APIRET APIENTRY libWin32kInit(void)
43{
44 APIRET rc;
45
46 if (!fInited)
47 {
48 ULONG ulAction = 0UL;
49
50 rc = DosOpen("\\dev\\win32k$",
51 &hWin32k,
52 &ulAction,
53 0UL,
54 FILE_NORMAL,
55 OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
56 OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY | OPEN_FLAGS_NOINHERIT,
57 NULL);
58
59 fInited = rc == NO_ERROR;
60
61 /*
62 * Get the callgate selector.
63 */
64 if (fInited)
65 {
66 K32QUERYCALLGATE Param;
67 ULONG cbParam = sizeof(Param);
68 ULONG cbData = 0UL;
69
70 Param.hdr.cb = sizeof(Param);
71 Param.hdr.rc = ERROR_NOT_SUPPORTED;
72 Param.pusCGSelector = &usCGSelector;
73
74 rc = DosDevIOCtl(hWin32k,
75 IOCTL_W32K_K32,
76 K32_QUERYCALLGATE,
77 &Param, sizeof(Param), &cbParam,
78 "", 1, &cbData);
79 if (rc != NO_ERROR || Param.hdr.rc != NO_ERROR)
80 {
81 usCGSelector = 0; /* Just to be 100% it isn't set on a failure */
82 /* since we checks if it's 0 to see if it's usable */
83 rc = NO_ERROR; /* This isn't a fatal error, we may still use the IOCtls. */
84 }
85 }
86 }
87 else
88 rc = NO_ERROR;
89
90 return rc;
91}
92
Note: See TracBrowser for help on using the repository browser.