source: trunk/src/win32k/k32/k32QueryOptionsStatus.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: 8.9 KB
Line 
1/* $Id: k32QueryOptionsStatus.cpp,v 1.6 2001-02-10 11:11:44 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#define INCL_OS2KRNL_LDR
23
24#define NO_WIN32K_LIB_FUNCTIONS
25
26/*******************************************************************************
27* Header Files *
28*******************************************************************************/
29#include <os2.h> /* OS/2 header file. */
30#include <peexe.h> /* Wine PE structs and definitions. */
31#include <neexe.h> /* Wine NE structs and definitions. */
32#include <newexe.h> /* OS/2 NE structs and definitions. */
33#include <exe386.h> /* OS/2 LX structs and definitions. */
34
35#include "devSegDf.h" /* Win32k segment definitions. */
36
37#include "malloc.h" /* win32k malloc (resident). Not C library! */
38#include "smalloc.h" /* win32k swappable heap. */
39#include "rmalloc.h" /* win32k resident heap. */
40
41#include <string.h> /* C library string.h. */
42#include <stdlib.h> /* C library stdlib.h. */
43#include <stddef.h> /* C library stddef.h. */
44#include <stdarg.h> /* C library stdarg.h. */
45
46#include "vprintf.h" /* win32k printf and vprintf. Not C library! */
47#include "dev1632.h" /* Common 16- and 32-bit parts */
48#include "dev32.h" /* 32-Bit part of the device driver. (SSToDS) */
49#include "OS2Krnl.h" /* kernel structs. (SFN) */
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.fPEOneObject = options.fPEOneObject;
132 TmpOptions.ulInfoLevel = options.ulInfoLevel;
133 TmpOptions.fElf = options.fElf;
134 TmpOptions.fUNIXScript = options.fUNIXScript;
135 TmpOptions.fREXXScript = options.fREXXScript;
136 TmpOptions.fJava = options.fJava;
137 TmpOptions.fNoLoader = options.fNoLoader;
138 TmpOptions.fDllFixes = options.fDllFixes;
139 TmpOptions.cbSwpHeapMax = options.cbSwpHeapMax;
140 TmpOptions.cbResHeapMax = options.cbResHeapMax;
141
142 rc = TKSuBuff(pOptions, SSToDS(&TmpOptions), sizeof(K32OPTIONS), TK_FUSU_NONFATAL);
143 if (rc != NO_ERROR) /* retry once if we fail. (For some reason it seems to work.) */
144 rc = TKSuBuff(pOptions, SSToDS(&TmpOptions), sizeof(K32OPTIONS), TK_FUSU_NONFATAL);
145 }
146
147 /*
148 * Get status.
149 */
150 if (rc == NO_ERROR && pStatus)
151 {
152 K32STATUS TmpStatus;
153 HEAPSTATE HeapState;
154
155 /* initate the temporary structure */
156 memset(SSToDS(&TmpStatus), 0, sizeof(K32STATUS));
157 TmpStatus.cb = sizeof(K32STATUS);
158
159 /* options */
160 TmpStatus.fQuiet = options.fQuiet;
161 TmpStatus.fKernel = options.fKernel; /* Smp or uni kernel. */
162 TmpStatus.ulBuild = options.ulBuild; /* Kernel build. */
163 TmpStatus.usVerMajor = options.usVerMajor; /* OS/2 major ver - 20 */
164 TmpStatus.usVerMinor = options.usVerMinor; /* OS/2 minor ver - 30,40 */
165
166 /* swappable heap */
167 if (_swp_state((PHEAPSTATE)SSToDS(&HeapState)) == 0)
168 {
169 TmpStatus.cbSwpHeapInit = options.cbSwpHeapInit; /* Initial heapsize. */
170 TmpStatus.cbSwpHeapFree = HeapState.cbHeapFree; /* Amount of used space. */
171 TmpStatus.cbSwpHeapUsed = HeapState.cbHeapUsed; /* Amount of free space reserved. */
172 TmpStatus.cbSwpHeapSize = HeapState.cbHeapSize; /* Amount of memory used by the heap free and used++. */
173 TmpStatus.cSwpBlocksUsed = HeapState.cBlocksUsed; /* Count of used blocks. */
174 TmpStatus.cSwpBlocksFree = HeapState.cBlocksFree; /* Count of free blocks. */
175 }
176
177 /* resident heap */
178 if (_res_state((PHEAPSTATE)SSToDS(&HeapState)) == 0)
179 {
180 TmpStatus.cbResHeapInit = options.cbResHeapInit; /* Initial heapsize. */
181 TmpStatus.cbResHeapFree = HeapState.cbHeapFree; /* Amount of used space. */
182 TmpStatus.cbResHeapUsed = HeapState.cbHeapUsed; /* Amount of free space reserved. */
183 TmpStatus.cbResHeapSize = HeapState.cbHeapSize; /* Amount of memory used by the heap free and used++. */
184 TmpStatus.cResBlocksUsed = HeapState.cBlocksUsed; /* Count of used blocks. */
185 TmpStatus.cResBlocksFree = HeapState.cBlocksFree; /* Count of free blocks. */
186 }
187
188 /* Win32k Build and version; and symfile name or SymDB. */
189 strcpy((char*)SSToDS(TmpStatus.szBuildDate), szBuildDate); /* Date of the win32k build. */
190 strcpy((char*)SSToDS(TmpStatus.szBuildTime), szBuildTime); /* Time of the win32k build. */
191 TmpStatus.ulVersion = PE2LX_VERSION; /* Win32k version */
192 strcpy((char*)SSToDS(TmpStatus.szSymFile), szSymbolFile); /* The name of the symbol file or sym database. */
193
194 /* Module counts */
195 TmpStatus.cPe2LxModules = Pe2Lx::getLoadedModuleCount();/* Number of Pe2Lx modules currently loaded. */
196 TmpStatus.cElf2LxModules = /*Elf2Lx::getLoadedModuleCount()*/ 0; /* Number of Elf2Lx modules currently loaded. */
197
198 rc = TKSuBuff(pStatus, SSToDS(&TmpStatus), sizeof(K32STATUS), TK_FUSU_NONFATAL);
199 if (rc != NO_ERROR) /* retry once if we fail. (For some reason it seems to work.) */
200 rc = TKSuBuff(pStatus, SSToDS(&TmpStatus), sizeof(K32STATUS), TK_FUSU_NONFATAL);
201 }
202
203 /*
204 * Release loader semaphore and return.
205 */
206 LDRClearSem();
207
208 return rc;
209}
210
Note: See TracBrowser for help on using the repository browser.