source: trunk/src/win32k/k32/k32QueryOptionsStatus.cpp@ 4774

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

Added option fDllFixes.

File size: 8.9 KB
Line 
1/* $Id: k32QueryOptionsStatus.cpp,v 1.4 2000-12-11 06:22:15 bird Exp $
2 *
3 * k32QueryOptionsStatus - Queries the options and/or the status of
4 * Win32k.sys driver.
5 *
6 * Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
7 *
8 * Project Odin Software License can be found in LICENSE.TXT
9 *
10 */
11
12
13/*******************************************************************************
14* Defined Constants And Macros *
15*******************************************************************************/
16#define FOR_EXEHDR 1 /* To make all object flags OBJ???. */
17#define INCL_DOSMEMMGR
18#define INCL_DOSERRORS
19
20#define INCL_OS2KRNL_TK
21#define INCL_OS2KRNL_SEM
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 "ldrCalls.h" /* ldr* calls. (ldrRead) */
50#include "log.h" /* Logging. */
51#include "avl.h" /* AVL tree. (ldr.h need it) */
52#include "ldr.h" /* ldr helpers. (ldrGetExePath) */
53#include "env.h" /* Environment helpers. */
54#include "modulebase.h" /* ModuleBase class definitions, ++. */
55#include "pe2lx.h" /* Pe2Lx class definitions, ++. */
56#include <versionos2.h> /* Pe2Lx version. */
57#include "options.h" /* Win32k options. */
58
59#include "ProbKrnl.h" /* ProbKrnl variables and definitions. */
60#include "win32k.h" /* Win32k API structures. */
61#include "k32.h" /* Internal Win32k API structures. */
62
63
64/**
65 * Queries the options and/or the status of Win32k.sys driver.
66 * @returns OS2 returncode.
67 * @param pOptions Pointer to options structure. (NULL is allowed)
68 * @param pStatus Pointer to status structure. (NULL is allowed)
69 * @status completely implelemented.
70 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
71 * @remark One of the pointer may be NULL.
72 */
73APIRET k32QueryOptionsStatus(PK32OPTIONS pOptions, PK32STATUS pStatus)
74{
75 APIRET rc;
76 ULONG cb;
77
78 /*
79 * Validate parameters.
80 * Ensure that the buffer pointer is sensible.
81 * Ensure that the structure sizes are correct.
82 */
83 if (((ULONG)pOptions < 0x10000 && pOptions != NULL)
84 ||
85 ((ULONG)pStatus < 0x10000 && pStatus != NULL)
86 ||
87 (pOptions == NULL && pStatus == NULL)
88 )
89 rc = ERROR_INVALID_PARAMETER;
90
91 if (pOptions != NULL)
92 {
93 rc = TKFuULongNF(SSToDS(&cb), &pOptions->cb);
94 if (rc)
95 return rc;
96 if (cb != sizeof(K32OPTIONS))
97 return ERROR_INVALID_PARAMETER;
98 }
99
100 if (pStatus != NULL)
101 {
102 rc = TKFuULongNF(SSToDS(&cb), &pStatus->cb);
103 if (rc)
104 return rc;
105 if (cb != sizeof(K32STATUS))
106 return ERROR_INVALID_PARAMETER;
107 }
108
109
110 /*
111 * Take loader semaphore. (We might accessing LDR structures.)
112 */
113 rc = LDRRequestSem();
114 if (rc != NO_ERROR)
115 {
116 kprintf(("k32QueryOptionsStatus: LDRRequestSem failed with rc = %d\n", rc));
117 return rc;
118 }
119
120 /*
121 * Get options.
122 */
123 if (pOptions)
124 {
125 K32OPTIONS TmpOptions;
126
127 TmpOptions.cb = sizeof(K32OPTIONS);
128 TmpOptions.usCom = options.usCom;
129 TmpOptions.fLogging = options.fLogging;
130 TmpOptions.fPE = options.fPE;
131 TmpOptions.ulInfoLevel = options.ulInfoLevel;
132 TmpOptions.fElf = options.fElf;
133 TmpOptions.fUNIXScript = options.fUNIXScript;
134 TmpOptions.fREXXScript = options.fREXXScript;
135 TmpOptions.fJava = options.fJava;
136 TmpOptions.fNoLoader = options.fNoLoader;
137 TmpOptions.fDllFixes = options.fDllFixes;
138 TmpOptions.cbSwpHeapMax = options.cbSwpHeapMax;
139 TmpOptions.cbResHeapMax = options.cbResHeapMax;
140
141 rc = TKSuBuff(pOptions, SSToDS(&TmpOptions), sizeof(K32OPTIONS), TK_FUSU_NONFATAL);
142 if (rc != NO_ERROR) /* retry once if we fail. (For some reason it seems to work.) */
143 rc = TKSuBuff(pOptions, SSToDS(&TmpOptions), sizeof(K32OPTIONS), TK_FUSU_NONFATAL);
144 }
145
146 /*
147 * Get status.
148 */
149 if (rc == NO_ERROR && pStatus)
150 {
151 K32STATUS TmpStatus;
152 HEAPSTATE HeapState;
153
154 /* initate the temporary structure */
155 memset(SSToDS(&TmpStatus), 0, sizeof(K32STATUS));
156 TmpStatus.cb = sizeof(K32STATUS);
157
158 /* options */
159 TmpStatus.fQuiet = options.fQuiet;
160 TmpStatus.fKernel = options.fKernel; /* Smp or uni kernel. */
161 TmpStatus.ulBuild = options.ulBuild; /* Kernel build. */
162 TmpStatus.usVerMajor = options.usVerMajor; /* OS/2 major ver - 20 */
163 TmpStatus.usVerMinor = options.usVerMinor; /* OS/2 minor ver - 30,40 */
164
165 /* swappable heap */
166 if (_swp_state((PHEAPSTATE)SSToDS(&HeapState)) == 0)
167 {
168 TmpStatus.cbSwpHeapInit = options.cbSwpHeapInit; /* Initial heapsize. */
169 TmpStatus.cbSwpHeapFree = HeapState.cbHeapFree; /* Amount of used space. */
170 TmpStatus.cbSwpHeapUsed = HeapState.cbHeapUsed; /* Amount of free space reserved. */
171 TmpStatus.cbSwpHeapSize = HeapState.cbHeapSize; /* Amount of memory used by the heap free and used++. */
172 TmpStatus.cSwpBlocksUsed = HeapState.cBlocksUsed; /* Count of used blocks. */
173 TmpStatus.cSwpBlocksFree = HeapState.cBlocksFree; /* Count of free blocks. */
174 }
175
176 /* resident heap */
177 if (_res_state((PHEAPSTATE)SSToDS(&HeapState)) == 0)
178 {
179 TmpStatus.cbResHeapInit = options.cbResHeapInit; /* Initial heapsize. */
180 TmpStatus.cbResHeapFree = HeapState.cbHeapFree; /* Amount of used space. */
181 TmpStatus.cbResHeapUsed = HeapState.cbHeapUsed; /* Amount of free space reserved. */
182 TmpStatus.cbResHeapSize = HeapState.cbHeapSize; /* Amount of memory used by the heap free and used++. */
183 TmpStatus.cResBlocksUsed = HeapState.cBlocksUsed; /* Count of used blocks. */
184 TmpStatus.cResBlocksFree = HeapState.cBlocksFree; /* Count of free blocks. */
185 }
186
187 /* Win32k Build and version; and symfile name or SymDB. */
188 strcpy((char*)SSToDS(TmpStatus.szBuildDate), szBuildDate); /* Date of the win32k build. */
189 strcpy((char*)SSToDS(TmpStatus.szBuildTime), szBuildTime); /* Time of the win32k build. */
190 TmpStatus.ulVersion = PE2LX_VERSION; /* Win32k version */
191 strcpy((char*)SSToDS(TmpStatus.szSymFile), szSymbolFile); /* The name of the symbol file or sym database. */
192
193 /* Module counts */
194 TmpStatus.cPe2LxModules = Pe2Lx::getLoadedModuleCount();/* Number of Pe2Lx modules currently loaded. */
195 TmpStatus.cElf2LxModules = /*Elf2Lx::getLoadedModuleCount()*/ 0; /* Number of Elf2Lx modules currently loaded. */
196
197 rc = TKSuBuff(pStatus, SSToDS(&TmpStatus), sizeof(K32STATUS), TK_FUSU_NONFATAL);
198 if (rc != NO_ERROR) /* retry once if we fail. (For some reason it seems to work.) */
199 rc = TKSuBuff(pStatus, SSToDS(&TmpStatus), sizeof(K32STATUS), TK_FUSU_NONFATAL);
200 }
201
202 /*
203 * Release loader semaphore and return.
204 */
205 LDRClearSem();
206
207 return rc;
208}
209
Note: See TracBrowser for help on using the repository browser.