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

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

Moved ldrCalls.h into the OS2Krnl.h tree as OS2KLDR.h.
Also moved the Ldr definitions from OS2Krnl.h and into OS2KLDR.h.

File size: 7.1 KB
Line 
1/* $Id: k32SetOptions.cpp,v 1.6 2001-02-10 11:11:44 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#define INCL_OS2KRNL_LDR
22
23#define NO_WIN32K_LIB_FUNCTIONS
24
25/*******************************************************************************
26* Header Files *
27*******************************************************************************/
28#include <os2.h> /* OS/2 header file. */
29#include <peexe.h> /* Wine PE structs and definitions. */
30#include <neexe.h> /* Wine NE structs and definitions. */
31#include <newexe.h> /* OS/2 NE structs and definitions. */
32#include <exe386.h> /* OS/2 LX structs and definitions. */
33
34#include "devSegDf.h" /* Win32k segment definitions. */
35
36#include "malloc.h" /* win32k malloc (resident). Not C library! */
37#include "smalloc.h" /* win32k swappable heap. */
38#include "rmalloc.h" /* win32k resident heap. */
39
40#include <string.h> /* C library string.h. */
41#include <stdlib.h> /* C library stdlib.h. */
42#include <stddef.h> /* C library stddef.h. */
43#include <stdarg.h> /* C library stdarg.h. */
44
45#include "vprintf.h" /* win32k printf and vprintf. Not C library! */
46#include "dev1632.h" /* Common 16- and 32-bit parts */
47#include "dev32.h" /* 32-Bit part of the device driver. (SSToDS) */
48#include "OS2Krnl.h" /* kernel structs. (SFN) */
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.fPEOneObject > 2)
115 return ERROR_INVALID_PARAMETER;
116 if (TmpOptions.ulInfoLevel > 4)
117 return ERROR_INVALID_PARAMETER;
118 if (TmpOptions.fElf > 1)
119 return ERROR_INVALID_PARAMETER;
120 if (TmpOptions.fUNIXScript > 1)
121 return ERROR_INVALID_PARAMETER;
122 if (TmpOptions.fREXXScript > 1)
123 return ERROR_INVALID_PARAMETER;
124 if (TmpOptions.fJava > 1)
125 return ERROR_INVALID_PARAMETER;
126 if (TmpOptions.fNoLoader > 1)
127 return ERROR_INVALID_PARAMETER;
128 if (TmpOptions.fREXXScript > 1)
129 return ERROR_INVALID_PARAMETER;
130 if (TmpOptions.fDllFixes > 1)
131 return ERROR_INVALID_PARAMETER;
132 if (TmpOptions.cbSwpHeapMax > (32768*1024) || TmpOptions.cbSwpHeapMax < options.cbSwpHeapInit)
133 return ERROR_INVALID_PARAMETER;
134 if (TmpOptions.cbResHeapMax > (32768*1024) || TmpOptions.cbResHeapMax < options.cbResHeapInit)
135 return ERROR_INVALID_PARAMETER;
136
137 /*
138 * Take loader semaphore. (We might accessing LDR structures.)
139 */
140 rc = LDRRequestSem();
141 if (rc != NO_ERROR)
142 {
143 kprintf(("k32QueryOptionsStatus: LDRRequestSem failed with rc = %d\n", rc));
144 return rc;
145 }
146
147
148 /*
149 * Apply changes
150 */
151 options.usCom = TmpOptions.usCom; /* Output port no. */
152 options.fLogging = (USHORT)TmpOptions.fLogging;/* Logging. */
153 options.fPE = TmpOptions.fPE; /* Flags set the type of conversion. */
154 options.fPEOneObject= TmpOptions.fPEOneObject; /* All in One Object Forces fix. */
155 options.ulInfoLevel = TmpOptions.ulInfoLevel; /* Pe2Lx InfoLevel. */
156 options.fElf = TmpOptions.fElf; /* Elf flags. */
157 options.fUNIXScript = TmpOptions.fUNIXScript; /* UNIX script flags. */
158 options.fREXXScript = TmpOptions.fREXXScript; /* REXX script flags. */
159 options.fJava = TmpOptions.fJava; /* Java flags. */
160 options.fNoLoader = TmpOptions.fNoLoader; /* No loader stuff. !FIXME! We should import / functions even if this flag is set!!! */
161 options.fDllFixes = TmpOptions.fDllFixes; /* Enables the long DLL name and non .DLL extention fixes. */
162
163 options.cbSwpHeapMax = TmpOptions.cbSwpHeapMax; /* Maximum heapsize. */
164 cbSwpHeapMax = (unsigned)options.cbSwpHeapMax;
165 options.cbResHeapMax = TmpOptions.cbResHeapMax; /* Maxiumem residentheapsize. */
166 cbResHeapMax = (unsigned)options.cbResHeapMax;
167
168 /*
169 * Release loader semaphore and return
170 */
171 LDRClearSem();
172
173 }
174
175 return rc;
176}
177
Note: See TracBrowser for help on using the repository browser.