1 | /* $Id: win32k.h,v 1.8 2001-02-20 04:56:28 bird Exp $
|
---|
2 | *
|
---|
3 | * Top level make file for the Win32k library.
|
---|
4 | * Contains library and 32-bit IOCtl definition.
|
---|
5 | *
|
---|
6 | * Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
|
---|
7 | *
|
---|
8 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
9 | *
|
---|
10 | */
|
---|
11 | #ifndef _WIN32K_H_
|
---|
12 | #define _WIN32K_H_
|
---|
13 |
|
---|
14 | /*******************************************************************************
|
---|
15 | * Defined Constants And Macros *
|
---|
16 | *******************************************************************************/
|
---|
17 | /*
|
---|
18 | * IOCtls categories.
|
---|
19 | */
|
---|
20 | #define IOCTL_W32K_K32 0xC1
|
---|
21 | #define IOCTL_W32K_ELF 0xC2
|
---|
22 |
|
---|
23 | /*
|
---|
24 | * K32 category - these are the functions found in the k32 directory.
|
---|
25 | */
|
---|
26 | #define K32_ALLOCMEMEX 0x01
|
---|
27 | #define K32_QUERYOTES 0x02
|
---|
28 | #define K32_QUERYOPTIONSSTATUS 0x03
|
---|
29 | #define K32_SETOPTIONS 0x04
|
---|
30 | #define K32_PROCESSREADWRITE 0x05
|
---|
31 | #define K32_HANDLESYSTEMEVENT 0x06
|
---|
32 | #define K32_QUERYSYSTEMMEMINFO 0x07
|
---|
33 | #define K32_LASTIOCTLFUNCTION K32_QUERYSYSTEMMEMINFO
|
---|
34 |
|
---|
35 |
|
---|
36 | /*
|
---|
37 | * Elf category
|
---|
38 | */
|
---|
39 | #define ELF_DUMMY 0x01
|
---|
40 |
|
---|
41 |
|
---|
42 | /*
|
---|
43 | * DosAllocMemEx - Extra (bsememf.h) flag definitions.
|
---|
44 | */
|
---|
45 | #define OBJ_ALIGNDEFAULT 0x00000000UL
|
---|
46 | #define OBJ_ALIGN64K 0x10000000UL
|
---|
47 | #define OBJ_ALIGNPAGE 0x20000000UL
|
---|
48 | #define OBJ_ALIGNMASK 0x30000000UL
|
---|
49 | #define OBJ_LOCATION 0x80000000UL
|
---|
50 | #ifndef OBJ_SELMAPALL
|
---|
51 | #define OBJ_SELMAPALL 0x00000800UL /* This isn't ours. It just a dropout form bsememf.h */
|
---|
52 | #endif
|
---|
53 |
|
---|
54 |
|
---|
55 | /*
|
---|
56 | * System event Identifiers.
|
---|
57 | */
|
---|
58 | #define K32_SYSEVENT_SM_MOUSE 0x00 /* dh SendEvent - Session Manager (mouse) */
|
---|
59 | #define K32_SYSEVENT_CTRL_BREAK 0x01 /* dh SendEvent - Ctrl-Break */
|
---|
60 | #define K32_SYSEVENT_CTRL_C 0x02 /* dh SendEvent - Ctrl-C */
|
---|
61 | #define K32_SYSEVENT_CTRL_SCREEN_LOCK 0x03 /* dh SendEvent - Ctrl-ScrollLock */
|
---|
62 | #define K32_SYSEVENT_CTRL_PRINT_SCREEN 0x04 /* dh SendEvent - Ctrl-PrtSc */
|
---|
63 | #define K32_SYSEVENT_SHIFT_PRINT_SCREEN 0x05 /* dh SendEvent - Shift-PrtSc */
|
---|
64 | #define K32_SYSEVENT_SM_KEYBOARD 0x06 /* dh SendEvent - Session Manager (keyboard) */
|
---|
65 | #define K32_SYSEVENT_SM_CTRL_ALT_DELETE 0x07 /* dh SendEvent - Ctrl-Alt-Del */
|
---|
66 | #define K32_SYSEVENT_HOT_PLUG 0x08 /* dh SendEvent - Keyboard Hot Plug/Reset */
|
---|
67 | #define K32_SYSEVENT_POWER 0x09 /* dh SendEvent - Power suspend event */
|
---|
68 | #define K32_SYSEVENT_POWEROFF 0x0a /* dh SendEvent - Power off event */
|
---|
69 | #define K32_SYSEVENT_CTRL_ALT_2xNUMLOCK 0x0b /* VectorSDF - System Dump */
|
---|
70 | #define K32_SYSEVENT_LAST K32_SYSEVENT_CTRL_ALT_2xNUMLOCK
|
---|
71 |
|
---|
72 | /*
|
---|
73 | * System Memory Info flags.
|
---|
74 | */
|
---|
75 | #define K32_SYSMEMINFO_ALL 0 /* Everything is queried. */
|
---|
76 | #define K32_SYSMEMINFO_SWAPFILE 0x01 /* Swapfile stuff is queried. */
|
---|
77 | #define K32_SYSMEMINFO_PAGING 0x02 /* Paging and Physical memory stuff is queried. */
|
---|
78 | #define K32_SYSMEMINFO_VM 0x04 /* Virtual memory stuff is all queried. */
|
---|
79 |
|
---|
80 |
|
---|
81 | #ifndef INCL_16 /* We don't need this in 16-bit code. */
|
---|
82 |
|
---|
83 | /*******************************************************************************
|
---|
84 | * Structures and Typedefs *
|
---|
85 | *******************************************************************************/
|
---|
86 | #pragma pack(1)
|
---|
87 |
|
---|
88 | /*
|
---|
89 | * Object Table Entry buffer.
|
---|
90 | */
|
---|
91 | typedef struct _QueryOTE
|
---|
92 | {
|
---|
93 | ULONG ote_size; /* Object virtual size */
|
---|
94 | ULONG ote_base; /* Object base virtual address */
|
---|
95 | ULONG ote_flags; /* Attribute flags */
|
---|
96 | ULONG ote_pagemap; /* Object page map index */
|
---|
97 | ULONG ote_mapsize; /* Num of entries in obj page map */
|
---|
98 | /*ULONG ote_reserved;*/
|
---|
99 | USHORT ote_sel; /* Object Selector */
|
---|
100 | USHORT ote_hob; /* Object Handle */
|
---|
101 | } QOTE, *PQOTE;
|
---|
102 |
|
---|
103 | typedef struct _QueryOTEBuffer
|
---|
104 | {
|
---|
105 | ULONG cOTEs; /* Number of entries in aOTE. */
|
---|
106 | QOTE aOTE[1]; /* Array of OTEs. */
|
---|
107 | } QOTEBUFFER, *PQOTEBUFFER;
|
---|
108 |
|
---|
109 |
|
---|
110 | /*
|
---|
111 | * Options struct.
|
---|
112 | *
|
---|
113 | * (The function of these members are described in options.h in
|
---|
114 | * the src\win32k\include directory.)
|
---|
115 | * All members of this struct (except cb ofcourse) is changable.
|
---|
116 | */
|
---|
117 | typedef struct _K32Options
|
---|
118 | {
|
---|
119 | ULONG cb;
|
---|
120 |
|
---|
121 | /** @cat logging options */
|
---|
122 | USHORT usCom; /* Output port no. */
|
---|
123 | ULONG fLogging; /* Logging. */
|
---|
124 |
|
---|
125 | /** @cat Options affecting the generated LX executables */
|
---|
126 | ULONG fPE; /* Flags set the type of conversion. */
|
---|
127 | ULONG fPEOneObject; /* All in one object. */
|
---|
128 | ULONG ulInfoLevel; /* Pe2Lx InfoLevel. */
|
---|
129 |
|
---|
130 | /** @cat Options affecting the generated ELF executables */
|
---|
131 | ULONG fElf; /* Elf flags. */
|
---|
132 |
|
---|
133 | /** @cat Options affecting the UNIX script executables */
|
---|
134 | ULONG fUNIXScript; /* UNIX script flags. */
|
---|
135 |
|
---|
136 | /** @cat Options affecting the REXX script executables */
|
---|
137 | ULONG fREXXScript; /* REXX script flags. */
|
---|
138 |
|
---|
139 | /** @cat Options affecting the JAVA executables */
|
---|
140 | ULONG fJava; /* Java flags. */
|
---|
141 |
|
---|
142 | /** @cat Options affecting the executables */
|
---|
143 | ULONG fNoLoader; /* No loader stuff. !FIXME! We should import / functions even if this flag is set!!! */
|
---|
144 |
|
---|
145 | /** @cat Options affecting the behaviour changes in the OS/2 loader */
|
---|
146 | ULONG fDllFixes; /* Enables the long DLL name and non .DLL extention fixes. */
|
---|
147 | ULONG fExeFixes; /* Enables EXE files to export entry points. */
|
---|
148 | ULONG fForcePreload; /* Forces the loader to preload executable images. Handy for ICAT Ring-3 debugging. */
|
---|
149 | ULONG fApiEnh; /* Enables the API enhancements */
|
---|
150 |
|
---|
151 | /** @cat Options affecting the heap. */
|
---|
152 | ULONG cbSwpHeapMax; /* Maximum heapsize. */
|
---|
153 | ULONG cbResHeapMax; /* Maxiumem residentheapsize. */
|
---|
154 | } K32OPTIONS, *PK32OPTIONS;
|
---|
155 |
|
---|
156 |
|
---|
157 | /*
|
---|
158 | * Status struct.
|
---|
159 | *
|
---|
160 | */
|
---|
161 | typedef struct _K32Status
|
---|
162 | {
|
---|
163 | ULONG cb;
|
---|
164 |
|
---|
165 | /** @cat Options status. */
|
---|
166 | ULONG fQuiet; /* Quiet initialization. */
|
---|
167 |
|
---|
168 | /** @cat Kernel status. */
|
---|
169 | ULONG fKernel; /* Smp or uni kernel. */
|
---|
170 | ULONG ulBuild; /* Kernel build. */
|
---|
171 | USHORT usVerMajor; /* OS/2 major ver - 20 */
|
---|
172 | USHORT usVerMinor; /* OS/2 minor ver - 30,40 */
|
---|
173 |
|
---|
174 | /** @cat Heap status. */
|
---|
175 | ULONG cbSwpHeapInit; /* Initial heapsize. */
|
---|
176 | ULONG cbSwpHeapFree; /* Amount of used space. */
|
---|
177 | ULONG cbSwpHeapUsed; /* Amount of free space reserved. */
|
---|
178 | ULONG cbSwpHeapSize; /* Amount of memory used by the heap free and used++. */
|
---|
179 | ULONG cSwpBlocksUsed; /* Count of used blocks. */
|
---|
180 | ULONG cSwpBlocksFree; /* Count of free blocks. */
|
---|
181 |
|
---|
182 | ULONG cbResHeapInit; /* Initial heapsize. */
|
---|
183 | ULONG cbResHeapFree; /* Amount of free space reserved. */
|
---|
184 | ULONG cbResHeapUsed; /* Amount of used space. */
|
---|
185 | ULONG cbResHeapSize; /* Amount of memory used by the heap free and used++. */
|
---|
186 | ULONG cResBlocksUsed; /* Count of used blocks. */
|
---|
187 | ULONG cResBlocksFree; /* Count of free blocks. */
|
---|
188 |
|
---|
189 | /** @cat Win32k build, version and init stuff */
|
---|
190 | CHAR szBuildDate[12]; /* Date of the win32k build. (Sep 02 2000) */
|
---|
191 | CHAR szBuildTime[9]; /* Time of the win32k build. (11:44:21) */
|
---|
192 | ULONG ulVersion; /* Win32k version */
|
---|
193 | CHAR szSymFile[CCHMAXPATH]; /* The name of the symbol file or sym database. */
|
---|
194 |
|
---|
195 | /** @cat Statistics */
|
---|
196 | ULONG cPe2LxModules; /* Number of Pe2Lx modules currently loaded. */
|
---|
197 | ULONG cElf2LxModules; /* Number of Elf2Lx modules currently loaded. */
|
---|
198 | /*...*/
|
---|
199 | } K32STATUS, *PK32STATUS;
|
---|
200 |
|
---|
201 |
|
---|
202 | /*
|
---|
203 | * Memory information struct.
|
---|
204 | */
|
---|
205 | typedef struct _k32SystemMemInfo
|
---|
206 | {
|
---|
207 | ULONG cb; /* Size of this structure - must be set. */
|
---|
208 | /* This will be used to distinguish futher versions. */
|
---|
209 | ULONG flFlags; /* This is used to limit amount of information collected - must be set. (K32_SYSMEMINFO_*) */
|
---|
210 | /* Some conciderations.
|
---|
211 | * - VM uses worker functions which traverses internal lists.
|
---|
212 | * - Page and physical memory traverses one internal structure (PGPhysAvail())
|
---|
213 | * - Swap File only accesses variables.
|
---|
214 | */
|
---|
215 |
|
---|
216 | /* SwapFile Info */
|
---|
217 | BOOL fSwapFile; /* Swap File: Swapping enabled or disabled. (SMswapping) */
|
---|
218 | /* (The SwapFile data below is valid when swapping is enbled!) */
|
---|
219 | ULONG cbSwapFileSize; /* Swap File: Current size. (smFileSize<<PAGESIZE) */
|
---|
220 | ULONG cbSwapFileAvail; /* Swap File: Available within current file. ((smFileSize-smcBrokenDF-SMcDFInuse)<<PAGESIZE) */
|
---|
221 | ULONG cbSwapFileUsed; /* Swap File: Used within current file. (SMcDFInuse<<PAGESIZE) */
|
---|
222 | ULONG cbSwapFileMinFree; /* Swap File: Addjusted min free on swap volume. (SMMinFree<<PAGESHIFT) */
|
---|
223 | ULONG cbSwapFileCFGMinFree; /* Swap File: Configured min free on swap volume. ((SMCFGMinFree<<PAGESHIFT)/4) */
|
---|
224 | ULONG cbSwapFileCFGSwapSize; /* Swap File: Configured initial swap file size. ((SMCFGSwapSize<<PAGESHIFT)/4) */
|
---|
225 | ULONG cSwapFileBrokenDF; /* Swap File: Number of broken disk frames (DF). (smcBrokenDF) */
|
---|
226 | ULONG cSwapFileGrowFails; /* Swap File: Number of times growoperation has failed. (smcGrowFails) */
|
---|
227 | ULONG cSwapFileInMemFile; /* Swap File: Number of pages in the "In-Memory-swapFile". (SMcInMemFile) */
|
---|
228 | /* These pages are not counted into the SMcDFInuse count I think. */
|
---|
229 |
|
---|
230 | /* Physical Memory Info */
|
---|
231 | ULONG cbPhysSize; /* Physical memory: total (bytes). (pgPhysPages<<PAGESHIFT) */
|
---|
232 | ULONG cbPhysAvail; /* Physical memory: available (bytes). (PGPhysAvail()) */
|
---|
233 | ULONG cbPhysUsed; /* Physical memory: used (bytes). (PGPhysPresent()<<PAGESHIFT) */
|
---|
234 |
|
---|
235 | /* Other paging info */
|
---|
236 | BOOL fPagingSwapEnabled; /* Paging: TRUE when swapping is enabled, else false. (PGSwapEnabled) */
|
---|
237 | ULONG cPagingPageFaults; /* Paging: Number of pagefaults which has occured since boot. (pgcPageFaults) */
|
---|
238 | ULONG cPagingPageFaultsActive;/* Paging: Number of pagefaults currently being processed. (pgcPageFaultsActive) */
|
---|
239 | ULONG cPagingPhysPages; /* Paging: Count of physical pages. (hope this is correct) (pgPhysPages) */
|
---|
240 | ULONG ulPagingPhysMax; /* Paging: Top of physical memory (physical page number) (pgPhysMax) */
|
---|
241 | ULONG cPagingResidentPages; /* Paging: Count of resident pages. (pgResidentPages) */
|
---|
242 | ULONG cPagingSwappablePages; /* Paging: Count of swappable pages which is currently present in memory. (pgSwappablePages) */
|
---|
243 | ULONG cPagingDiscardableInmem;/* Paging: Count of discardable pages which is currently present in memory. (pgDiscardableInmem) */
|
---|
244 | ULONG cPagingDiscardablePages;/* Paging: Count of discardable pages allocated. (pgDiscardablePages) */
|
---|
245 |
|
---|
246 | /* Virtual Memory manager info. */
|
---|
247 | ULONG ulAddressLimit; /* VM: Current user virtual address limit - use this for high arena check. (VirtualAddressLimit / 0x20000000) */
|
---|
248 | ULONG ulVMArenaPrivMax; /* VM: Current highest address in the private arena. (vmRecalcShrBound()) */
|
---|
249 | ULONG ulVMArenaSharedMin; /* VM: Current lowest address in the shared arena. (ahvmShr) */
|
---|
250 | ULONG ulVMArenaSharedMax; /* VM: Current highest address in the shared arena. (ahvmShr) */
|
---|
251 | ULONG ulVMArenaSystemMin; /* VM: Current lowest address in the system arena. (ahvmhSys) */
|
---|
252 | ULONG ulVMArenaSystemMax; /* VM: Current highest address in the system arena. (ahvmhSys) */
|
---|
253 | ULONG ulVMArenaHighPrivMax; /* VM: Current highest address in the high private arena - aurora/smp only. (vmRecalcShrBound) */
|
---|
254 | ULONG ulVMArenaHighSharedMin; /* VM: Current lowest address in the high shared arena - aurora/smp only. (ahvmhShr) */
|
---|
255 | ULONG ulVMArenaHighSharedMax; /* VM: Current highest address in the high shared arena - aurora/smp only. (ahvmhShr) */
|
---|
256 |
|
---|
257 | } K32SYSTEMMEMINFO, *PK32SYSTEMMEMINFO;
|
---|
258 |
|
---|
259 |
|
---|
260 | /*
|
---|
261 | * K32 category parameter structs
|
---|
262 | *
|
---|
263 | * Note. The ULONG rc should allways be the first datamember!
|
---|
264 | */
|
---|
265 | typedef struct _k32AllocMemEx
|
---|
266 | {
|
---|
267 | ULONG rc; /* Return code. */
|
---|
268 | PPVOID ppv; /* Pointer to pointer to the allocated memory block */
|
---|
269 | /* On input it (*ppv) may hold the suggested location of the block. */
|
---|
270 | ULONG cb; /* Blocksize (bytes) */
|
---|
271 | ULONG flFlags; /* Flags (equal to DosAllocMem flags) */
|
---|
272 | ULONG ulCS; /* Call CS */
|
---|
273 | ULONG ulEIP; /* Call EIP */
|
---|
274 | } K32ALLOCMEMEX, *PK32ALLOCMEMEX;
|
---|
275 |
|
---|
276 | typedef struct _k32QueryOTEs
|
---|
277 | {
|
---|
278 | ULONG rc; /* Return code. */
|
---|
279 | HMODULE hMTE; /* Module handle. */
|
---|
280 | PQOTEBUFFER pQOte; /* Pointer to output buffer. */
|
---|
281 | ULONG cbQOte; /* Size of the buffer pointed to by pQOte */
|
---|
282 | } K32QUERYOTES, *PK32QUERYOTES;
|
---|
283 |
|
---|
284 | typedef struct _k32QueryOptionsStatus
|
---|
285 | {
|
---|
286 | ULONG rc; /* Return code. */
|
---|
287 | PK32OPTIONS pOptions; /* Pointer to option struct. (NULL allowed) */
|
---|
288 | PK32STATUS pStatus; /* Pointer to status struct. (NULL allowed) */
|
---|
289 | } K32QUERYOPTIONSSTATUS, *PK32QUERYOPTIONSSTATUS;
|
---|
290 |
|
---|
291 | typedef struct _k32SetOptions
|
---|
292 | {
|
---|
293 | ULONG rc; /* Return code. */
|
---|
294 | PK32OPTIONS pOptions; /* Pointer to option struct. (NULL allowed) */
|
---|
295 | } K32SETOPTIONS, *PK32SETOPTIONS;
|
---|
296 |
|
---|
297 | typedef struct _k32ProcessReadWrite
|
---|
298 | {
|
---|
299 | ULONG rc; /* Return code. */
|
---|
300 | PID pid; /* Process ID of the process to access memory in. */
|
---|
301 | ULONG cb; /* Number of bytes to read or write. */
|
---|
302 | PVOID pvSource; /* Pointer to source data. */
|
---|
303 | PVOID pvTarget; /* Pointer to target area. */
|
---|
304 | BOOL fRead; /* TRUE: pvSource is within pid while pvTarget is ours. */
|
---|
305 | /* FALSE: pvTarget is within pid while pvSource is ours. */
|
---|
306 | } K32PROCESSREADWRITE, *PK32PROCESSREADWRITE;
|
---|
307 |
|
---|
308 | typedef struct _k32HandleSystemEvent
|
---|
309 | {
|
---|
310 | ULONG rc; /* Return code. */
|
---|
311 | ULONG ulEvent; /* Event identifier. One of the K32_SYSEVENT_ defines. */
|
---|
312 | HEV hev; /* Handle of shared event semaphore which should be */
|
---|
313 | /* posted when the the requested event occurs. */
|
---|
314 | BOOL fHandle; /* Action flag. */
|
---|
315 | /* TRUE: Take control of the event. */
|
---|
316 | /* FALSE: Give control back to the OS of this event. (hev must match the current handle!) */
|
---|
317 | } K32HANDLESYSTEMEVENT, *PK32HANDLESYSTEMEVENT;
|
---|
318 |
|
---|
319 | typedef struct _k32QuerySystemMemInfo
|
---|
320 | {
|
---|
321 | APIRET rc; /* Return code. */
|
---|
322 | PK32SYSTEMMEMINFO pMemInfo; /* Pointer to system memory info structure with cb set. */
|
---|
323 | /* The other members will be filled on successful return. */
|
---|
324 | } K32QUERYSYSTEMMEMINFO, *PK32QUERYSYSTEMMEMINFO;
|
---|
325 |
|
---|
326 |
|
---|
327 | #pragma pack()
|
---|
328 |
|
---|
329 | #ifndef NO_WIN32K_LIB_FUNCTIONS
|
---|
330 | /*******************************************************************************
|
---|
331 | * External Functions *
|
---|
332 | *******************************************************************************/
|
---|
333 | /* Win32k APIs */
|
---|
334 | APIRET APIENTRY libWin32kInit(void);
|
---|
335 | APIRET APIENTRY libWin32kTerm(void);
|
---|
336 | BOOL APIENTRY libWin32kInstalled(void);
|
---|
337 | APIRET APIENTRY libWin32kQueryOptionsStatus(PK32OPTIONS pOptions, PK32STATUS pStatus);
|
---|
338 | APIRET APIENTRY libWin32kSetOptions(PK32OPTIONS pOptions);
|
---|
339 | APIRET APIENTRY libWin32kSetOption(PK32OPTIONS pOptions);
|
---|
340 |
|
---|
341 | /* "Extra OS2 APIs" */
|
---|
342 | APIRET APIENTRY DosAllocMemEx(PPVOID ppv, ULONG cb, ULONG flag);
|
---|
343 | APIRET APIENTRY W32kQueryOTEs(HMODULE hMTE, PQOTEBUFFER pQOte, ULONG cbQOte);
|
---|
344 | APIRET APIENTRY W32kQuerySystemMemInfo(PK32SYSTEMMEMINFO pMemInfo);
|
---|
345 | APIRET APIENTRY W32kProcessReadWrite(PID pid, ULONG cb, PVOID pvSource, PVOID pvTarget, BOOL fRead);
|
---|
346 | APIRET APIENTRY W32kHandleSystemEvent(ULONG ulEvent, HEV hev, BOOL fHandle);
|
---|
347 |
|
---|
348 | /* Helper function */
|
---|
349 | USHORT APIENTRY libHelperGetCS(void);
|
---|
350 |
|
---|
351 |
|
---|
352 | #endif
|
---|
353 |
|
---|
354 | #endif /* !defined(INCL_16) */
|
---|
355 |
|
---|
356 | #endif
|
---|