source: trunk/src/win32k/kKrnlLib/include/OS2KTK.h

Last change on this file was 6815, checked in by bird, 24 years ago

Updated to work for kKrnlLib.DLL and internally in kKrnlLib.

File size: 10.4 KB
Line 
1/* $Id: OS2KTK.h,v 1.2 2001-09-26 03:52:37 bird Exp $
2 *
3 * OS2KTK - OS/2 Kernel Task.
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#ifndef _OS2KTK_h_
11#define _OS2KTK_h_
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17
18/*******************************************************************************
19* Defined Constants And Macros *
20*******************************************************************************/
21#define TK_FUSU_FATAL 0x3 /* Traps the task on failure. */
22#define TK_FUSU_NONFATAL 0x0 /* Returns error code to caller on failure. */
23#define TK_FUSU_USER_SRC 0x10 /* Source buffer is in user memory. (TKSuFuBuff) */
24#define TK_FUSU_USER_DST 0x20 /* Target buffer is in user memory. (TKSuFuBuff) */
25
26
27
28#define TKFuChar(pch, pchUsr) \
29 TKFuBuff((PVOID)pch, (PVOID)pchUsr, sizeof(char), TK_FUSU_FATAL)
30#define TKSuChar(pchUsr, pch) \
31 TKSuBuff((PVOID)pchUsr, (PVOID)pch, sizeof(char), TK_FUSU_FATAL)
32
33#define TKFuCharNF(pch, pchUsr) \
34 TKFuBuff((PVOID)pch, (PVOID)pchUsr, sizeof(char), TK_FUSU_NONFATAL)
35#define TKSuCharNF(pchUsr, pch) \
36 TKSuBuff((PVOID)pchUsr, (PVOID)pch, sizeof(char), TK_FUSU_NONFATAL)
37
38
39#define TKFuUShort(pus, pusUsr) \
40 TKFuBuff((PVOID)pus, (PVOID)pusUsr, sizeof(USHORT), TK_FUSU_FATAL)
41#define TKSuUShort(pusUsr, pus) \
42 TKSuBuff((PVOID)pusUsr, (PVOID)pus, sizeof(USHORT), TK_FUSU_FATAL)
43
44#define TKFuUShortNF(pus, pusUsr) \
45 TKFuBuff((PVOID)pus, (PVOID)pusUsr, sizeof(USHORT), TK_FUSU_NONFATAL)
46#define TKSuUShortNF(pusUsr, pus) \
47 TKSuBuff((PVOID)pusUsr, (PVOID)pus, sizeof(USHORT), TK_FUSU_NONFATAL)
48
49
50#define TKFuULong(pul, pulUsr) \
51 TKFuBuff((PVOID)pul, (PVOID)pulUsr, sizeof(ULONG), TK_FUSU_FATAL)
52#define TKSuULong(pulUsr, pul) \
53 TKSuBuff((PVOID)pulUsr, (PVOID)pul, sizeof(ULONG), TK_FUSU_FATAL)
54
55#define TKFuULongNF(pul, pulUsr) \
56 TKFuBuff((PVOID)pul, (PVOID)pulUsr, sizeof(ULONG), TK_FUSU_NONFATAL)
57#define TKSuULongNF(pulUsr, pul) \
58 TKSuBuff((PVOID)pulUsr, (PVOID)pul, sizeof(ULONG), TK_FUSU_NONFATAL)
59
60
61#define TKFuStrLen(pcch, pvUsr, cchMax) \
62 TKFuBufLen(pcch, pvUsr, cchMax, TK_FUSU_FATAL, FALSE)
63#define TKFuStrLenNZ(pcch, pvUsr, cchMax) \
64 TKFuBufLenNZ(pcch, pvUsr, cchMax, TK_FUSU_NONFATAL, FALSE)
65
66#define TKFuStrLenZ(pcch, pvUsr, cchMax) \
67 TKFuBufLenZ(pcch, pvUsr, cchMax, TK_FUSU_FATAL, TRUE)
68#define TKFuStrLenZNZ(pcch, pvUsr, cchMax) \
69 TKFuBufLenZNZ(pcch, pvUsr, cchMax, TK_FUSU_NONFATAL, TRUE)
70
71
72/*
73 * Scan tasks flags. (Very similar to POST_SIGNAL).
74 */
75#define TKST_COMMANDTREE 0
76#define TKST_PROCESS 1
77#define TKST_DESCENDANTS 2
78#define TKST_SCREENGROUP 3
79#define TKST_ALL 4
80
81#define TKST_ERR_WORKER_STOP 0x00000100
82#define TKST_ERR_WORKER_RET 0x00000200
83#define TKST_INCLUDE_EXECCHILD 0x00000400
84#define TKST_INCLUDE_ZOMBIES 0x00000800
85
86
87/*******************************************************************************
88* External Functions *
89*******************************************************************************/
90
91/**
92 * Copy user memory into system memory.
93 * @returns OS/2 return code. (NO_ERROR is success)
94 * @param pv Pointer to target (system) data area.
95 * @param pvUsr Pointer to source (user) data area.
96 * @param cb Count of bytes to copy.
97 * @param fl Flags.
98 */
99extern ULONG KRNLCALL TKFuBuff(PVOID pv, PVOID pvUsr, ULONG cb, ULONG fl);
100extern ULONG KRNLCALL OrgTKFuBuff(PVOID pv, PVOID pvUsr, ULONG cb, ULONG fl);
101
102
103/**
104 * Copy system memory to user memory.
105 * @returns OS/2 return code. (NO_ERROR is success)
106 * @param pvUsr Pointer to target (user) data area.
107 * @param pv Pointer to source (system) data area.
108 * @param cb Count of bytes to copy.
109 * @param fl Flags.
110 */
111extern ULONG KRNLCALL TKSuBuff(PVOID pvUsr, PVOID pv, ULONG cb, ULONG fl);
112extern ULONG KRNLCALL OrgTKSuBuff(PVOID pvUsr, PVOID pv, ULONG cb, ULONG fl);
113
114
115/**
116 * String length.
117 * @returns OS/2 return code. (NO_ERROR is success)
118 * @param pcch Pointer to length variable.
119 * @param pvUsr Pointer to user data to preform string length on.
120 * @param cchMax Max string length.
121 * @param fl Flags.
122 * @param fDblNULL TRUE: Double '\0' (ie. '\0\0') terminated. Usefull for scanning environments.
123 * FALSE: Single string. (ie. one '\0').
124 */
125extern ULONG KRNLCALL TKFuBufLen(PLONG pcch, PVOID pvUsr, ULONG cchMax, ULONG fl, BOOL fDblNULL);
126extern ULONG KRNLCALL OrgTKFuBufLen(PLONG pcch, PVOID pvUsr, ULONG cchMax, ULONG fl, BOOL fDblNULL);
127
128
129/**
130 * Copy user memory to user memory.
131 * @returns OS/2 return code. (NO_ERROR is success)
132 * @param pvTarget Pointer to target (user) data area.
133 * @param pvSource Pointer to source (user) data area.
134 * @param cb Count of bytes to copy.
135 * @param fl Flags.
136 */
137extern ULONG KRNLCALL TKSuFuBuff(PVOID pvTarget, PVOID pvSource, ULONG cb, ULONG fl);
138extern ULONG KRNLCALL OrgTKSuFuBuff(PVOID pvTarget, PVOID pvSource, ULONG cb, ULONG fl);
139
140
141#ifdef INCL_OS2KRNL_PTDA
142/**
143 * PID to PTDA pointer.
144 * @returns OS/2 return code.
145 * @param pid Process Identifier.
146 * @param ppPTDA Pointer to the PTDA-pointer variabel which is to receive
147 * the PTDA pointer on successful return.
148 */
149extern ULONG KRNLCALL TKPidToPTDA(PID pid, PPPTDA ppPTDA);
150extern ULONG KRNLCALL OrgTKPidToPTDA(PID pid, PPPTDA ppPTDA);
151#endif
152
153
154#ifdef INCL_OS2KRNL_PTDA
155/**
156 * Worker prototype.
157 */
158typedef ULONG (KRNLCALL TKSCANTASKWORKER)(PPTDA, ULONG);
159typedef TKSCANTASKWORKER * PTKSCANTASKWORKER;
160
161/**
162 * Scans tasks (ie. processes) in the system calling the working for each which matches the
163 * flFlags and id combination.
164 * @return NO_ERROR on success.
165 * On error, depends on flags, but appropriate error code.
166 * @param flFlags TKST_* flags.
167 * @param id Process id og screen group id.
168 * @param pfnWorker Pointer (FLAT) to the worker procesdure.
169 * @param ulArg User argument which is passed on as second parameter to worker
170 */
171extern ULONG KRNLCALL TKScanTasks(ULONG flFlags, ULONG id, PTKSCANTASKWORKER pfnWorker, ULONG ulArg);
172extern ULONG KRNLCALL OrgTKScanTasks(ULONG flFlags, ULONG id, PTKSCANTASKWORKER pfnWorker, ULONG ulArg);
173#endif
174
175
176/**
177 * Post signal to one or more processes.
178 * @returns NO_ERROR on success.
179 * On error ERROR_NOT_DESCENDANT, ERROR_SIGNAL_REFUSED,
180 * ERROR_INVALID_PROCID, ERROR_ZOMBIE_PROCESS, ERROR_SIGNAL_PENDING. (it seems)
181 * @param usSignal Signal number.
182 * @param usAction Action.
183 * 0 - the process and all children.
184 * 1 - only the process
185 * 2 - the process and all it's descendants.
186 * 3 - all processes in that screen group.
187 * @param usSignalArg Signal argument.
188 * @param usPIDSGR Process Id or Screen Group Id.
189 * @remark Win32k Internal call.
190 */
191extern ULONG _Optlink POST_SIGNAL32(USHORT usSignal, USHORT usAction, USHORT usSignalArg, USHORT usPIDSGR);
192
193#ifdef __cplusplus
194}
195#endif
196
197
198#ifdef INCL_OS2KRNL_TCB
199/**
200 * Force a thread to be made ready.
201 * @param flFlag Which flag(s?) to set.
202 * @param pTCB Pointer to the thread control block of the thread to be forced.
203 */
204extern void KRNLCALL TKForceThread(ULONG flFlag, PTCB pTCB);
205extern void KRNLCALL OrgTKForceThread(ULONG flFlag, PTCB pTCB);
206#endif
207
208#ifdef INCL_OS2KRNL_PTDA
209/**
210 * Set force flag on a task.
211 * @param flFlag Which flag(s?) to set.
212 * @param pPTDA Pointer to the PTDA of the task to be processed.
213 * @param fForce FALSE Just set the flag on all threads.
214 * TRUE Force all threads ready by calling TKForceThread.
215 */
216extern void KRNLCALL TKForceTask(ULONG flFlag, PPTDA pPTDA, BOOL fForce);
217extern void KRNLCALL OrgTKForceTask(ULONG flFlag, PPTDA pPTDA, BOOL fForce);
218#endif
219
220#ifdef INCL_OS2KRNL_TCB
221/**
222 * Get priotity of a thread.
223 * @returns Thread priority.
224 * @param pTCB pointer to the TCB of the thread in question.
225 */
226extern ULONG KRNLCALL TKGetPriority(PTCB pTCB);
227extern ULONG KRNLCALL OrgTKGetPriority(PTCB pTCB);
228#endif
229
230/**
231 * Make current thread sleep.
232 * @returns NO_ERROR on success.
233 * ERROR_INTERRUPT if a signal is forced on the thread.
234 * ERROR_TIMEOUT if we timeout.
235 * @param ulSleepId 32-bit sleep id which TKWakeup will be called with.
236 * @param ulTimeout Number of milliseconds to sleep. (0 is not yield)
237 * -1 means forever or till wakeup.
238 * @param fUnint TRUE: may not interrupt sleep.
239 * FALSE: may interrupt sleep.
240 * @param flSleepType ???
241 */
242extern ULONG KRNLCALL TKSleep(ULONG ulSleepId, ULONG ulTimeout, ULONG fUnInterruptable, ULONG flWakeupType);
243extern ULONG KRNLCALL OrgTKSleep(ULONG ulSleepId, ULONG ulTimeout, ULONG fUnInterruptable, ULONG flWakeupType);
244
245/**
246 * Wakeup sleeping thread(s).
247 * @returns NO_ERROR on succes.
248 * Appropriate error code on failure.
249 * @param ulSleepId 32-bit sleep id which threads are sleeping on.
250 * @param flWakeUpType How/what to wakeup.
251 * @param pcWakedUp Pointer to variable which is to hold the count of
252 * thread waked up.
253 */
254extern ULONG KRNLCALL TKWakeup(ULONG ulSleepId, ULONG flWakeupType, PULONG cWakedUp);
255extern ULONG KRNLCALL OrgTKWakeup(ULONG ulSleepId, ULONG flWakeupType, PULONG cWakedUp);
256
257#ifdef INCL_OS2KRNL_TCB
258/**
259 * Wake up a single thread.
260 * @returns NO_ERROR on succes.
261 * Appropriate error code on failure.
262 * @param pTCB Pointer to the TCB of the thread to be waken.
263 */
264extern ULONG KRNLCALL TKWakeThread(PTCB pTCB);
265extern ULONG KRNLCALL OrgTKWakeThread(PTCB pTCB);
266#endif
267
268#ifdef INCL_OS2KRNL_TCB
269/**
270 * See which thread will be Wakeup.
271 * @returns Pointer to TCB of the thread on success.
272 * NULL on failure or no threads.
273 * @param ulSleepId 32-bit sleep id which threads are sleeping on.
274 * @param flWakeUpType How/what to wakeup.
275 */
276extern PTCB KRNLCALL TKQueryWakeup(ULONG ulSleepId, ULONG flWakeupType);
277extern PTCB KRNLCALL OrgTKQueryWakeup(ULONG ulSleepId, ULONG flWakeupType);
278#endif
279
280#endif
Note: See TracBrowser for help on using the repository browser.