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

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

Added force preload, exefix and apifix options.

File size: 7.7 KB
Line 
1/* $Id: k32SetOptions.cpp,v 1.7 2001-02-11 23:43:00 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.fExeFixes > 1)
133 return ERROR_INVALID_PARAMETER;
134 if (TmpOptions.fForcePreload > 1)
135 return ERROR_INVALID_PARAMETER;
136 if (TmpOptions.fApiEnh > 1)
137 return ERROR_INVALID_PARAMETER;
138 if (TmpOptions.cbSwpHeapMax > (32768*1024) || TmpOptions.cbSwpHeapMax < options.cbSwpHeapInit)
139 return ERROR_INVALID_PARAMETER;
140 if (TmpOptions.cbResHeapMax > (32768*1024) || TmpOptions.cbResHeapMax < options.cbResHeapInit)
141 return ERROR_INVALID_PARAMETER;
142
143 /*
144 * Take loader semaphore. (We might accessing LDR structures.)
145 */
146 rc = LDRRequestSem();
147 if (rc != NO_ERROR)
148 {
149 kprintf(("k32QueryOptionsStatus: LDRRequestSem failed with rc = %d\n", rc));
150 return rc;
151 }
152
153
154 /*
155 * Apply changes
156 */
157 options.usCom = TmpOptions.usCom; /* Output port no. */
158 options.fLogging = (USHORT)TmpOptions.fLogging;/* Logging. */
159 options.fPE = TmpOptions.fPE; /* Flags set the type of conversion. */
160 options.fPEOneObject= TmpOptions.fPEOneObject; /* All in One Object Forces fix. */
161 options.ulInfoLevel = TmpOptions.ulInfoLevel; /* Pe2Lx InfoLevel. */
162 options.fElf = TmpOptions.fElf; /* Elf flags. */
163 options.fUNIXScript = TmpOptions.fUNIXScript; /* UNIX script flags. */
164 options.fREXXScript = TmpOptions.fREXXScript; /* REXX script flags. */
165 options.fJava = TmpOptions.fJava; /* Java flags. */
166 options.fNoLoader = TmpOptions.fNoLoader; /* No loader stuff. !FIXME! We should import / functions even if this flag is set!!! */
167 options.fDllFixes = TmpOptions.fDllFixes; /* Enables the long DLL name and non .DLL extention fixes. */
168 options.fExeFixes = TmpOptions.fExeFixes; /* Enables EXE files to export entry points. */
169 options.fForcePreload=TmpOptions.fForcePreload; /* Forces the loader to preload executable images. Handy for ICAT Ring-3 debugging. */
170 options.fApiEnh = TmpOptions.fApiEnh; /* Enables the API enhancements */
171
172 options.cbSwpHeapMax = TmpOptions.cbSwpHeapMax; /* Maximum heapsize. */
173 cbSwpHeapMax = (unsigned)options.cbSwpHeapMax;
174 options.cbResHeapMax = TmpOptions.cbResHeapMax; /* Maxiumem residentheapsize. */
175 cbResHeapMax = (unsigned)options.cbResHeapMax;
176
177 /*
178 * Release loader semaphore and return
179 */
180 LDRClearSem();
181 }
182
183 return rc;
184}
185
Note: See TracBrowser for help on using the repository browser.