[6560] | 1 | /* $Id: libInit.c,v 1.5 2001-08-19 01:21:13 bird Exp $
|
---|
[2823] | 2 | *
|
---|
| 3 | * Inits the Win32k library functions.
|
---|
| 4 | *
|
---|
[5224] | 5 | * Copyright (c) 2000-2001 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
---|
[2823] | 6 | *
|
---|
| 7 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
| 8 | *
|
---|
| 9 | */
|
---|
| 10 |
|
---|
| 11 |
|
---|
| 12 | /*******************************************************************************
|
---|
| 13 | * Header Files *
|
---|
| 14 | *******************************************************************************/
|
---|
[2904] | 15 | #define INCL_DOSERRORS
|
---|
[2823] | 16 | #define INCL_DOSFILEMGR
|
---|
| 17 | #define INCL_DOSDEVICES
|
---|
| 18 |
|
---|
| 19 |
|
---|
| 20 | /*******************************************************************************
|
---|
| 21 | * Internal Functions *
|
---|
| 22 | *******************************************************************************/
|
---|
| 23 | #include <os2.h>
|
---|
| 24 |
|
---|
[5224] | 25 | #include "win32k.h"
|
---|
| 26 | #include "libPrivate.h"
|
---|
[2823] | 27 |
|
---|
| 28 | /*******************************************************************************
|
---|
| 29 | * Global Variables *
|
---|
| 30 | *******************************************************************************/
|
---|
[2904] | 31 | BOOL fInited = FALSE;
|
---|
| 32 | HFILE hWin32k = NULLHANDLE;
|
---|
[2823] | 33 |
|
---|
| 34 |
|
---|
| 35 | /**
|
---|
| 36 | * Initiates the library.
|
---|
| 37 | * @returns OS/2 return code.
|
---|
| 38 | * @status
|
---|
[4787] | 39 | * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
---|
[2823] | 40 | * @remark
|
---|
| 41 | */
|
---|
| 42 | APIRET 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,
|
---|
[6560] | 56 | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY | OPEN_FLAGS_NOINHERIT,
|
---|
[2823] | 57 | NULL);
|
---|
| 58 |
|
---|
| 59 | fInited = rc == NO_ERROR;
|
---|
[5224] | 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 | }
|
---|
[2823] | 86 | }
|
---|
| 87 | else
|
---|
| 88 | rc = NO_ERROR;
|
---|
| 89 |
|
---|
| 90 | return rc;
|
---|
| 91 | }
|
---|
| 92 |
|
---|