source: trunk/src/win32k/k32/k32SetOptions.cpp@ 4164

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

Merged in the Grace branch. New Win32k!

File size: 6.8 KB
Line 
1/* $Id: k32SetOptions.cpp,v 1.2 2000-09-02 21:08:06 bird Exp $
2 *
3 * k32SetOptions - Sets the changable options of win32k.sys the options.
4 *
5 * Copyright (c) 2000 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* Defined Constants And Macros *
14*******************************************************************************/
15#define FOR_EXEHDR 1 /* To make all object flags OBJ???. */
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> /* OS/2 header file. */
28#include <peexe.h> /* Wine PE structs and definitions. */
29#include <neexe.h> /* Wine NE structs and definitions. */
30#include <newexe.h> /* OS/2 NE structs and definitions. */
31#include <exe386.h> /* OS/2 LX structs and definitions. */
32
33#include "devSegDf.h" /* Win32k segment definitions. */
34
35#include "malloc.h" /* win32k malloc (resident). Not C library! */
36#include "smalloc.h" /* win32k swappable heap. */
37#include "rmalloc.h" /* win32k resident heap. */
38
39#include <string.h> /* C library string.h. */
40#include <stdlib.h> /* C library stdlib.h. */
41#include <stddef.h> /* C library stddef.h. */
42#include <stdarg.h> /* C library stdarg.h. */
43
44#include "vprintf.h" /* win32k printf and vprintf. Not C library! */
45#include "dev1632.h" /* Common 16- and 32-bit parts */
46#include "dev32.h" /* 32-Bit part of the device driver. (SSToDS) */
47#include "OS2Krnl.h" /* kernel structs. (SFN) */
48#include "ldrCalls.h" /* ldr* calls. (ldrRead) */
49#include "log.h" /* Logging. */
50#include "avl.h" /* AVL tree. (ldr.h need it) */
51#include "ldr.h" /* ldr helpers. (ldrGetExePath) */
52#include "env.h" /* Environment helpers. */
53#include "modulebase.h" /* ModuleBase class definitions, ++. */
54#include "pe2lx.h" /* Pe2Lx class definitions, ++. */
55#include <versionos2.h> /* Pe2Lx version. */
56#include "options.h" /* Win32k options. */
57
58#include "ProbKrnl.h" /* ProbKrnl variables and definitions. */
59#include "win32k.h" /* Win32k API structures. */
60#include "k32.h" /* Internal Win32k API structures. */
61
62
63/**
64 * Sets the changable options of win32k.sys the options.
65 * @returns OS2 returncode.
66 * @param pOptions Pointer to options structure. (NULL is allowed)
67 * @status completely implelemented.
68 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
69 * @remark One of the pointer may be NULL.
70 */
71APIRET k32SetOptions(PK32OPTIONS pOptions)
72{
73 APIRET rc;
74 ULONG cb;
75
76 /*
77 * Validate parameters.
78 * Ensure that the buffer pointer is sensible.
79 * Ensure that the structure sizes are correct.
80 */
81 if ((ULONG)pOptions < 0x10000)
82 rc = ERROR_INVALID_PARAMETER;
83
84 if (pOptions != NULL)
85 {
86 rc = TKFuULongNF(SSToDS(&cb), &pOptions->cb);
87 if (rc)
88 return rc;
89 if (cb != sizeof(K32OPTIONS))
90 return ERROR_INVALID_PARAMETER;
91 }
92
93
94 /*
95 * Get options.
96 */
97 K32OPTIONS TmpOptions;
98
99 rc = TKFuBuff(SSToDS(&TmpOptions), pOptions, sizeof(K32OPTIONS), TK_FUSU_NONFATAL);
100 if (rc == NO_ERROR)
101 {
102 /*
103 * Validate contents.
104 */
105 if ( TmpOptions.usCom != OUTPUT_COM1
106 && TmpOptions.usCom != OUTPUT_COM2
107 && TmpOptions.usCom != OUTPUT_COM3
108 && TmpOptions.usCom != OUTPUT_COM4)
109 return ERROR_INVALID_PARAMETER;
110 if (TmpOptions.fLogging > 1)
111 return ERROR_INVALID_PARAMETER;
112 if (TmpOptions.fPE > 4)
113 return ERROR_INVALID_PARAMETER;
114 if (TmpOptions.ulInfoLevel > 4)
115 return ERROR_INVALID_PARAMETER;
116 if (TmpOptions.fElf > 1)
117 return ERROR_INVALID_PARAMETER;
118 if (TmpOptions.fUNIXScript > 1)
119 return ERROR_INVALID_PARAMETER;
120 if (TmpOptions.fREXXScript > 1)
121 return ERROR_INVALID_PARAMETER;
122 if (TmpOptions.fJava > 1)
123 return ERROR_INVALID_PARAMETER;
124 if (TmpOptions.fNoLoader > 1)
125 return ERROR_INVALID_PARAMETER;
126 if (TmpOptions.fREXXScript > 1)
127 return ERROR_INVALID_PARAMETER;
128 if (TmpOptions.cbSwpHeapMax > (32768*1024) || TmpOptions.cbSwpHeapMax < options.cbSwpHeapInit)
129 return ERROR_INVALID_PARAMETER;
130 if (TmpOptions.cbResHeapMax > (32768*1024) || TmpOptions.cbResHeapMax < options.cbResHeapInit)
131 return ERROR_INVALID_PARAMETER;
132
133 /*
134 * Take loader semaphore. (We might accessing LDR structures.)
135 */
136 rc = LDRRequestSem();
137 if (rc != NO_ERROR)
138 {
139 kprintf(("k32QueryOptionsStatus: LDRRequestSem failed with rc = %d\n", rc));
140 return rc;
141 }
142
143
144 /*
145 * Apply changes
146 */
147 options.usCom = TmpOptions.usCom; /* Output port no. */
148 options.fLogging = TmpOptions.fLogging; /* Logging. */
149 options.fPE = TmpOptions.fPE; /* Flags set the type of conversion. */
150 options.ulInfoLevel = TmpOptions.ulInfoLevel; /* Pe2Lx InfoLevel. */
151 options.fElf = TmpOptions.fElf; /* Elf flags. */
152 options.fUNIXScript = TmpOptions.fUNIXScript; /* UNIX script flags. */
153 options.fREXXScript = TmpOptions.fREXXScript; /* REXX script flags. */
154 options.fJava = TmpOptions.fJava; /* Java flags. */
155 options.fNoLoader = TmpOptions.fNoLoader; /* No loader stuff. !FIXME! We should import / functions even if this flag is set!!! */
156
157 options.cbSwpHeapMax = TmpOptions.cbSwpHeapMax; /* Maximum heapsize. */
158 cbSwpHeapMax = (unsigned)options.cbSwpHeapMax;
159 options.cbResHeapMax = TmpOptions.cbResHeapMax; /* Maxiumem residentheapsize. */
160 cbResHeapMax = (unsigned)options.cbResHeapMax;
161
162 /*
163 * Release loader semaphore and return
164 */
165 LDRClearSem();
166
167 }
168
169 return rc;
170}
171
Note: See TracBrowser for help on using the repository browser.